use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.
the class PingRequestCommandAbstractTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
moduleContext.addService(IOFSwitchService.class, switchService);
final DatapathId dpIdAlpha = DatapathId.of(0x0000fffe00000001L);
final DatapathId dpIdBeta = DatapathId.of(0x0000fffe00000002L);
final DatapathId dpIdGamma = DatapathId.of(0x0000fffe00000003L);
final DatapathId dpIdDelta = DatapathId.of(0x0000fffe00000004L);
OFFactory ofFactory = new OFFactoryVer13();
expect(switchAlpha.getId()).andReturn(dpIdAlpha).anyTimes();
expect(switchBeta.getId()).andReturn(dpIdBeta).anyTimes();
expect(switchMissing.getId()).andReturn(dpIdGamma).anyTimes();
expect(switchNotCapable.getId()).andReturn(dpIdDelta).anyTimes();
expect(switchAlpha.getOFFactory()).andReturn(ofFactory).anyTimes();
expect(switchBeta.getOFFactory()).andReturn(ofFactory).anyTimes();
expect(switchNotCapable.getOFFactory()).andReturn(new OFFactoryVer12()).anyTimes();
expect(switchService.getActiveSwitch(dpIdAlpha)).andReturn(switchAlpha).anyTimes();
expect(switchService.getActiveSwitch(dpIdBeta)).andReturn(switchBeta).anyTimes();
expect(switchService.getActiveSwitch(dpIdGamma)).andReturn(null).anyTimes();
expect(switchService.getActiveSwitch(dpIdDelta)).andReturn(switchNotCapable).anyTimes();
}
use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.
the class BfdFeatureTest method createSwitchWithDescription.
private static IOFSwitch createSwitchWithDescription(SwitchDescription description) {
OFFactory factory = new OFFactoryVer13();
DatapathId dpid = DatapathId.of("1");
OFConnection connection = new OFConnection(dpid, factory, new LocalChannel(), OFAuxId.MAIN, new MockDebugCounterService(), new HashedWheelTimer());
OFSwitch sw = new OFSwitch(connection, factory, new OFSwitchManager(), dpid);
sw.setSwitchProperties(description);
return sw;
}
use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.
the class PingResponseCommandTest method success.
@Test
public void success() throws Exception {
final PingService realPingService = new PingService();
moduleContext.addService(PingService.class, realPingService);
final ISwitchManager realSwitchManager = new SwitchManager();
moduleContext.addService(ISwitchManager.class, realSwitchManager);
InputService inputService = createMock(InputService.class);
moduleContext.addService(InputService.class, inputService);
inputService.addTranslator(eq(OFType.PACKET_IN), anyObject());
replayAll();
final DatapathId dpIdBeta = DatapathId.of(0x0000fffe000002L);
final Ping ping = new Ping(new NetworkEndpoint(new SwitchId(dpIdBeta.getLong()), 8), new NetworkEndpoint(new SwitchId(dpId.getLong()), 9), new FlowTransitEncapsulation(2, FlowEncapsulationType.TRANSIT_VLAN), 3);
final PingData payload = PingData.of(ping);
moduleContext.addConfigParam(new PathVerificationService(), "hmac256-secret", "secret");
realPingService.setup(moduleContext);
byte[] signedPayload = realPingService.getSignature().sign(payload);
byte[] wireData = realPingService.wrapData(ping, signedPayload).serialize();
OFFactory ofFactory = new OFFactoryVer13();
OFPacketIn message = ofFactory.buildPacketIn().setReason(OFPacketInReason.ACTION).setXid(1L).setCookie(PingService.OF_CATCH_RULE_COOKIE).setData(wireData).build();
FloodlightContext metadata = new FloodlightContext();
IPacket decodedEthernet = new Ethernet().deserialize(wireData, 0, wireData.length);
Assert.assertTrue(decodedEthernet instanceof Ethernet);
IFloodlightProviderService.bcStore.put(metadata, IFloodlightProviderService.CONTEXT_PI_PAYLOAD, (Ethernet) decodedEthernet);
OfInput input = new OfInput(iofSwitch, message, metadata);
final PingResponseCommand command = makeCommand(input);
command.call();
final List<Message> replies = kafkaMessageCatcher.getValues();
Assert.assertEquals(1, replies.size());
InfoMessage response = (InfoMessage) replies.get(0);
PingResponse pingResponse = (PingResponse) response.getData();
Assert.assertNull(pingResponse.getError());
Assert.assertNotNull(pingResponse.getMeters());
Assert.assertEquals(payload.getPingId(), pingResponse.getPingId());
}
use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.
the class RecordHandler method doDeleteSwitchRules.
private void doDeleteSwitchRules(final CommandMessage message) {
SwitchRulesDeleteRequest request = (SwitchRulesDeleteRequest) message.getData();
logger.info("Deleting rules from '{}' switch: action={}, criteria={}", request.getSwitchId(), request.getDeleteRulesAction(), request.getCriteria());
final IKafkaProducerService producerService = getKafkaProducer();
final String replyToTopic = context.getKafkaSwitchManagerTopic();
DatapathId dpid = DatapathId.of(request.getSwitchId().toLong());
DeleteRulesAction deleteAction = request.getDeleteRulesAction();
DeleteRulesCriteria criteria = request.getCriteria();
ISwitchManager switchManager = context.getSwitchManager();
try {
List<Long> removedRules = new ArrayList<>();
if (deleteAction != null) {
switch(deleteAction) {
case REMOVE_DROP:
criteria = DeleteRulesCriteria.builder().cookie(DROP_RULE_COOKIE).build();
break;
case REMOVE_BROADCAST:
criteria = DeleteRulesCriteria.builder().cookie(VERIFICATION_BROADCAST_RULE_COOKIE).build();
break;
case REMOVE_UNICAST:
criteria = DeleteRulesCriteria.builder().cookie(VERIFICATION_UNICAST_RULE_COOKIE).build();
break;
case REMOVE_VERIFICATION_LOOP:
criteria = DeleteRulesCriteria.builder().cookie(DROP_VERIFICATION_LOOP_RULE_COOKIE).build();
break;
case REMOVE_BFD_CATCH:
criteria = DeleteRulesCriteria.builder().cookie(CATCH_BFD_RULE_COOKIE).build();
break;
case REMOVE_ROUND_TRIP_LATENCY:
criteria = DeleteRulesCriteria.builder().cookie(ROUND_TRIP_LATENCY_RULE_COOKIE).build();
break;
case REMOVE_UNICAST_VXLAN:
criteria = DeleteRulesCriteria.builder().cookie(VERIFICATION_UNICAST_VXLAN_RULE_COOKIE).build();
break;
case REMOVE_MULTITABLE_PRE_INGRESS_PASS_THROUGH:
criteria = DeleteRulesCriteria.builder().cookie(MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE).build();
break;
case REMOVE_MULTITABLE_INGRESS_DROP:
criteria = DeleteRulesCriteria.builder().cookie(MULTITABLE_INGRESS_DROP_COOKIE).build();
break;
case REMOVE_MULTITABLE_POST_INGRESS_DROP:
criteria = DeleteRulesCriteria.builder().cookie(MULTITABLE_POST_INGRESS_DROP_COOKIE).build();
break;
case REMOVE_MULTITABLE_EGRESS_PASS_THROUGH:
criteria = DeleteRulesCriteria.builder().cookie(MULTITABLE_EGRESS_PASS_THROUGH_COOKIE).build();
break;
case REMOVE_MULTITABLE_TRANSIT_DROP:
criteria = DeleteRulesCriteria.builder().cookie(MULTITABLE_TRANSIT_DROP_COOKIE).build();
break;
case REMOVE_LLDP_INPUT_PRE_DROP:
criteria = DeleteRulesCriteria.builder().cookie(LLDP_INPUT_PRE_DROP_COOKIE).build();
break;
case REMOVE_LLDP_INGRESS:
criteria = DeleteRulesCriteria.builder().cookie(LLDP_INGRESS_COOKIE).build();
break;
case REMOVE_LLDP_POST_INGRESS:
criteria = DeleteRulesCriteria.builder().cookie(LLDP_POST_INGRESS_COOKIE).build();
break;
case REMOVE_LLDP_POST_INGRESS_VXLAN:
criteria = DeleteRulesCriteria.builder().cookie(LLDP_POST_INGRESS_VXLAN_COOKIE).build();
break;
case REMOVE_LLDP_POST_INGRESS_ONE_SWITCH:
criteria = DeleteRulesCriteria.builder().cookie(LLDP_POST_INGRESS_ONE_SWITCH_COOKIE).build();
break;
case REMOVE_LLDP_TRANSIT:
criteria = DeleteRulesCriteria.builder().cookie(LLDP_TRANSIT_COOKIE).build();
break;
case REMOVE_ARP_INPUT_PRE_DROP:
criteria = DeleteRulesCriteria.builder().cookie(ARP_INPUT_PRE_DROP_COOKIE).build();
break;
case REMOVE_ARP_INGRESS:
criteria = DeleteRulesCriteria.builder().cookie(ARP_INGRESS_COOKIE).build();
break;
case REMOVE_ARP_POST_INGRESS:
criteria = DeleteRulesCriteria.builder().cookie(ARP_POST_INGRESS_COOKIE).build();
break;
case REMOVE_ARP_POST_INGRESS_VXLAN:
criteria = DeleteRulesCriteria.builder().cookie(ARP_POST_INGRESS_VXLAN_COOKIE).build();
break;
case REMOVE_ARP_POST_INGRESS_ONE_SWITCH:
criteria = DeleteRulesCriteria.builder().cookie(ARP_POST_INGRESS_ONE_SWITCH_COOKIE).build();
break;
case REMOVE_ARP_TRANSIT:
criteria = DeleteRulesCriteria.builder().cookie(ARP_TRANSIT_COOKIE).build();
break;
case REMOVE_SERVER_42_FLOW_RTT_TURNING:
case REMOVE_SERVER_42_TURNING:
criteria = DeleteRulesCriteria.builder().cookie(SERVER_42_FLOW_RTT_TURNING_COOKIE).build();
break;
case REMOVE_SERVER_42_FLOW_RTT_VXLAN_TURNING:
criteria = DeleteRulesCriteria.builder().cookie(SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE).build();
break;
case REMOVE_SERVER_42_FLOW_RTT_OUTPUT_VLAN:
case REMOVE_SERVER_42_OUTPUT_VLAN:
criteria = DeleteRulesCriteria.builder().cookie(SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE).build();
break;
case REMOVE_SERVER_42_FLOW_RTT_OUTPUT_VXLAN:
case REMOVE_SERVER_42_OUTPUT_VXLAN:
criteria = DeleteRulesCriteria.builder().cookie(SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE).build();
break;
case REMOVE_SERVER_42_ISL_RTT_TURNING:
criteria = DeleteRulesCriteria.builder().cookie(SERVER_42_ISL_RTT_TURNING_COOKIE).build();
break;
case REMOVE_SERVER_42_ISL_RTT_OUTPUT:
criteria = DeleteRulesCriteria.builder().cookie(SERVER_42_ISL_RTT_OUTPUT_COOKIE).build();
break;
default:
logger.warn("Received unexpected delete switch rule action: {}", deleteAction);
}
// The cases when we delete all non-default rules.
if (deleteAction.nonDefaultRulesToBeRemoved()) {
removedRules.addAll(switchManager.deleteAllNonDefaultRules(dpid));
}
// The cases when we delete the default rules.
if (deleteAction.defaultRulesToBeRemoved()) {
removedRules.addAll(switchManager.deleteDefaultRules(dpid, request.getIslPorts(), request.getFlowPorts(), request.getFlowLldpPorts(), request.getFlowArpPorts(), request.getServer42FlowRttPorts(), request.isMultiTable(), request.isSwitchLldp(), request.isSwitchArp(), request.isServer42FlowRttFeatureToggle() && request.isServer42FlowRttSwitchProperty(), request.isServer42IslRttEnabled()));
}
}
// The case when we either delete by criteria or a specific default rule.
if (criteria != null) {
removedRules.addAll(switchManager.deleteRulesByCriteria(dpid, false, null, criteria));
}
// The cases when we (re)install the default rules.
if (deleteAction != null && deleteAction.defaultRulesToBeInstalled()) {
switchManager.installDefaultRules(dpid);
if (request.isMultiTable()) {
processInstallDefaultFlowByCookie(request.getSwitchId(), MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE);
processInstallDefaultFlowByCookie(request.getSwitchId(), MULTITABLE_INGRESS_DROP_COOKIE);
processInstallDefaultFlowByCookie(request.getSwitchId(), MULTITABLE_POST_INGRESS_DROP_COOKIE);
processInstallDefaultFlowByCookie(request.getSwitchId(), MULTITABLE_EGRESS_PASS_THROUGH_COOKIE);
processInstallDefaultFlowByCookie(request.getSwitchId(), MULTITABLE_TRANSIT_DROP_COOKIE);
processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_POST_INGRESS_COOKIE);
processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_POST_INGRESS_VXLAN_COOKIE);
processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_POST_INGRESS_ONE_SWITCH_COOKIE);
processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_POST_INGRESS_COOKIE);
processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_POST_INGRESS_VXLAN_COOKIE);
processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_POST_INGRESS_ONE_SWITCH_COOKIE);
for (int port : request.getIslPorts()) {
switchManager.installMultitableEndpointIslRules(dpid, port);
}
for (int port : request.getFlowPorts()) {
switchManager.installIntermediateIngressRule(dpid, port);
}
for (Integer port : request.getFlowLldpPorts()) {
switchManager.installLldpInputCustomerFlow(dpid, port);
}
for (Integer port : request.getFlowArpPorts()) {
switchManager.installArpInputCustomerFlow(dpid, port);
}
if (request.isSwitchLldp()) {
processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_INPUT_PRE_DROP_COOKIE);
processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_TRANSIT_COOKIE);
processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_INGRESS_COOKIE);
}
if (request.isSwitchArp()) {
processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_INPUT_PRE_DROP_COOKIE);
processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_TRANSIT_COOKIE);
processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_INGRESS_COOKIE);
}
}
Integer server42Port = request.getServer42Port();
Integer server42Vlan = request.getServer42Vlan();
MacAddress server42MacAddress = request.getServer42MacAddress();
if (request.isServer42FlowRttFeatureToggle()) {
switchManager.installServer42FlowRttTurningFlow(dpid);
switchManager.installServer42FlowRttVxlanTurningFlow(dpid);
if (request.isServer42FlowRttSwitchProperty() && server42Port != null && server42Vlan != null && server42MacAddress != null) {
switchManager.installServer42FlowRttOutputVlanFlow(dpid, server42Port, server42Vlan, server42MacAddress);
switchManager.installServer42FlowRttOutputVxlanFlow(dpid, server42Port, server42Vlan, server42MacAddress);
for (Integer port : request.getServer42FlowRttPorts()) {
switchManager.installServer42FlowRttInputFlow(dpid, server42Port, port, server42MacAddress);
}
}
}
if (request.isServer42IslRttEnabled()) {
switchManager.installServer42IslRttTurningFlow(dpid);
switchManager.installServer42IslRttOutputFlow(dpid, server42Port, server42Vlan, server42MacAddress);
for (Integer port : request.getIslPorts()) {
switchManager.installServer42IslRttInputFlow(dpid, server42Port, port);
}
}
}
SwitchRulesResponse response = new SwitchRulesResponse(removedRules);
InfoMessage infoMessage = new InfoMessage(response, System.currentTimeMillis(), message.getCorrelationId());
producerService.sendMessageAndTrack(replyToTopic, record.key(), infoMessage);
} catch (SwitchNotFoundException e) {
logger.error("Deleting switch rules was unsuccessful. Switch '{}' not found", request.getSwitchId());
anError(ErrorType.NOT_FOUND).withMessage(e.getMessage()).withDescription(request.getSwitchId().toString()).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).withKey(record.key()).sendVia(producerService);
} catch (SwitchOperationException e) {
logger.error("Failed to delete switch '{}' rules.", request.getSwitchId(), e);
anError(ErrorType.DELETION_FAILURE).withMessage(e.getMessage()).withDescription(request.getSwitchId().toString()).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).withKey(record.key()).sendVia(producerService);
}
}
use of org.projectfloodlight.openflow.types.DatapathId in project open-kilda by telstra.
the class RecordHandler method doInstallSwitchRules.
private void doInstallSwitchRules(final CommandMessage message) {
SwitchRulesInstallRequest request = (SwitchRulesInstallRequest) message.getData();
logger.info("Installing rules on '{}' switch: action={}", request.getSwitchId(), request.getInstallRulesAction());
final IKafkaProducerService producerService = getKafkaProducer();
final String replyToTopic = context.getKafkaSwitchManagerTopic();
DatapathId dpid = DatapathId.of(request.getSwitchId().toLong());
ISwitchManager switchManager = context.getSwitchManager();
InstallRulesAction installAction = request.getInstallRulesAction();
List<Long> installedRules = new ArrayList<>();
try {
if (installAction == InstallRulesAction.INSTALL_DROP) {
installedRules.add(switchManager.installDropFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_BROADCAST) {
installedRules.add(switchManager.installVerificationRule(dpid, true));
} else if (installAction == InstallRulesAction.INSTALL_UNICAST) {
// TODO: this isn't always added (ie if OF1.2). Is there a better response?
installedRules.add(switchManager.installVerificationRule(dpid, false));
} else if (installAction == InstallRulesAction.INSTALL_DROP_VERIFICATION_LOOP) {
installedRules.add(switchManager.installDropLoopRule(dpid));
} else if (installAction == InstallRulesAction.INSTALL_BFD_CATCH) {
// TODO: this isn't installed as well. Refactor this section
installedRules.add(switchManager.installBfdCatchFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_ROUND_TRIP_LATENCY) {
// TODO: this isn't installed as well. Refactor this section
installedRules.add(switchManager.installRoundTripLatencyFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_UNICAST_VXLAN) {
installedRules.add(switchManager.installUnicastVerificationRuleVxlan(dpid));
} else if (installAction == InstallRulesAction.INSTALL_MULTITABLE_PRE_INGRESS_PASS_THROUGH) {
installedRules.add(switchManager.installPreIngressTablePassThroughDefaultRule(dpid));
} else if (installAction == InstallRulesAction.INSTALL_MULTITABLE_INGRESS_DROP) {
installedRules.add(switchManager.installDropFlowForTable(dpid, INGRESS_TABLE_ID, MULTITABLE_INGRESS_DROP_COOKIE));
} else if (installAction == InstallRulesAction.INSTALL_MULTITABLE_POST_INGRESS_DROP) {
installedRules.add(switchManager.installDropFlowForTable(dpid, POST_INGRESS_TABLE_ID, MULTITABLE_POST_INGRESS_DROP_COOKIE));
} else if (installAction == InstallRulesAction.INSTALL_MULTITABLE_EGRESS_PASS_THROUGH) {
installedRules.add(switchManager.installEgressTablePassThroughDefaultRule(dpid));
} else if (installAction == InstallRulesAction.INSTALL_MULTITABLE_TRANSIT_DROP) {
installedRules.add(switchManager.installDropFlowForTable(dpid, TRANSIT_TABLE_ID, MULTITABLE_TRANSIT_DROP_COOKIE));
} else if (installAction == InstallRulesAction.INSTALL_LLDP_INPUT_PRE_DROP) {
installedRules.add(switchManager.installLldpInputPreDropFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_LLDP_INGRESS) {
installedRules.add(switchManager.installLldpIngressFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_LLDP_POST_INGRESS) {
installedRules.add(switchManager.installLldpPostIngressFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_LLDP_POST_INGRESS_VXLAN) {
installedRules.add(switchManager.installLldpPostIngressVxlanFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_LLDP_POST_INGRESS_ONE_SWITCH) {
installedRules.add(switchManager.installLldpPostIngressOneSwitchFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_LLDP_TRANSIT) {
installedRules.add(switchManager.installLldpTransitFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_ARP_INPUT_PRE_DROP) {
installedRules.add(switchManager.installArpInputPreDropFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_ARP_INGRESS) {
installedRules.add(switchManager.installArpIngressFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_ARP_POST_INGRESS) {
installedRules.add(switchManager.installArpPostIngressFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_ARP_POST_INGRESS_VXLAN) {
installedRules.add(switchManager.installArpPostIngressVxlanFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_ARP_POST_INGRESS_ONE_SWITCH) {
installedRules.add(switchManager.installArpPostIngressOneSwitchFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_ARP_TRANSIT) {
installedRules.add(switchManager.installArpTransitFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_SERVER_42_OUTPUT_VLAN || installAction == InstallRulesAction.INSTALL_SERVER_42_FLOW_RTT_OUTPUT_VLAN) {
validateServer42Fields(request, installAction);
installedRules.add(switchManager.installServer42FlowRttOutputVlanFlow(dpid, request.getServer42Port(), request.getServer42Vlan(), request.getServer42MacAddress()));
} else if (installAction == InstallRulesAction.INSTALL_SERVER_42_OUTPUT_VXLAN || installAction == InstallRulesAction.INSTALL_SERVER_42_FLOW_RTT_OUTPUT_VXLAN) {
validateServer42Fields(request, installAction);
installedRules.add(switchManager.installServer42FlowRttOutputVxlanFlow(dpid, request.getServer42Port(), request.getServer42Vlan(), request.getServer42MacAddress()));
} else if (installAction == InstallRulesAction.INSTALL_SERVER_42_TURNING || installAction == InstallRulesAction.INSTALL_SERVER_42_FLOW_RTT_TURNING) {
installedRules.add(switchManager.installServer42FlowRttTurningFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_SERVER_42_FLOW_RTT_VXLAN_TURNING) {
installedRules.add(switchManager.installServer42FlowRttVxlanTurningFlow(dpid));
} else if (installAction == InstallRulesAction.INSTALL_SERVER_42_ISL_RTT_OUTPUT) {
validateServer42Fields(request, installAction);
installedRules.add(switchManager.installServer42IslRttOutputFlow(dpid, request.getServer42Port(), request.getServer42Vlan(), request.getServer42MacAddress()));
} else if (installAction == InstallRulesAction.INSTALL_SERVER_42_ISL_RTT_TURNING) {
installedRules.add(switchManager.installServer42IslRttTurningFlow(dpid));
} else {
installedRules.addAll(switchManager.installDefaultRules(dpid));
if (request.isMultiTable()) {
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), MULTITABLE_PRE_INGRESS_PASS_THROUGH_COOKIE));
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), MULTITABLE_INGRESS_DROP_COOKIE));
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), MULTITABLE_POST_INGRESS_DROP_COOKIE));
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), MULTITABLE_EGRESS_PASS_THROUGH_COOKIE));
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), MULTITABLE_TRANSIT_DROP_COOKIE));
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_POST_INGRESS_COOKIE));
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_POST_INGRESS_VXLAN_COOKIE));
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_POST_INGRESS_ONE_SWITCH_COOKIE));
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_POST_INGRESS_COOKIE));
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_POST_INGRESS_VXLAN_COOKIE));
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_POST_INGRESS_ONE_SWITCH_COOKIE));
for (int port : request.getIslPorts()) {
installedRules.addAll(switchManager.installMultitableEndpointIslRules(dpid, port));
}
for (int port : request.getFlowPorts()) {
installedRules.add(switchManager.installIntermediateIngressRule(dpid, port));
}
for (Integer port : request.getFlowLldpPorts()) {
installedRules.add(switchManager.installLldpInputCustomerFlow(dpid, port));
}
for (Integer port : request.getFlowArpPorts()) {
installedRules.add(switchManager.installArpInputCustomerFlow(dpid, port));
}
if (request.isSwitchLldp()) {
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_INPUT_PRE_DROP_COOKIE));
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_TRANSIT_COOKIE));
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), LLDP_INGRESS_COOKIE));
}
if (request.isSwitchArp()) {
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_INPUT_PRE_DROP_COOKIE));
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_TRANSIT_COOKIE));
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), ARP_INGRESS_COOKIE));
}
}
Integer server42Port = request.getServer42Port();
Integer server42Vlan = request.getServer42Vlan();
MacAddress server42MacAddress = request.getServer42MacAddress();
if (request.isServer42FlowRttFeatureToggle()) {
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), SERVER_42_FLOW_RTT_TURNING_COOKIE));
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE));
if (request.isServer42FlowRttSwitchProperty() && server42Port != null && server42Vlan != null && server42MacAddress != null) {
installedRules.add(switchManager.installServer42FlowRttOutputVlanFlow(dpid, server42Port, server42Vlan, server42MacAddress));
installedRules.add(switchManager.installServer42FlowRttOutputVxlanFlow(dpid, server42Port, server42Vlan, server42MacAddress));
for (Integer port : request.getServer42FlowRttPorts()) {
installedRules.add(switchManager.installServer42FlowRttInputFlow(dpid, server42Port, port, server42MacAddress));
}
}
}
if (request.isServer42IslRttEnabled()) {
installedRules.add(processInstallDefaultFlowByCookie(request.getSwitchId(), SERVER_42_ISL_RTT_TURNING_COOKIE));
installedRules.add(switchManager.installServer42IslRttOutputFlow(dpid, request.getServer42Port(), request.getServer42Vlan(), request.getServer42MacAddress()));
for (Integer port : request.getIslPorts()) {
installedRules.add(switchManager.installServer42IslRttInputFlow(dpid, server42Port, port));
}
}
}
SwitchRulesResponse response = new SwitchRulesResponse(installedRules.stream().filter(Objects::nonNull).collect(Collectors.toList()));
InfoMessage infoMessage = new InfoMessage(response, System.currentTimeMillis(), message.getCorrelationId());
producerService.sendMessageAndTrack(replyToTopic, record.key(), infoMessage);
} catch (SwitchOperationException e) {
logger.error("Failed to install rules on switch '{}'", request.getSwitchId(), e);
anError(ErrorType.CREATION_FAILURE).withMessage(e.getMessage()).withDescription(request.getSwitchId().toString()).withCorrelationId(message.getCorrelationId()).withTopic(replyToTopic).withKey(record.key()).sendVia(producerService);
}
}
Aggregations