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;
}
}
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);
}
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));
}
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);
}
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);
}
Aggregations