Fixes OpenstackRoutingFloatingIpHandler don't create illegal upstream rules in case of multiple gateway nodes.
Change-Id: Icf831e4d08873370ef2cba0a82c73941f5676731
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackNetworkManager.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackNetworkManager.java
index 5dab60f..205602d 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackNetworkManager.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackNetworkManager.java
@@ -393,19 +393,13 @@
return;
}
- String upLinkPort = gatewayNode.uplinkPort();
-
- org.onosproject.net.Port port = deviceService.getPorts(gatewayNode.intgBridge()).stream()
- .filter(p -> Objects.equals(p.annotations().value(PORT_NAME), upLinkPort))
- .findAny().orElse(null);
-
- if (port == null) {
+ if (gatewayNode.uplinkPortNum() == null) {
log.warn("There's no uplink port for gateway node {}", gatewayNode.toString());
return;
}
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setOutput(port.number())
+ .setOutput(gatewayNode.uplinkPortNum())
.build();
packetService.emit(new DefaultOutboundPacket(
diff --git a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingFloatingIpHandler.java b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingFloatingIpHandler.java
index 4c4e599..42fd73d 100644
--- a/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingFloatingIpHandler.java
+++ b/apps/openstacknetworking/app/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingFloatingIpHandler.java
@@ -386,30 +386,30 @@
throw new IllegalStateException(error);
}
- TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder()
- .setIpSrc(floating.getIp4Address())
- .setEthSrc(instPort.macAddress())
- .setEthDst(externalPeerRouter.externalPeerRouterMac());
-
- if (osNet.getNetworkType().equals(NetworkType.VLAN)) {
- tBuilder.popVlan();
- }
-
- if (!externalPeerRouter.externalPeerRouterVlanId().equals(VlanId.NONE)) {
- tBuilder.pushVlan().setVlanId(externalPeerRouter.externalPeerRouterVlanId());
- }
+ TrafficSelector selector = sBuilder.build();
osNodeService.completeNodes(GATEWAY).forEach(gNode -> {
+ TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder()
+ .setIpSrc(floating.getIp4Address())
+ .setEthSrc(instPort.macAddress())
+ .setEthDst(externalPeerRouter.externalPeerRouterMac());
+ if (osNet.getNetworkType().equals(NetworkType.VLAN)) {
+ tBuilder.popVlan();
+ }
+
+ if (!externalPeerRouter.externalPeerRouterVlanId().equals(VlanId.NONE)) {
+ tBuilder.pushVlan().setVlanId(externalPeerRouter.externalPeerRouterVlanId());
+ }
osFlowRuleService.setRule(
appId,
gNode.intgBridge(),
- sBuilder.build(),
+ selector,
tBuilder.setOutput(gNode.uplinkPortNum()).build(),
PRIORITY_FLOATING_EXTERNAL,
GW_COMMON_TABLE,
install);
- });
+ });
log.trace("Succeeded to set flow rules for upstream on gateway nodes");
}