Search in sources :

Example 61 with MatchInfoBase

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

the class AbstractAclServiceImpl method programAclDispatcherTable.

protected void programAclDispatcherTable(AclInterface port, int addOrRemove) {
    SortedSet<Integer> remoteAclTags = getRemoteAclTags(port);
    if (remoteAclTags.isEmpty()) {
        LOG.debug("No {} rules with remote group id for port={}", this.directionString, port.getInterfaceId());
        return;
    }
    Integer firstRemoteAclTag = remoteAclTags.first();
    Integer lastRemoteAclTag = remoteAclTags.last();
    programFirstRemoteAclEntryInDispatcherTable(port, firstRemoteAclTag, addOrRemove);
    programLastRemoteAclEntryInDispatcherTable(port, lastRemoteAclTag, addOrRemove);
    Integer previousRemoteAclTag = firstRemoteAclTag;
    for (Integer remoteAclTag : remoteAclTags) {
        if (remoteAclTag.equals(firstRemoteAclTag)) {
            continue;
        }
        List<MatchInfoBase> matches = new ArrayList<>();
        matches.addAll(AclServiceUtils.buildMatchesForLPortTagAndRemoteAclTag(port.getLPortTag(), previousRemoteAclTag, serviceMode));
        String flowId = this.directionString + "_ACL_Dispatcher_" + port.getDpId() + "_" + port.getLPortTag() + "_" + remoteAclTag;
        List<InstructionInfo> instructions = AclServiceOFFlowBuilder.getGotoInstructionInfo(getAclRuleBasedFilterTable());
        instructions.add(AclServiceUtils.getWriteMetadataForRemoteAclTag(remoteAclTag));
        syncFlow(port.getDpId(), getAclFilterCumDispatcherTable(), flowId, AclConstants.ACE_GOTO_NEXT_REMOTE_ACL_PRIORITY, "ACL", 0, 0, AclConstants.COOKIE_ACL_BASE, matches, instructions, addOrRemove);
        previousRemoteAclTag = remoteAclTag;
    }
}
Also used : BigInteger(java.math.BigInteger) InstructionInfo(org.opendaylight.genius.mdsalutil.InstructionInfo) ArrayList(java.util.ArrayList) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase)

Example 62 with MatchInfoBase

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

the class AclServiceOFFlowBuilderTest method testProgramUdpFlow_NoSrcDstPortRange.

@Test
public void testProgramUdpFlow_NoSrcDstPortRange() {
    AceIpBuilder builder = new AceIpBuilder();
    AceIpv4Builder v4builder = new AceIpv4Builder();
    v4builder.setSourceIpv4Network(new Ipv4Prefix("10.1.1.1/24"));
    v4builder.setDestinationIpv4Network(new Ipv4Prefix("20.1.1.1/24"));
    builder.setAceIpVersion(v4builder.build());
    builder.setSourcePortRange(null);
    builder.setDestinationPortRange(null);
    short protocol = 1;
    builder.setProtocol(protocol);
    Map<String, List<MatchInfoBase>> flowMatchesMap = AclServiceOFFlowBuilder.programUdpFlow(builder.build());
    List<MatchInfoBase> flowMatches = flowMatchesMap.get("UDP_SOURCE_ALL_");
    AclServiceTestUtils.verifyGeneralFlows(flowMatches, "1", "10.1.1.1", "20.1.1.1", "24");
    AclServiceTestUtils.verifyMatchFieldTypeDontExist(flowMatches, NxMatchUdpSourcePort.class);
    AclServiceTestUtils.verifyMatchFieldTypeDontExist(flowMatches, NxMatchUdpDestinationPort.class);
}
Also used : 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) ArrayList(java.util.ArrayList) List(java.util.List) 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) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) Test(org.junit.Test)

Example 63 with MatchInfoBase

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

the class AclServiceOFFlowBuilderTest method testprogramTcpFlow_WithSrcDstPortRange.

