Search in sources :

Example 36 with FlowEndpoint

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

the class IngressFlowModFactory method makeDoubleVlanFlowLoopMessage.

/**
 * Make ingress flow loop rule to match all flow traffic by port and two vlans and route it back to port from
 * where it came and restore vlan stack.
 */
public OFFlowMod makeDoubleVlanFlowLoopMessage() {
    FlowEndpoint endpoint = command.getEndpoint();
    RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(endpoint.getOuterVlanId()).build(switchFeatures);
    return flowModBuilderFactory.makeBuilder(of, TableId.of(SwitchManager.INGRESS_TABLE_ID), 10).setMatch(of.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(endpoint.getPortNumber())).setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(endpoint.getInnerVlanId())).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 37 with FlowEndpoint

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

the class IngressFlowModFactory method makeDoubleVlanServer42IngressFlowMessage.

/**
 * Make rule to match server 42 packets by inner VLAN tag and forward in in ISL.
 */
public OFFlowMod makeDoubleVlanServer42IngressFlowMessage() {
    FlowEndpoint endpoint = command.getEndpoint();
    RoutingMetadata metadata = buildServer42IngressMetadata();
    OFFlowMod.Builder builder = flowModBuilderFactory.makeBuilder(of, TableId.of(SwitchManager.INGRESS_TABLE_ID), SERVER_42_INGRESS_DOUBLE_VLAN_FLOW_PRIORITY_OFFSET).setMatch(of.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(getCommand().getRulesContext().getServer42Port())).setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(endpoint.getInnerVlanId())).setMasked(MatchField.METADATA, OFMetadata.of(metadata.getValue()), OFMetadata.of(metadata.getMask())).build());
    return makeServer42IngressFlowMessage(builder, FlowEndpoint.makeVlanStack(endpoint.getInnerVlanId()));
}
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 38 with FlowEndpoint

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

the class IngressFlowModFactory method makeServer42OuterVlanMatchSharedMessage.

/**
 * Make rule to match traffic by server 42 port and vlan, write vlan into metadata and pass packet into next table.
 * This rule is shared across all flow with equal vlan(outer).
 */
public OFFlowMod makeServer42OuterVlanMatchSharedMessage() {
    FlowEndpoint endpoint = command.getEndpoint();
    FlowSharedSegmentCookie cookie = FlowSharedSegmentCookie.builder(SharedSegmentType.SERVER42_QINQ_OUTER_VLAN).portNumber(getCommand().getRulesContext().getServer42Port()).vlanId(endpoint.getOuterVlanId()).build();
    return flowModBuilderFactory.makeBuilder(of, TableId.of(SwitchManager.PRE_INGRESS_TABLE_ID)).setCookie(U64.of(cookie.getValue())).setMatch(of.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(getCommand().getRulesContext().getServer42Port())).setExact(MatchField.VLAN_VID, OFVlanVidMatch.ofVlan(endpoint.getOuterVlanId())).build()).setInstructions(makeOuterVlanMatchInstructions()).build();
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie)

Example 39 with FlowEndpoint

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

the class OneSwitchFlowInstallFlowModFactory method makeOutputAction.

@Override
protected OFAction makeOutputAction() {
    FlowEndpoint endpoint = command.getEndpoint();
    FlowEndpoint egressEndpoint = command.getEgressEndpoint();
    if (endpoint.getPortNumber().equals(egressEndpoint.getPortNumber())) {
        return super.makeOutputAction(OFPort.IN_PORT);
    }
    return super.makeOutputAction(OFPort.of(egressEndpoint.getPortNumber()));
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint)

Example 40 with FlowEndpoint

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

the class SimpleSwitchRuleConverter method buildIngressSimpleSwitchRules.

/**
 * Build ingress rules ({@link SimpleSwitchRule}) for provided {@link FlowPath}.
 */
