Search in sources :

Example 21 with PopVlanAction

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

the class MultiTableIngressRuleGeneratorTest method buildCommandsVlanEncapsulationDoubleVlanPortOverlappingTest.

@Test
public void buildCommandsVlanEncapsulationDoubleVlanPortOverlappingTest() {
    Flow oneSwitchFlow = buildFlow(ONE_SWITCH_PATH, OUTER_VLAN_ID_2, 0);
    Set<FlowSideAdapter> overlapping = Sets.newHashSet(FlowSideAdapter.makeIngressAdapter(oneSwitchFlow, ONE_SWITCH_PATH));
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
    MultiTableIngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION, overlapping);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(3, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
    MeterSpeakerData meterCommand = (MeterSpeakerData) commands.get(2);
    assertEquals(newArrayList(meterCommand.getUuid()), new ArrayList<>(ingressCommand.getDependsOn()));
    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)));
    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));
    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) Flow(org.openkilda.model.Flow) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) 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 22 with PopVlanAction

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

the class OfInstructionsConverter method convertToRuleManagerAction.

/**
 * Converts action.
 */
public Action convertToRuleManagerAction(OFAction action) {
    switch(action.getType()) {
        case PUSH_VLAN:
            return new PushVlanAction();
        case POP_VLAN:
            return new PopVlanAction();
        case METER:
            OFActionMeter meterAction = (OFActionMeter) action;
            MeterId meterId = new MeterId(meterAction.getMeterId());
            return new MeterAction(meterId);
        case GROUP:
            OFActionGroup groupAction = (OFActionGroup) action;
            GroupId groupId = new GroupId(groupAction.getGroup().getGroupNumber());
            return new GroupAction(groupId);
        case OUTPUT:
            OFActionOutput outputAction = (OFActionOutput) action;
            PortNumber portNumber = convertPort(outputAction.getPort());
            return new PortOutAction(portNumber);
        case EXPERIMENTER:
            if (action instanceof OFActionNoviflowPushVxlanTunnel) {
                OFActionNoviflowPushVxlanTunnel pushNoviVxlan = (OFActionNoviflowPushVxlanTunnel) action;
                return PushVxlanAction.builder().type(ActionType.PUSH_VXLAN_NOVIFLOW).vni((int) pushNoviVxlan.getVni()).srcMacAddress(convertMac(pushNoviVxlan.getEthSrc())).dstMacAddress(convertMac(pushNoviVxlan.getEthDst())).srcIpv4Address(convertIPv4Address(pushNoviVxlan.getIpv4Src())).dstIpv4Address(convertIPv4Address(pushNoviVxlan.getIpv4Dst())).udpSrc(pushNoviVxlan.getUdpSrc()).build();
            } else if (action instanceof OFActionKildaPushVxlanField) {
                OFActionKildaPushVxlanField pushKildaVxlan = (OFActionKildaPushVxlanField) action;
                return PushVxlanAction.builder().type(ActionType.PUSH_VXLAN_OVS).vni((int) pushKildaVxlan.getVni()).srcMacAddress(convertMac(pushKildaVxlan.getEthSrc())).dstMacAddress(convertMac(pushKildaVxlan.getEthDst())).srcIpv4Address(convertIPv4Address(pushKildaVxlan.getIpv4Src())).dstIpv4Address(convertIPv4Address(pushKildaVxlan.getIpv4Dst())).udpSrc(pushKildaVxlan.getUdpSrc()).build();
            } else if (action instanceof OFActionNoviflowCopyField) {
                OFActionNoviflowCopyField copyField = (OFActionNoviflowCopyField) action;
                return CopyFieldAction.builder().numberOfBits(copyField.getNBits()).srcOffset(copyField.getSrcOffset()).dstOffset(copyField.getDstOffset()).oxmSrcHeader(convertOxmHeader(copyField.getOxmSrcHeader())).oxmDstHeader(convertOxmHeader(copyField.getOxmDstHeader())).build();
            } else if (action instanceof OFActionNoviflowSwapField) {
                OFActionNoviflowSwapField swapField = (OFActionNoviflowSwapField) action;
                return SwapFieldAction.builder().type(ActionType.NOVI_SWAP_FIELD).numberOfBits(swapField.getNBits()).srcOffset(swapField.getSrcOffset()).dstOffset(swapField.getDstOffset()).oxmSrcHeader(convertOxmHeader(swapField.getOxmSrcHeader())).oxmDstHeader(convertOxmHeader(swapField.getOxmDstHeader())).build();
            } else if (action instanceof OFActionKildaSwapField) {
                OFActionKildaSwapField swapField = (OFActionKildaSwapField) action;
                return SwapFieldAction.builder().type(ActionType.KILDA_SWAP_FIELD).numberOfBits(swapField.getNBits()).srcOffset(swapField.getSrcOffset()).dstOffset(swapField.getDstOffset()).oxmSrcHeader(convertOxmHeader(swapField.getOxmSrcHeader())).oxmDstHeader(convertOxmHeader(swapField.getOxmDstHeader())).build();
            } else if (action instanceof OFActionNoviflowPopVxlanTunnel) {
                return new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW);
            } else if (action instanceof OFActionKildaPopVxlanField) {
                return new PopVxlanAction(ActionType.POP_VXLAN_OVS);
            } else {
                throw new IllegalStateException(format("Unknown experimenter action %s", action.getType()));
            }
        case SET_FIELD:
            OFActionSetField setFieldAction = (OFActionSetField) action;
            return convertOxm(setFieldAction.getField());
        case SET_VLAN_VID:
            OFActionSetVlanVid setVlanVid = (OFActionSetVlanVid) action;
            return SetFieldAction.builder().field(Field.VLAN_VID).value(setVlanVid.getVlanVid().getVlan()).build();
        default:
            throw new IllegalStateException(format("Unknown action type %s", action.getType()));
    }
}
Also used : OFActionOutput(org.projectfloodlight.openflow.protocol.action.OFActionOutput) OFActionNoviflowPushVxlanTunnel(org.projectfloodlight.openflow.protocol.action.OFActionNoviflowPushVxlanTunnel) OFActionNoviflowPopVxlanTunnel(org.projectfloodlight.openflow.protocol.action.OFActionNoviflowPopVxlanTunnel) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) MeterAction(org.openkilda.rulemanager.action.MeterAction) OFActionNoviflowCopyField(org.projectfloodlight.openflow.protocol.action.OFActionNoviflowCopyField) OFActionGroup(org.projectfloodlight.openflow.protocol.action.OFActionGroup) OFActionNoviflowSwapField(org.projectfloodlight.openflow.protocol.action.OFActionNoviflowSwapField) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) MeterId(org.openkilda.model.MeterId) GroupId(org.openkilda.model.GroupId) GroupAction(org.openkilda.rulemanager.action.GroupAction) OFActionMeter(org.projectfloodlight.openflow.protocol.action.OFActionMeter) OFActionSetVlanVid(org.projectfloodlight.openflow.protocol.action.OFActionSetVlanVid) OFActionKildaPushVxlanField(org.projectfloodlight.openflow.protocol.action.OFActionKildaPushVxlanField) OFActionKildaPopVxlanField(org.projectfloodlight.openflow.protocol.action.OFActionKildaPopVxlanField) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) OFActionSetField(org.projectfloodlight.openflow.protocol.action.OFActionSetField) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) OFActionKildaSwapField(org.projectfloodlight.openflow.protocol.action.OFActionKildaSwapField)

