Search in sources :

Example 16 with Match

use of org.projectfloodlight.openflow.protocol.match.Match in project open-kilda by telstra.

the class ArpTransitFlowGenerator method getArpFlowMod.

@Override
OFFlowMod getArpFlowMod(IOFSwitch sw, OFInstructionMeter meter, List<OFAction> actionList) {
    OFFactory ofFactory = sw.getOFFactory();
    Match match = ofFactory.buildMatch().setExact(MatchField.ETH_TYPE, EthType.ARP).build();
    actionList.add(actionSendToController(sw.getOFFactory()));
    OFInstructionApplyActions actions = ofFactory.instructions().applyActions(actionList).createBuilder().build();
    return prepareFlowModBuilder(ofFactory, ARP_TRANSIT_COOKIE, ARP_TRANSIT_ISL_PRIORITY, TRANSIT_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) Match(org.projectfloodlight.openflow.protocol.match.Match)

Example 17 with Match

use of org.projectfloodlight.openflow.protocol.match.Match in project open-kilda by telstra.

the class LldpPostIngressFlowGenerator method getLldpFlowMod.

@Override
OFFlowMod getLldpFlowMod(IOFSwitch sw, OFInstructionMeter meter, List<OFAction> actionList) {
    OFFactory ofFactory = sw.getOFFactory();
    RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().lldpFlag(true), sw);
    Match match = ofFactory.buildMatch().setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).build();
    actionList.add(actionSendToController(sw.getOFFactory()));
    OFInstructionApplyActions actions = ofFactory.instructions().applyActions(actionList).createBuilder().build();
    return prepareFlowModBuilder(ofFactory, LLDP_POST_INGRESS_COOKIE, LLDP_POST_INGRESS_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) Match(org.projectfloodlight.openflow.protocol.match.Match)

Example 18 with Match

use of org.projectfloodlight.openflow.protocol.match.Match in project open-kilda by telstra.

the class LldpPostIngressVxlanFlowGenerator method getLldpFlowMod.

@Override
OFFlowMod getLldpFlowMod(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().lldpFlag(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(STUB_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, LLDP_POST_INGRESS_VXLAN_COOKIE, LLDP_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)

Example 19 with Match

use of org.projectfloodlight.openflow.protocol.match.Match in project open-kilda by telstra.

the class Server42FlowRttInputFlowGenerator method generateFlowMod.

/**
 * Generated OFFlowMod for Server 42 Flow RTT input rule.
 */
public static Optional<OFFlowMod> generateFlowMod(OFFactory ofFactory, Set<SwitchFeature> features, int udpOffset, int customerPort, int server42Port, MacAddress server42macAddress) {
    Match match = buildMatch(ofFactory, server42Port, customerPort + udpOffset, server42macAddress);
    List<OFAction> actions = Lists.newArrayList(actionSetUdpSrcAction(ofFactory, TransportPort.of(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT)), actionSetUdpDstAction(ofFactory, TransportPort.of(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT)));
    if (features.contains(NOVIFLOW_COPY_FIELD)) {
        actions.add(buildServer42CopyFirstTimestamp(ofFactory));
    }
    List<OFInstruction> instructions = ImmutableList.of(buildInstructionApplyActions(ofFactory, actions), instructionWriteMetadata(ofFactory, customerPort, features), instructionGoToTable(ofFactory, TableId.of(PRE_INGRESS_TABLE_ID)));
    return Optional.of(prepareFlowModBuilder(ofFactory, encodeServer42FlowRttInput(customerPort), SERVER_42_FLOW_RTT_INPUT_PRIORITY, INPUT_TABLE_ID).setMatch(match).setInstructions(instructions).build());
}
Also used : OFInstruction(org.projectfloodlight.openflow.protocol.instruction.OFInstruction) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) Match(org.projectfloodlight.openflow.protocol.match.Match)

Example 20 with Match

use of org.projectfloodlight.openflow.protocol.match.Match in project open-kilda by telstra.

the class BfdCatchFlowGenerator method generateFlow.

@Override
public SwitchFlowTuple generateFlow(IOFSwitch sw) {
    Set<SwitchFeature> features = featureDetectorService.detectSwitch(sw);
    if (!features.contains(SwitchFeature.BFD)) {
        return SwitchFlowTuple.getEmpty();
    }
    OFFactory ofFactory = sw.getOFFactory();
    Match match = catchRuleMatch(sw.getId(), ofFactory);
    OFFlowMod flowMod = prepareFlowModBuilder(ofFactory, CATCH_BFD_RULE_COOKIE, CATCH_BFD_RULE_PRIORITY, INPUT_TABLE_ID).setMatch(match).setActions(ImmutableList.of(ofFactory.actions().buildOutput().setPort(OFPort.LOCAL).build())).build();
    return SwitchFlowTuple.builder().sw(sw).flow(flowMod).build();
}
Also used : OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) SwitchFeature(org.openkilda.model.SwitchFeature) OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod) Match(org.projectfloodlight.openflow.protocol.match.Match)

Aggregations

Match (org.projectfloodlight.openflow.protocol.match.Match)64 OFVlanVidMatch (org.projectfloodlight.openflow.types.OFVlanVidMatch)32 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)28 OFFlowMod (org.projectfloodlight.openflow.protocol.OFFlowMod)18 OFAction (org.projectfloodlight.openflow.protocol.action.OFAction)18 OFInstructionApplyActions (org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions)18 RoutingMetadata (org.openkilda.floodlight.utils.metadata.RoutingMetadata)10 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)8 OFInstructionGotoTable (org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable)7 ArrayList (java.util.ArrayList)6 OFFlowDelete (org.projectfloodlight.openflow.protocol.OFFlowDelete)6 OFInstruction (org.projectfloodlight.openflow.protocol.instruction.OFInstruction)6 SwitchFeature (org.openkilda.model.SwitchFeature)5 OFFactoryVer13 (org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13)5 HashSet (java.util.HashSet)4 Test (org.junit.Test)4 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)4 OFFlowAdd (org.projectfloodlight.openflow.protocol.OFFlowAdd)4 Builder (org.projectfloodlight.openflow.protocol.match.Match.Builder)3 U64 (org.projectfloodlight.openflow.types.U64)3