datapath-windows: Define OVS_DPPORT_NUMBER_INVALID
authorAlin Serdean <aserdean@cloudbasesolutions.com>
Thu, 9 Oct 2014 17:46:55 +0000 (17:46 +0000)
committerBen Pfaff <blp@nicira.com>
Thu, 9 Oct 2014 22:47:29 +0000 (15:47 -0700)
The fields externalVport and internalVport of the OVS_SWITCH_CONTEXT
struct are currently defined as PVOID. However, all over the code they
are used as POVS_VPORT_ENTRY. In order to improve clarity and reduce the
need for useless casts to POVS_VPORT_ENTRY, this patch changes the type
from PVOID to POVS_VPORT_ENTRY.

This patch does not cleanup the code that already uses casts to
POVS_VPORT_ENTRY. This cleanup can be done later on as well.

Signed-off-by: Samuel Ghinet <sghinet@cloudbasesolutions.com>
Co-authored-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Tested-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath-windows/ovsext/Datapath.c
datapath-windows/ovsext/Vport.c
datapath-windows/ovsext/Vport.h

index 96d0cab..65390b2 100644 (file)
@@ -1462,7 +1462,7 @@ OvsGetVportDumpNext(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
     */
     ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL);
     NdisAcquireRWLockRead(gOvsSwitchContext->dispatchLock, &lockState,
-        NDIS_RWL_AT_DISPATCH_LEVEL);
+                          NDIS_RWL_AT_DISPATCH_LEVEL);
 
     if (gOvsSwitchContext->numVports > 0) {
         /* inBucket: the bucket, used for lookup */
@@ -1490,7 +1490,7 @@ OvsGetVportDumpNext(POVS_USER_PARAMS_CONTEXT usrParamsCtx,
                 if (outIndex >= inIndex) {
                     vport = CONTAINING_RECORD(link, OVS_VPORT_ENTRY, portLink);
 
-                    if (vport->portNo != 0) {
+                    if (vport->portNo != OVS_DPPORT_NUMBER_INVALID) {
                         OvsCreateMsgFromVport(vport, msgIn,
                                               usrParamsCtx->outputBuffer,
                                               usrParamsCtx->outputLength,
index 942bad0..98ec439 100644 (file)
@@ -718,7 +718,7 @@ POVS_VPORT_ENTRY vport)
         vport->nicIndex != 0) {
         vport->portNo = OvsGetVportNo(switchContext, vport->nicIndex,
             vport->ovsType, vport->portType == NdisSwitchPortTypeExternal);
-        if (vport->portNo == 0) {
+        if (vport->portNo == OVS_DPPORT_NUMBER_INVALID) {
             return NDIS_STATUS_RESOURCES;
         }
         ASSERT(OVS_IS_VPORT_ENTRY_NULL(switchContext,
index 0061b0f..2e96e95 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "Switch.h"
 
+#define OVS_DPPORT_NUMBER_INVALID 0
+
 /*
  * A Vport, or Virtual Port, is a port on the OVS. It can be one of the
  * following types. Some of the Vports are "real" ports on the hyper-v switch,