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);
}
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());
}
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;
}
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;
}
Aggregations