[ovs-dev] [PATCH RFC] datapath-windows: Remove neighbor entries when Iphelper instance is deleted

Anand Kumar kumaranand at vmware.com
Tue Oct 2 23:00:45 UTC 2018


'OVS_IPHELPER_INSTANCE' is linked to ovsSortedIPNeighList.
So when an Iphelper instance is deleted, also delete the ip
neighboring entries associated with that instance.

Also fix accessing Iphelper instance without acquiring thelock.

Signed-off-by: Anand Kumar <kumaranand at vmware.com>
---
 datapath-windows/ovsext/IpHelper.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/datapath-windows/ovsext/IpHelper.c b/datapath-windows/ovsext/IpHelper.c
index 6bbd096..581be61 100644
--- a/datapath-windows/ovsext/IpHelper.c
+++ b/datapath-windows/ovsext/IpHelper.c
@@ -1446,6 +1446,17 @@ static VOID
 OvsIpHelperDeleteInstance(POVS_IPHELPER_INSTANCE instance)
 {
     if (instance) {
+        if (ovsNumFwdEntries) {
+            POVS_IPNEIGH_ENTRY ipn;
+            PLIST_ENTRY link, next;
+            LIST_FORALL_SAFE(&ovsSortedIPNeighList, link, next) {
+                ipn = CONTAINING_RECORD(link, OVS_IPNEIGH_ENTRY, slink);
+                POVS_IPHELPER_INSTANCE ipnInstance = (POVS_IPHELPER_INSTANCE)ipn->context;
+                if (ipnInstance == instance) {
+                    OvsRemoveIPNeighEntry(ipn);
+                }
+            }
+        }
         ExDeleteResourceLite(&instance->lock);
         OvsFreeMemoryWithTag(instance, OVS_IPHELPER_POOL_TAG);
     }
@@ -1942,13 +1953,13 @@ OvsStartIpHelper(PVOID data)
             NTSTATUS status;
             POVS_IPHELPER_INSTANCE instance = (POVS_IPHELPER_INSTANCE)ipn->context;
             NdisReleaseSpinLock(&ovsIpHelperLock);
-            ExAcquireResourceExclusiveLite(&ovsInstanceListLock, TRUE);
+            ExAcquireResourceExclusiveLite(&instance->lock, TRUE);
 
             status = OvsGetOrResolveIPNeigh(&instance->internalRow,
                                             ipAddr, &ipNeigh);
             OvsUpdateIPNeighEntry(ipAddr, &ipNeigh, status);
 
-            ExReleaseResourceLite(&ovsInstanceListLock);
+            ExReleaseResourceLite(&instance->lock);
 
             NdisAcquireSpinLock(&ovsIpHelperLock);
         }
@@ -2098,11 +2109,10 @@ OvsCleanupIpHelper(VOID)
     OvsFreeMemoryWithTag(ovsFwdHashTable, OVS_IPHELPER_POOL_TAG);
     OvsFreeMemoryWithTag(ovsRouteHashTable, OVS_IPHELPER_POOL_TAG);
     OvsFreeMemoryWithTag(ovsNeighHashTable, OVS_IPHELPER_POOL_TAG);
-
+    OvsIpHelperDeleteAllInstances();
     NdisFreeRWLock(ovsTableLock);
     NdisFreeSpinLock(&ovsIpHelperLock);
 
-    OvsIpHelperDeleteAllInstances();
     ExDeleteResourceLite(&ovsInstanceListLock);
 }
 
-- 
2.9.3.windows.1



More information about the dev mailing list