use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class MultiTableIngressRuleGeneratorTest method buildCommandsVlanEncapsulationDoubleVlanPortOverlappingTest.
@Test
public void buildCommandsVlanEncapsulationDoubleVlanPortOverlappingTest() {
Flow oneSwitchFlow = buildFlow(ONE_SWITCH_PATH, OUTER_VLAN_ID_2, 0);
Set<FlowSideAdapter> overlapping = Sets.newHashSet(FlowSideAdapter.makeIngressAdapter(oneSwitchFlow, ONE_SWITCH_PATH));
Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
MultiTableIngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION, overlapping);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(3, commands.size());
FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
MeterSpeakerData meterCommand = (MeterSpeakerData) commands.get(2);
assertEquals(newArrayList(meterCommand.getUuid()), new ArrayList<>(ingressCommand.getDependsOn()));
RoutingMetadata ingressMetadata = RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(INNER_VLAN_ID_1).build(), FieldMatch.builder().field(Field.METADATA).value(ingressMetadata.getValue()).mask(ingressMetadata.getMask()).build());
List<Action> expectedIngressActions = newArrayList(SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
Set<FieldMatch> expectedPreIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID_1).build());
FlowSharedSegmentCookie preIngressCookie = FlowSharedSegmentCookie.builder(SharedSegmentType.QINQ_OUTER_VLAN).portNumber(PORT_NUMBER_1).vlanId(OUTER_VLAN_ID_1).build();
RoutingMetadata preIngressMetadata = RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
assertPreIngressCommand(preIngressCommand, preIngressCookie, Priority.FLOW_PRIORITY, expectedPreIngressMatch, newArrayList(new PopVlanAction()), mapMetadata(preIngressMetadata));
assertIngressCommand(ingressCommand, Priority.DOUBLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions, METER_ID, null);
assertMeterCommand(meterCommand);
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class Server42IslRttTurningRuleGeneratorTest method server42IslRttTurningRuleGeneratorTest.
@Test
public void server42IslRttTurningRuleGeneratorTest() {
Switch sw = buildSwitch("OF_13", Sets.newHashSet(NOVIFLOW_COPY_FIELD));
List<SpeakerData> commands = generator.generateCommands(sw);
assertEquals(1, commands.size());
FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
assertEquals(sw.getSwitchId(), flowCommandData.getSwitchId());
assertEquals(sw.getOfVersion(), flowCommandData.getOfVersion().toString());
assertTrue(flowCommandData.getDependsOn().isEmpty());
assertEquals(new Cookie(SERVER_42_ISL_RTT_TURNING_COOKIE), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(SERVER_42_ISL_RTT_TURNING_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.ETH_DST).value(MAC_ADDRESS.toLong()).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(Field.IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(Field.UDP_SRC).value(SERVER_42_ISL_RTT_FORWARD_UDP_PORT).build());
assertEquals(expectedMatch, flowCommandData.getMatch());
List<Action> expectedApplyActions = Lists.newArrayList(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_ISL_RTT_REVERSE_UDP_PORT).build(), new PortOutAction(new PortNumber(SpecialPortType.IN_PORT)));
Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
assertEquals(expectedInstructions, flowCommandData.getInstructions());
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class OfMatchConverterTest method testConvertToRuleManagerMatchExact.
@Test
public void testConvertToRuleManagerMatchExact() {
OFFactoryVer13 factory = new OFFactoryVer13();
Match match = factory.buildMatch().setExact(MatchField.ETH_TYPE, EthType.IPv4).setExact(MatchField.ETH_SRC, MacAddress.of(1)).setExact(MatchField.ETH_DST, MacAddress.of(2)).setExact(MatchField.IP_PROTO, IpProtocol.of((short) 17)).setExact(MatchField.UDP_SRC, TransportPort.of(11)).setExact(MatchField.UDP_DST, TransportPort.of(22)).setExact(MatchField.METADATA, OFMetadata.of(U64.of(333))).setExact(MatchField.IN_PORT, OFPort.of(12)).setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(444)).setExact(MatchField.TUNNEL_ID, U64.of(555)).setExact(MatchField.KILDA_VXLAN_VNI, U32.of(666)).build();
Set<FieldMatch> expectedMatches = new HashSet<>();
expectedMatches.add(FieldMatch.builder().value(2048).field(Field.ETH_TYPE).build());
expectedMatches.add(FieldMatch.builder().value(1).field(Field.ETH_SRC).build());
expectedMatches.add(FieldMatch.builder().value(2).field(Field.ETH_DST).build());
expectedMatches.add(FieldMatch.builder().value(17).field(Field.IP_PROTO).build());
expectedMatches.add(FieldMatch.builder().value(11).field(Field.UDP_SRC).build());
expectedMatches.add(FieldMatch.builder().value(22).field(Field.UDP_DST).build());
expectedMatches.add(FieldMatch.builder().value(333).field(Field.METADATA).build());
expectedMatches.add(FieldMatch.builder().value(12).field(Field.IN_PORT).build());
expectedMatches.add(FieldMatch.builder().value(444).field(Field.VLAN_VID).build());
expectedMatches.add(FieldMatch.builder().value(555).field(Field.NOVIFLOW_TUNNEL_ID).build());
expectedMatches.add(FieldMatch.builder().value(666).field(Field.OVS_VXLAN_VNI).build());
Set<FieldMatch> fieldMatches = OfMatchConverter.INSTANCE.convertToRuleManagerMatch(match);
assertEquals(expectedMatches, fieldMatches);
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class OfMatchConverterTest method testConvertToRuleManagerMatchMasked.
@Test
public void testConvertToRuleManagerMatchMasked() {
OFFactoryVer13 factory = new OFFactoryVer13();
Match match = factory.buildMatch().setMasked(MatchField.ETH_TYPE, EthType.IPv4, EthType.IPv4).setMasked(MatchField.ETH_SRC, MacAddress.of(1), MacAddress.of(1)).setMasked(MatchField.ETH_DST, MacAddress.of(2), MacAddress.of(2)).setMasked(MatchField.IP_PROTO, IpProtocol.of((short) 17), IpProtocol.of((short) 17)).setMasked(MatchField.UDP_SRC, TransportPort.of(11), TransportPort.of(11)).setMasked(MatchField.UDP_DST, TransportPort.of(22), TransportPort.of(22)).setMasked(MatchField.METADATA, OFMetadata.of(U64.of(333)), OFMetadata.of(U64.of(333))).setMasked(MatchField.IN_PORT, OFPort.of(12), OFPort.of(12)).setMasked(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(444), OFVlanVidMatch.ofVlan(444)).setMasked(MatchField.TUNNEL_ID, U64.of(555), U64.of(555)).build();
Set<FieldMatch> expectedMatches = new HashSet<>();
expectedMatches.add(FieldMatch.builder().value(2048).mask(2048L).field(Field.ETH_TYPE).build());
expectedMatches.add(FieldMatch.builder().value(1).mask(1L).field(Field.ETH_SRC).build());
expectedMatches.add(FieldMatch.builder().value(2).mask(2L).field(Field.ETH_DST).build());
expectedMatches.add(FieldMatch.builder().value(17).mask(17L).field(Field.IP_PROTO).build());
expectedMatches.add(FieldMatch.builder().value(11).mask(11L).field(Field.UDP_SRC).build());
expectedMatches.add(FieldMatch.builder().value(22).mask(22L).field(Field.UDP_DST).build());
expectedMatches.add(FieldMatch.builder().value(333).mask(333L).field(Field.METADATA).build());
expectedMatches.add(FieldMatch.builder().value(12).mask(12L).field(Field.IN_PORT).build());
expectedMatches.add(FieldMatch.builder().value(444).mask(444L).field(Field.VLAN_VID).build());
expectedMatches.add(FieldMatch.builder().value(555).mask(555L).field(Field.NOVIFLOW_TUNNEL_ID).build());
Set<FieldMatch> fieldMatches = OfMatchConverter.INSTANCE.convertToRuleManagerMatch(match);
assertEquals(expectedMatches, fieldMatches);
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class ArpInputPreDropRuleGeneratorTest method checkMatch.
@Override
protected void checkMatch(Set<FieldMatch> match) {
assertEquals(1, match.size());
FieldMatch ethTypeMatch = getMatchByField(Field.ETH_TYPE, match);
assertEquals(EthType.ARP, ethTypeMatch.getValue());
assertFalse(ethTypeMatch.isMasked());
}
Aggregations