Search in sources :

Example 6 with FlowSharedSegmentCookie

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

the class RecordHandler method processInstallServer42RttRule.

private void processInstallServer42RttRule(InstallServer42Flow command) throws SwitchOperationException {
    ISwitchManager switchManager = context.getSwitchManager();
    DatapathId dpid = DatapathId.of(command.getSwitchId().toLong());
    Cookie cookie = new Cookie(command.getCookie());
    FlowSharedSegmentCookie sharedSegmentCookie = new FlowSharedSegmentCookie(command.getCookie());
    if (command.getCookie() == SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE) {
        switchManager.installServer42FlowRttOutputVlanFlow(dpid, command.getOutputPort(), command.getServer42Vlan(), command.getServer42MacAddress());
    } else if (command.getCookie() == SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE) {
        switchManager.installServer42FlowRttOutputVxlanFlow(dpid, command.getOutputPort(), command.getServer42Vlan(), command.getServer42MacAddress());
    } else if (cookie.getType() == CookieType.SERVER_42_FLOW_RTT_INPUT) {
        PortColourCookie portColourCookie = new PortColourCookie(command.getCookie());
        int customerPort = portColourCookie.getPortNumber();
        switchManager.installServer42FlowRttInputFlow(dpid, command.getInputPort(), customerPort, command.getServer42MacAddress());
    } else if (cookie.getType() == CookieType.SHARED_OF_FLOW && sharedSegmentCookie.getSegmentType() == SharedSegmentType.SERVER42_QINQ_OUTER_VLAN) {
        switchManager.installServer42OuterVlanMatchSharedFlow(dpid, sharedSegmentCookie);
    } else if (command.getCookie() == SERVER_42_ISL_RTT_OUTPUT_COOKIE) {
        processInstallServer42IslRttRule(command.getSwitchId(), command.getCookie(), command.getOutputPort(), command.getServer42Vlan(), command.getServer42MacAddress());
    } else if (cookie.getType() == CookieType.SERVER_42_ISL_RTT_INPUT) {
        processInstallServer42IslRttRule(command.getSwitchId(), command.getCookie(), command.getInputPort(), command.getServer42Vlan(), command.getServer42MacAddress());
    } else {
        logger.warn("Skipping the installation of unexpected server 42 switch rule {} for switch {}", Long.toHexString(command.getCookie()), command.getSwitchId());
    }
}
Also used : FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) Cookie(org.openkilda.model.cookie.Cookie) ISwitchManager(org.openkilda.floodlight.switchmanager.ISwitchManager) FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie) DatapathId(org.projectfloodlight.openflow.types.DatapathId) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) FlowEndpoint(org.openkilda.model.FlowEndpoint)

Example 7 with FlowSharedSegmentCookie

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

the class IngressFlowModFactory method makeOuterVlanMatchSharedMessage.

/**
 * Make rule to match traffic by port and vlan, write vlan into metadata and pass packet into "next" table. This
 * rule is shared across all flow with equal port and vlan(outer).
 */
public OFFlowMod makeOuterVlanMatchSharedMessage() {
    FlowEndpoint endpoint = command.getEndpoint();
    FlowSharedSegmentCookie cookie = FlowSharedSegmentCookie.builder(SharedSegmentType.QINQ_OUTER_VLAN).portNumber(endpoint.getPortNumber()).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(endpoint.getPortNumber())).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)

Example 8 with FlowSharedSegmentCookie

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

the class RecordHandler method installSharedFlow.

private void installSharedFlow(InstallSharedFlow command) throws SwitchOperationException, FlowCommandException {
    FlowSharedSegmentCookie cookie = new FlowSharedSegmentCookie(command.getCookie());
    SharedSegmentType segmentType = cookie.getSegmentType();
    if (segmentType == SharedSegmentType.QINQ_OUTER_VLAN) {
        context.getSwitchManager().installOuterVlanMatchSharedFlow(command.getSwitchId(), command.getId(), cookie);
    } else {
        throw new FlowCommandException(command.getId(), command.getCookie(), command.getTransactionId(), ErrorType.REQUEST_INVALID, format("Unsupported shared segment type %s (cookie: %s)", segmentType, cookie));
    }
}
Also used : FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie) SharedSegmentType(org.openkilda.model.cookie.FlowSharedSegmentCookie.SharedSegmentType) FlowCommandException(org.openkilda.floodlight.error.FlowCommandException)

Example 9 with FlowSharedSegmentCookie

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

the class MultiTableIngressRuleGeneratorTest method buildCommandsVlanEncapsulationDoubleVlanTest.

@Test
public void buildCommandsVlanEncapsulationDoubleVlanTest() {
    Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
    MultiTableIngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
    List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
    assertEquals(4, commands.size());
    FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
    FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
    FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(2);
    MeterSpeakerData meterCommand = (MeterSpeakerData) commands.get(3);
    assertEquals(newArrayList(meterCommand.getUuid()), new ArrayList<>(ingressCommand.getDependsOn()));
    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));
    assertInputCustomerCommand(inputCustomerCommand, new PortColourCookie(MULTI_TABLE_INGRESS_RULES, PORT_NUMBER_1), Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build()));
    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.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) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) Flow(org.openkilda.model.Flow) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) 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 10 with FlowSharedSegmentCookie

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

the class MultiTableServer42IngressRuleGenerator method buildServer42PreIngressCommand.

private FlowSpeakerData buildServer42PreIngressCommand(Switch sw, FlowEndpoint endpoint) {
    FlowSharedSegmentCookie cookie = FlowSharedSegmentCookie.builder(SharedSegmentType.SERVER42_QINQ_OUTER_VLAN).portNumber(switchProperties.getServer42Port()).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(SERVER_42_PRE_INGRESS_FLOW_PRIORITY).match(Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(switchProperties.getServer42Port()).build(), FieldMatch.builder().field(Field.VLAN_VID).value(endpoint.getOuterVlanId()).build())).instructions(instructions);
    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)

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