[v2,2/3] app/testpmd: add actions to modify TCP header fields

Message ID 1554218001-62012-3-git-send-email-dekelp@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series None |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/Performance-Testing fail build patch failure

Commit Message

Dekel Peled April 2, 2019, 3:13 p.m. UTC
  Add actions:
- INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
- DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
- INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
                header.
- DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
                header.

Original work by Xiaoyu Min.

Signed-off-by: Dekel Peled <dekelp@mellanox.com>
---
 app/test-pmd/cmdline_flow.c                 | 100 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
 2 files changed, 116 insertions(+)
  

Comments

Ori Kam April 2, 2019, 4:33 p.m. UTC | #1
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Dekel Peled
> Sent: Tuesday, April 2, 2019 6:13 PM
> To: Adrien Mazarguil <adrien.mazarguil@6wind.com>; wenzhuo.lu@intel.com;
> jingjing.wu@intel.com; bernard.iremonger@intel.com; Yongseok Koh
> <yskoh@mellanox.com>; Shahaf Shuler <shahafs@mellanox.com>
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>; Dekel Peled
> <dekelp@mellanox.com>
> Subject: [dpdk-dev] [PATCH v2 2/3] app/testpmd: add actions to modify TCP
> header fields
> 
> Add actions:
> - INC_TCP_SEQ - Increase sequence number in the outermost TCP header.
> - DEC_TCP_SEQ - Decrease sequence number in the outermost TCP header.
> - INC_TCP_ACK - Increase acknowledgment number in the outermost TCP
>                 header.
> - DEC_TCP_ACK - Decrease acknowledgment number in the outermost TCP
>                 header.
> 
> Original work by Xiaoyu Min.
> 
> Signed-off-by: Dekel Peled <dekelp@mellanox.com>
> ---
>  app/test-pmd/cmdline_flow.c                 | 100
> ++++++++++++++++++++++++++++
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  16 +++++
>  2 files changed, 116 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 36659a6..5cd4ceb 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -271,6 +271,14 @@ enum index {
>  	ACTION_SET_MAC_SRC_MAC_SRC,
>  	ACTION_SET_MAC_DST,
>  	ACTION_SET_MAC_DST_MAC_DST,
> +	ACTION_INC_TCP_SEQ,
> +	ACTION_INC_TCP_SEQ_VALUE,
> +	ACTION_DEC_TCP_SEQ,
> +	ACTION_DEC_TCP_SEQ_VALUE,
> +	ACTION_INC_TCP_ACK,
> +	ACTION_INC_TCP_ACK_VALUE,
> +	ACTION_DEC_TCP_ACK,
> +	ACTION_DEC_TCP_ACK_VALUE,
>  };
> 
>  /** Maximum size for pattern in struct rte_flow_item_raw. */
> @@ -884,6 +892,10 @@ struct parse_action_priv {
>  	ACTION_SET_TTL,
>  	ACTION_SET_MAC_SRC,
>  	ACTION_SET_MAC_DST,
> +	ACTION_INC_TCP_SEQ,
> +	ACTION_DEC_TCP_SEQ,
> +	ACTION_INC_TCP_ACK,
> +	ACTION_DEC_TCP_ACK,
>  	ZERO,
>  };
> 
> @@ -1046,6 +1058,30 @@ struct parse_action_priv {
>  	ZERO,
>  };
> 
> +static const enum index action_inc_tcp_seq[] = {
> +	ACTION_INC_TCP_SEQ_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
> +static const enum index action_dec_tcp_seq[] = {
> +	ACTION_DEC_TCP_SEQ_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
> +static const enum index action_inc_tcp_ack[] = {
> +	ACTION_INC_TCP_ACK_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
> +static const enum index action_dec_tcp_ack[] = {
> +	ACTION_DEC_TCP_ACK_VALUE,
> +	ACTION_NEXT,
> +	ZERO,
> +};
> +
>  static int parse_init(struct context *, const struct token *,
>  		      const char *, unsigned int,
>  		      void *, unsigned int);
> @@ -2843,6 +2879,70 @@ static int comp_vc_action_rss_queue(struct context
> *, const struct token *,
>  			     (struct rte_flow_action_set_mac, mac_addr)),
>  		.call = parse_vc_conf,
>  	},
> +	[ACTION_INC_TCP_SEQ] = {
> +		.name = "inc_tcp_seq",
> +		.help = "increase TCP sequence number",
> +		.priv = PRIV_ACTION(INC_TCP_SEQ,
> +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> +		.next = NEXT(action_inc_tcp_seq),
> +		.call = parse_vc,
> +	},
> +	[ACTION_INC_TCP_SEQ_VALUE] = {
> +		.name = "value",
> +		.help = "the value to increase TCP sequence number by",
> +		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_modify_tcp_seq, value)),
> +		.call = parse_vc_conf,
> +	},
> +	[ACTION_DEC_TCP_SEQ] = {
> +		.name = "dec_tcp_seq",
> +		.help = "decrease TCP sequence number",
> +		.priv = PRIV_ACTION(DEC_TCP_SEQ,
> +			sizeof(struct rte_flow_action_modify_tcp_seq)),
> +		.next = NEXT(action_dec_tcp_seq),
> +		.call = parse_vc,
> +	},
> +	[ACTION_DEC_TCP_SEQ_VALUE] = {
> +		.name = "value",
> +		.help = "the value to decrease TCP sequence number by",
> +		.next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_modify_tcp_seq, value)),
> +		.call = parse_vc_conf,
> +	},
> +	[ACTION_INC_TCP_ACK] = {
> +		.name = "inc_tcp_ack",
> +		.help = "increase TCP acknowledgment number",
> +		.priv = PRIV_ACTION(INC_TCP_ACK,
> +			sizeof(struct rte_flow_action_modify_tcp_ack)),
> +		.next = NEXT(action_inc_tcp_ack),
> +		.call = parse_vc,
> +	},
> +	[ACTION_INC_TCP_ACK_VALUE] = {
> +		.name = "value",
> +		.help = "the value to increase TCP acknowledgment number
> by",
> +		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_modify_tcp_ack, value)),
> +		.call = parse_vc_conf,
> +	},
> +	[ACTION_DEC_TCP_ACK] = {
> +		.name = "dec_tcp_ack",
> +		.help = "decrease TCP acknowledgment number",
> +		.priv = PRIV_ACTION(DEC_TCP_ACK,
> +			sizeof(struct rte_flow_action_modify_tcp_ack)),
> +		.next = NEXT(action_dec_tcp_ack),
> +		.call = parse_vc,
> +	},
> +	[ACTION_DEC_TCP_ACK_VALUE] = {
> +		.name = "value",
> +		.help = "the value to decrease TCP acknowledgment number
> by",
> +		.next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
> +		.args = ARGS(ARGS_ENTRY_HTON
> +			(struct rte_flow_action_modify_tcp_ack, value)),
> +		.call = parse_vc_conf,
> +	},
>  };
> 
>  /** Remove and return last entry from argument stack. */
> diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index bcf1449..bf93cea 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -3997,6 +3997,22 @@ This section lists supported actions and their
> attributes, if any.
> 
>    - ``mac_addr {MAC-48}``: new destination MAC address
> 
> +- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header.
> +
> +  - ``value {unsigned}``: Value to increase TCP sequence number by.
> +
> +- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header.
> +
> +  - ``value {unsigned}``: Value to decrease TCP sequence number by.
> +
> +- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP
> header.
> +
> +  - ``value {unsigned}``: Value to increase TCP acknowledgment number by.
> +
> +- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP
> header.
> +
> +  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by.
> +
>  Destroying flow rules
>  ~~~~~~~~~~~~~~~~~~~~~
> 
> --
> 1.8.3.1

