Search in sources :

Example 11 with PortColourCookie

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

the class TransitIslVxlanRuleGeneratorTest method shouldBuildCorrectRuleWithOpenKildaVxlanFeature.

@Test
public void shouldBuildCorrectRuleWithOpenKildaVxlanFeature() {
    Switch sw = buildSwitch("OF_13", Sets.newHashSet(KILDA_OVS_PUSH_POP_MATCH_VXLAN));
    List<SpeakerData> commands = generator.generateCommands(sw);
    assertEquals(1, commands.size());
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    assertEquals(sw.getSwitchId(), flowCommandData.getSwitchId());
    assertEquals(sw.getOfVersion(), flowCommandData.getOfVersion().toString());
    assertTrue(flowCommandData.getDependsOn().isEmpty());
    assertEquals(new PortColourCookie(CookieType.MULTI_TABLE_ISL_VXLAN_TRANSIT_RULES, ISL_PORT), flowCommandData.getCookie());
    assertEquals(OfTable.INPUT, flowCommandData.getTable());
    assertEquals(ISL_TRANSIT_VXLAN_RULE_PRIORITY_MULTITABLE, flowCommandData.getPriority());
    Set<FieldMatch> match = flowCommandData.getMatch();
    assertEquals(5, match.size());
    checkMatch(match);
    FieldMatch ethTypeMatch = getMatchByField(Field.ETH_TYPE, match);
    assertEquals(EthType.IPv4, ethTypeMatch.getValue());
    assertFalse(ethTypeMatch.isMasked());
    Instructions instructions = flowCommandData.getInstructions();
    assertEquals(OfTable.TRANSIT, instructions.getGoToTable());
}
Also used : FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Utils.buildSwitch(org.openkilda.rulemanager.Utils.buildSwitch) Switch(org.openkilda.model.Switch) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Instructions(org.openkilda.rulemanager.Instructions) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) Test(org.junit.Test)

Example 12 with PortColourCookie

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

the class MultiTableIngressRuleGenerator method buildCustomerPortSharedCatchCommand.

private FlowSpeakerData buildCustomerPortSharedCatchCommand(Switch sw, FlowEndpoint endpoint) {
    PortColourCookie cookie = new PortColourCookie(CookieType.MULTI_TABLE_INGRESS_RULES, endpoint.getPortNumber());
    Instructions instructions = Instructions.builder().goToTable(OfTable.PRE_INGRESS).build();
    FlowSpeakerDataBuilder<?, ?> builder = FlowSpeakerData.builder().switchId(endpoint.getSwitchId()).ofVersion(OfVersion.of(sw.getOfVersion())).cookie(cookie).table(OfTable.INPUT).priority(Priority.INGRESS_CUSTOMER_PORT_RULE_PRIORITY_MULTITABLE).match(Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(endpoint.getPortNumber()).build())).instructions(instructions);
    return builder.build();
}
Also used : Instructions(org.openkilda.rulemanager.Instructions) PortColourCookie(org.openkilda.model.cookie.PortColourCookie)

Example 13 with PortColourCookie

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

the class InputArpRuleGeneratorTest method buildCorrectRuleForOf13Test.

