Search in sources :

Example 96 with PortOutAction

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

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

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

Example 99 with PortOutAction

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

the class IngressMirrorRuleGenerator method buildFlowBucket.

private Bucket buildFlowBucket(Set<SwitchFeature> features) {
    Set<Action> actions = new HashSet<>();
    // for one switch flow all vlan manipulations were made by ingress rule, not group.
    if (!flowPath.isOneSwitchFlow()) {
        switch(encapsulation.getType()) {
            case TRANSIT_VLAN:
                actions.addAll(makeVlanReplaceActions(new ArrayList<>(), makeVlanStack(encapsulation.getId())));
                break;
            case VXLAN:
                actions.add(buildPushVxlan(encapsulation.getId(), flowPath.getSrcSwitchId(), flowPath.getDestSwitchId(), VXLAN_UDP_SRC, features));
                break;
            default:
                throw new IllegalArgumentException(format("Unknown encapsulation type %s", encapsulation.getType()));
        }
    }
    actions.add(new PortOutAction(getOutPort(flowPath, flow)));
    return Bucket.builder().watchGroup(WatchGroup.ANY).watchPort(WatchPort.ANY).writeActions(actions).build();
}
Also used : Action(org.openkilda.rulemanager.action.Action) GroupAction(org.openkilda.rulemanager.action.GroupAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) HashSet(java.util.HashSet)

Example 100 with PortOutAction

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

the class BfdCatchRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    if (!sw.getFeatures().contains(SwitchFeature.BFD)) {
        return Collections.emptyList();
    }
    Set<FieldMatch> match = catchRuleMatch(sw);
    Instructions instructions = Instructions.builder().applyActions(Collections.singletonList(new PortOutAction(new PortNumber(SpecialPortType.LOCAL)))).build();
    return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(CATCH_BFD_RULE_COOKIE)).table(OfTable.INPUT).priority(CATCH_BFD_RULE_PRIORITY).match(match).instructions(instructions).build());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber)

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