datapath-windows: Pause switch state on PnP event
authorAlin Serdean <aserdean@cloudbasesolutions.com>
Thu, 10 Mar 2016 13:33:42 +0000 (13:33 +0000)
committerBen Pfaff <blp@ovn.org>
Tue, 26 Apr 2016 15:19:31 +0000 (08:19 -0700)
A PnP(plug and play) event will be triggered before trying to disable
the extension. We could use this PnP event to prepare for detaching
the datapath.

This patch sets the switch into a paused state so no more net buffers
are queued.

Also clean some commentaries.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
datapath-windows/ovsext/Switch.c

index 7ad2e98..825fa3c 100644 (file)
@@ -353,14 +353,13 @@ OvsExtPause(NDIS_HANDLE filterModuleContext,
     OVS_LOG_TRACE("Enter: filterModuleContext %p",
                   filterModuleContext);
 
-    ASSERT(switchContext->dataFlowState == OvsSwitchRunning);
     switchContext->dataFlowState = OvsSwitchPaused;
     KeMemoryBarrier();
     while(switchContext->pendingOidCount > 0) {
         NdisMSleep(1000);
     }
 
-    OVS_LOG_TRACE("Exit: OvsDetach Successfully");
+    OVS_LOG_TRACE("Exit: OvsExtPause Successfully");
     return NDIS_STATUS_SUCCESS;
 }
 
@@ -613,6 +612,11 @@ OvsExtNetPnPEvent(NDIS_HANDLE filterModuleContext,
         }
     }
 
+    if (netPnPEvent->NetPnPEvent.NetEvent == NetEventFilterPreDetach) {
+        switchContext->dataFlowState = OvsSwitchPaused;
+        KeMemoryBarrier();
+    }
+
     status = NdisFNetPnPEvent(switchContext->NdisFilterHandle,
                               netPnPEvent);
     OVS_LOG_TRACE("Exit: OvsExtNetPnPEvent");