use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class TransitYRuleGeneratorTest method assertTransitCommand.
private void assertTransitCommand(List<SpeakerData> commands, OfTable table, FlowTransitEncapsulation encapsulation) {
assertEquals(1, commands.size());
FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
assertEquals(SWITCH_1.getSwitchId(), flowCommandData.getSwitchId());
assertEquals(SWITCH_1.getOfVersion(), flowCommandData.getOfVersion().toString());
assertTrue(flowCommandData.getDependsOn().contains(SHARED_METER_UUID));
assertEquals(COOKIE, flowCommandData.getCookie());
assertEquals(table, flowCommandData.getTable());
assertEquals(Priority.Y_FLOW_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch;
if (encapsulation.getType().equals(FlowEncapsulationType.TRANSIT_VLAN)) {
expectedMatch = buildExpectedVlanMatch(PORT_NUMBER_1, encapsulation.getId());
} else {
expectedMatch = buildExpectedVxlanMatch(PORT_NUMBER_1, encapsulation.getId());
}
assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
Instructions expectedInstructions = Instructions.builder().applyActions(Lists.newArrayList(new PortOutAction(new PortNumber(PORT_NUMBER_2)))).goToMeter(SHARED_METER_ID).build();
assertEquals(expectedInstructions, flowCommandData.getInstructions());
assertEquals(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS), flowCommandData.getFlags());
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class SingleTableServer42IngressRuleGenerator method buildMatch.
private Set<FieldMatch> buildMatch(FlowEndpoint ingressEndpoint) {
int udpSrcPort = ingressEndpoint.getPortNumber() + config.getServer42FlowRttUdpPortOffset();
Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(switchProperties.getServer42Port()).build(), FieldMatch.builder().field(Field.ETH_SRC).value(switchProperties.getServer42MacAddress().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(udpSrcPort).build());
if (isVlanIdSet(ingressEndpoint.getOuterVlanId())) {
match.add(FieldMatch.builder().field(Field.VLAN_VID).value(ingressEndpoint.getOuterVlanId()).build());
}
return match;
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGenerator method buildServer42IngressSingleVlanCommand.
private FlowSpeakerData buildServer42IngressSingleVlanCommand(Switch sw, FlowEndpoint ingressEndpoint) {
RoutingMetadata metadata = RoutingMetadata.builder().inputPort(ingressEndpoint.getPortNumber()).outerVlanId(ingressEndpoint.getOuterVlanId()).build(sw.getFeatures());
Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(switchProperties.getServer42Port()).build(), FieldMatch.builder().field(Field.METADATA).value(metadata.getValue()).mask(metadata.getMask()).build());
return buildServer42IngressCommand(sw, ingressEndpoint, match, SERVER_42_INGRESS_SINGLE_VLAN_FLOW_PRIORITY);
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGenerator method buildServer42InputCommand.
private FlowSpeakerData buildServer42InputCommand(Switch sw, int inPort) {
int udpSrcPort = inPort + config.getServer42FlowRttUdpPortOffset();
Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(switchProperties.getServer42Port()).build(), FieldMatch.builder().field(Field.ETH_SRC).value(switchProperties.getServer42MacAddress().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(udpSrcPort).build());
PortColourCookie cookie = new PortColourCookie(CookieType.SERVER_42_FLOW_RTT_INPUT, inPort);
List<Action> applyActions = Lists.newArrayList(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT).build(), SetFieldAction.builder().field(Field.UDP_DST).value(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT).build());
if (sw.getFeatures().contains(NOVIFLOW_COPY_FIELD)) {
applyActions.add(buildServer42CopyFirstTimestamp());
}
Instructions instructions = Instructions.builder().applyActions(applyActions).goToTable(OfTable.PRE_INGRESS).writeMetadata(mapMetadata(RoutingMetadata.builder().inputPort(inPort).build(sw.getFeatures()))).build();
return FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(cookie).table(OfTable.INPUT).priority(Priority.SERVER_42_FLOW_RTT_INPUT_PRIORITY).match(match).instructions(instructions).build();
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class UniCastDiscoveryRuleGenerator method buildMatch.
private Set<FieldMatch> buildMatch(Switch sw) {
Set<FieldMatch> match = new HashSet<>();
long srcMac = new SwitchId(config.getFlowPingMagicSrcMacAddress()).toLong();
long dstMac = sw.getSwitchId().toLong();
match.add(FieldMatch.builder().field(Field.ETH_SRC).value(srcMac).mask(Mask.NO_MASK).build());
match.add(FieldMatch.builder().field(Field.ETH_DST).value(dstMac).mask(Mask.NO_MASK).build());
return match;
}
Aggregations