Search in sources :

Example 11 with FlowSideAdapter

use of org.openkilda.adapter.FlowSideAdapter in project open-kilda by telstra.

the class MultiTableIngressYRuleGeneratorTest method buildCommandsWithoutMeter.

@Test
public void buildCommandsWithoutMeter() {
    Flow oneSwitchFlow = buildFlow(ONE_SWITCH_PATH, OUTER_VLAN_ID_2, 0);
    Set<FlowSideAdapter> overlapping = Sets.newHashSet(FlowSideAdapter.makeIngressAdapter(oneSwitchFlow, ONE_SWITCH_PATH));
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
    MultiTableIngressYRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION, overlapping, false);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(1, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    assertEquals(newArrayList(SHARED_METER_UUID), new ArrayList<>(ingressCommand.getDependsOn()));
    RoutingMetadata ingressMetadata = RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
    Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(INNER_VLAN_ID_1).build(), FieldMatch.builder().field(Field.METADATA).value(ingressMetadata.getValue()).mask(ingressMetadata.getMask()).build());
    List<Action> expectedIngressActions = newArrayList(SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
    assertIngressCommand(ingressCommand, Priority.Y_FLOW_DOUBLE_VLAN_PRIORITY, expectedIngressMatch, expectedIngressActions, SHARED_METER_ID, null);
}
Also used : SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Flow(org.openkilda.model.Flow) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) SpeakerData(org.openkilda.rulemanager.SpeakerData) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 12 with FlowSideAdapter

use of org.openkilda.adapter.FlowSideAdapter in project open-kilda by telstra.

the class InputArpRuleGeneratorTest method buildArpRuleWithOverlappedEndpointsTest.

@Test
public void buildArpRuleWithOverlappedEndpointsTest() {
    FlowEndpoint endpoint = new FlowEndpoint(SW.getSwitchId(), PORT_NUMBER_1, 0, 0, true, false);
    FlowSideAdapter adapter = new FlowSourceAdapter(Flow.builder().flowId("some").srcSwitch(SW).destSwitch(buildSwitch("OF_13", Collections.emptySet())).detectConnectedDevices(DetectConnectedDevices.builder().srcArp(true).srcSwitchArp(true).build()).build());
    InputArpRuleGenerator generator = InputArpRuleGenerator.builder().ingressEndpoint(endpoint).multiTable(true).overlappingIngressAdapters(Sets.newHashSet(adapter)).build();
    assertEquals(0, generator.generateCommands(SW).size());
}
Also used : FlowSourceAdapter(org.openkilda.adapter.FlowSourceAdapter) FlowEndpoint(org.openkilda.model.FlowEndpoint) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) Test(org.junit.Test)

Example 13 with FlowSideAdapter

use of org.openkilda.adapter.FlowSideAdapter 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)

Example 14 with FlowSideAdapter

use of org.openkilda.adapter.FlowSideAdapter in project open-kilda by telstra.

the class SpeakerFlowSegmentRequestBuilder method makePathRequests.

@SuppressWarnings("squid:S00107")
private List<FlowSegmentRequestFactory> makePathRequests(@NonNull Flow flow, @NonNull FlowPath path, CommandContext context, FlowTransitEncapsulation encapsulation, boolean doIngress, boolean doTransit, boolean doEgress, RulesContext rulesContext, MirrorContext mirrorContext) {
    final FlowSideAdapter ingressSide = FlowSideAdapter.makeIngressAdapter(flow, path);
    final FlowSideAdapter egressSide = FlowSideAdapter.makeEgressAdapter(flow, path);
    final List<FlowSegmentRequestFactory> requests = new ArrayList<>();
    PathSegment lastSegment = null;
    for (PathSegment segment : path.getSegments()) {
        if (lastSegment == null) {
            if (doIngress) {
                requests.addAll(makeIngressSegmentRequests(context, path, encapsulation, ingressSide, segment, egressSide, rulesContext, mirrorContext));
                if (ingressLoopRuleRequired(flow, ingressSide)) {
                    requests.addAll(makeLoopRequests(context, path, encapsulation, ingressSide, egressSide, segment));
                }
            }
        } else {
            if (doTransit) {
                requests.add(makeTransitSegmentRequest(context, path, encapsulation, lastSegment, segment));
            }
        }
        lastSegment = segment;
    }
    if (lastSegment != null) {
        if (doEgress) {
            requests.addAll(makeEgressSegmentRequests(context, path, encapsulation, lastSegment, egressSide, ingressSide, mirrorContext));
        }
    } else if (flow.isOneSwitchFlow()) {
        // one switch flow (path without path segments)
        requests.addAll(makeOneSwitchRequest(context, path, ingressSide, egressSide, rulesContext, mirrorContext));
        if (singleSwitchLoopRuleRequired(flow)) {
            requests.add(makeSingleSwitchIngressLoopRequest(context, path, ingressSide));
        }
    }
    return requests;
}
Also used : IngressMirrorFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressMirrorFlowSegmentRequestFactory) IngressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.IngressFlowSegmentRequestFactory) EgressMirrorFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.EgressMirrorFlowSegmentRequestFactory) EgressFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.EgressFlowSegmentRequestFactory) TransitFlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.TransitFlowSegmentRequestFactory) FlowSegmentRequestFactory(org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory) ArrayList(java.util.ArrayList) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) PathSegment(org.openkilda.model.PathSegment)

Aggregations

FlowSideAdapter (org.openkilda.adapter.FlowSideAdapter)14 Test (org.junit.Test)9 Flow (org.openkilda.model.Flow)9 FlowEndpoint (org.openkilda.model.FlowEndpoint)8 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)7 SpeakerData (org.openkilda.rulemanager.SpeakerData)7 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)7 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)7 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)5 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)5 Action (org.openkilda.rulemanager.action.Action)5 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)5 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)5 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)5 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)5 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)5 ArrayList (java.util.ArrayList)4 FlowSourceAdapter (org.openkilda.adapter.FlowSourceAdapter)4 PathSegment (org.openkilda.model.PathSegment)4 Lists (com.google.common.collect.Lists)2