Search in sources :

Example 71 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.

the class FlowLoopTransitRuleGenerator method buildInstructions.

private Instructions buildInstructions(SwitchId switchId) {
    List<Action> applyActions = new ArrayList<>();
    if (FlowEncapsulationType.VXLAN.equals(encapsulation.getType())) {
        // After turning of VXLAN packet we must update eth_dst header because egress rule on the last switch
        // will match the packet by this field.
        applyActions.add(SetFieldAction.builder().field(ETH_SRC).value(switchId.toMacAddressAsLong()).build());
        applyActions.add(SetFieldAction.builder().field(ETH_DST).value(flowPath.getSrcSwitchId().toMacAddressAsLong()).build());
    }
    applyActions.add(new PortOutAction(new PortNumber(SpecialPortType.IN_PORT)));
    return Instructions.builder().applyActions(applyActions).build();
}
Also used : Action(org.openkilda.rulemanager.action.Action) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 72 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.

the class RoundTripLatencyRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    if (!sw.getFeatures().contains(NOVIFLOW_COPY_FIELD)) {
        return Collections.emptyList();
    }
    Set<FieldMatch> match = roundTripLatencyRuleMatch(sw);
    List<Action> actions = ImmutableList.of(actionAddRxTimestamp(), new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
    Instructions instructions = Instructions.builder().applyActions(actions).build();
    return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(ROUND_TRIP_LATENCY_RULE_COOKIE)).table(OfTable.INPUT).priority(ROUND_TRIP_LATENCY_RULE_PRIORITY).match(match).instructions(instructions).build());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) Action(org.openkilda.rulemanager.action.Action) CopyFieldAction(org.openkilda.rulemanager.action.noviflow.CopyFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

Example 73 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.

the class Server42FlowRttOutputVxlanRuleGenerator 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();
    }
    List<Action> actions = new ArrayList<>();
    actions.add(buildPopVxlanAction(features));
    if (server42Vlan > 0) {
        actions.add(new PushVlanAction());
        actions.add(SetFieldAction.builder().field(Field.VLAN_VID).value(server42Vlan).build());
    }
    actions.add(SetFieldAction.builder().field(Field.ETH_SRC).value(sw.getSwitchId().toLong()).build());
    actions.add(SetFieldAction.builder().field(Field.ETH_DST).value(server42MacAddress.toLong()).build());
    actions.add(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_FLOW_RTT_REVERSE_UDP_PORT).build());
    if (sw.getFeatures().contains(NOVIFLOW_COPY_FIELD)) {
        // NOTE: We must call copy field action after all set field actions. All set actions called after copy field
        // actions will be ignored. It's Noviflow bug.
        actions.add(buildCopyTimestamp());
    }
    actions.add(new PortOutAction(new PortNumber(server42Port)));
    Instructions instructions = Instructions.builder().applyActions(actions).build();
    return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE)).table(OfTable.INPUT).priority(SERVER_42_FLOW_RTT_OUTPUT_VXLAN_PRIORITY).match(buildMatch(sw.getSwitchId())).instructions(instructions).build());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) Action(org.openkilda.rulemanager.action.Action) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) CopyFieldAction(org.openkilda.rulemanager.action.noviflow.CopyFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) ArrayList(java.util.ArrayList) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SwitchFeature(org.openkilda.model.SwitchFeature)

Example 74 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.

the class Server42IslRttOutputRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    List<Action> actions = new ArrayList<>();
    if (server42Vlan > 0) {
        actions.add(new PushVlanAction());
        actions.add(SetFieldAction.builder().field(Field.VLAN_VID).value(server42Vlan).build());
    }
    actions.add(SetFieldAction.builder().field(ETH_SRC).value(sw.getSwitchId().toMacAddressAsLong()).build());
    actions.add(SetFieldAction.builder().field(ETH_DST).value(server42MacAddress.toLong()).build());
    actions.add(new PortOutAction(new PortNumber(server42Port)));
    Instructions instructions = Instructions.builder().applyActions(actions).build();
    Set<FieldMatch> match = buildMatch(new MacAddress(config.getServer42IslRttMagicMacAddress()));
    return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(SERVER_42_ISL_RTT_OUTPUT_COOKIE)).table(OfTable.INPUT).priority(SERVER_42_ISL_RTT_OUTPUT_PRIORITY).match(match).instructions(instructions).build());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) Action(org.openkilda.rulemanager.action.Action) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) ArrayList(java.util.ArrayList) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) MacAddress(org.openkilda.model.MacAddress)

Example 75 with PortNumber

use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.

the class FlowLoopIngressRuleGenerator method makeIngressFlowLoopInstructions.

private Instructions makeIngressFlowLoopInstructions(FlowEndpoint endpoint) {
    List<Action> applyActions = new ArrayList<>();
    if (multiTable) {
        applyActions.addAll(Utils.makeVlanReplaceActions(FlowEndpoint.makeVlanStack(endpoint.getInnerVlanId()), endpoint.getVlanStack()));
    }
    applyActions.add(new PortOutAction(new PortNumber(SpecialPortType.IN_PORT)));
    return Instructions.builder().applyActions(applyActions).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)

Aggregations

PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)76 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)76 Action (org.openkilda.rulemanager.action.Action)58 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)52 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)52 SpeakerData (org.openkilda.rulemanager.SpeakerData)49 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)47 Test (org.junit.Test)46 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)41 Flow (org.openkilda.model.Flow)40 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)37 Instructions (org.openkilda.rulemanager.Instructions)24 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)23 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)21 ArrayList (java.util.ArrayList)19 Cookie (org.openkilda.model.cookie.Cookie)15 FlowPath (org.openkilda.model.FlowPath)14 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)14 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)13 GroupSpeakerData (org.openkilda.rulemanager.GroupSpeakerData)8