Skip to content

Commit

Permalink
datapath-windows: Solved BSOD when loading an activated extension
Browse files Browse the repository at this point in the history
If the OVS extension was previously enabled and the driver unloaded,
when the driver is loaded again a BSOD is triggered.

This happens because the OVS extension registers its FilterXxx routines
to NDIS, by calling NdisFRegisterFilterDriver, before performing all
the necessary initialization. Because drivers that call
NdisFRegisterFilterDriver must be prepared for an immediate call to any
of their FilterXxx functions.

The BSOD is triggered because the FilterAttach routine, OvsExtAttach,
tries to acquire the control lock, when the lock is not yet initialized.
This happens because the FilterAttach is called before the driver
finishes initialization, in OvsInit().

The solution is to perform all necessary initialization before
registering OVS FilterXxx routines.

If device object creation fails, all allocated resources during init
phase are released by calling OvsCleanup and NdisFDeregisterFilterDriver
functions.

Signed-off-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Reported-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Reported-at: openvswitch/ovs-issues#67
Acked-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
  • Loading branch information
svinturis authored and blp committed Jan 30, 2015
1 parent 7be0b8a commit 448d667
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 1 addition & 4 deletions datapath-windows/ovsext/Datapath.c
Expand Up @@ -448,10 +448,8 @@ OvsCreateDeviceObject(NDIS_HANDLE ovsExtDriverHandle)
if (ovsExt) {
ovsExt->numberOpenInstance = 0;
}
} else {
/* Initialize the associated data structures. */
OvsInit();
}

OVS_LOG_TRACE("DeviceObject: %p", gOvsDeviceObject);
return status;
}
Expand All @@ -474,7 +472,6 @@ OvsDeleteDeviceObject()
gOvsDeviceHandle = NULL;
gOvsDeviceObject = NULL;
}
OvsCleanup();
}

POVS_OPEN_INSTANCE
Expand Down
2 changes: 2 additions & 0 deletions datapath-windows/ovsext/Datapath.h
Expand Up @@ -81,6 +81,8 @@ typedef struct _OVS_OPEN_INSTANCE {

NDIS_STATUS OvsCreateDeviceObject(NDIS_HANDLE ovsExtDriverHandle);
VOID OvsDeleteDeviceObject();
VOID OvsInit();
VOID OvsCleanup();

POVS_OPEN_INSTANCE OvsGetOpenInstance(PFILE_OBJECT fileObject,
UINT32 dpNo);
Expand Down
8 changes: 8 additions & 0 deletions datapath-windows/ovsext/Driver.c
Expand Up @@ -95,6 +95,9 @@ DriverEntry(PDRIVER_OBJECT driverObject,

UNREFERENCED_PARAMETER(registryPath);

/* Initialize driver associated data structures. */
OvsInit();

gOvsExtDriverObject = driverObject;

RtlZeroMemory(&driverChars, sizeof driverChars);
Expand Down Expand Up @@ -145,6 +148,7 @@ DriverEntry(PDRIVER_OBJECT driverObject,
/* Create the communication channel for usersapce. */
status = OvsCreateDeviceObject(gOvsExtDriverHandle);
if (status != NDIS_STATUS_SUCCESS) {
OvsCleanup();
NdisFDeregisterFilterDriver(gOvsExtDriverHandle);
gOvsExtDriverHandle = NULL;
}
Expand All @@ -163,7 +167,11 @@ OvsExtUnload(struct _DRIVER_OBJECT *driverObject)
{
UNREFERENCED_PARAMETER(driverObject);

/* Release driver associated data structures. */
OvsCleanup();

OvsDeleteDeviceObject();

NdisFDeregisterFilterDriver(gOvsExtDriverHandle);
}

Expand Down

0 comments on commit 448d667

Please sign in to comment.