Search in sources :

Example 56 with PortOutAction

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

the class MeteredServiceRuleGenerator method buildSendToControllerInstructions.

protected static Instructions buildSendToControllerInstructions() {
    List<Action> actions = new ArrayList<>();
    actions.add(new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
    return Instructions.builder().applyActions(actions).build();
}
Also used : Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 57 with PortOutAction

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

the class UnicastVerificationVxlanRuleGenerator method buildUnicastVerificationRuleVxlan.

private FlowSpeakerData buildUnicastVerificationRuleVxlan(Switch sw, Cookie cookie) {
    List<Action> actions = new ArrayList<>();
    if (sw.getFeatures().contains(NOVIFLOW_PUSH_POP_VXLAN)) {
        actions.add(new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW));
    } else {
        actions.add(new PopVxlanAction(ActionType.POP_VXLAN_OVS));
    }
    actions.add(new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
    // todo remove unnecessary action
    actions.add(SetFieldAction.builder().field(ETH_DST).value(sw.getSwitchId().toLong()).build());
    Instructions instructions = Instructions.builder().applyActions(actions).build();
    long ethSrc = new SwitchId(config.getFlowPingMagicSrcMacAddress()).toLong();
    Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(ETH_SRC).value(ethSrc).mask(NO_MASK).build(), FieldMatch.builder().field(ETH_DST).value(sw.getSwitchId().toLong()).mask(NO_MASK).build(), FieldMatch.builder().field(ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(UDP_SRC).value(STUB_VXLAN_UDP_SRC).build());
    return FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(cookie).table(OfTable.INPUT).priority(VERIFICATION_RULE_VXLAN_PRIORITY).match(match).instructions(instructions).build();
}
Also used : Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) ArrayList(java.util.ArrayList) Instructions(org.openkilda.rulemanager.Instructions) SwitchId(org.openkilda.model.SwitchId) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 58 with PortOutAction

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

the class MultiTableIngressRuleGenerator method buildFlowIngressCommand.

private FlowSpeakerData buildFlowIngressCommand(Switch sw, FlowEndpoint ingressEndpoint) {
    // TODO should we check if switch supports encapsulation?
    List<Action> actions = new ArrayList<>(buildTransformActions(ingressEndpoint.getInnerVlanId(), sw.getFeatures()));
    actions.add(new PortOutAction(getOutPort(flowPath, flow)));
    FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(ingressEndpoint.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(flowPath.getCookie()).table(OfTable.INGRESS).priority(getPriority(ingressEndpoint)).match(buildIngressMatch(ingressEndpoint, sw.getFeatures())).instructions(buildInstructions(sw, actions));
    if (sw.getFeatures().contains(SwitchFeature.RESET_COUNTS_FLAG)) {
        builder.flags(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS));
    }
    return builder.build();
}
Also used : Action(org.openkilda.rulemanager.action.Action) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList)

Example 59 with PortOutAction

use of org.openkilda.rulemanager.action.PortOutAction 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 60 with PortOutAction

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

the class Server42IslRttTurningRuleGeneratorTest method server42IslRttTurningRuleGeneratorTest.

@Test
public void server42IslRttTurningRuleGeneratorTest() {
    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_TURNING_COOKIE), flowCommandData.getCookie());
    assertEquals(OfTable.INPUT, flowCommandData.getTable());
    assertEquals(SERVER_42_ISL_RTT_TURNING_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_FORWARD_UDP_PORT).build());
    assertEquals(expectedMatch, flowCommandData.getMatch());
    List<Action> expectedApplyActions = Lists.newArrayList(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_ISL_RTT_REVERSE_UDP_PORT).build(), new PortOutAction(new PortNumber(SpecialPortType.IN_PORT)));
    Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
    assertEquals(expectedInstructions, flowCommandData.getInstructions());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) 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) Test(org.junit.Test)

Aggregations

PortOutAction (org.openkilda.rulemanager.action.PortOutAction)102 Action (org.openkilda.rulemanager.action.Action)80 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)76 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)60 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)59 SpeakerData (org.openkilda.rulemanager.SpeakerData)56 Test (org.junit.Test)53 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)48 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)45 Flow (org.openkilda.model.Flow)40 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)40 Instructions (org.openkilda.rulemanager.Instructions)33 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)30 ArrayList (java.util.ArrayList)27 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)26 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)18 Cookie (org.openkilda.model.cookie.Cookie)17 MeterAction (org.openkilda.rulemanager.action.MeterAction)15 FlowPath (org.openkilda.model.FlowPath)14 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)14