Search in sources :

Example 11 with RoutingMetadata

use of org.openkilda.floodlight.utils.metadata.RoutingMetadata 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 12 with RoutingMetadata

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

the class IngressFlowModFactory method makeServer42IngressFlowMatch.

private Match makeServer42IngressFlowMatch(Match.Builder builder, int server42UpdPortOffset) {
    builder.setExact(MatchField.IN_PORT, OFPort.of(command.getRulesContext().getServer42Port()));
    if (getCommand().getMetadata().isMultiTable()) {
        RoutingMetadata metadata = buildServer42IngressMetadata();
        builder.setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).build();
    } else {
        MacAddress macAddress = MacAddress.of(getCommand().getRulesContext().getServer42MacAddress().toString());
        int udpSrcPort = server42UpdPortOffset + command.getEndpoint().getPortNumber();
        builder.setExact(MatchField.ETH_SRC, macAddress).setExact(MatchField.ETH_TYPE, EthType.IPv4).setExact(MatchField.IP_PROTO, IpProtocol.UDP).setExact(MatchField.UDP_SRC, TransportPort.of(udpSrcPort));
    }
    return builder.build();
}
Also used : RoutingMetadata(org.openkilda.floodlight.utils.metadata.RoutingMetadata) MacAddress(org.projectfloodlight.openflow.types.MacAddress) FlowEndpoint(org.openkilda.model.FlowEndpoint)

Example 13 with RoutingMetadata

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

the class IngressFlowModFactory method makeSingleVlanFlowLoopMessage.

/**
 * Make ingress flow loop rule to match all flow traffic by port&vlan and route it back to port from
 * where it came.
 */
public OFFlowMod makeSingleVlanFlowLoopMessage() {
    FlowEndpoint endpoint = command.getEndpoint();
    RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(endpoint.getOuterVlanId()).build(switchFeatures);
    return flowModBuilderFactory.makeBuilder(of, TableId.of(SwitchManager.INGRESS_TABLE_ID)).setMatch(of.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(endpoint.getPortNumber())).setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).build()).setCookie(U64.of(command.getCookie().getValue())).setInstructions(makeIngressFlowLoopInstructions(endpoint)).build();
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) RoutingMetadata(org.openkilda.floodlight.utils.metadata.RoutingMetadata)

Example 14 with RoutingMetadata

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

the class IngressFlowModFactory method makeSingleVlanForwardMessage.

/**
 * Make rule to forward traffic matched by outer VLAN tag and forward in in ISL (or out port in case one-switch
 * flow).
 */
public OFFlowMod makeSingleVlanForwardMessage(EffectiveIds effectiveIds) {
    FlowEndpoint endpoint = command.getEndpoint();
    RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(endpoint.getOuterVlanId()).build(switchFeatures);
    OFFlowMod.Builder builder = flowModBuilderFactory.makeBuilder(of, TableId.of(SwitchManager.INGRESS_TABLE_ID)).setMatch(of.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(endpoint.getPortNumber())).setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).build());
    // list as current vlanStack
    return makeForwardMessage(builder, effectiveIds, Collections.emptyList());
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) RoutingMetadata(org.openkilda.floodlight.utils.metadata.RoutingMetadata) Builder(org.projectfloodlight.openflow.protocol.OFFlowMod.Builder) OFFlowMod(org.projectfloodlight.openflow.protocol.OFFlowMod)

Example 15 with RoutingMetadata

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

the class IngressFlowSegmentInstallFlowModFactoryTest method testMakeSingleVlanForwardMessageVlanEncoded.

private void testMakeSingleVlanForwardMessageVlanEncoded(MeterConfig meter) {
    IngressFlowSegmentInstallCommand command = makeCommand(endpointSingleVlan, meter, encapsulationVlan);
    FlowEndpoint endpoint = command.getEndpoint();
    RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(endpoint.getOuterVlanId()).build(Collections.emptySet());
    List<OFAction> vlanTransformation = OfAdapter.INSTANCE.makeVlanReplaceActions(of, Collections.emptyList(), Collections.singletonList(command.getEncapsulation().getId()));
    OFFlowAdd expected = makeVlanForwardingMessage(command, 0, of.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(endpoint.getPortNumber())).setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).build(), getTargetIngressTableId(), vlanTransformation);
    IngressFlowModFactory factory = makeFactory(command);
    verifyOfMessageEquals(expected, factory.makeSingleVlanForwardMessage(new EffectiveIds(getEffectiveMeterId(command.getMeterConfig()), null)));
}
Also used : IngressFlowSegmentInstallCommand(org.openkilda.floodlight.command.flow.ingress.IngressFlowSegmentInstallCommand) FlowEndpoint(org.openkilda.model.FlowEndpoint) EffectiveIds(org.openkilda.floodlight.model.EffectiveIds) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) RoutingMetadata(org.openkilda.floodlight.utils.metadata.RoutingMetadata) OFFlowAdd(org.projectfloodlight.openflow.protocol.OFFlowAdd)

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