use of org.openkilda.model.cookie.FlowSharedSegmentCookie in project open-kilda by telstra.
the class RecordHandlerTest method installServer42SharedTest.
@Test
public void installServer42SharedTest() throws SwitchOperationException {
FlowSharedSegmentCookie cookie = FlowSharedSegmentCookie.builder(SharedSegmentType.SERVER42_QINQ_OUTER_VLAN).portNumber(SERVER42_PORT).vlanId(VLAN_1).build();
switchManager.installServer42OuterVlanMatchSharedFlow(DATAPATH_ID, cookie);
expectLastCall().once();
replay(switchManager);
InstallServer42Flow request = InstallServer42Flow.builder().id("shared").switchId(SWITCH_ID).cookie(cookie.getValue()).inputPort(SERVER42_PORT).outputPort(0).build();
recordHandler.handleCommand(new CommandMessage(new InstallFlowForSwitchManagerRequest(request), 0, CORRELATION_ID));
verify(switchManager);
}
use of org.openkilda.model.cookie.FlowSharedSegmentCookie in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGeneratorTest method assertPreIngressCommand.
private void assertPreIngressCommand(FlowSpeakerData command, List<Action> expectedApplyActions) {
FlowSharedSegmentCookie cookie = FlowSharedSegmentCookie.builder(SharedSegmentType.SERVER42_QINQ_OUTER_VLAN).portNumber(SERVER_42_PORT_NUMBER).vlanId(OUTER_VLAN_ID_1).build();
assertEquals(SWITCH_1.getSwitchId(), command.getSwitchId());
assertEquals(SWITCH_1.getOfVersion(), command.getOfVersion().toString());
assertEquals(cookie, command.getCookie());
assertEquals(OfTable.PRE_INGRESS, command.getTable());
assertEquals(Priority.SERVER_42_PRE_INGRESS_FLOW_PRIORITY, command.getPriority());
assertTrue(command.getDependsOn().isEmpty());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(SERVER_42_PORT_NUMBER).build(), FieldMatch.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID_1).build());
assertEqualsMatch(expectedMatch, command.getMatch());
Instructions expectedInstructions = Instructions.builder().writeMetadata(mapMetadata(RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures()))).applyActions(expectedApplyActions).goToTable(OfTable.INGRESS).build();
assertEquals(expectedInstructions, command.getInstructions());
assertTrue(command.getFlags().isEmpty());
}
use of org.openkilda.model.cookie.FlowSharedSegmentCookie in project open-kilda by telstra.
the class MultiTableIngressRuleGenerator method buildFlowPreIngressCommand.
private FlowSpeakerData buildFlowPreIngressCommand(Switch sw, FlowEndpoint endpoint) {
FlowSharedSegmentCookie cookie = FlowSharedSegmentCookie.builder(SharedSegmentType.QINQ_OUTER_VLAN).portNumber(endpoint.getPortNumber()).vlanId(endpoint.getOuterVlanId()).build();
RoutingMetadata metadata = RoutingMetadata.builder().outerVlanId(endpoint.getOuterVlanId()).build(sw.getFeatures());
Instructions instructions = Instructions.builder().applyActions(Lists.newArrayList(new PopVlanAction())).writeMetadata(new OfMetadata(metadata.getValue(), metadata.getMask())).goToTable(OfTable.INGRESS).build();
FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(endpoint.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(cookie).table(OfTable.PRE_INGRESS).priority(Constants.Priority.FLOW_PRIORITY).match(buildPreIngressMatch(endpoint)).instructions(instructions);
// todo add RESET_COUNTERS flag
return builder.build();
}
use of org.openkilda.model.cookie.FlowSharedSegmentCookie in project open-kilda by telstra.
the class MultiTableIngressRuleGeneratorTest method buildCommandsVlanEncapsulationDoubleVlanPortOverlappingTest.
@Test
public void buildCommandsVlanEncapsulationDoubleVlanPortOverlappingTest() {
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);
MultiTableIngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION, overlapping);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(3, commands.size());
FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
MeterSpeakerData meterCommand = (MeterSpeakerData) commands.get(2);
assertEquals(newArrayList(meterCommand.getUuid()), 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)));
Set<FieldMatch> expectedPreIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.VLAN_VID).value(OUTER_VLAN_ID_1).build());
FlowSharedSegmentCookie preIngressCookie = FlowSharedSegmentCookie.builder(SharedSegmentType.QINQ_OUTER_VLAN).portNumber(PORT_NUMBER_1).vlanId(OUTER_VLAN_ID_1).build();
RoutingMetadata preIngressMetadata = RoutingMetadata.builder().outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
assertPreIngressCommand(preIngressCommand, preIngressCookie, Priority.FLOW_PRIORITY, expectedPreIngressMatch, newArrayList(new PopVlanAction()), mapMetadata(preIngressMetadata));
assertIngressCommand(ingressCommand, Priority.DOUBLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions, METER_ID, null);
assertMeterCommand(meterCommand);
}
use of org.openkilda.model.cookie.FlowSharedSegmentCookie 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();
}
Aggregations