BUG-4917 Ensure all OVS flows are deleted 29/34529/1
authorJosh <jhershbe@redhat.com>
Tue, 9 Feb 2016 09:31:48 +0000 (11:31 +0200)
committerAnil Vishnoi <vishnoianil@gmail.com>
Fri, 12 Feb 2016 01:59:18 +0000 (01:59 +0000)
This commit is basically a revert of this change:
https://git.opendaylight.org/gerrit/#/c/27521/
With that change the cache cleanup in fact never ran because the
port is removed before the code is actually run.
The bug for which that commit was a fix is resolved
with this code new commit as well.

In addition, updateL3ForNeutronPort() now allows
deleting flows even when networkId is not found
in networkIdToRouterMacCache. This takes care of
some of the DHCP issues.

Change-Id: Idc3c1ff4b57f5471615ccc6c627ca8f411c37db2
Signed-off-by: Josh <jhershbe@redhat.com>
Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
(cherry picked from commit 5824899205c6eb36b45064a3a3f54668e1117a40)

openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/NeutronL3Adapter.java

index 023e84672a17470821b9b3f317289ca0702153f4..44261aea3bd6b9afe0cb6032f4a4062546790b34 100644 (file)
@@ -549,12 +549,6 @@ public class NeutronL3Adapter extends AbstractHandler implements GatewayMacResol
             this.updateL3ForNeutronPort(neutronPort, currPortShouldBeDeleted);
         }
 
-        if (isDelete) {
-            /*
-             *  Bug 4277: Remove the router interface cache only after deleting the neutron port l3 flows.
-             */
-            this.cleanupRouterCache(neutronRouterInterface);
-        }
     }
 
     /**
@@ -846,15 +840,17 @@ public class NeutronL3Adapter extends AbstractHandler implements GatewayMacResol
         final String networkUUID = neutronPort.getNetworkUUID();
         final String routerMacAddress = networkIdToRouterMacCache.get(networkUUID);
 
-        // If there is no router interface handling the networkUUID, we are done
-        if (routerMacAddress == null || routerMacAddress.isEmpty()) {
-            return;
-        }
+        if(!isDelete) {
+            // If there is no router interface handling the networkUUID, we are done
+            if (routerMacAddress == null || routerMacAddress.isEmpty()) {
+                return;
+            }
 
-        // If this is the neutron port for the router interface itself, ignore it as well. Ports that represent the
-        // router interface are handled via handleNeutronRouterInterfaceEvent.
-        if (routerMacAddress.equalsIgnoreCase(neutronPort.getMacAddress())) {
-            return;
+            // If this is the neutron port for the router interface itself, ignore it as well. Ports that represent the
+            // router interface are handled via handleNeutronRouterInterfaceEvent.
+            if (routerMacAddress.equalsIgnoreCase(neutronPort.getMacAddress())) {
+                return;
+            }
         }
 
         final NeutronNetwork neutronNetwork = neutronNetworkCache.getNetwork(networkUUID);
@@ -1080,7 +1076,11 @@ public class NeutronL3Adapter extends AbstractHandler implements GatewayMacResol
             }
         }
 
-        // Keep cache for finding router's mac from network uuid -- NOTE: remove is done later, via cleanupRouterCache()
+        if (isDelete) {
+            networkIdToRouterMacCache.remove(neutronNetwork.getNetworkUUID());
+            networkIdToRouterIpListCache.remove(neutronNetwork.getNetworkUUID());
+            subnetIdToRouterInterfaceCache.remove(subnet.getSubnetUUID());
+        }
     }
 
     private void programFlowForNetworkFromExternal(final Node node,
@@ -1449,21 +1449,6 @@ public class NeutronL3Adapter extends AbstractHandler implements GatewayMacResol
         return null;
     }
 
-     private void cleanupRouterCache(final NeutronRouter_Interface neutronRouterInterface) {
-         /*
-          *  Fix for 4277
-          *  Remove the router cache only after deleting the neutron
-          *  port l3 flows.
-          */
-         final NeutronPort neutronPort = neutronPortCache.getPort(neutronRouterInterface.getPortUUID());
-
-         if (neutronPort != null) {
-             networkIdToRouterMacCache.remove(neutronPort.getNetworkUUID());
-             networkIdToRouterIpListCache.remove(neutronPort.getNetworkUUID());
-             subnetIdToRouterInterfaceCache.remove(neutronRouterInterface.getSubnetUUID());
-         }
-     }
-
     private void cleanupFloatingIPRules(final NeutronPort neutronPort) {
 
         List<NeutronFloatingIP> neutronFloatingIps = neutronFloatingIpCache.getAllFloatingIPs();
@@ -1521,7 +1506,9 @@ public class NeutronL3Adapter extends AbstractHandler implements GatewayMacResol
     }
 
     public void removePortFromCleanupCache(NeutronPort port) {
-        this.portCleanupCache.remove(port.getPortUUID());
+        if(port != null) {
+            this.portCleanupCache.remove(port.getPortUUID());
+        }
     }
 
     public Map<String, NeutronPort> getPortCleanupCache() {