use of org.openkilda.model.cookie.PortColourCookie in project open-kilda by telstra.
the class RecordHandler method processInstallDefaultFlowByCookie.
private Long processInstallDefaultFlowByCookie(SwitchId switchId, long cookie) throws SwitchOperationException {
ISwitchManager switchManager = context.getSwitchManager();
DatapathId dpid = DatapathId.of(switchId.toLong());
Cookie encodedCookie = new Cookie(cookie);
PortColourCookie portColourCookie = new PortColourCookie(cookie);
CookieType cookieType = encodedCookie.getType();
if (cookie == DROP_RULE_COOKIE) {
return switchManager.installDropFlow(dpid);
} else if (cookie == VERIFICATION_BROADCAST_RULE_COOKIE) {
return switchManager.installVerificationRule(dpid, true);
} else if (cookie == VERIFICATION_UNICAST_RULE_COOKIE) {
return switchManager.installVerificationRule(dpid, false);
} else if (cookie == DROP_VERIFICATION_LOOP_RULE_COOKIE) {
return switchManager.installDropLoopRule(dpid);
} else if (cookie == CATCH_BFD_RULE_COOKIE) {
return switchManager.installBfdCatchFlow(dpid);
} else if (cookie == ROUND_TRIP_LATENCY_RULE_COOKIE) {
return switchManager.installRoundTripLatencyFlow(dpid);
} else if (cookie == VERIFICATION_UNICAST_VXLAN_RULE_COOKIE) {
return switchManager.installUnicastVerificationRuleVxlan(dpid);
} else if (cookie == MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE) {
return switchManager.installPreIngressTablePassThroughDefaultRule(dpid);
} else if (cookie == MULTITABLE_INGRESS_DROP_COOKIE) {
return switchManager.installDropFlowForTable(dpid, INGRESS_TABLE_ID, MULTITABLE_INGRESS_DROP_COOKIE);
} else if (cookie == MULTITABLE_POST_INGRESS_DROP_COOKIE) {
return switchManager.installDropFlowForTable(dpid, POST_INGRESS_TABLE_ID, MULTITABLE_POST_INGRESS_DROP_COOKIE);
} else if (cookie == MULTITABLE_EGRESS_PASS_THROUGH_COOKIE) {
return switchManager.installEgressTablePassThroughDefaultRule(dpid);
} else if (cookie == MULTITABLE_TRANSIT_DROP_COOKIE) {
return switchManager.installDropFlowForTable(dpid, TRANSIT_TABLE_ID, MULTITABLE_TRANSIT_DROP_COOKIE);
} else if (cookie == LLDP_INPUT_PRE_DROP_COOKIE) {
return switchManager.installLldpInputPreDropFlow(dpid);
} else if (cookie == LLDP_INGRESS_COOKIE) {
return switchManager.installLldpIngressFlow(dpid);
} else if (cookie == LLDP_POST_INGRESS_COOKIE) {
return switchManager.installLldpPostIngressFlow(dpid);
} else if (cookie == LLDP_POST_INGRESS_VXLAN_COOKIE) {
return switchManager.installLldpPostIngressVxlanFlow(dpid);
} else if (cookie == LLDP_POST_INGRESS_ONE_SWITCH_COOKIE) {
return switchManager.installLldpPostIngressOneSwitchFlow(dpid);
} else if (cookie == LLDP_TRANSIT_COOKIE) {
return switchManager.installLldpTransitFlow(dpid);
} else if (cookie == ARP_INPUT_PRE_DROP_COOKIE) {
return switchManager.installArpInputPreDropFlow(dpid);
} else if (cookie == ARP_INGRESS_COOKIE) {
return switchManager.installArpIngressFlow(dpid);
} else if (cookie == ARP_POST_INGRESS_COOKIE) {
return switchManager.installArpPostIngressFlow(dpid);
} else if (cookie == ARP_POST_INGRESS_VXLAN_COOKIE) {
return switchManager.installArpPostIngressVxlanFlow(dpid);
} else if (cookie == ARP_POST_INGRESS_ONE_SWITCH_COOKIE) {
return switchManager.installArpPostIngressOneSwitchFlow(dpid);
} else if (cookie == ARP_TRANSIT_COOKIE) {
return switchManager.installArpTransitFlow(dpid);
} else if (cookie == SERVER_42_FLOW_RTT_TURNING_COOKIE) {
return switchManager.installServer42FlowRttTurningFlow(dpid);
} else if (cookie == SERVER_42_ISL_RTT_TURNING_COOKIE) {
return switchManager.installServer42IslRttTurningFlow(dpid);
} else if (cookie == SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE) {
return switchManager.installServer42FlowRttVxlanTurningFlow(dpid);
} else if (cookieType == CookieType.MULTI_TABLE_INGRESS_RULES) {
return switchManager.installIntermediateIngressRule(dpid, portColourCookie.getPortNumber());
} else if (cookieType == CookieType.MULTI_TABLE_ISL_VLAN_EGRESS_RULES) {
return switchManager.installEgressIslVlanRule(dpid, portColourCookie.getPortNumber());
} else if (cookieType == CookieType.MULTI_TABLE_ISL_VXLAN_TRANSIT_RULES) {
return switchManager.installTransitIslVxlanRule(dpid, portColourCookie.getPortNumber());
} else if (cookieType == CookieType.MULTI_TABLE_ISL_VXLAN_EGRESS_RULES) {
return switchManager.installEgressIslVxlanRule(dpid, portColourCookie.getPortNumber());
} else if (cookieType == CookieType.LLDP_INPUT_CUSTOMER_TYPE) {
return switchManager.installLldpInputCustomerFlow(dpid, portColourCookie.getPortNumber());
} else if (cookieType == CookieType.ARP_INPUT_CUSTOMER_TYPE) {
return switchManager.installArpInputCustomerFlow(dpid, portColourCookie.getPortNumber());
} else if (cookie == SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE) {
return switchManager.installServer42FlowRttVxlanTurningFlow(dpid);
} else {
logger.warn("Skipping the installation of unexpected default switch rule {} for switch {}", encodedCookie, switchId);
}
return null;
}
use of org.openkilda.model.cookie.PortColourCookie in project open-kilda by telstra.
the class RecordHandler method processInstallServer42Rule.
private Long processInstallServer42Rule(ReinstallServer42FlowForSwitchManagerRequest command) throws SwitchOperationException {
ISwitchManager switchManager = context.getSwitchManager();
DatapathId dpid = DatapathId.of(command.getSwitchId().toLong());
long cookie = command.getCookie();
if (cookie == SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE) {
return switchManager.installServer42FlowRttOutputVlanFlow(dpid, command.getServer42Port(), command.getServer42Vlan(), command.getServer42MacAddress());
} else if (cookie == SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE) {
return switchManager.installServer42FlowRttOutputVxlanFlow(dpid, command.getServer42Port(), command.getServer42Vlan(), command.getServer42MacAddress());
} else if (new Cookie(cookie).getType() == CookieType.SERVER_42_FLOW_RTT_INPUT) {
PortColourCookie portColourCookie = new PortColourCookie(cookie);
int customerPort = portColourCookie.getPortNumber();
return switchManager.installServer42FlowRttInputFlow(dpid, command.getServer42Port(), customerPort, command.getServer42MacAddress());
} else if (cookie == SERVER_42_ISL_RTT_OUTPUT_COOKIE || new Cookie(cookie).getType() == CookieType.SERVER_42_ISL_RTT_INPUT) {
return processInstallServer42IslRttRule(command.getSwitchId(), command.getCookie(), command.getServer42Port(), command.getServer42Vlan(), command.getServer42MacAddress());
} else {
logger.warn("Skipping the installation of unexpected server 42 switch rule {} for switch {}", Long.toHexString(cookie), command.getSwitchId());
return null;
}
}
use of org.openkilda.model.cookie.PortColourCookie in project open-kilda by telstra.
the class RecordHandlerTest method installServer42InputTest.
@Test
public void installServer42InputTest() throws SwitchOperationException {
PortColourCookie cookie = PortColourCookie.builder().portNumber(CUSTOMER_PORT).type(SERVER_42_FLOW_RTT_INPUT).build();
expect(switchManager.installServer42FlowRttInputFlow(DATAPATH_ID, SERVER42_PORT, CUSTOMER_PORT, SERVER42_MAC_ADDRESS)).andReturn(cookie.getValue()).once();
replay(switchManager);
InstallServer42Flow request = InstallServer42Flow.builder().id("input").switchId(SWITCH_ID).cookie(cookie.getValue()).inputPort(SERVER42_PORT).outputPort(0).server42MacAddress(SERVER42_MAC_ADDRESS).server42Vlan(SERVER42_VLAN).build();
recordHandler.handleCommand(new CommandMessage(new InstallFlowForSwitchManagerRequest(request), 0, CORRELATION_ID));
verify(switchManager);
}
use of org.openkilda.model.cookie.PortColourCookie in project open-kilda by telstra.
the class RecordHandlerTest method reinstallServer42FlowRttInputTest.
@Test
public void reinstallServer42FlowRttInputTest() throws SwitchOperationException {
PortColourCookie cookie = PortColourCookie.builder().portNumber(CUSTOMER_PORT).type(SERVER_42_FLOW_RTT_INPUT).build();
expect(switchManager.installServer42FlowRttInputFlow(DATAPATH_ID, SERVER42_PORT, CUSTOMER_PORT, SERVER42_MAC_ADDRESS)).andReturn(cookie.getValue()).once();
expect(switchManager.deleteRulesByCriteria(DATAPATH_ID, false, null, DeleteRulesCriteria.builder().cookie(cookie.getValue()).build())).andReturn(Lists.newArrayList(cookie.getValue())).once();
replay(switchManager);
ReinstallServer42FlowForSwitchManagerRequest request = new ReinstallServer42FlowForSwitchManagerRequest(SWITCH_ID, cookie.getValue(), SERVER42_MAC_ADDRESS, SERVER42_VLAN, SERVER42_PORT);
recordHandler.handleCommand(new CommandMessage(request, 0, null));
verify(switchManager);
}
use of org.openkilda.model.cookie.PortColourCookie in project open-kilda by telstra.
the class EgressIslVlanRuleGeneratorTest method shouldBuildCorrectRule.
@Test
public void shouldBuildCorrectRule() {
Switch sw = buildSwitch("OF_13", Collections.emptySet());
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_VLAN_EGRESS_RULES, ISL_PORT), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(ISL_EGRESS_VLAN_RULE_PRIORITY_MULTITABLE, flowCommandData.getPriority());
assertEquals(1, flowCommandData.getMatch().size());
FieldMatch inPortMatch = getMatchByField(Field.IN_PORT, flowCommandData.getMatch());
assertEquals(ISL_PORT, inPortMatch.getValue());
assertFalse(inPortMatch.isMasked());
Instructions instructions = flowCommandData.getInstructions();
assertEquals(OfTable.EGRESS, instructions.getGoToTable());
}
Aggregations