Search in sources :

Example 71 with Instructions

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

the class SingleTableIngressRuleGenerator method buildFlowIngressCommand.

private FlowSpeakerData buildFlowIngressCommand(Switch sw, FlowEndpoint ingressEndpoint) {
    List<Action> actions = new ArrayList<>();
    Instructions instructions = Instructions.builder().applyActions(actions).build();
    // TODO should we check if switch supports encapsulation?
    actions.addAll(buildTransformActions(ingressEndpoint.getOuterVlanId(), sw.getFeatures()));
    actions.add(new PortOutAction(getOutPort(flowPath, flow)));
    addMeterToInstructions(flowPath.getMeterId(), sw, instructions);
    FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(ingressEndpoint.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(flowPath.getCookie()).table(OfTable.INPUT).priority(isFullPortEndpoint(ingressEndpoint) ? Constants.Priority.DEFAULT_FLOW_PRIORITY : Constants.Priority.FLOW_PRIORITY).match(buildMatch(ingressEndpoint, sw.getFeatures())).instructions(instructions);
    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) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList) Instructions(org.openkilda.rulemanager.Instructions)

Example 72 with Instructions

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

the class LldpPostIngressRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().lldpFlag(true), sw);
    Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(Field.METADATA).value(metadata.getValue()).mask(metadata.getMask()).build());
    Instructions instructions = buildSendToControllerInstructions();
    Cookie cookie = new Cookie(LLDP_POST_INGRESS_COOKIE);
    return buildCommands(sw, cookie, OfTable.POST_INGRESS, Priority.LLDP_POST_INGRESS_PRIORITY, match, instructions);
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Instructions(org.openkilda.rulemanager.Instructions)

Example 73 with Instructions

use of org.openkilda.rulemanager.Instructions 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 74 with Instructions

use of org.openkilda.rulemanager.Instructions 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 75 with Instructions

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

the class Server42FlowRttVxlanTurningRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    Set<SwitchFeature> features = sw.getFeatures();
    if (!features.contains(NOVIFLOW_SWAP_ETH_SRC_ETH_DST) && !features.contains(KILDA_OVS_SWAP_FIELD)) {
        return Collections.emptyList();
    }
    Set<FieldMatch> match = buildMatch(sw.getSwitchId());
    match.add(FieldMatch.builder().field(Field.UDP_DST).value(VXLAN_UDP_DST).build());
    Instructions instructions = buildInstructions(sw, SERVER_42_FLOW_RTT_REVERSE_UDP_VXLAN_PORT);
    return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(new Cookie(SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE)).table(OfTable.INPUT).priority(SERVER_42_FLOW_RTT_VXLAN_TURNING_PRIORITY).match(match).instructions(instructions).build());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) SwitchFeature(org.openkilda.model.SwitchFeature)

Aggregations

Instructions (org.openkilda.rulemanager.Instructions)84 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)55 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)40 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)35 Action (org.openkilda.rulemanager.action.Action)34 Cookie (org.openkilda.model.cookie.Cookie)31 SpeakerData (org.openkilda.rulemanager.SpeakerData)29 Test (org.junit.Test)26 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)25 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)24 ArrayList (java.util.ArrayList)14 PortColourCookie (org.openkilda.model.cookie.PortColourCookie)14 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)13 Switch (org.openkilda.model.Switch)12 Utils.buildSwitch (org.openkilda.rulemanager.Utils.buildSwitch)12 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)11 PopVxlanAction (org.openkilda.rulemanager.action.PopVxlanAction)10 MeterAction (org.openkilda.rulemanager.action.MeterAction)9 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)9 OfMetadata (org.openkilda.rulemanager.OfMetadata)8