Search in sources :

Example 6 with PopVlanAction

use of org.openkilda.rulemanager.action.PopVlanAction in project open-kilda by telstra.

the class MultiTableServer42IngressRuleGeneratorTest method buildTransformActionsVxlanEncapsulationDoubleVlanTest.

@Test
public void buildTransformActionsVxlanEncapsulationDoubleVlanTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
    MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VXLAN_ENCAPSULATION);
    List<Action> transformActions = generator.buildTransformActions(INNER_VLAN_ID_1, FEATURES);
    List<Action> expectedActions = newArrayList(new PopVlanAction(), buildPushVxlan());
    assertEquals(expectedActions, transformActions);
}
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) Flow(org.openkilda.model.Flow) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) Test(org.junit.Test)

Example 7 with PopVlanAction

use of org.openkilda.rulemanager.action.PopVlanAction in project open-kilda by telstra.

the class MultiTableServer42IngressRuleGeneratorTest method buildCommandsVxlanEncapsulationSingleVlanTest.

@Test
public void buildCommandsVxlanEncapsulationSingleVlanTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, 0);
    MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VXLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(3, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
    FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(2);
    assertPreIngressCommand(preIngressCommand, newArrayList(new PopVlanAction()));
    assertInputCommand(inputCustomerCommand);
    RoutingMetadata ingressMetadata = RoutingMetadata.builder().inputPort(PORT_NUMBER_1).outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
    Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(SERVER_42_PORT_NUMBER).build(), FieldMatch.builder().field(Field.METADATA).value(ingressMetadata.getValue()).mask(ingressMetadata.getMask()).build());
    List<Action> expectedIngressActions = newArrayList(buildPushVxlan(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
    assertIngressCommand(ingressCommand, Priority.SERVER_42_INGRESS_SINGLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions);
}
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) Flow(org.openkilda.model.Flow) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 8 with PopVlanAction

use of org.openkilda.rulemanager.action.PopVlanAction in project open-kilda by telstra.

the class MultiTableServer42IngressRuleGeneratorTest method buildCommandsVlanEncapsulationDoubleVlanTest.

@Test
public void buildCommandsVlanEncapsulationDoubleVlanTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
    MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(3, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
    FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(2);
    assertPreIngressCommand(preIngressCommand, newArrayList(new PopVlanAction()));
    assertInputCommand(inputCustomerCommand);
    RoutingMetadata ingressMetadata = RoutingMetadata.builder().inputPort(PORT_NUMBER_1).outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
    Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(SERVER_42_PORT_NUMBER).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.ETH_SRC).value(SWITCH_ID_1.toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.ETH_DST).value(SWITCH_ID_2.toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
    assertIngressCommand(ingressCommand, Priority.SERVER_42_INGRESS_DOUBLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions);
}
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) Flow(org.openkilda.model.Flow) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 9 with PopVlanAction

use of org.openkilda.rulemanager.action.PopVlanAction in project open-kilda by telstra.

the class SingleTableIngressYRuleGeneratorTest method buildTransformActionsOneSwitchSingleVlanInFullPortOutTest.

@Test
public void buildTransformActionsOneSwitchSingleVlanInFullPortOutTest() {
    Flow flow = buildFlow(ONE_SWITCH_PATH, OUTER_VLAN_ID_1, 0);
    SingleTableIngressYRuleGenerator generator = buildGenerator(ONE_SWITCH_PATH, flow, VLAN_ENCAPSULATION);
    List<Action> transformActions = generator.buildTransformActions(OUTER_VLAN_ID_1, FEATURES);
    List<Action> expectedActions = newArrayList(new PopVlanAction());
    assertEquals(expectedActions, transformActions);
}
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) Flow(org.openkilda.model.Flow) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) Test(org.junit.Test)

Example 10 with PopVlanAction

use of org.openkilda.rulemanager.action.PopVlanAction in project open-kilda by telstra.

the class Utils method makeVlanReplaceActions.

/**
 * Create series of actions required to reTAG one set of vlan tags to another.
 */
public static List<Action> makeVlanReplaceActions(List<Integer> currentVlanStack, List<Integer> targetVlanStack) {
    Iterator<Integer> currentIter = currentVlanStack.iterator();
    Iterator<Integer> targetIter = targetVlanStack.iterator();
    final List<Action> actions = new ArrayList<>();
    while (currentIter.hasNext() && targetIter.hasNext()) {
        Integer current = currentIter.next();
        Integer target = targetIter.next();
        if (current == null || target == null) {
            throw new IllegalArgumentException("Null elements are not allowed inside currentVlanStack and targetVlanStack arguments");
        }
        if (!current.equals(target)) {
            // remove all extra VLANs
            while (currentIter.hasNext()) {
                currentIter.next();
                actions.add(new PopVlanAction());
            }
            // rewrite existing VLAN stack "head"
            actions.add(SetFieldAction.builder().field(Field.VLAN_VID).value(target).build());
            break;
        }
    }
    // remove all extra VLANs (if previous loops ends with lack of target VLANs)
    while (currentIter.hasNext()) {
        currentIter.next();
        actions.add(new PopVlanAction());
    }
    while (targetIter.hasNext()) {
        actions.add(new PushVlanAction());
        actions.add(SetFieldAction.builder().field(Field.VLAN_VID).value(targetIter.next()).build());
    }
    return actions;
}
Also used : 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) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) ArrayList(java.util.ArrayList) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction)

Aggregations

PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)35 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)33 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)33 Action (org.openkilda.rulemanager.action.Action)32 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)32 Test (org.junit.Test)29 Flow (org.openkilda.model.Flow)29 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)28 GroupAction (org.openkilda.rulemanager.action.GroupAction)14 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)11 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)11 SpeakerData (org.openkilda.rulemanager.SpeakerData)11 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)7 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)7 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)7 CopyFieldAction (org.openkilda.rulemanager.action.noviflow.CopyFieldAction)5 FlowPath (org.openkilda.model.FlowPath)4 FlowSharedSegmentCookie (org.openkilda.model.cookie.FlowSharedSegmentCookie)4 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)4 ArrayList (java.util.ArrayList)3