public List<SimpleSwitchRule> buildIngressSimpleSwitchRules(Flow flow, FlowPath flowPath, EncapsulationId encapsulationId, long flowMeterMinBurstSizeInKbits, double flowMeterBurstCoefficient) {
    boolean forward = flow.isForward(flowPath);
    int inPort = forward ? flow.getSrcPort() : flow.getDestPort();
    int outPort = forward ? flow.getDestPort() : flow.getSrcPort();
    SimpleSwitchRule rule = SimpleSwitchRule.builder().switchId(flowPath.getSrcSwitchId()).cookie(flowPath.getCookie().getValue()).inPort(inPort).meterId(flowPath.getMeterId() != null ? flowPath.getMeterId().getValue() : null).meterRate(flow.getBandwidth()).meterBurstSize(Meter.calculateBurstSize(flow.getBandwidth(), flowMeterMinBurstSizeInKbits, flowMeterBurstCoefficient, flowPath.getSrcSwitch().getDescription())).meterFlags(Meter.getMeterKbpsFlags()).ingressRule(true).build();
    FlowSideAdapter ingress = FlowSideAdapter.makeIngressAdapter(flow, flowPath);
    FlowEndpoint endpoint = ingress.getEndpoint();
    if (flowPath.isSrcWithMultiTable()) {
        // in multi-table mode actual ingress rule will match port+inner_vlan+metadata(outer_vlan)
        if (FlowEndpoint.isVlanIdSet(endpoint.getInnerVlanId())) {
            rule.setInVlan(endpoint.getInnerVlanId());
        }
    } else {
        rule.setInVlan(endpoint.getOuterVlanId());
    }
    int transitVlan = 0;
    int vni = 0;
    if (flow.isOneSwitchFlow()) {
        FlowEndpoint egressEndpoint = FlowSideAdapter.makeEgressAdapter(flow, flowPath).getEndpoint();
        rule.setOutPort(outPort);
        rule.setOutVlan(calcVlanSetSequence(ingress, flowPath, egressEndpoint.getVlanStack()));
    } else {
        PathSegment ingressSegment = flowPath.getSegments().stream().filter(segment -> segment.getSrcSwitchId().equals(flowPath.getSrcSwitchId())).findAny().orElseThrow(() -> new IllegalStateException(String.format("PathSegment was not found for ingress flow rule, flowId: %s", flow.getFlowId())));
        outPort = ingressSegment.getSrcPort();
        rule.setOutPort(outPort);
        if (flow.getEncapsulationType().equals(FlowEncapsulationType.TRANSIT_VLAN)) {
            transitVlan = encapsulationId.getEncapsulationId();
            rule.setOutVlan(calcVlanSetSequence(ingress, flowPath, Collections.singletonList(transitVlan)));
        } else if (flow.getEncapsulationType().equals(FlowEncapsulationType.VXLAN)) {
            vni = encapsulationId.getEncapsulationId();
            rule.setTunnelId(vni);
        }
    }
    List<SimpleSwitchRule> rules = Lists.newArrayList(rule);
    if (ingress.isLooped() && !flowPath.isProtected()) {
        rules.add(buildIngressLoopSimpleSwitchRule(rule, flowPath, ingress));
    }
    Optional<FlowMirrorPoints> foundFlowMirrorPoints = flowPath.getFlowMirrorPointsSet().stream().filter(mirrorPoints -> mirrorPoints.getMirrorSwitchId().equals(flowPath.getSrcSwitchId())).findFirst();
    if (foundFlowMirrorPoints.isPresent()) {
        FlowMirrorPoints flowMirrorPoints = foundFlowMirrorPoints.get();
        SimpleSwitchRule mirrorRule = rule.toBuilder().outPort(0).tunnelId(0).cookie(flowPath.getCookie().toBuilder().mirror(true).build().getValue()).groupId(flowMirrorPoints.getMirrorGroupId().intValue()).groupBuckets(mapGroupBuckets(flowMirrorPoints.getMirrorPaths(), outPort, transitVlan, vni)).build();
        if (!flow.isOneSwitchFlow()) {
            mirrorRule.setOutVlan(Collections.emptyList());
        }
        rules.add(mirrorRule);
    }
    return rules;
}
Also used : PathSegment(org.openkilda.model.PathSegment) FlowPath(org.openkilda.model.FlowPath) ArrayList(java.util.ArrayList) Lists(com.google.common.collect.Lists) Flow(org.openkilda.model.Flow) SwitchFlowEntries(org.openkilda.messaging.info.rule.SwitchFlowEntries) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) SwitchGroupEntries(org.openkilda.messaging.info.rule.SwitchGroupEntries) FlowEncapsulationType(org.openkilda.model.FlowEncapsulationType) FlowEndpoint(org.openkilda.model.FlowEndpoint) SimpleGroupBucket(org.openkilda.wfm.share.utils.rule.validation.SimpleSwitchRule.SimpleGroupBucket) Iterator(java.util.Iterator) GroupBucket(org.openkilda.messaging.info.rule.GroupBucket) FlowEntry(org.openkilda.messaging.info.rule.FlowEntry) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) SimpleSwitchRuleBuilder(org.openkilda.wfm.share.utils.rule.validation.SimpleSwitchRule.SimpleSwitchRuleBuilder) Collection(java.util.Collection) GroupEntry(org.openkilda.messaging.info.rule.GroupEntry) Collectors(java.util.stream.Collectors) SwitchMeterEntries(org.openkilda.messaging.info.meter.SwitchMeterEntries) FlowApplyActions(org.openkilda.messaging.info.rule.FlowApplyActions) Objects(java.util.Objects) List(java.util.List) SwitchId(org.openkilda.model.SwitchId) FlowSetFieldAction(org.openkilda.messaging.info.rule.FlowSetFieldAction) NumberUtils(org.apache.commons.lang3.math.NumberUtils) FlowMirrorPath(org.openkilda.model.FlowMirrorPath) Optional(java.util.Optional) Meter(org.openkilda.model.Meter) Comparator(java.util.Comparator) Collections(java.util.Collections) EncapsulationId(org.openkilda.model.EncapsulationId) FlowEndpoint(org.openkilda.model.FlowEndpoint) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) PathSegment(org.openkilda.model.PathSegment) FlowEndpoint(org.openkilda.model.FlowEndpoint)

Aggregations

FlowEndpoint (org.openkilda.model.FlowEndpoint)105 Test (org.junit.Test)26 Flow (org.openkilda.model.Flow)22 ArrayList (java.util.ArrayList)15 RoutingMetadata (org.openkilda.floodlight.utils.metadata.RoutingMetadata)12 YFlow (org.openkilda.model.YFlow)11 FlowPath (org.openkilda.model.FlowPath)10 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)9 SpeakerData (org.openkilda.rulemanager.SpeakerData)9 SwitchId (org.openkilda.model.SwitchId)8 YSubFlow (org.openkilda.model.YSubFlow)8 HashSet (java.util.HashSet)7 FlowSideAdapter (org.openkilda.adapter.FlowSideAdapter)7 FlowSourceAdapter (org.openkilda.adapter.FlowSourceAdapter)7 IngressFlowSegmentInstallCommand (org.openkilda.floodlight.command.flow.ingress.IngressFlowSegmentInstallCommand)7 EffectiveIds (org.openkilda.floodlight.model.EffectiveIds)7 FlowSegmentWrapperCommand (org.openkilda.floodlight.command.flow.FlowSegmentWrapperCommand)6 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)6 OFFlowAdd (org.projectfloodlight.openflow.protocol.OFFlowAdd)6 MessageContext (org.openkilda.messaging.MessageContext)5