Search in sources :

Example 26 with RoutingMetadata

use of org.openkilda.floodlight.utils.metadata.RoutingMetadata in project open-kilda by telstra.

the class IngressFlowLoopSegmentInstallCommandTest method assertMetadata.

private void assertMetadata(Match match, int expectedOuterVlan) {
    RoutingMetadataBuilder metadataBuilder = RoutingMetadata32.builder();
    metadataBuilder.outerVlanId(expectedOuterVlan);
    RoutingMetadata metadata = metadataBuilder.build(FEATURES);
    assertEquals(metadata.getValue(), match.getMasked(MatchField.METADATA).getValue().getValue());
    assertEquals(metadata.getMask(), match.getMasked(MatchField.METADATA).getMask().getValue());
}
Also used : RoutingMetadataBuilder(org.openkilda.floodlight.utils.metadata.RoutingMetadata.RoutingMetadataBuilder) RoutingMetadata(org.openkilda.floodlight.utils.metadata.RoutingMetadata)

Example 27 with RoutingMetadata

use of org.openkilda.floodlight.utils.metadata.RoutingMetadata in project open-kilda by telstra.

the class SwitchManager method installOuterVlanMatchSharedFlow.

@Override
public void installOuterVlanMatchSharedFlow(SwitchId switchId, String flowId, FlowSharedSegmentCookie cookie) throws SwitchOperationException {
    IOFSwitch sw = lookupSwitch(DatapathId.of(switchId.toLong()));
    OFFactory of = sw.getOFFactory();
    RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(cookie.getVlanId()).build(featureDetectorService.detectSwitch(sw));
    ImmutableList<OFInstruction> instructions = ImmutableList.of(of.instructions().applyActions(ImmutableList.of(of.actions().popVlan())), of.instructions().writeMetadata(metadata.getValue(), metadata.getMask()), of.instructions().gotoTable(TableId.of(SwitchManager.INGRESS_TABLE_ID)));
    OFFlowMod flow = prepareFlowModBuilder(of, cookie.getValue(), FLOW_PRIORITY, PRE_INGRESS_TABLE_ID).setMatch(of.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(cookie.getPortNumber())).setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(cookie.getVlanId())).build()).setInstructions(instructions).build();
    pushFlow(sw, flowId, flow);
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) OFInstruction(org.projectfloodlight.openflow.protocol.instruction.OFInstruction) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) RoutingMetadata(org.openkilda.floodlight.utils.metadata.RoutingMetadata) OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod)

Example 28 with RoutingMetadata

use of org.openkilda.floodlight.utils.metadata.RoutingMetadata in project open-kilda by telstra.

the class SwitchManager method buildLldpInputCustomerFlow.

@Override
public OFFlowMod buildLldpInputCustomerFlow(DatapathId dpid, int port) throws SwitchNotFoundException {
    IOFSwitch sw = lookupSwitch(dpid);
    OFFactory ofFactory = sw.getOFFactory();
    Match match = ofFactory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(port)).setExact(MatchField.ETH_TYPE, EthType.LLDP).build();
    RoutingMetadata metadata = buildMetadata(RoutingMetadata.builder().lldpFlag(true), sw);
    OFInstructionWriteMetadata writeMetadata = ofFactory.instructions().buildWriteMetadata().setMetadata(metadata.getValue()).setMetadataMask(metadata.getMask()).build();
    OFInstructionGotoTable goToTable = ofFactory.instructions().gotoTable(TableId.of(PRE_INGRESS_TABLE_ID));
    return prepareFlowModBuilder(ofFactory, Cookie.encodeLldpInputCustomer(port), LLDP_INPUT_CUSTOMER_PRIORITY, INPUT_TABLE_ID).setMatch(match).setInstructions(ImmutableList.of(goToTable, writeMetadata)).build();
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) OFInstructionGotoTable(org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFInstructionWriteMetadata(org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata) RoutingMetadata(org.openkilda.floodlight.utils.metadata.RoutingMetadata) Match(org.projectfloodlight.openflow.protocol.match.Match) OFVlanVidMatch(org.projectfloodlight.openflow.types.OFVlanVidMatch)

Example 29 with RoutingMetadata

use of org.openkilda.floodlight.utils.metadata.RoutingMetadata in project open-kilda by telstra.

the class ArpPostIngressOneSwitchFlowGenerator method getArpFlowMod.

@Override
OFFlowMod getArpFlowMod(IOFSwitch sw, OFInstructionMeter meter, List<OFAction> actionList) {
    OFFactory ofFactory = sw.getOFFactory();
    RoutingMetadata metadata = makeMetadataMatch(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, ARP_POST_INGRESS_ONE_SWITCH_COOKIE, ARP_POST_INGRESS_ONE_SWITCH_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)

Aggregations

RoutingMetadata (org.openkilda.floodlight.utils.metadata.RoutingMetadata)29 FlowEndpoint (org.openkilda.model.FlowEndpoint)13 OFFactory (org.projectfloodlight.openflow.protocol.OFFactory)12 Match (org.projectfloodlight.openflow.protocol.match.Match)10 OFInstructionApplyActions (org.projectfloodlight.openflow.protocol.instruction.OFInstructionApplyActions)8 OFFlowAdd (org.projectfloodlight.openflow.protocol.OFFlowAdd)7 EffectiveIds (org.openkilda.floodlight.model.EffectiveIds)6 OFFlowMod (org.projectfloodlight.openflow.protocol.OFFlowMod)6 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)4 IngressFlowSegmentInstallCommand (org.openkilda.floodlight.command.flow.ingress.IngressFlowSegmentInstallCommand)4 Builder (org.projectfloodlight.openflow.protocol.OFFlowMod.Builder)4 OFAction (org.projectfloodlight.openflow.protocol.action.OFAction)3 OFInstructionWriteMetadata (org.projectfloodlight.openflow.protocol.instruction.OFInstructionWriteMetadata)3 OneSwitchFlowInstallCommand (org.openkilda.floodlight.command.flow.ingress.OneSwitchFlowInstallCommand)2 RoutingMetadataBuilder (org.openkilda.floodlight.utils.metadata.RoutingMetadata.RoutingMetadataBuilder)2 SwitchFeature (org.openkilda.model.SwitchFeature)2 OFInstruction (org.projectfloodlight.openflow.protocol.instruction.OFInstruction)2 OFInstructionGotoTable (org.projectfloodlight.openflow.protocol.instruction.OFInstructionGotoTable)2 OFVlanVidMatch (org.projectfloodlight.openflow.types.OFVlanVidMatch)2 Test (org.junit.Test)1