[ovs-dev] [PATCH v2] datapath-windows: use correct dst port during Vxlan Tx

Alin Serdean aserdean at cloudbasesolutions.com
Fri Jun 19 15:47:39 UTC 2015


Just a personal preference maybe we could drop OvsIpHlprCbVxlan all togheter.

Rest looks fine with me.

Acked-by: Alin Gabriel Serdean <aserdean at cloudbasesolutions.com>

-----Mesaj original-----
De la: dev [mailto:dev-bounces at openvswitch.org] În numele Nithin Raju
Trimis: Friday, June 19, 2015 7:00 AM
Către: dev at openvswitch.org
Subiect: [ovs-dev] [PATCH v2] datapath-windows: use correct dst port during Vxlan Tx

A previous commit used the wrong DST port in the UDP header during Vxlan Tx which caused Vxlan tunneling to break. Fixing it here..

Also included is a cosmetic fix in OvsDetectTunnelRxPkt() where we were using htons() instead of ntohs(). Doesn't make a difference in practice though.

Testing done: Ping across Vxlan tunnel and Stt tunnel.

Signed-off-by: Nithin Raju <nithin at vmware.com>
Reported-by: Eitan Eliahu <eliahue at vmware.com>
---
v2: updated the commit message
---
 datapath-windows/ovsext/Actions.c |  9 ++++-----
 datapath-windows/ovsext/Stt.c     |  4 ++--
 datapath-windows/ovsext/Vxlan.c   | 18 +++++++++++++-----
 datapath-windows/ovsext/Vxlan.h   |  3 ++-
 4 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/datapath-windows/ovsext/Actions.c b/datapath-windows/ovsext/Actions.c
