[ovs-dev] [PATCH] datapath-windows: Output a packet to two or more VXLAN ports

Alin Serdean aserdean at cloudbasesolutions.com
Fri Jun 19 02:27:24 UTC 2015


If we have a flow rule in the following form:
actions=strip_vlan,set_tunnel:0x3e9,15,16,17
(Where port 15, 16 and 17 are VXLAN tunnels with different tunnelling
information)

A packet which will hit that specific flow will only be sent out encapsulated
with the first tunnelling information.

This patch saves the initial packet vport, source port and NIC index for
further use of the currently implemented pipeline and ignores the latter if it
is the last tunnelling port.

Signed-off-by: Alin Gabriel Serdean <aserdean at cloudbasesolutions.com>
---
 datapath-windows/ovsext/Actions.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/datapath-windows/ovsext/Actions.c b/datapath-windows/ovsext/Actions.c
index d75949c..ba6d7c3 100644
--- a/datapath-windows/ovsext/Actions.c
+++ b/datapath-windows/ovsext/Actions.c
@@ -680,7 +680,7 @@ OvsTunnelPortTx(OvsForwardingContext *ovsFwdCtx)
         ASSERT(ovsFwdCtx->curNbl == NULL);
     } else {
         /*
-        * XXX: Temporary freeing of the packet until we register a
+         * XXX: Temporary freeing of the packet until we register a
          * callback to IP helper.
          */
         OvsCompleteNBLForwardingCtx(ovsFwdCtx,
@@ -796,7 +796,7 @@ dropNbl:
  * --------------------------------------------------------------------------
  */
 static __inline NDIS_STATUS
-OvsOutputForwardingCtx(OvsForwardingContext *ovsFwdCtx)
+OvsOutputForwardingCtx(OvsForwardingContext *ovsFwdCtx, BOOLEAN savePorts)
 {
     NDIS_STATUS status = STATUS_SUCCESS;
     POVS_SWITCH_CONTEXT switchContext = ovsFwdCtx->switchContext;
@@ -865,7 +865,23 @@ OvsOutputForwardingCtx(OvsForwardingContext *ovsFwdCtx)
     }
 
     if (ovsFwdCtx->tunnelTxNic != NULL) {
+        /*
+        * Save the source vport number, source port id and source NIC index,
+        * in the case we need for further usage
+        */
+        UINT32 tempVportNo = ovsFwdCtx->srcVportNo;
+        UINT32 tempSourcePortId = ovsFwdCtx->fwdDetail->SourcePortId;
+        UINT32 tempNicIndex = ovsFwdCtx->fwdDetail->SourceNicIndex;
+
         status = OvsTunnelPortTx(ovsFwdCtx);
+
+        if (savePorts) {
+            /* Write back the initial ports */
+            ovsFwdCtx->srcVportNo = tempVportNo;
+            ovsFwdCtx->fwdDetail->SourcePortId = tempSourcePortId;
+            ovsFwdCtx->fwdDetail->SourceNicIndex = tempNicIndex;
+        }
+
         ASSERT(ovsFwdCtx->tunnelTxNic == NULL);
         ASSERT(ovsFwdCtx->tunKey.dst == 0);
     } else if (ovsFwdCtx->tunnelRxNic != NULL) {
@@ -976,8 +992,8 @@ OvsOutputBeforeSetAction(OvsForwardingContext *ovsFwdCtx)
     ASSERT(ovsFwdCtx->destPortsSizeOut > 0 ||
            ovsFwdCtx->tunnelTxNic != NULL || ovsFwdCtx->tunnelRxNic != NULL);
 
-    /* Send the original packet out */
-    status = OvsOutputForwardingCtx(ovsFwdCtx);
+    /* Send the original packet out and save the ports*/
+    status = OvsOutputForwardingCtx(ovsFwdCtx, TRUE);
     ASSERT(ovsFwdCtx->curNbl == NULL);
     ASSERT(ovsFwdCtx->destPortsSizeOut == 0);
     ASSERT(ovsFwdCtx->tunnelRxNic == NULL);
@@ -1580,7 +1596,7 @@ OvsActionsExecute(POVS_SWITCH_CONTEXT switchContext,
 
     if (ovsFwdCtx.destPortsSizeOut > 0 || ovsFwdCtx.tunnelTxNic != NULL
         || ovsFwdCtx.tunnelRxNic != NULL) {
-        status = OvsOutputForwardingCtx(&ovsFwdCtx);
+        status = OvsOutputForwardingCtx(&ovsFwdCtx, FALSE);
         ASSERT(ovsFwdCtx.curNbl == NULL);
     }
 
-- 
1.9.5.msysgit.0



More information about the dev mailing list