Example 23 with PopVlanAction

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

the class IngressMirrorRuleGeneratorTest method buildSingleTableIngressActionsOneSwitchSingleVlanInFullPortOutTest.

@Test
public void buildSingleTableIngressActionsOneSwitchSingleVlanInFullPortOutTest() {
    Flow flow = buildFlow(SINGLE_TABLE_ONE_SWITCH_PATH, OUTER_VLAN_ID_1, 0, 0, 0);
    IngressMirrorRuleGenerator generator = buildGenerator(SINGLE_TABLE_ONE_SWITCH_PATH, flow, VLAN_ENCAPSULATION);
    List<Action> transformActions = generator.buildIngressActions(getEndpoint(flow), GROUP_ID);
    List<Action> expectedActions = newArrayList(new PopVlanAction(), new GroupAction(GROUP_ID));
    assertEquals(expectedActions, transformActions);
}
Also used : GroupAction(org.openkilda.rulemanager.action.GroupAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) 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 24 with PopVlanAction

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

the class IngressMirrorRuleGeneratorTest method buildIngressActionsVlanEncapsulationInnerVlanEqualTransitVlanTest.

@Test
public void buildIngressActionsVlanEncapsulationInnerVlanEqualTransitVlanTest() {
    Flow flow = buildFlow(MULTI_TABLE_PATH, OUTER_VLAN_ID_1, TRANSIT_VLAN_ID);
    IngressMirrorRuleGenerator generator = buildGenerator(MULTI_TABLE_PATH, flow, VLAN_ENCAPSULATION);
    List<Action> transformActions = generator.buildIngressActions(getEndpoint(flow), GROUP_ID);
    List<Action> expectedActions = newArrayList(new PopVlanAction(), new GroupAction(GROUP_ID));
    assertEquals(expectedActions, transformActions);
}
Also used : GroupAction(org.openkilda.rulemanager.action.GroupAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) 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 25 with PopVlanAction

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

the class IngressMirrorRuleGeneratorTest method buildSingleTableCommandsVlanEncapsulationSingleVlanTest.

@Test
public void buildSingleTableCommandsVlanEncapsulationSingleVlanTest() {
    Flow flow = buildFlow(SINGLE_TABLE_PATH, OUTER_VLAN_ID_1, 0);
    IngressMirrorRuleGenerator generator = buildGenerator(SINGLE_TABLE_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(), FieldMatch.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID_1).build());
    List<Action> expectedIngressActions = newArrayList(new PopVlanAction(), new GroupAction(GROUP_ID));
    assertIngressCommand(ingressCommand, Priority.MIRROR_FLOW_PRIORITY, INPUT, expectedIngressMatch, expectedIngressActions, METER_ID, groupCommand.getUuid());
    Set<Action> expectedFlowBucketActions = newHashSet(new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
    assertGroupCommand(groupCommand, expectedFlowBucketActions);
}
Also used : GroupAction(org.openkilda.rulemanager.action.GroupAction) 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) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Flow(org.openkilda.model.Flow) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) Test(org.junit.Test)

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