[ovs-dev] [PATCH] datapath-windows: define a OVS_VPORTNO_DEFAULT instead of using 0

Nithin Raju nithin at vmware.com
Thu Aug 14 20:18:59 UTC 2014


Signed-off-by: Nithin Raju <nithin at vmware.com>
---
 datapath-windows/ovsext/OvsActions.c |    2 +-
 datapath-windows/ovsext/OvsSwitch.h  |    1 +
 datapath-windows/ovsext/OvsUser.c    |    3 ++-
 datapath-windows/ovsext/OvsVport.c   |   10 +++++-----
 4 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/datapath-windows/ovsext/OvsActions.c b/datapath-windows/ovsext/OvsActions.c
index 635becc..f10c54b 100644
--- a/datapath-windows/ovsext/OvsActions.c
+++ b/datapath-windows/ovsext/OvsActions.c
@@ -273,7 +273,7 @@ OvsDetectTunnelPkt(OvsForwardingContext *ovsFwdCtx,
          * If the packet will not be encapsulated, consume the tunnel context
          * by clearing it.
          */
-        if (ovsFwdCtx->srcVportNo != 0 &&
+        if (ovsFwdCtx->srcVportNo != OVS_VPORTNO_DEFAULT &&
             !OvsIsVifVportNo(ovsFwdCtx->srcVportNo)) {
             ovsFwdCtx->tunKey.dst = 0;
         }
diff --git a/datapath-windows/ovsext/OvsSwitch.h b/datapath-windows/ovsext/OvsSwitch.h
index d49fe9b..35fc78c 100644
--- a/datapath-windows/ovsext/OvsSwitch.h
+++ b/datapath-windows/ovsext/OvsSwitch.h
@@ -28,6 +28,7 @@
 #define OVS_VPORT_MASK (OVS_MAX_VPORT_ARRAY_SIZE - 1)
 
 #define OVS_INTERNAL_VPORT_DEFAULT_INDEX 0
+#define OVS_VPORTNO_DEFAULT    0
 
 //Tunnel port indicies
 #define RESERVED_START_INDEX1    1
diff --git a/datapath-windows/ovsext/OvsUser.c b/datapath-windows/ovsext/OvsUser.c
index 5093f20..3a2f5fe 100644
--- a/datapath-windows/ovsext/OvsUser.c
+++ b/datapath-windows/ovsext/OvsUser.c
@@ -369,7 +369,8 @@ OvsExecuteDpIoctl(PVOID inputBuffer,
         NdisAcquireRWLockRead(gOvsSwitchContext->dispatchLock, &lockState,
                               NDIS_RWL_AT_DISPATCH_LEVEL);
         ndisStatus = OvsActionsExecute(gOvsSwitchContext, NULL, pNbl,
-                                       vport ? vport->portNo : 0,
+                                       vport ? vport->portNo :
+                                               OVS_VPORTNO_DEFAULT,
                                        NDIS_SEND_FLAGS_SWITCH_DESTINATION_GROUP,
                                        &key, NULL, &layers, actions,
                                        execute->actionsLen);
diff --git a/datapath-windows/ovsext/OvsVport.c b/datapath-windows/ovsext/OvsVport.c
index 35bdaea..1bb004e 100644
--- a/datapath-windows/ovsext/OvsVport.c
+++ b/datapath-windows/ovsext/OvsVport.c
@@ -529,9 +529,9 @@ OvsGetVportNo(POVS_SWITCH_CONTEXT switchContext,
     switch (ovsType) {
     case OVSWIN_VPORT_TYPE_EXTERNAL:
         if (nicIndex == 0) {
-            return 0;  // not a valid portNo
+            return OVS_VPORTNO_DEFAULT;  // not a valid portNo
         } else if (nicIndex > OVS_MAX_PHYS_ADAPTERS) {
-            return 0;
+            return OVS_VPORTNO_DEFAULT;
         } else {
             index = nicIndex + OVS_EXTERNAL_VPORT_START;
         }
@@ -554,7 +554,7 @@ OvsGetVportNo(POVS_SWITCH_CONTEXT switchContext,
             }
         }
         if (i == (OVS_MAX_VPORT_ARRAY_SIZE - OVS_VM_VPORT_START)) {
-            return 0; // not available
+            return OVS_VPORTNO_DEFAULT; // not available
         }
         switchContext->lastPortIndex = index;
         break;
@@ -576,7 +576,7 @@ OvsGetVportNo(POVS_SWITCH_CONTEXT switchContext,
     }
     gen = (UINT64)switchContext->vportArray[index];
     if (gen > 0xff) {
-        return 0;
+        return OVS_VPORTNO_DEFAULT;
     } else if (gen == 0) {
         gen++;
     }
@@ -711,7 +711,7 @@ POVS_VPORT_ENTRY vport)
         vport->nicIndex != 0) {
         vport->portNo = OvsGetVportNo(switchContext, vport->nicIndex,
             vport->ovsType);
-        if (vport->portNo == 0) {
+        if (vport->portNo == OVS_VPORTNO_DEFAULT) {
             return NDIS_STATUS_RESOURCES;
         }
         ASSERT(OVS_IS_VPORT_ENTRY_NULL(switchContext,
-- 
1.7.4.1




More information about the dev mailing list