Search in sources :

Example 1 with PortColourCookie

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

the class EgressIslVxlanRuleGeneratorTest 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_EGRESS_RULES, ISL_PORT), flowCommandData.getCookie());
    assertEquals(OfTable.INPUT, flowCommandData.getTable());
    assertEquals(ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE, flowCommandData.getPriority());
    Set<FieldMatch> match = flowCommandData.getMatch();
    assertEquals(6, match.size());
    checkMatch(match, sw.getSwitchId());
    FieldMatch ethTypeMatch = getMatchByField(Field.ETH_TYPE, match);
    assertEquals(EthType.IPv4, ethTypeMatch.getValue());
    assertFalse(ethTypeMatch.isMasked());
    Instructions instructions = flowCommandData.getInstructions();
    assertEquals(OfTable.EGRESS, 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 2 with PortColourCookie

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

the class EgressIslVxlanRuleGeneratorTest method shouldBuildCorrectRuleWithNoviflowVxlanFeature.

@Test
public void shouldBuildCorrectRuleWithNoviflowVxlanFeature() {
    Switch sw = buildSwitch("OF_13", Sets.newHashSet(SwitchFeature.NOVIFLOW_PUSH_POP_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_EGRESS_RULES, ISL_PORT), flowCommandData.getCookie());
    assertEquals(OfTable.INPUT, flowCommandData.getTable());
    assertEquals(ISL_EGRESS_VXLAN_RULE_PRIORITY_MULTITABLE, flowCommandData.getPriority());
    Set<FieldMatch> match = flowCommandData.getMatch();
    assertEquals(6, match.size());
    checkMatch(match, sw.getSwitchId());
    Instructions instructions = flowCommandData.getInstructions();
    assertEquals(OfTable.EGRESS, 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 3 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 4 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 5 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