Search in sources :

Example 6 with PushVlanAction

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

the class MultiTableServer42IngressRuleGeneratorTest method buildTransformActionsVlanEncapsulationFullPortTest.

@Test
public void buildTransformActionsVlanEncapsulationFullPortTest() {
    Flow flow = buildFlow(PATH, 0, 0);
    MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
    List<Action> transformActions = generator.buildTransformActions(0, FEATURES);
    List<Action> expectedActions = 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(), new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build());
    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) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 7 with PushVlanAction

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

the class FlowLoopIngressRuleGeneratorTest method buildMultiTableSingleVlanRuleTest.

@Test
public void buildMultiTableSingleVlanRuleTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_1, 0, OUTER_VLAN_2, INNER_VLAN_2);
    List<SpeakerData> commands = buildGenerator(flow, true).generateCommands(SWITCH_1);
    assertIngressCommands(commands, OfTable.INGRESS, Priority.LOOP_FLOW_PRIORITY, newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), buildMetadataMatch(OUTER_VLAN_1)), newArrayList(new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_1).build(), new PortOutAction(new PortNumber(SpecialPortType.IN_PORT))));
}
Also used : PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 8 with PushVlanAction

use of org.openkilda.rulemanager.action.PushVlanAction 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)

Example 9 with PushVlanAction

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

the class SingleTableIngressRuleGeneratorTest method oneSwitchFlowFullPortRuleTest.

@Test
public void oneSwitchFlowFullPortRuleTest() {
    Flow flow = buildFlow(ONE_SWITCH_PATH, 0, OUTER_VLAN_ID_2);
    SingleTableIngressRuleGenerator generator = buildGenerator(ONE_SWITCH_PATH, flow, VLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(1, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    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)));
    assertIngressCommand(ingressCommand, Priority.DEFAULT_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions, null);
}
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) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) 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) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Example 10 with PushVlanAction

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

the class FlowLoopIngressRuleGeneratorTest method buildMultiTableDoubleVlanRuleTest.

@Test
public void buildMultiTableDoubleVlanRuleTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_1, INNER_VLAN_1, 0, 0);
    List<SpeakerData> commands = buildGenerator(flow, true).generateCommands(SWITCH_1);
    assertIngressCommands(commands, OfTable.INGRESS, Priority.LOOP_DOUBLE_VLAN_FLOW_PRIORITY, newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(INNER_VLAN_1).build(), buildMetadataMatch(OUTER_VLAN_1)), newArrayList(new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(OUTER_VLAN_1).build(), new PortOutAction(new PortNumber(SpecialPortType.IN_PORT))));
}
Also used : PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Flow(org.openkilda.model.Flow) Test(org.junit.Test)

Aggregations

PortOutAction (org.openkilda.rulemanager.action.PortOutAction)58 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)58 Action (org.openkilda.rulemanager.action.Action)53 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)53 Test (org.junit.Test)48 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)48 Flow (org.openkilda.model.Flow)46 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)37 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)23 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)21 SpeakerData (org.openkilda.rulemanager.SpeakerData)21 GroupAction (org.openkilda.rulemanager.action.GroupAction)16 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)15 FlowPath (org.openkilda.model.FlowPath)10 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)10 CopyFieldAction (org.openkilda.rulemanager.action.noviflow.CopyFieldAction)9 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)7 ArrayList (java.util.ArrayList)6 Cookie (org.openkilda.model.cookie.Cookie)6 Instructions (org.openkilda.rulemanager.Instructions)6