[ovs-dev] [PATCH 4/4] datapath-windows: Add support for OVS_KEY_ATTR_TCP set action

Alin Serdean aserdean at cloudbasesolutions.com
Thu Jan 26 23:42:55 UTC 2017


Forgot to add version number.

Please ignore this patch.

Alin.

> -----Original Message-----
> From: Alin Serdean
> Sent: Friday, January 27, 2017 1:41 AM
> To: dev at openvswitch.org
> Cc: Alin Serdean <aserdean at cloudbasesolutions.com>
> Subject: [PATCH 4/4] datapath-windows: Add support for
> OVS_KEY_ATTR_TCP set action
> 
> From: Alin Serdean <aserdean at cloudbasesolutions.com>
> 
> This patch adds support for set action with OVS_KEY_ATTR_TCP attribute
> (change TCP source or destination port).
> 
> If the source or destination TCP port was changed, update the TCP
> checksum.
> 
> A sample flow can look like the following:
> set(tcp(src=80,dst=443))
> 
> Signed-off-by: Alin Gabriel Serdean <aserdean at cloudbasesolutions.com>
> ---
> v3: check for layers->isTcp as suggested by Sairam Venugopal
> <vsairam at vmware.com>
> v2: set action for tcp attribute changed to function: OvsUpdateTcpPorts
> ---
>  datapath-windows/ovsext/Actions.c | 48
> +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
> 
> diff --git a/datapath-windows/ovsext/Actions.c b/datapath-
> windows/ovsext/Actions.c
> index 3dfcc68..bce37f8 100644
> --- a/datapath-windows/ovsext/Actions.c
> +++ b/datapath-windows/ovsext/Actions.c
> @@ -1430,6 +1430,49 @@ OvsUpdateUdpPorts(OvsForwardingContext
> *ovsFwdCtx,
> 
>  /*
>   *----------------------------------------------------------------------------
> + * OvsUpdateTcpPorts --
> + *      Updates the TCP source or destination port in ovsFwdCtx.curNbl inline
> + *      based on the specified key.
> +
> +*----------------------------------------------------------------------
> +------
> + */
> +static __inline NDIS_STATUS
> +OvsUpdateTcpPorts(OvsForwardingContext *ovsFwdCtx,
> +                  const struct ovs_key_tcp *tcpAttr) {
> +    PUINT8 bufferStart;
> +    OVS_PACKET_HDR_INFO *layers = &ovsFwdCtx->layers;
> +    TCPHdr *tcpHdr = NULL;
> +
> +    ASSERT(layers->value != 0);
> +
> +    if (!layers->isTcp) {
> +        ovsActionStats.noCopiedNbl++;
> +        return NDIS_STATUS_FAILURE;
> +    }
> +
> +    bufferStart = OvsGetHeaderBySize(ovsFwdCtx, layers->l7Offset);
> +    if (!bufferStart) {
> +        return NDIS_STATUS_RESOURCES;
> +    }
> +
> +    tcpHdr = (TCPHdr *)(bufferStart + layers->l4Offset);
> +
> +    if (tcpHdr->source != tcpAttr->tcp_src) {
> +        tcpHdr->check = ChecksumUpdate16(tcpHdr->check, tcpHdr->source,
> +                                         tcpAttr->tcp_src);
> +        tcpHdr->source = tcpAttr->tcp_src;
> +    }
> +    if (tcpHdr->dest != tcpAttr->tcp_dst) {
> +        tcpHdr->check = ChecksumUpdate16(tcpHdr->check, tcpHdr->dest,
> +                                         tcpAttr->tcp_dst);
> +        tcpHdr->dest = tcpAttr->tcp_dst;
> +    }
> +
> +    return NDIS_STATUS_SUCCESS;
> +}
> +
> +/*
> +
> +*----------------------------------------------------------------------
> +------
>   * OvsUpdateIPv4Header --
>   *      Updates the IPv4 header in ovsFwdCtx.curNbl inline based on the
>   *      specified key.
> @@ -1575,6 +1618,11 @@ OvsExecuteSetAction(OvsForwardingContext
> *ovsFwdCtx,
>              NlAttrGetUnspec(a, sizeof(struct ovs_key_udp)));
>          break;
> 
> +    case OVS_KEY_ATTR_TCP:
> +        status = OvsUpdateTcpPorts(ovsFwdCtx,
> +            NlAttrGetUnspec(a, sizeof(struct ovs_key_tcp)));
> +        break;
> +
>      default:
>          OVS_LOG_INFO("Unhandled attribute %#x", type);
>          break;
> --
> 2.10.2.windows.1


More information about the dev mailing list