@Test
public void testprogramTcpFlow_WithSrcDstPortRange() {
    AceIpBuilder builder = AclServiceTestUtils.prepareAceIpBuilder("10.1.1.1/24", "20.1.1.1/24", "1024", "1024", (short) 1);
    Map<String, List<MatchInfoBase>> flowMatchesMap = AclServiceOFFlowBuilder.programTcpFlow(builder.build());
    List<MatchInfoBase> srcFlowMatches = new ArrayList<>();
    List<MatchInfoBase> dstFlowMatches = new ArrayList<>();
    for (String flowId : flowMatchesMap.keySet()) {
        if (flowId.startsWith("TCP_SOURCE_")) {
            srcFlowMatches.addAll(flowMatchesMap.get(flowId));
        }
        if (flowId.startsWith("TCP_DESTINATION_")) {
            dstFlowMatches.addAll(flowMatchesMap.get(flowId));
        }
    }
    AclServiceTestUtils.verifyGeneralFlows(srcFlowMatches, "1", "10.1.1.1", "20.1.1.1", "24");
    List<MatchInfoBase> tcpSrcMatches = srcFlowMatches.stream().filter(item -> item instanceof NxMatchTcpSourcePort).collect(Collectors.toList());
    assertEquals(new NxMatchTcpSourcePort(1024, 65535), tcpSrcMatches.get(0));
    AclServiceTestUtils.verifyGeneralFlows(dstFlowMatches, "1", "10.1.1.1", "20.1.1.1", "24");
    List<MatchInfoBase> tcpDstMatches = dstFlowMatches.stream().filter(item -> item instanceof NxMatchTcpDestinationPort).collect(Collectors.toList());
    assertEquals(new NxMatchTcpDestinationPort(1024, 65535), tcpDstMatches.get(0));
}
Also used : MatchIpv4Source(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Source) NxMatchUdpSourcePort(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchUdpSourcePort) NxMatchTcpSourcePort(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchTcpSourcePort) NxMatchUdpDestinationPort(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchUdpDestinationPort) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) Collectors(java.util.stream.Collectors) NxMatchTcpDestinationPort(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchTcpDestinationPort) ArrayList(java.util.ArrayList) MatchIcmpv4(org.opendaylight.genius.mdsalutil.matches.MatchIcmpv4) MatchIpv4Destination(org.opendaylight.genius.mdsalutil.matches.MatchIpv4Destination) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) Map(java.util.Map) MatchEthernetType(org.opendaylight.genius.mdsalutil.matches.MatchEthernetType) 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) Assert.assertEquals(org.junit.Assert.assertEquals) 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) NxMatchTcpDestinationPort(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchTcpDestinationPort) NxMatchTcpSourcePort(org.opendaylight.genius.mdsalutil.nxmatches.NxMatchTcpSourcePort) 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) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) Test(org.junit.Test)

Example 64 with MatchInfoBase

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

the class AclServiceOFFlowBuilderTest method testprogramIcmpFlow.

@Test
public void testprogramIcmpFlow() {
    AceIpBuilder builder = AclServiceTestUtils.prepareAceIpBuilder("10.1.1.1/24", "20.1.1.1/24", "1024", "2048", (short) 1);
    Map<String, List<MatchInfoBase>> flowMatchesMap = AclServiceOFFlowBuilder.programIcmpFlow(builder.build());
    List<MatchInfoBase> flowMatches = flowMatchesMap.entrySet().iterator().next().getValue();
    AclServiceTestUtils.verifyGeneralFlows(flowMatches, "1", "10.1.1.1", "20.1.1.1", "24");
    int matches = 0;
    MatchIcmpv4 check = new MatchIcmpv4((short) 1024, (short) 2048);
    for (MatchInfoBase flowMatch : flowMatches) {
        if (check.equals(flowMatch)) {
            matches++;
        }
    }
    assertEquals(2, matches);
}
Also used : MatchIcmpv4(org.opendaylight.genius.mdsalutil.matches.MatchIcmpv4) 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) ArrayList(java.util.ArrayList) List(java.util.List) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) Test(org.junit.Test)

Example 65 with MatchInfoBase

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

the class AclServiceOFFlowBuilderTest method testprogramTcpFlow_NoSrcDstPortRange.

@Test
public void testprogramTcpFlow_NoSrcDstPortRange() {
    AceIpBuilder builder = AclServiceTestUtils.prepareAceIpBuilder("10.1.1.1/24", "20.1.1.1/24", null, null, (short) 1);
    Map<String, List<MatchInfoBase>> flowMatchesMap = AclServiceOFFlowBuilder.programTcpFlow(builder.build());
    List<MatchInfoBase> flowMatches = flowMatchesMap.get("TCP_SOURCE_ALL_");
    AclServiceTestUtils.verifyGeneralFlows(flowMatches, "1", "10.1.1.1", "20.1.1.1", "24");
    AclServiceTestUtils.verifyMatchFieldTypeDontExist(flowMatches, NxMatchTcpSourcePort.class);
    AclServiceTestUtils.verifyMatchFieldTypeDontExist(flowMatches, NxMatchTcpDestinationPort.class);
}
Also used : 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) ArrayList(java.util.ArrayList) List(java.util.List) MatchInfoBase(org.opendaylight.genius.mdsalutil.MatchInfoBase) Test(org.junit.Test)

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