Search in sources :

Example 21 with PortColourCookie

use of org.openkilda.model.cookie.PortColourCookie in project open-kilda by telstra.

the class TransitIslVxlanRuleGeneratorTest method shouldBuildCorrectRuleWithNoviflowVxlanFeature.

@Test
public void shouldBuildCorrectRuleWithNoviflowVxlanFeature() {
    Switch sw = buildSwitch("OF_13", Sets.newHashSet(SwitchFeature.NOVIFLOW_PUSH_POP_VXLAN));
    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.MULTI_TABLE_ISL_VXLAN_TRANSIT_RULES, ISL_PORT), flowCommandData.getCookie());
    assertEquals(OfTable.INPUT, flowCommandData.getTable());
    assertEquals(ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE, flowCommandData.getPriority());
    Set<FieldMatch> match = flowCommandData.getMatch();
    assertEquals(5, match.size());
    checkMatch(match);
    Instructions instructions = flowCommandData.getInstructions();
    assertEquals(OfTable.TRANSIT, instructions.getGoToTable());
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Utils.buildSwitch(org.openkilda.rulemanager.Utils.buildSwitch) Switch(org.openkilda.model.Switch) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) Test(org.junit.Test)

Example 22 with PortColourCookie

use of org.openkilda.model.cookie.PortColourCookie in project open-kilda by telstra.

the class Server42IslRttInputRuleGeneratorTest method server42IslRttInputRuleGeneratorTest.

@Test
public void server42IslRttInputRuleGeneratorTest() {
    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 PortColourCookie(CookieType.SERVER_42_ISL_RTT_INPUT, ISL_PORT), flowCommandData.getCookie());
    assertEquals(OfTable.INPUT, flowCommandData.getTable());
    assertEquals(SERVER_42_ISL_RTT_INPUT_PRIORITY, flowCommandData.getPriority());
    Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(Utils.SERVER_42_PORT).build(), 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(OFFSET + ISL_PORT).build());
    assertEquals(expectedMatch, flowCommandData.getMatch());
    List<Action> expectedApplyActions = Lists.newArrayList(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_ISL_RTT_FORWARD_UDP_PORT).build(), SetFieldAction.builder().field(Field.ETH_DST).value(MAC_ADDRESS.toLong()).build(), new PortOutAction(new PortNumber(ISL_PORT)));
    Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
    assertEquals(expectedInstructions, flowCommandData.getInstructions());
}
Also used : Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Utils.buildSwitch(org.openkilda.rulemanager.Utils.buildSwitch) Switch(org.openkilda.model.Switch) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) Test(org.junit.Test)

Example 23 with PortColourCookie

use of org.openkilda.model.cookie.PortColourCookie in project open-kilda by telstra.

the class MultiTableIngressRuleGeneratorTest method oneSwitchFlowFullPortRuleTest.

@Test
public void oneSwitchFlowFullPortRuleTest() {
    Flow flow = buildFlow(ONE_SWITCH_PATH, 0, 0, OUTER_VLAN_ID_2, 0);
    MultiTableIngressRuleGenerator generator = buildGenerator(ONE_SWITCH_PATH, flow, VLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(2, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(1);
    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 PortOutAction(new PortNumber(PORT_NUMBER_2)));
    RoutingMetadata metadata = RoutingMetadata.builder().oneSwitchFlowFlag(true).build(SWITCH_1.getFeatures());
    assertIngressCommand(ingressCommand, Priority.DEFAULT_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions, null, mapMetadata(metadata));
    assertInputCustomerCommand(inputCustomerCommand, new PortColourCookie(MULTI_TABLE_INGRESS_RULES, PORT_NUMBER_1), Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build()));
}
Also used : SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) Flow(org.openkilda.model.Flow) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 24 with PortColourCookie

use of org.openkilda.model.cookie.PortColourCookie in project open-kilda by telstra.

the class MultiTableIngressRuleGeneratorTest method buildCommandsVlanEncapsulationDoubleVlanTest.

@Test
public void buildCommandsVlanEncapsulationDoubleVlanTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
    MultiTableIngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(4, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
    FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(2);
    MeterSpeakerData meterCommand = (MeterSpeakerData) commands.get(3);
    assertEquals(newArrayList(meterCommand.getUuid()), new ArrayList<>(ingressCommand.getDependsOn()));
    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));
    assertInputCustomerCommand(inputCustomerCommand, new PortColourCookie(MULTI_TABLE_INGRESS_RULES, PORT_NUMBER_1), Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build()));
    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)));
    assertIngressCommand(ingressCommand, Priority.DOUBLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions, METER_ID, null);
    assertMeterCommand(meterCommand);
}
Also used : SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) Flow(org.openkilda.model.Flow) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 25 with PortColourCookie

use of org.openkilda.model.cookie.PortColourCookie in project open-kilda by telstra.

the class EgressIslVxlanRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    Set<SwitchFeature> features = sw.getFeatures();
    if (!(features.contains(NOVIFLOW_PUSH_POP_VXLAN) || features.contains(KILDA_OVS_PUSH_POP_MATCH_VXLAN))) {
        return Collections.emptyList();
    }
    Set<FieldMatch> match = buildEgressIslVxlanRuleMatch(sw.getSwitchId());
    Instructions instructions = Instructions.builder().goToTable(OfTable.EGRESS).build();
    return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new PortColourCookie(CookieType.MULTI_TABLE_ISL_VXLAN_EGRESS_RULES, islPort)).table(OfTable.INPUT).priority(ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE).match(match).instructions(instructions).build());
}
Also used : FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) SwitchFeature(org.openkilda.model.SwitchFeature) PortColourCookie(org.openkilda.model.cookie.PortColourCookie)

Aggregations

PortColourCookie (org.openkilda.model.cookie.PortColourCookie)27 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)15 Test (org.junit.Test)14 Instructions (org.openkilda.rulemanager.Instructions)14 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)10 SpeakerData (org.openkilda.rulemanager.SpeakerData)10 Switch (org.openkilda.model.Switch)6 Utils.buildSwitch (org.openkilda.rulemanager.Utils.buildSwitch)6 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)6 FlowEndpoint (org.openkilda.model.FlowEndpoint)5 FlowSharedSegmentCookie (org.openkilda.model.cookie.FlowSharedSegmentCookie)5 Action (org.openkilda.rulemanager.action.Action)5 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)5 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)5 ISwitchManager (org.openkilda.floodlight.switchmanager.ISwitchManager)4 CommandMessage (org.openkilda.messaging.command.CommandMessage)4 Cookie (org.openkilda.model.cookie.Cookie)4 OfMetadata (org.openkilda.rulemanager.OfMetadata)4 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)4 DatapathId (org.projectfloodlight.openflow.types.DatapathId)4