[ovs-dev] [PATCH v3] datapath-windows: Add a wrapper to retreive external vport

Shashank Ram rams at vmware.com
Tue Jan 24 20:37:32 UTC 2017


This wrapper is to simplify readability.

Signed-off-by: Shashank Ram <rams at vmware.com>
---
 datapath-windows/ovsext/Actions.c  | 8 ++++----
 datapath-windows/ovsext/PacketIO.c | 6 +++---
 datapath-windows/ovsext/Vport.c    | 6 ++++++
 datapath-windows/ovsext/Vport.h    | 2 ++
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/datapath-windows/ovsext/Actions.c b/datapath-windows/ovsext/Actions.c
index b4a286b..df1280d 100644
--- a/datapath-windows/ovsext/Actions.c
+++ b/datapath-windows/ovsext/Actions.c
@@ -290,8 +290,8 @@ OvsDetectTunnelPkt(OvsForwardingContext *ovsFwdCtx,
          * default port.
          */
         BOOLEAN validSrcPort =
-            (ovsFwdCtx->fwdDetail->SourcePortId ==
-                 ovsFwdCtx->switchContext->virtualExternalPortId) ||
+            (OvsIsExternalVportByPortId(ovsFwdCtx->switchContext,
+                 ovsFwdCtx->fwdDetail->SourcePortId)) ||
             (ovsFwdCtx->fwdDetail->SourcePortId ==
                  NDIS_SWITCH_DEFAULT_PORT_ID);

@@ -2130,8 +2130,8 @@ OvsDoRecirc(POVS_SWITCH_CONTEXT switchContext,
         }
         status = OvsCreateAndAddPackets(NULL, 0, OVS_PACKET_CMD_MISS,
                                         vport, key, ovsFwdCtx.curNbl,
-                                        vport->portId ==
-                                        switchContext->virtualExternalPortId,
+                                        OvsIsExternalVportByPortId(switchContext,
+                                            vport->portId),
                                         &ovsFwdCtx.layers,
                                         ovsFwdCtx.switchContext,
                                         &missedPackets, &num);
diff --git a/datapath-windows/ovsext/PacketIO.c b/datapath-windows/ovsext/PacketIO.c
index 4005589..a90b556 100644
--- a/datapath-windows/ovsext/PacketIO.c
+++ b/datapath-windows/ovsext/PacketIO.c
@@ -259,13 +259,13 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
                 curNbl,
                 nextNativeForwardedNbl,
                 sendCompleteFlags,
-                sourcePort == switchContext->virtualExternalPortId);
+                OvsIsExternalVportByPortId(switchContext, sourcePort));
             continue;
         }
 #endif /* NDIS_SUPPORT_NDIS640 */

         ctx = OvsInitExternalNBLContext(switchContext, curNbl,
-                  sourcePort == switchContext->virtualExternalPortId);
+                  OvsIsExternalVportByPortId(switchContext, sourcePort));
         if (ctx == NULL) {
             RtlInitUnicodeString(&filterReason,
                 L"Cannot allocate external NBL context.");
@@ -345,7 +345,7 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
                 datapath->misses++;
                 status = OvsCreateAndAddPackets(NULL, 0, OVS_PACKET_CMD_MISS,
                              vport, &key, curNbl,
-                             sourcePort == switchContext->virtualExternalPortId,
+                             OvsIsExternalVportByPortId(switchContext, sourcePort),
                              &layers, switchContext, &missedPackets, &num);
                 if (status == NDIS_STATUS_SUCCESS) {
                     /* Complete the packet since it was copied to user
diff --git a/datapath-windows/ovsext/Vport.c b/datapath-windows/ovsext/Vport.c
index e9e22aa..9142937 100644
--- a/datapath-windows/ovsext/Vport.c
+++ b/datapath-windows/ovsext/Vport.c
@@ -909,6 +909,12 @@ OvsFindVportByPortIdAndNicIndex(POVS_SWITCH_CONTEXT switchContext,
     }
 }

+BOOLEAN OvsIsExternalVportByPortId(POVS_SWITCH_CONTEXT switchContext,
+                                   NDIS_SWITCH_PORT_ID portId)
+{
+    return (portId == switchContext->virtualExternalPortId);
+}
+
 POVS_VPORT_ENTRY
 OvsAllocateVport(VOID)
 {
diff --git a/datapath-windows/ovsext/Vport.h b/datapath-windows/ovsext/Vport.h
index 4dc4e00..7d88f86 100644
--- a/datapath-windows/ovsext/Vport.h
+++ b/datapath-windows/ovsext/Vport.h
@@ -134,6 +134,8 @@ POVS_VPORT_ENTRY OvsFindVportByHvNameW(POVS_SWITCH_CONTEXT switchContext,
 POVS_VPORT_ENTRY OvsFindVportByPortIdAndNicIndex(POVS_SWITCH_CONTEXT switchContext,
                                                  NDIS_SWITCH_PORT_ID portId,
                                                  NDIS_SWITCH_NIC_INDEX index);
+BOOLEAN OvsIsExternalVportByPortId(POVS_SWITCH_CONTEXT switchContext,
+                                   NDIS_SWITCH_PORT_ID portId);
 POVS_VPORT_ENTRY OvsFindTunnelVportByDstPortAndType(POVS_SWITCH_CONTEXT switchContext,
                                                     UINT16 dstPort,
                                                     OVS_VPORT_TYPE ovsPortType);
--
2.6.2



More information about the dev mailing list