Acked-by: Sairam Venugopal <[email protected]>






On 1/26/17, 3:41 PM, "[email protected] on behalf of Alin 
Serdean" <[email protected] on behalf of 
[email protected]> wrote:

>From: Alin Serdean <[email protected]>
>
>This patch adds support for set action with OVS_KEY_ATTR_UDP attribute
>(change UDP source or destination port).
>
>If the source or destination UDP port was changed, update the UDP checksum.
>
>A sample flow can look like the following:
>set(udp(src=67,dst=68))
>
>Signed-off-by: Alin Gabriel Serdean <[email protected]>
>---
>v3: check if udp checksum is 0
>v2: no change
>---
> datapath-windows/ovsext/Actions.c | 52 ++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 51 insertions(+), 1 deletion(-)
>
>diff --git a/datapath-windows/ovsext/Actions.c 
>b/datapath-windows/ovsext/Actions.c
>index 467bfbc..3dfcc68 100644
>--- a/datapath-windows/ovsext/Actions.c
>+++ b/datapath-windows/ovsext/Actions.c
>@@ -1306,7 +1306,6 @@ OvsUpdateEthHeader(OvsForwardingContext *ovsFwdCtx,
>     return NDIS_STATUS_SUCCESS;
> }
> 
>-
> /*
>  *----------------------------------------------------------------------------
>  * OvsGetHeaderBySize --
>@@ -1382,6 +1381,52 @@ PUINT8 OvsGetHeaderBySize(OvsForwardingContext 
>*ovsFwdCtx,
>     return start + curMdlOffset;
> }
> 
>+/*
>+ *----------------------------------------------------------------------------
>+ * OvsUpdateUdpPorts --
>+ *      Updates the UDP source or destination port in ovsFwdCtx.curNbl inline
>+ *      based on the specified key.
>+ *----------------------------------------------------------------------------
>+ */
>+static __inline NDIS_STATUS
>+OvsUpdateUdpPorts(OvsForwardingContext *ovsFwdCtx,
>+                  const struct ovs_key_udp *udpAttr)
>+{
>+    PUINT8 bufferStart;
>+    OVS_PACKET_HDR_INFO *layers = &ovsFwdCtx->layers;
>+    UDPHdr *udpHdr = NULL;
>+
>+    ASSERT(layers->value != 0);
>+
>+    if (!layers->isUdp) {
>+        ovsActionStats.noCopiedNbl++;
>+        return NDIS_STATUS_FAILURE;
>+    }
>+
>+    bufferStart = OvsGetHeaderBySize(ovsFwdCtx, layers->l7Offset);
>+    if (!bufferStart) {
>+        return NDIS_STATUS_RESOURCES;
>+    }
>+
>+    udpHdr = (UDPHdr *)(bufferStart + layers->l4Offset);
>+    if (udpHdr->check) {
>+        if (udpHdr->source != udpAttr->udp_src) {
>+            udpHdr->check = ChecksumUpdate16(udpHdr->check, udpHdr->source,
>+                                             udpAttr->udp_src);
>+            udpHdr->source = udpAttr->udp_src;
>+        }
>+        if (udpHdr->dest != udpAttr->udp_dst) {
>+            udpHdr->check = ChecksumUpdate16(udpHdr->check, udpHdr->dest,
>+                                             udpAttr->udp_dst);
>+            udpHdr->dest = udpAttr->udp_dst;
>+        }
>+    } else {
>+        udpHdr->source = udpAttr->udp_src;
>+        udpHdr->dest = udpAttr->udp_dst;
>+    }
>+
>+    return NDIS_STATUS_SUCCESS;
>+}
> 
> /*
>  *----------------------------------------------------------------------------
>@@ -1525,6 +1570,11 @@ OvsExecuteSetAction(OvsForwardingContext *ovsFwdCtx,
>         break;
>     }
> 
>+    case OVS_KEY_ATTR_UDP:
>+        status = OvsUpdateUdpPorts(ovsFwdCtx,
>+            NlAttrGetUnspec(a, sizeof(struct ovs_key_udp)));
>+        break;
>+
>     default:
>         OVS_LOG_INFO("Unhandled attribute %#x", type);
>         break;
>-- 
>2.10.2.windows.1
>_______________________________________________
>dev mailing list
>[email protected]
>https://mail.openvswitch.org/mailman/listinfo/ovs-dev
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to