use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class Server42FlowRttOutputVxlanRuleGeneratorTest method testOutputRule.
private void testOutputRule(Switch sw, Action expectedPopVxlan, boolean copyField) {
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_FLOW_RTT_OUTPUT_VXLAN_COOKIE), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(SERVER_42_FLOW_RTT_OUTPUT_VXLAN_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.ETH_DST).value(sw.getSwitchId().toMacAddressAsLong()).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_FLOW_RTT_REVERSE_UDP_VXLAN_PORT).build(), FieldMatch.builder().field(Field.UDP_DST).value(VXLAN_UDP_DST).build());
assertEquals(expectedMatch, flowCommandData.getMatch());
List<Action> expectedApplyActions = Lists.newArrayList(expectedPopVxlan, new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(Utils.SERVER_42_VLAN).build(), SetFieldAction.builder().field(Field.ETH_SRC).value(sw.getSwitchId().toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.ETH_DST).value(Utils.SERVER_42_MAC_ADDRESS.toLong()).build(), SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_FLOW_RTT_REVERSE_UDP_PORT).build());
if (copyField) {
expectedApplyActions.add(CopyFieldAction.builder().oxmSrcHeader(OpenFlowOxms.NOVIFLOW_TX_TIMESTAMP).oxmDstHeader(OpenFlowOxms.NOVIFLOW_UDP_PAYLOAD_OFFSET).srcOffset(0).dstOffset(NOVIFLOW_TIMESTAMP_SIZE_IN_BITS).numberOfBits(NOVIFLOW_TIMESTAMP_SIZE_IN_BITS).build());
}
expectedApplyActions.add(new PortOutAction(new PortNumber(Utils.SERVER_42_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 Server42FlowRttVxlanTurningRuleGeneratorTest method testOutputRule.
private void testOutputRule(Switch sw, ActionType expectedSwapFieldType) {
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_FLOW_RTT_VXLAN_TURNING_COOKIE), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(SERVER_42_FLOW_RTT_VXLAN_TURNING_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.ETH_DST).value(sw.getSwitchId().toMacAddressAsLong()).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_FLOW_RTT_FORWARD_UDP_PORT).build(), FieldMatch.builder().field(Field.UDP_DST).value(VXLAN_UDP_DST).build());
assertEquals(expectedMatch, flowCommandData.getMatch());
List<Action> expectedApplyActions = Lists.newArrayList(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_FLOW_RTT_REVERSE_UDP_VXLAN_PORT).build(), SwapFieldAction.builder().type(expectedSwapFieldType).numberOfBits(MAC_ADDRESS_SIZE_IN_BITS).srcOffset(0).dstOffset(0).oxmSrcHeader(OpenFlowOxms.ETH_SRC).oxmDstHeader(OpenFlowOxms.ETH_DST).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 Server42IslRttOutputRuleGeneratorTest method server42IslRttOutputRuleGeneratorTest.
@Test
public void server42IslRttOutputRuleGeneratorTest() {
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_OUTPUT_COOKIE), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(SERVER_42_ISL_RTT_OUTPUT_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_REVERSE_UDP_PORT).build());
assertEquals(expectedMatch, flowCommandData.getMatch());
List<Action> expectedApplyActions = Lists.newArrayList(new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(Utils.SERVER_42_VLAN).build(), SetFieldAction.builder().field(Field.ETH_SRC).value(sw.getSwitchId().toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.ETH_DST).value(Utils.SERVER_42_MAC_ADDRESS.toLong()).build(), new PortOutAction(new PortNumber(Utils.SERVER_42_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 RuleManagerHelperTest method buildFullFlowSpeakerCommandData.
private FlowSpeakerData buildFullFlowSpeakerCommandData(MeterId goToMeterId, UUID dependsOnUuid) {
Set<FieldMatch> match = Arrays.stream(Field.values()).map(f -> FieldMatch.builder().field(f).value(f.ordinal()).mask(f.ordinal() + 1L).build()).collect(Collectors.toSet());
Set<OfFlowFlag> flags = Sets.newHashSet(OfFlowFlag.values());
List<Action> applyActions = new ArrayList<>(buildAllActions());
applyActions.addAll(buildAllActions());
Instructions instructions = Instructions.builder().goToMeter(goToMeterId).goToTable(OfTable.INPUT).writeMetadata(new OfMetadata(15, 0xff)).writeActions(new HashSet<>(buildAllActions())).applyActions(applyActions).build();
return FlowSpeakerData.builder().uuid(UUID.randomUUID()).cookie(new Cookie(123)).priority(PRIORITY).table(OfTable.INPUT).match(match).instructions(instructions).flags(flags).switchId(SWITCH_ID).ofVersion(OfVersion.OF_13).dependsOn(dependsOnUuid == null ? newArrayList() : newArrayList(dependsOnUuid)).build();
}
use of org.openkilda.rulemanager.match.FieldMatch in project open-kilda by telstra.
the class IngressMirrorRuleGeneratorTest method oneSwitchFlowFullPortRuleTest.
@Test
public void oneSwitchFlowFullPortRuleTest() {
Flow flow = buildFlow(MULTI_TABLE_ONE_SWITCH_PATH, 0, 0, OUTER_VLAN_ID_2, 0);
IngressMirrorRuleGenerator generator = buildGenerator(MULTI_TABLE_ONE_SWITCH_PATH, flow, VLAN_ENCAPSULATION);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(2, commands.size());
FlowSpeakerData ingressCommand = getCommand(FlowSpeakerData.class, commands);
GroupSpeakerData groupCommand = getCommand(GroupSpeakerData.class, commands);
Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build());
List<Action> expectedIngressActions = newArrayList(new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID_2).build(), new GroupAction(GROUP_ID));
assertIngressCommand(ingressCommand, Priority.MIRROR_DEFAULT_FLOW_PRIORITY, INGRESS, expectedIngressMatch, expectedIngressActions, null, groupCommand.getUuid());
Set<Action> expectedFlowBucketActions = newHashSet(new PortOutAction(new PortNumber(PORT_NUMBER_2)));
assertGroupCommand(groupCommand, expectedFlowBucketActions);
}
Aggregations