Search in sources :

Example 21 with SwitchFeature

use of org.openkilda.model.SwitchFeature in project open-kilda by telstra.

the class Server42FlowRttOutputVxlanFlowGenerator method generateFlow.

@Override
public SwitchFlowTuple generateFlow(IOFSwitch sw) {
    Set<SwitchFeature> features = featureDetectorService.detectSwitch(sw);
    if (!features.contains(NOVIFLOW_PUSH_POP_VXLAN) && !features.contains(KILDA_OVS_PUSH_POP_MATCH_VXLAN)) {
        return SwitchFlowTuple.getEmpty();
    }
    OFFactory ofFactory = sw.getOFFactory();
    List<OFAction> actions = new ArrayList<>();
    actions.add(buildPopVxlanAction(ofFactory, features));
    if (server42Vlan > 0) {
        actions.add(actionPushVlan(ofFactory, EthType.VLAN_FRAME.getValue()));
        actions.add(actionReplaceVlan(ofFactory, server42Vlan));
    }
    actions.add(actionSetSrcMac(ofFactory, convertDpIdToMac(sw.getId())));
    actions.add(actionSetDstMac(ofFactory, org.projectfloodlight.openflow.types.MacAddress.of(server42MacAddress.getAddress())));
    actions.add(actionSetUdpSrcAction(ofFactory, TransportPort.of(SERVER_42_FLOW_RTT_REVERSE_UDP_PORT)));
    if (features.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(ofFactory));
    }
    actions.add(actionSetOutputPort(ofFactory, OFPort.of(server42Port)));
    OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE, SERVER_42_FLOW_RTT_OUTPUT_VXLAN_PRIORITY, INPUT_TABLE_ID).setMatch(buildMatch(sw.getId(), ofFactory)).setInstructions(ImmutableList.of(buildInstructionApplyActions(ofFactory, actions))).build();
    return SwitchFlowTuple.builder().sw(sw).flow(flowMod).build();
}
Also used : OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) ArrayList(java.util.ArrayList) SwitchFeature(org.openkilda.model.SwitchFeature) OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod)

Example 22 with SwitchFeature

use of org.openkilda.model.SwitchFeature in project open-kilda by telstra.

the class Server42FlowRttVxlanTurningFlowGenerator method generateFlow.

@Override
public SwitchFlowTuple generateFlow(IOFSwitch sw) {
    Set<SwitchFeature> switchFeatures = featureDetectorService.detectSwitch(sw);
    if (!switchFeatures.contains(NOVIFLOW_SWAP_ETH_SRC_ETH_DST) && !switchFeatures.contains(KILDA_OVS_SWAP_FIELD)) {
        return SwitchFlowTuple.getEmpty();
    }
    OFFactory ofFactory = sw.getOFFactory();
    Match match = buildMatch(sw.getId(), ofFactory);
    List<OFAction> actions = ImmutableList.of(actionSetUdpSrcAction(ofFactory, TransportPort.of(SERVER_42_FLOW_RTT_REVERSE_UDP_VXLAN_PORT)), buildSwapAction(switchFeatures, ofFactory), actionSetOutputPort(ofFactory, OFPort.IN_PORT));
    OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE, SERVER_42_FLOW_RTT_VXLAN_TURNING_PRIORITY, INPUT_TABLE_ID).setMatch(match).setInstructions(ImmutableList.of(buildInstructionApplyActions(ofFactory, actions))).build();
    return SwitchFlowTuple.builder().sw(sw).flow(flowMod).build();
}
Also used : OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) SwitchFeature(org.openkilda.model.SwitchFeature) OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod) Match(org.projectfloodlight.openflow.protocol.match.Match)

Example 23 with SwitchFeature

use of org.openkilda.model.SwitchFeature in project open-kilda by telstra.

the class ArpPostIngressVxlanFlowGenerator method getArpFlowMod.

@Override
OFFlowMod getArpFlowMod(IOFSwitch sw, OFInstructionMeter meter, List<OFAction> actionList) {
    OFFactory ofFactory = sw.getOFFactory();
    Set<SwitchFeature> features = featureDetectorService.detectSwitch(sw);
    if (!features.contains(NOVIFLOW_PUSH_POP_VXLAN) && !features.contains(KILDA_OVS_PUSH_POP_MATCH_VXLAN)) {
        return null;
    }
    RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().arpFlag(true), sw);
    Match.Builder matchBuilder = ofFactory.buildMatch().setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).setExact(MatchField.IP_PROTO, IpProtocol.UDP).setExact(MatchField.UDP_SRC, TransportPort.of(ARP_VXLAN_UDP_SRC)).setExact(MatchField.UDP_DST, TransportPort.of(VXLAN_UDP_DST));
    if (features.contains(KILDA_OVS_PUSH_POP_MATCH_VXLAN)) {
        matchBuilder.setExact(MatchField.ETH_TYPE, EthType.IPv4);
    }
    Match match = matchBuilder.build();
    if (features.contains(NOVIFLOW_PUSH_POP_VXLAN)) {
        actionList.add(ofFactory.actions().noviflowPopVxlanTunnel());
    } else {
        actionList.add(ofFactory.actions().kildaPopVxlanField());
    }
    actionList.add(actionSendToController(sw.getOFFactory()));
    OFInstructionApplyActions actions = ofFactory.instructions().applyActions(actionList).createBuilder().build();
    return prepareFlowModBuilder(ofFactory, ARP_POST_INGRESS_VXLAN_COOKIE, ARP_POST_INGRESS_VXLAN_PRIORITY, POST_INGRESS_TABLE_ID).setMatch(match).setInstructions(meter != null ? ImmutableList.of(meter, actions) : ImmutableList.of(actions)).build();
}
Also used : OFInstructionApplyActions(org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) RoutingMetadata(org.openkilda.floodlight.utils.metadata.RoutingMetadata) SwitchFeature(org.openkilda.model.SwitchFeature) Match(org.projectfloodlight.openflow.protocol.match.Match)

Aggregations

SwitchFeature (org.openkilda.model.SwitchFeature)23 ArrayList (java.util.ArrayList)7 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)7 OFFlowMod (org.projectfloodlight.openflow.protocol.OFFlowMod)6 Match (org.projectfloodlight.openflow.protocol.match.Match)5 Instructions (org.openkilda.rulemanager.Instructions)4 OFAction (org.projectfloodlight.openflow.protocol.action.OFAction)4 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)3 SwitchDescription (net.floodlightcontroller.core.SwitchDescription)3 Cookie (org.openkilda.model.cookie.Cookie)3 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)3 HashSet (java.util.HashSet)2 RoutingMetadata (org.openkilda.floodlight.utils.metadata.RoutingMetadata)2 IpSocketAddress (org.openkilda.model.IpSocketAddress)2 LagLogicalPort (org.openkilda.model.LagLogicalPort)2 PhysicalPort (org.openkilda.model.PhysicalPort)2 Switch (org.openkilda.model.Switch)2 PortColourCookie (org.openkilda.model.cookie.PortColourCookie)2 Sets (com.google.common.collect.Sets)1 SetView (com.google.common.collect.Sets.SetView)1