diff mbox series

[ovs-dev,RFC,v2] datapath-windows: Remove IP neighbor entries when internal adapter is down.

Message ID 20181017000022.5324-1-kumaranand@vmware.com
State Accepted
Headers show
Series [ovs-dev,RFC,v2] datapath-windows: Remove IP neighbor entries when internal adapter is down. | expand

Commit Message

Anand Kumar Oct. 17, 2018, midnight UTC
Remove the IP neighboring entries when adapter is down,
so that when 'OVS_IPHELPER_INSTANCE' is deleted, no stale entries
are present

Also fix accessing iphelper instance without acquiring the lock.

Signed-off-by: Anand Kumar <kumaranand@vmware.com>
---
v1->v2: Rebase and address comments
---
 datapath-windows/ovsext/IpHelper.c | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

Comments

Alin-Gabriel Serdean Oct. 24, 2018, 6:13 p.m. UTC | #1
> 
> Remove the IP neighboring entries when adapter is down, so that when
> 'OVS_IPHELPER_INSTANCE' is deleted, no stale entries are present
> 
> Also fix accessing iphelper instance without acquiring the lock.
> 
> Signed-off-by: Anand Kumar <kumaranand@vmware.com>
> ---
Thanks for incorporating the comments:
Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
Tested-by: Alin Gabriel Serdean <aserdean@ovn.org>
Alin-Gabriel Serdean Oct. 24, 2018, 6:24 p.m. UTC | #2
Thanks for the patch Anand! Applied on master.

Alin

> >
> > Remove the IP neighboring entries when adapter is down, so that when
> > 'OVS_IPHELPER_INSTANCE' is deleted, no stale entries are present
> >
> > Also fix accessing iphelper instance without acquiring the lock.
> >
> > Signed-off-by: Anand Kumar <kumaranand@vmware.com>
> > ---
> Thanks for incorporating the comments:
> Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
> Tested-by: Alin Gabriel Serdean <aserdean@ovn.org>
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
Alin-Gabriel Serdean Oct. 31, 2018, 4:09 p.m. UTC | #3
Also applied on branch-2.10.

—
Alin.

> On 24 Oct 2018, at 21:24, aserdean@ovn.org wrote:
> 
> Thanks for the patch Anand! Applied on master.
> 
> Alin
> 
>>> 
>>> Remove the IP neighboring entries when adapter is down, so that when
>>> 'OVS_IPHELPER_INSTANCE' is deleted, no stale entries are present
>>> 
>>> Also fix accessing iphelper instance without acquiring the lock.
>>> 
>>> Signed-off-by: Anand Kumar <kumaranand@vmware.com>
>>> ---
>> Thanks for incorporating the comments:
>> Acked-by: Alin Gabriel Serdean <aserdean@ovn.org>
>> Tested-by: Alin Gabriel Serdean <aserdean@ovn.org>
>> 
>> _______________________________________________
>> dev mailing list
>> dev@openvswitch.org
>> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
diff mbox series

Patch

diff --git a/datapath-windows/ovsext/IpHelper.c b/datapath-windows/ovsext/IpHelper.c
index 876da92..d7fa2ca 100644
--- a/datapath-windows/ovsext/IpHelper.c
+++ b/datapath-windows/ovsext/IpHelper.c
@@ -72,7 +72,7 @@  static OVS_IP_HELPER_THREAD_CONTEXT ovsIpHelperThreadContext;
 static POVS_IPFORWARD_ENTRY OvsLookupIPForwardEntry(PIP_ADDRESS_PREFIX prefix);
 static VOID OvsRemoveIPForwardEntry(POVS_IPFORWARD_ENTRY ipf);
 static VOID OvsRemoveAllFwdEntriesWithSrc(UINT32 ipAddr);
-static VOID OvsRemoveAllFwdEntriesWithPortNo(UINT32 portNo);
+static VOID OvsRemoveIPNeighEntriesWithInstance(POVS_IPHELPER_INSTANCE instance);
 static VOID OvsCleanupIpHelperRequestList(VOID);
 static VOID OvsCleanupFwdTable(VOID);
 static VOID OvsAddToSortedNeighList(POVS_IPNEIGH_ENTRY ipn);
@@ -1243,18 +1243,16 @@  OvsRemoveAllFwdEntriesWithSrc(UINT32 ipAddr)
 
 
 static VOID
-OvsRemoveAllFwdEntriesWithPortNo(UINT32 portNo)
+OvsRemoveIPNeighEntriesWithInstance(POVS_IPHELPER_INSTANCE instance)
 {
-    UINT32 i;
-    PLIST_ENTRY link, next;
-
-    for (i = 0; i < OVS_FWD_HASH_TABLE_SIZE; i++) {
-        LIST_FORALL_SAFE(&ovsFwdHashTable[i], link, next) {
-            POVS_FWD_ENTRY fwdEntry;
-
-            fwdEntry = CONTAINING_RECORD(link, OVS_FWD_ENTRY, link);
-            if (fwdEntry->info.srcPortNo == portNo) {
-                OvsRemoveFwdEntry(fwdEntry);
+    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 = ipn->instance;
+            if (ipnInstance == instance) {
+                OvsRemoveIPNeighEntry(ipn);
             }
         }
     }
@@ -1857,7 +1855,7 @@  OvsStartIpHelper(PVOID data)
                         IsEqualGUID(&instance->netCfgId, &netCfgInstanceId)) {
 
                         NdisAcquireRWLockWrite(ovsTableLock, &lockState, 0);
-                        OvsRemoveAllFwdEntriesWithPortNo(instance->portNo);
+                        OvsRemoveIPNeighEntriesWithInstance(instance);
                         NdisReleaseRWLock(ovsTableLock, &lockState);
 
                         RemoveEntryList(&instance->link);
@@ -1908,14 +1906,16 @@  OvsStartIpHelper(PVOID data)
             NTSTATUS status;
             POVS_IPHELPER_INSTANCE instance = ipn->instance;
             NdisReleaseSpinLock(&ovsIpHelperLock);
-            ExAcquireResourceExclusiveLite(&ovsInstanceListLock, TRUE);
 
-            status = OvsGetOrResolveIPNeigh(&instance->internalRow,
-                                            ipAddr, &ipNeigh);
-            OvsUpdateIPNeighEntry(ipAddr, &ipNeigh, status);
+            if (instance) {
+                ExAcquireResourceExclusiveLite(&instance->lock, TRUE);
 
-            ExReleaseResourceLite(&ovsInstanceListLock);
+                status = OvsGetOrResolveIPNeigh(&instance->internalRow,
+                                                ipAddr, &ipNeigh);
+                OvsUpdateIPNeighEntry(ipAddr, &ipNeigh, status);
 
+                ExReleaseResourceLite(&instance->lock);
+            }
             NdisAcquireSpinLock(&ovsIpHelperLock);
         }
         if (!IsListEmpty(&ovsIpHelperRequestList)) {