BUG-5456:DHCP port ARP flows not removed in compute node.
authorbalakrishnan <balakrishnan.ka@hcl.com>
Thu, 24 Mar 2016 11:02:00 +0000 (16:32 +0530)
committerbalakrishnan <balakrishnan.ka@hcl.com>
Tue, 29 Mar 2016 09:35:41 +0000 (15:05 +0530)
  * When the last VM instance belongs to the network is deleted from compute node,
  * We are checking the arp needed flag for the particular node
  * based on the flag value deleting last instance and
  * DHCP arp entries from the the compute node.

Change-Id: I351b5e4e6d49fbe73c7c8d5f5c16961e1a3d2c2c
Signed-off-by: balakrishnan <balakrishnan.ka@hcl.com>
openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/DistributedArpService.java

index 3633cda2cb2ad2a6c0f4bd07e99de36453f3e7d4..a9a063fc456ecb105602357affbfccd4026eb1e5 100644 (file)
@@ -185,6 +185,7 @@ public class DistributedArpService implements ConfigInterface {
             }
         }
 
+        List<Neutron_IPs> network_Ips = neutronPort.getFixedIPs();
         for (Node node : nodes) {
             // Arp rule is only needed when segmentation exists in the given node (bug 4752)
             // or in case the port is a router interface
@@ -192,7 +193,6 @@ public class DistributedArpService implements ConfigInterface {
             boolean arpNeeded = isRouterInterface ||
                     tenantNetworkManager.isTenantNetworkPresentInNode(node, providerSegmentationId);
             final Action actionForNode = arpNeeded ? actionToPerform : Action.DELETE;
-
             final Long dpid = getDatapathIdIntegrationBridge(node);
             if (dpid == null) {
                 continue;
@@ -204,9 +204,29 @@ public class DistributedArpService implements ConfigInterface {
                     continue;
                 }
 
-                programStaticRuleStage1(dpid, providerSegmentationId, macAddress, ipAddress, actionForNode);
-            }
-        }
+                // Arp rules for dhcp port should be removed from compute node
+                // when delete the last VM instance belongs to the network (bug 5456)
+                if (false == arpNeeded && Action.DELETE == actionForNode && null != network_Ips && !network_Ips.isEmpty()) {
+                    for (NeutronPort port : neutronPortCache.getAllPorts()) {
+                         if (!port.getDeviceOwner().equalsIgnoreCase(ROUTER_INTERFACE_DEVICE_OWNER)) {
+                             final String portMacAddress = port.getMacAddress();
+                             if ( null == portMacAddress || portMacAddress.isEmpty()) {
+                                continue;
+                             }
+                             for (Neutron_IPs neutronIPAddr : port.getFixedIPs()) {
+                                 final String portIPAddress = neutronIPAddr.getIpAddress();
+                                 if (null == portIPAddress || portIPAddress.isEmpty()) {
+                                     continue;
+                                 }
+                             programStaticRuleStage1(dpid, providerSegmentationId, portMacAddress, portIPAddress, Action.DELETE);
+                             }
+                          }
+                    }
+                 } else {
+                     programStaticRuleStage1(dpid, providerSegmentationId, macAddress, ipAddress, actionForNode);
+              }
+              }
+          }
 
         //use action instead of actionToPerform - only write to the cache when the port is created
         if(isDhcpPort && action == Action.ADD){