Search in sources :

Example 6 with MatchInfoBase

use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.

the class AclServiceOFFlowBuilder method addLPortTagMatches.

/**
 * Adds LPort matches to the flow.
 * @param lportTag lport tag
 * @param conntrackState conntrack state to be used with matches
 * @param conntrackMask conntrack mask to be used with matches
 * @param serviceMode ingress or egress service
 * @return list of matches
 */
public static List<MatchInfoBase> addLPortTagMatches(int lportTag, int conntrackState, int conntrackMask, Class<? extends ServiceModeBase> serviceMode) {
    List<MatchInfoBase> matches = new ArrayList<>();
    matches.add(AclServiceUtils.buildLPortTagMatch(lportTag, serviceMode));
    matches.add(new NxMatchCtState(conntrackState, conntrackMask));
    return matches;
}
Also used : ArrayList(java.util.ArrayList) NxMatchCtState(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 7 with MatchInfoBase

use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.

the class AclServiceUtils method buildMatchesForLPortTagAndRemoteAclTag.

public static List<MatchInfoBase> buildMatchesForLPortTagAndRemoteAclTag(Integer lportTag, Integer remoteAclTag, Class<? extends ServiceModeBase> serviceMode) {
    List<MatchInfoBase> matches = new ArrayList<>();
    if (serviceMode != null && serviceMode.isAssignableFrom(ServiceModeEgress.class)) {
        matches.add(AclServiceUtils.buildLPortTagMatch(lportTag, serviceMode));
        matches.add(AclServiceUtils.buildRemoteAclTagMetadataMatch(remoteAclTag));
    } else {
        // In case of ingress service mode, only metadata is used for
        // matching both lportTag and aclTag. Hence performing "or"
        // operation on both lportTag and aclTag metadata.
        BigInteger metaData = MetaDataUtil.getLportTagMetaData(lportTag).or(getRemoteAclTagMetadata(BigInteger.valueOf(remoteAclTag)));
        BigInteger metaDataMask = MetaDataUtil.METADATA_MASK_LPORT_TAG.or(MetaDataUtil.METADATA_MASK_REMOTE_ACL_TAG);
        matches.add(new MatchMetadata(metaData, metaDataMask));
    }
    return matches;
}
Also used : MatchMetadata(org.opendaylight.genius.mdsalutil.matches.MatchMetadata) ServiceModeEgress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.ServiceModeEgress) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 8 with MatchInfoBase

use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.

the class AclServiceUtils method buildArpIpMatches.

/**
 * Builds the arp ip matches.
 * @param ipPrefixOrAddress the ip prefix or address
 * @return the MatchInfoBase list
 */
public static List<MatchInfoBase> buildArpIpMatches(IpPrefixOrAddress ipPrefixOrAddress) {
    List<MatchInfoBase> flowMatches = new ArrayList<>();
    IpPrefix ipPrefix = ipPrefixOrAddress.getIpPrefix();
    if (ipPrefix != null) {
        Ipv4Prefix ipv4Prefix = ipPrefix.getIpv4Prefix();
        if (ipv4Prefix != null && !ipv4Prefix.getValue().equals(AclConstants.IPV4_ALL_NETWORK)) {
            flowMatches.add(new MatchArpSpa(ipv4Prefix));
        }
    } else {
        IpAddress ipAddress = ipPrefixOrAddress.getIpAddress();
        if (ipAddress != null && ipAddress.getIpv4Address() != null) {
            flowMatches.add(new MatchArpSpa(ipAddress.getIpv4Address().getValue(), "32"));
        }
    }
    return flowMatches;
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) ArrayList(java.util.ArrayList) MatchArpSpa(org.opendaylight.genius.mdsalutil.matches.MatchArpSpa) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 9 with MatchInfoBase

use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.

the class AclServiceUtils method getFlowForAllowedAddresses.

public static Map<String, List<MatchInfoBase>> getFlowForAllowedAddresses(List<AllowedAddressPairs> syncAllowedAddresses, Map<String, List<MatchInfoBase>> flowMatchesMap, boolean isSourceIpMacMatch) {
    if (flowMatchesMap == null) {
        return null;
    }
    Map<String, List<MatchInfoBase>> updatedFlowMatchesMap = new HashMap<>();
    MatchInfoBase ipv4Match = MatchEthernetType.IPV4;
    MatchInfoBase ipv6Match = MatchEthernetType.IPV6;
    for (Entry<String, List<MatchInfoBase>> entry : flowMatchesMap.entrySet()) {
        String flowName = entry.getKey();
        List<MatchInfoBase> flows = entry.getValue();
        // iterate over allow address pair and update match type
        for (AllowedAddressPairs aap : syncAllowedAddresses) {
            List<MatchInfoBase> matchInfoBaseList;
            String flowId;
            if (flows.contains(ipv4Match) && isIPv4Address(aap) && isNotIpv4AllNetwork(aap)) {
                matchInfoBaseList = updateAAPMatches(isSourceIpMacMatch, flows, aap);
                flowId = flowName + "_ipv4_remoteACL_interface_aap_" + getAapFlowId(aap);
                updatedFlowMatchesMap.put(flowId, matchInfoBaseList);
            } else if (flows.contains(ipv6Match) && !isIPv4Address(aap) && isNotIpv6AllNetwork(aap)) {
                matchInfoBaseList = updateAAPMatches(isSourceIpMacMatch, flows, aap);
                flowId = flowName + "_ipv6_remoteACL_interface_aap_" + getAapFlowId(aap);
                updatedFlowMatchesMap.put(flowId, matchInfoBaseList);
            }
        }
    }
    return updatedFlowMatchesMap;
}
Also used : HashMap(java.util.HashMap) AllowedAddressPairs(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs) ArrayList(java.util.ArrayList) List(java.util.List) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 10 with MatchInfoBase

use of org.opendaylight.genius.mdsalutil.MatchInfoBase in project netvirt by opendaylight.

the class AclServiceUtils method buildL2BroadcastMatches.

public static List<MatchInfoBase> buildL2BroadcastMatches() {
    List<MatchInfoBase> matches = new ArrayList<>();
    matches.add(new MatchEthernetDestination(new MacAddress(AclConstants.BROADCAST_MAC)));
    return matches;
}
Also used : ArrayList(java.util.ArrayList) MatchEthernetDestination(org.opendaylight.genius.mdsalutil.matches.MatchEthernetDestination) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Aggregations

MatchInfoBase (org.opendaylight.genius.mdsalutil.MatchInfoBase)70 ArrayList (java.util.ArrayList)60 InstructionInfo (org.opendaylight.genius.mdsalutil.InstructionInfo)33 BigInteger (java.math.BigInteger)18 ActionInfo (org.opendaylight.genius.mdsalutil.ActionInfo)18 List (java.util.List)16 MatchMetadata (org.opendaylight.genius.mdsalutil.matches.MatchMetadata)15 InstructionApplyActions (org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions)13 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)11 Test (org.junit.Test)10 NxMatchCtState (org.opendaylight.genius.mdsalutil.nxmatches.NxMatchCtState)10 AceIpBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpBuilder)10 MatchIpv4Destination (org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination)9 ActionNxConntrack (org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)8 AllowedAddressPairs (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.aclservice.rev160608.interfaces._interface.AllowedAddressPairs)8 MatchIpv4Source (org.opendaylight.genius.mdsalutil.matches.MatchIpv4Source)7 AceIpv4Builder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder)7 HashMap (java.util.HashMap)6 NxCtAction (org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack.NxCtAction)6