From: Josh Date: Tue, 9 Feb 2016 09:31:48 +0000 (+0200) Subject: BUG-4917 Ensure all OVS flows are deleted X-Git-Tag: release/boron~471 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=1bedc79c70edf75ff40f3146b0f4e49043adf500;p=netvirt.git BUG-4917 Ensure all OVS flows are deleted 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 Signed-off-by: Anil Vishnoi (cherry picked from commit 5824899205c6eb36b45064a3a3f54668e1117a40) --- diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/NeutronL3Adapter.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/NeutronL3Adapter.java index 023e84672a..44261aea3b 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/NeutronL3Adapter.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/NeutronL3Adapter.java @@ -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 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 getPortCleanupCache() {