@Test
public void buildCorrectRuleForOf13Test() {
    FlowEndpoint endpoint = new FlowEndpoint(SW.getSwitchId(), PORT_NUMBER_1, 0, 0, false, true);
    FlowSideAdapter overlapAdapter = new FlowSourceAdapter(Flow.builder().flowId("some").srcSwitch(SW).destSwitch(buildSwitch("OF_13", Collections.emptySet())).detectConnectedDevices(DetectConnectedDevices.builder().srcArp(false).srcSwitchArp(false).build()).build());
    InputArpRuleGenerator generator = InputArpRuleGenerator.builder().ingressEndpoint(endpoint).multiTable(true).overlappingIngressAdapters(Sets.newHashSet(overlapAdapter)).build();
    List<SpeakerData> commands = generator.generateCommands(SW);
    assertEquals(1, commands.size());
    FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
    assertEquals(SW.getSwitchId(), flowCommandData.getSwitchId());
    assertEquals(SW.getOfVersion(), flowCommandData.getOfVersion().toString());
    assertTrue(flowCommandData.getDependsOn().isEmpty());
    assertEquals(new PortColourCookie(CookieType.ARP_INPUT_CUSTOMER_TYPE, PORT_NUMBER_1), flowCommandData.getCookie());
    assertEquals(OfTable.INPUT, flowCommandData.getTable());
    assertEquals(Priority.ARP_INPUT_CUSTOMER_PRIORITY, flowCommandData.getPriority());
    Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(PORT_NUMBER_1).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.ARP).build());
    assertEqualsMatch(expectedMatch, flowCommandData.getMatch());
    RoutingMetadata metadata = RoutingMetadata.builder().arpFlag(true).build(SW.getFeatures());
    Instructions expectedInstructions = Instructions.builder().writeMetadata(new OfMetadata(metadata.getValue(), metadata.getMask())).goToTable(OfTable.PRE_INGRESS).build();
    assertEquals(expectedInstructions, flowCommandData.getInstructions());
    assertTrue(flowCommandData.getFlags().isEmpty());
}
Also used : FlowSourceAdapter(org.openkilda.adapter.FlowSourceAdapter) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) RoutingMetadata(org.openkilda.rulemanager.utils.RoutingMetadata) Instructions(org.openkilda.rulemanager.Instructions) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) OfMetadata(org.openkilda.rulemanager.OfMetadata) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FlowEndpoint(org.openkilda.model.FlowEndpoint) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) Test(org.junit.Test)

Example 14 with PortColourCookie

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

the class RecordHandler method processInstallServer42IslRttRule.

private Long processInstallServer42IslRttRule(SwitchId switchId, long cookie, int server42Port, int server42Vlan, MacAddress server42MacAddress) throws SwitchOperationException {
    ISwitchManager switchManager = context.getSwitchManager();
    DatapathId dpid = DatapathId.of(switchId.toLong());
    if (cookie == SERVER_42_ISL_RTT_OUTPUT_COOKIE) {
        return switchManager.installServer42IslRttOutputFlow(dpid, server42Port, server42Vlan, server42MacAddress);
    } else if (new Cookie(cookie).getType() == CookieType.SERVER_42_ISL_RTT_INPUT) {
        PortColourCookie portColourCookie = new PortColourCookie(cookie);
        int islPort = portColourCookie.getPortNumber();
        return switchManager.installServer42IslRttInputFlow(dpid, server42Port, islPort);
    } else {
        logger.warn("Skipping the installation of unexpected server 42 switch rule {} for switch {}", Long.toHexString(cookie), switchId);
        return null;
    }
}
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) DatapathId(org.projectfloodlight.openflow.types.DatapathId) PortColourCookie(org.openkilda.model.cookie.PortColourCookie)

Example 15 with PortColourCookie

use of org.openkilda.model.cookie.PortColourCookie 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)

Aggregations

PortColourCookie (org.openkilda.model.cookie.PortColourCookie)27 FieldMatch (org.openkilda.rulemanager.match.FieldMatch)15 Test (org.junit.Test)14 Instructions (org.openkilda.rulemanager.Instructions)14 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)10 SpeakerData (org.openkilda.rulemanager.SpeakerData)10 Switch (org.openkilda.model.Switch)6 Utils.buildSwitch (org.openkilda.rulemanager.Utils.buildSwitch)6 RoutingMetadata (org.openkilda.rulemanager.utils.RoutingMetadata)6 FlowEndpoint (org.openkilda.model.FlowEndpoint)5 FlowSharedSegmentCookie (org.openkilda.model.cookie.FlowSharedSegmentCookie)5 Action (org.openkilda.rulemanager.action.Action)5 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)5 SetFieldAction (org.openkilda.rulemanager.action.SetFieldAction)5 ISwitchManager (org.openkilda.floodlight.switchmanager.ISwitchManager)4 CommandMessage (org.openkilda.messaging.command.CommandMessage)4 Cookie (org.openkilda.model.cookie.Cookie)4 OfMetadata (org.openkilda.rulemanager.OfMetadata)4 PopVlanAction (org.openkilda.rulemanager.action.PopVlanAction)4 DatapathId (org.projectfloodlight.openflow.types.DatapathId)4