Search in sources :

Example 91 with FlowEndpoint

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

the class SingleTableServer42IngressRuleGenerator method buildServer42IngressCommand.

private FlowSpeakerData buildServer42IngressCommand(Switch sw, FlowEndpoint ingressEndpoint) {
    int priority = isVlanIdSet(ingressEndpoint.getOuterVlanId()) ? SERVER_42_INGRESS_SINGLE_VLAN_FLOW_PRIORITY : SERVER_42_INGRESS_DEFAULT_FLOW_PRIORITY;
    FlowSegmentCookie cookie = new FlowSegmentCookie(flowPath.getCookie().getValue()).toBuilder().type(CookieType.SERVER_42_FLOW_RTT_INGRESS).build();
    FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(ingressEndpoint.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(cookie).table(OfTable.INPUT).priority(priority).match(buildMatch(ingressEndpoint)).instructions(buildIngressInstructions(sw, ingressEndpoint.getOuterVlanId()));
    if (sw.getFeatures().contains(SwitchFeature.RESET_COUNTS_FLAG)) {
        builder.flags(Sets.newHashSet(OfFlowFlag.RESET_COUNTERS));
    }
    return builder.build();
}
Also used : FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) FlowEndpoint(org.openkilda.model.FlowEndpoint)

Example 92 with FlowEndpoint

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

the class SingleTableIngressYRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    if (flow.isOneSwitchFlow()) {
        throw new IllegalStateException("Y-Flow rules can't be created for one switch flow");
    }
    List<SpeakerData> result = new ArrayList<>();
    FlowEndpoint ingressEndpoint = FlowSideAdapter.makeIngressAdapter(flow, flowPath).getEndpoint();
    FlowSpeakerData command = buildFlowIngressCommand(sw, ingressEndpoint);
    if (command == null) {
        return Collections.emptyList();
    }
    result.add(command);
    if (generateMeterCommand) {
        SpeakerData meterCommand = buildMeter(externalMeterCommandUuid, flowPath, config, sharedMeterId, sw);
        if (meterCommand != null) {
            result.add(meterCommand);
            command.getDependsOn().add(externalMeterCommandUuid);
        }
    } else if (sw.getFeatures().contains(METERS) && sharedMeterId != null) {
        command.getDependsOn().add(externalMeterCommandUuid);
    }
    return result;
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FlowEndpoint(org.openkilda.model.FlowEndpoint) ArrayList(java.util.ArrayList) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData)

Example 93 with FlowEndpoint

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

the class FlowLoopIngressRuleGenerator method buildIngressLoopCommand.

private SpeakerData buildIngressLoopCommand(Switch sw) {
    FlowEndpoint ingressEndpoint = checkAndBuildIngressEndpoint(flow, flowPath, sw.getSwitchId());
    FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(flowPath.getCookie().toBuilder().looped(true).build()).table(multiTable ? OfTable.INGRESS : OfTable.INPUT).priority(getPriority(ingressEndpoint)).match(makeIngressMatch(ingressEndpoint, multiTable, sw.getFeatures())).instructions(makeIngressFlowLoopInstructions(ingressEndpoint));
    // todo add RESET_COUNTERS flag
    return builder.build();
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint)

Example 94 with FlowEndpoint

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

the class MultiTableIngressRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    List<SpeakerData> result = new ArrayList<>();
    FlowEndpoint ingressEndpoint = checkAndBuildIngressEndpoint(flow, flowPath, sw.getSwitchId());
    FlowSpeakerData command = buildFlowIngressCommand(sw, ingressEndpoint);
    if (command == null) {
        return Collections.emptyList();
    }
    result.add(command);
    if (needToBuildFlowPreIngressRule(ingressEndpoint)) {
        result.add(buildFlowPreIngressCommand(sw, ingressEndpoint));
    }
    if (overlappingIngressAdapters.isEmpty()) {
        result.add(buildCustomerPortSharedCatchCommand(sw, ingressEndpoint));
    }
    SpeakerData meterCommand = buildMeter(flowPath, config, flowPath.getMeterId(), sw);
    if (meterCommand != null) {
        result.add(meterCommand);
        command.getDependsOn().add(meterCommand.getUuid());
    }
    return result;
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FlowEndpoint(org.openkilda.model.FlowEndpoint) ArrayList(java.util.ArrayList) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData)

Example 95 with FlowEndpoint

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

the class RuleManagerImpl method getOverlappingMultiTableIngressAdapters.

private Set<FlowSideAdapter> getOverlappingMultiTableIngressAdapters(FlowPath path, DataAdapter adapter) {
    FlowEndpoint endpoint = makeIngressAdapter(adapter.getFlow(path.getPathId()), path).getEndpoint();
    Set<FlowSideAdapter> result = new HashSet<>();
    if (!path.isSrcWithMultiTable()) {
        // we do not care about overlapping for single table paths
        return result;
    }
    for (FlowPath overlappingPath : adapter.getFlowPaths().values()) {
        if (overlappingPath.isSrcWithMultiTable() && path.getSrcSwitchId().equals(overlappingPath.getSrcSwitchId())) {
            Flow overlappingFlow = adapter.getFlow(overlappingPath.getPathId());
            FlowSideAdapter flowAdapter = makeIngressAdapter(overlappingFlow, overlappingPath);
            if (endpoint.getPortNumber().equals(flowAdapter.getEndpoint().getPortNumber())) {
                result.add(flowAdapter);
            }
        }
    }
    return result;
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) FlowPath(org.openkilda.model.FlowPath) HashSet(java.util.HashSet) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow)

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