use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class BroadCastDiscoveryRuleGenerator method buildMatch.
private Set<FieldMatch> buildMatch(Switch sw) {
long dstMac = new SwitchId(config.getDiscoveryBcastPacketDst()).toLong();
Set<FieldMatch> match = new HashSet<>();
match.add(FieldMatch.builder().field(Field.ETH_DST).value(dstMac).mask(Mask.NO_MASK).build());
if (sw.getFeatures().contains(MATCH_UDP_PORT)) {
match.add(FieldMatch.builder().field(Field.IP_PROTO).value(IpProto.UDP).build());
match.add(FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.IPv4).build());
match.add(FieldMatch.builder().field(Field.UDP_DST).value(DISCOVERY_PACKET_UDP_PORT).build());
}
return match;
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class UnicastVerificationVxlanRuleGenerator method buildUnicastVerificationRuleVxlan.
private FlowSpeakerData buildUnicastVerificationRuleVxlan(Switch sw, Cookie cookie) {
List<Action> actions = new ArrayList<>();
if (sw.getFeatures().contains(NOVIFLOW_PUSH_POP_VXLAN)) {
actions.add(new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW));
} else {
actions.add(new PopVxlanAction(ActionType.POP_VXLAN_OVS));
}
actions.add(new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
// todo remove unnecessary action
actions.add(SetFieldAction.builder().field(ETH_DST).value(sw.getSwitchId().toLong()).build());
Instructions instructions = Instructions.builder().applyActions(actions).build();
long ethSrc = new SwitchId(config.getFlowPingMagicSrcMacAddress()).toLong();
Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(ETH_SRC).value(ethSrc).mask(NO_MASK).build(), FieldMatch.builder().field(ETH_DST).value(sw.getSwitchId().toLong()).mask(NO_MASK).build(), FieldMatch.builder().field(ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(UDP_SRC).value(STUB_VXLAN_UDP_SRC).build());
return FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(cookie).table(OfTable.INPUT).priority(VERIFICATION_RULE_VXLAN_PRIORITY).match(match).instructions(instructions).build();
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class InputArpRuleGeneratorTest method buildCorrectRuleForOf13Test.
@Test
public void buildCorrectRuleForOf13Test() {
FlowEndpoint endpoint = new FlowEndpoint(SW.getSwitchId(), PORT_NUMBER_1, 0, 0, false, true);
FlowSideAdapter overlapAdapter = new FlowSourceAdapter(Flow.builder().flowId("some").srcSwitch(SW).destSwitch(buildSwitch("OF_13", Collections.emptySet())).detectConnectedDevices(DetectConnectedDevices.builder().srcArp(false).srcSwitchArp(false).build()).build());
InputArpRuleGenerator generator = InputArpRuleGenerator.builder().ingressEndpoint(endpoint).multiTable(true).overlappingIngressAdapters(Sets.newHashSet(overlapAdapter)).build();
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 PortColourCookie(CookieType.ARP_INPUT_CUSTOMER_TYPE, PORT_NUMBER_1), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(Priority.ARP_INPUT_CUSTOMER_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.ARP).build());
assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
RoutingMetadata metadata = RoutingMetadata.builder().arpFlag(true).build(SW.getFeatures());
Instructions expectedInstructions = Instructions.builder().writeMetadata(new OfMetadata(metadata.getValue(), metadata.getMask())).goToTable(OfTable.PRE_INGRESS).build();
assertEquals(expectedInstructions, flowCommandData.getInstructions());
assertTrue(flowCommandData.getFlags().isEmpty());
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class MultiTableIngressRuleGeneratorTest method buildMatchVlanEncapsulationDoubleVlanTest.
@Test
public void buildMatchVlanEncapsulationDoubleVlanTest() {
Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
MultiTableIngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
Set<FieldMatch> match = generator.buildIngressMatch(new FlowSourceAdapter(flow).getEndpoint(), FEATURES);
RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
Set<FieldMatch> expectedMatch = 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(metadata.getValue()).mask(metadata.getMask()).build());
assertEqualsMatch(expectedMatch, match);
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class MultiTableIngressRuleGeneratorTest method buildMatchVlanEncapsulationFullPortTest.
@Test
public void buildMatchVlanEncapsulationFullPortTest() {
Flow flow = buildFlow(PATH, 0, 0);
MultiTableIngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
Set<FieldMatch> match = generator.buildIngressMatch(new FlowSourceAdapter(flow).getEndpoint(), FEATURES);
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build());
assertEqualsMatch(expectedMatch, match);
}
Aggregations