From 555fe6c93c150535e43399d3f4d9468782b18de1 Mon Sep 17 00:00:00 2001 From: Anand Kumar Date: Tue, 16 Oct 2018 17:00:22 -0700 Subject: datapath-windows: Remove IP neighbor entries when internal adapter is down. 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 Acked-by: Alin Gabriel Serdean Tested-by: Alin Gabriel Serdean Signed-off-by: Alin Gabriel Serdean --- datapath-windows/ovsext/IpHelper.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'datapath-windows') diff --git a/datapath-windows/ovsext/IpHelper.c b/datapath-windows/ovsext/IpHelper.c index 876da9225..d7fa2ca84 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)) { -- cgit v1.2.1