Search in sources :

Example 1 with FlowSharedSegmentCookie

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);
}
Also used : FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie) InstallFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.InstallFlowForSwitchManagerRequest) InstallServer42Flow(org.openkilda.messaging.command.flow.InstallServer42Flow) CommandMessage(org.openkilda.messaging.command.CommandMessage) Test(org.junit.Test)

Example 2 with FlowSharedSegmentCookie

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());
}
Also used : FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions)

Example 3 with FlowSharedSegmentCookie

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();
}
Also used : OfMetadata(org.openkilda.rulemanager.OfMetadata) FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Instructions(org.openkilda.rulemanager.Instructions) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction)

Example 4 with FlowSharedSegmentCookie

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);
}
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) FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Flow(org.openkilda.model.Flow) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) 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 5 with FlowSharedSegmentCookie

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();
}
Also used : FlowEndpoint(org.openkilda.model.FlowEndpoint) FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie)

Aggregations

FlowSharedSegmentCookie (org.openkilda.model.cookie.FlowSharedSegmentCookie)10 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)4 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)4 Test (org.junit.Test)3 FlowEndpoint (org.openkilda.model.FlowEndpoint)3 Instructions (org.openkilda.rulemanager.Instructions)3 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)3 Flow (org.openkilda.model.Flow)2 PortColourCookie (org.openkilda.model.cookie.PortColourCookie)2 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)2 MeterSpeakerData (org.openkilda.rulemanager.MeterSpeakerData)2 OfMetadata (org.openkilda.rulemanager.OfMetadata)2 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)2 SpeakerData (org.openkilda.rulemanager.SpeakerData)2 Action (org.openkilda.rulemanager.action.Action)2 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)2 PushVlanAction (org.openkilda.rulemanager.action.PushVlanAction)2 PushVxlanAction (org.openkilda.rulemanager.action.PushVxlanAction)2 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)2 FlowSideAdapter (org.openkilda.adapter.FlowSideAdapter)1