Thanks,
Acked-by: Ori Kam <orika@mellanox.com>
  

Patch

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 36659a6..5cd4ceb 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -271,6 +271,14 @@  enum index {
 	ACTION_SET_MAC_SRC_MAC_SRC,
 	ACTION_SET_MAC_DST,
 	ACTION_SET_MAC_DST_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_INC_TCP_ACK,
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_DEC_TCP_ACK,
+	ACTION_DEC_TCP_ACK_VALUE,
 };
 
 /** Maximum size for pattern in struct rte_flow_item_raw. */
@@ -884,6 +892,10 @@  struct parse_action_priv {
 	ACTION_SET_TTL,
 	ACTION_SET_MAC_SRC,
 	ACTION_SET_MAC_DST,
+	ACTION_INC_TCP_SEQ,
+	ACTION_DEC_TCP_SEQ,
+	ACTION_INC_TCP_ACK,
+	ACTION_DEC_TCP_ACK,
 	ZERO,
 };
 
@@ -1046,6 +1058,30 @@  struct parse_action_priv {
 	ZERO,
 };
 
+static const enum index action_inc_tcp_seq[] = {
+	ACTION_INC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_seq[] = {
+	ACTION_DEC_TCP_SEQ_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_inc_tcp_ack[] = {
+	ACTION_INC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
+static const enum index action_dec_tcp_ack[] = {
+	ACTION_DEC_TCP_ACK_VALUE,
+	ACTION_NEXT,
+	ZERO,
+};
+
 static int parse_init(struct context *, const struct token *,
 		      const char *, unsigned int,
 		      void *, unsigned int);
@@ -2843,6 +2879,70 @@  static int comp_vc_action_rss_queue(struct context *, const struct token *,
 			     (struct rte_flow_action_set_mac, mac_addr)),
 		.call = parse_vc_conf,
 	},
+	[ACTION_INC_TCP_SEQ] = {
+		.name = "inc_tcp_seq",
+		.help = "increase TCP sequence number",
+		.priv = PRIV_ACTION(INC_TCP_SEQ,
+			sizeof(struct rte_flow_action_modify_tcp_seq)),
+		.next = NEXT(action_inc_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP sequence number by",
+		.next = NEXT(action_inc_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_modify_tcp_seq, value)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_SEQ] = {
+		.name = "dec_tcp_seq",
+		.help = "decrease TCP sequence number",
+		.priv = PRIV_ACTION(DEC_TCP_SEQ,
+			sizeof(struct rte_flow_action_modify_tcp_seq)),
+		.next = NEXT(action_dec_tcp_seq),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_SEQ_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP sequence number by",
+		.next = NEXT(action_dec_tcp_seq, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_modify_tcp_seq, value)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_INC_TCP_ACK] = {
+		.name = "inc_tcp_ack",
+		.help = "increase TCP acknowledgment number",
+		.priv = PRIV_ACTION(INC_TCP_ACK,
+			sizeof(struct rte_flow_action_modify_tcp_ack)),
+		.next = NEXT(action_inc_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_INC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to increase TCP acknowledgment number by",
+		.next = NEXT(action_inc_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_modify_tcp_ack, value)),
+		.call = parse_vc_conf,
+	},
+	[ACTION_DEC_TCP_ACK] = {
+		.name = "dec_tcp_ack",
+		.help = "decrease TCP acknowledgment number",
+		.priv = PRIV_ACTION(DEC_TCP_ACK,
+			sizeof(struct rte_flow_action_modify_tcp_ack)),
+		.next = NEXT(action_dec_tcp_ack),
+		.call = parse_vc,
+	},
+	[ACTION_DEC_TCP_ACK_VALUE] = {
+		.name = "value",
+		.help = "the value to decrease TCP acknowledgment number by",
+		.next = NEXT(action_dec_tcp_ack, NEXT_ENTRY(UNSIGNED)),
+		.args = ARGS(ARGS_ENTRY_HTON
+			(struct rte_flow_action_modify_tcp_ack, value)),
+		.call = parse_vc_conf,
+	},
 };
 
 /** Remove and return last entry from argument stack. */
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index bcf1449..bf93cea 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -3997,6 +3997,22 @@  This section lists supported actions and their attributes, if any.
 
   - ``mac_addr {MAC-48}``: new destination MAC address
 
+- ``inc_tcp_seq``: Increase sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP sequence number by.
+
+- ``dec_tcp_seq``: Decrease sequence number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP sequence number by.
+
+- ``inc_tcp_ack``: Increase acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to increase TCP acknowledgment number by.
+
+- ``dec_tcp_ack``: Decrease acknowledgment number in the outermost TCP header.
+
+  - ``value {unsigned}``: Value to decrease TCP acknowledgment number by.
+
 Destroying flow rules
 ~~~~~~~~~~~~~~~~~~~~~