index d75949c..e5c122f 100644
--- a/datapath-windows/ovsext/Actions.c
+++ b/datapath-windows/ovsext/Actions.c
@@ -207,7 +207,7 @@ OvsDetectTunnelRxPkt(OvsForwardingContext *ovsFwdCtx,
      */
     if (!flowKey->ipKey.nwFrag &&
         flowKey->ipKey.nwProto == IPPROTO_UDP) {
-        UINT16 dstPort = htons(flowKey->ipKey.l4.tpDst);
+        UINT16 dstPort = ntohs(flowKey->ipKey.l4.tpDst);
         tunnelVport = OvsFindTunnelVportByDstPort(ovsFwdCtx->switchContext,
                                                   dstPort,
                                                   OVS_VPORT_TYPE_VXLAN); @@ -654,14 +654,13 @@ OvsTunnelPortTx(OvsForwardingContext *ovsFwdCtx)
     /* Do the encap. Encap function does not consume the NBL. */
     switch(ovsFwdCtx->tunnelTxNic->ovsType) {
     case OVS_VPORT_TYPE_VXLAN:
-        status = OvsEncapVxlan(ovsFwdCtx->curNbl, &ovsFwdCtx->tunKey,
-                               ovsFwdCtx->switchContext,
+        status = OvsEncapVxlan(ovsFwdCtx->tunnelTxNic, ovsFwdCtx->curNbl,
+                               &ovsFwdCtx->tunKey, 
+ ovsFwdCtx->switchContext,
                                &ovsFwdCtx->layers, &newNbl);
         break;
     case OVS_VPORT_TYPE_STT:
         status = OvsEncapStt(ovsFwdCtx->tunnelTxNic, ovsFwdCtx->curNbl,
-                             &ovsFwdCtx->tunKey,
-                             ovsFwdCtx->switchContext,
+                             &ovsFwdCtx->tunKey, 
+ ovsFwdCtx->switchContext,
                              &ovsFwdCtx->layers, &newNbl);
         break;
     default:
diff --git a/datapath-windows/ovsext/Stt.c b/datapath-windows/ovsext/Stt.c index 1f708c8..b6272c3 100644
--- a/datapath-windows/ovsext/Stt.c
+++ b/datapath-windows/ovsext/Stt.c
@@ -114,8 +114,8 @@ OvsEncapStt(POVS_VPORT_ENTRY vport,
         return NDIS_STATUS_FAILURE;
     }
 
-    status = OvsDoEncapStt(vport, curNbl, tunKey, &fwdInfo, layers, switchContext,
-                           newNbl);
+    status = OvsDoEncapStt(vport, curNbl, tunKey, &fwdInfo, layers,
+                           switchContext, newNbl);
     return status;
 }
 
diff --git a/datapath-windows/ovsext/Vxlan.c b/datapath-windows/ovsext/Vxlan.c index fa6be66..c724581 100644
--- a/datapath-windows/ovsext/Vxlan.c
+++ b/datapath-windows/ovsext/Vxlan.c
@@ -170,7 +170,8 @@ OvsCleanupVxlanTunnel(PIRP irp,
  *----------------------------------------------------------------------------
  */
 static __inline NDIS_STATUS
-OvsDoEncapVxlan(PNET_BUFFER_LIST curNbl,
+OvsDoEncapVxlan(POVS_VPORT_ENTRY vport,
+                PNET_BUFFER_LIST curNbl,
                 OvsIPv4TunnelKey *tunKey,
                 POVS_FWD_INFO fwdInfo,
                 POVS_PACKET_HDR_INFO layers, @@ -185,6 +186,7 @@ OvsDoEncapVxlan(PNET_BUFFER_LIST curNbl,
     IPHdr *ipHdr;
     UDPHdr *udpHdr;
     VXLANHdr *vxlanHdr;
+    POVS_VXLAN_VPORT vportVxlan;
     UINT32 headRoom = OvsGetVxlanTunHdrSize();
     UINT32 packetLength;
 
@@ -211,6 +213,10 @@ OvsDoEncapVxlan(PNET_BUFFER_LIST curNbl,
             }
         }
     }
+
+    vportVxlan = (POVS_VXLAN_VPORT) GetOvsVportPriv(vport);
+    ASSERT(vportVxlan);
+
     /* If we didn't split the packet above, make a copy now */
     if (*newNbl == NULL) {
         *newNbl = OvsPartialCopyNBL(switchContext, curNbl, 0, headRoom, @@ -274,7 +280,7 @@ OvsDoEncapVxlan(PNET_BUFFER_LIST curNbl,
         /* UDP header */
         udpHdr = (UDPHdr *)((PCHAR)ipHdr + sizeof *ipHdr);
         udpHdr->source = htons(tunKey->flow_hash | 32768);
-        udpHdr->dest = htons(tunKey->dst_port);
+        udpHdr->dest = htons(vportVxlan->dstPort);
         udpHdr->len = htons(NET_BUFFER_DATA_LENGTH(curNb) - headRoom +
                             sizeof *udpHdr + sizeof *vxlanHdr);
         udpHdr->check = 0;
@@ -308,7 +314,8 @@ ret_error:
  *----------------------------------------------------------------------------
  */
 NDIS_STATUS
-OvsEncapVxlan(PNET_BUFFER_LIST curNbl,
+OvsEncapVxlan(POVS_VPORT_ENTRY vport,
+              PNET_BUFFER_LIST curNbl,
               OvsIPv4TunnelKey *tunKey,
               POVS_SWITCH_CONTEXT switchContext,
               POVS_PACKET_HDR_INFO layers, @@ -331,7 +338,7 @@ OvsEncapVxlan(PNET_BUFFER_LIST curNbl,
         return NDIS_STATUS_FAILURE;
     }
 
-    return OvsDoEncapVxlan(curNbl, tunKey, &fwdInfo, layers,
+    return OvsDoEncapVxlan(vport, curNbl, tunKey, &fwdInfo, layers,
                            switchContext, newNbl);  }
 
@@ -359,7 +366,8 @@ OvsIpHlprCbVxlan(PNET_BUFFER_LIST curNbl,
 
     status = OvsExtractFlow(curNbl, inPort, &key, &layers, NULL);
     if (result == STATUS_SUCCESS) {
-        status = OvsDoEncapVxlan(curNbl, tunKey, fwdInfo, &layers,
+        ASSERT(FALSE);
+        status = OvsDoEncapVxlan(NULL, curNbl, tunKey, fwdInfo, 
+ &layers,
                 (POVS_SWITCH_CONTEXT)cbData1, NULL);
     } else {
         status = NDIS_STATUS_FAILURE;
diff --git a/datapath-windows/ovsext/Vxlan.h b/datapath-windows/ovsext/Vxlan.h index 448ee97..b010af0 100644
--- a/datapath-windows/ovsext/Vxlan.h
+++ b/datapath-windows/ovsext/Vxlan.h
@@ -62,7 +62,8 @@ NTSTATUS OvsCleanupVxlanTunnel(PIRP irp,  NDIS_STATUS OvsSlowPathDecapVxlan(const PNET_BUFFER_LIST packet,
                                   OvsIPv4TunnelKey *tunnelKey);
 
-NDIS_STATUS OvsEncapVxlan(PNET_BUFFER_LIST curNbl,
+NDIS_STATUS OvsEncapVxlan(POVS_VPORT_ENTRY vport,
+                          PNET_BUFFER_LIST curNbl,
                           OvsIPv4TunnelKey *tunKey,
                           POVS_SWITCH_CONTEXT switchContext,
                           POVS_PACKET_HDR_INFO layers,
--
1.8.5.6

_______________________________________________
dev mailing list
dev at openvswitch.org
http://openvswitch.org/mailman/listinfo/dev


More information about the dev mailing list