[03/10] app/testpmd: support IPv4 fragments

Message ID 1c0211586b73c14e58fa1da2d97077c3d950f717.1601474841.git.dekelp@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series support match on L3 fragmented packets |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Dekel Peled Sept. 30, 2020, 2:10 p.m. UTC
  This patch updates testpmd CLI to support fragment_offset field of
IPv4 header item.

To match on non-fragmented IPv4 packets, need to use pattern:
... ipv4 fragment_offset spec 0 fragment_offset mask 0x3fff ...
To match on fragmented IPv4 packets, need to use pattern:
... ipv4 fragment_offset spec 1 fragment_offset last 0x3fff
fragment_offset mask 0x3fff ...
(Use the full available range 1 to 0x3fff to include all possible
values.)
To match on any IPv4 packets, fragmented and non-fragmented,
the fragment_offset field should not be specified for match.

Signed-off-by: Dekel Peled <dekelp@nvidia.com>
---
 app/test-pmd/cmdline_flow.c | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Comments

Ori Kam Sept. 30, 2020, 2:54 p.m. UTC | #1
> -----Original Message-----
> From: Dekel Peled <dekelp@nvidia.com>
> Sent: Wednesday, September 30, 2020 5:10 PM
> Subject: [PATCH 03/10] app/testpmd: support IPv4 fragments
> 
> This patch updates testpmd CLI to support fragment_offset field of
> IPv4 header item.
> 
> To match on non-fragmented IPv4 packets, need to use pattern:
> ... ipv4 fragment_offset spec 0 fragment_offset mask 0x3fff ...
> To match on fragmented IPv4 packets, need to use pattern:
> ... ipv4 fragment_offset spec 1 fragment_offset last 0x3fff
> fragment_offset mask 0x3fff ...
> (Use the full available range 1 to 0x3fff to include all possible
> values.)
> To match on any IPv4 packets, fragmented and non-fragmented,
> the fragment_offset field should not be specified for match.
> 
> Signed-off-by: Dekel Peled <dekelp@nvidia.com>
> ---
>  app/test-pmd/cmdline_flow.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 6263d30..0c964c1 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -129,6 +129,7 @@ enum index {
>  	ITEM_VLAN_INNER_TYPE,
>  	ITEM_IPV4,
>  	ITEM_IPV4_TOS,
> +	ITEM_IPV4_FRAGMENT_OFFSET,
>  	ITEM_IPV4_TTL,
>  	ITEM_IPV4_PROTO,
>  	ITEM_IPV4_SRC,
> @@ -871,6 +872,7 @@ struct parse_action_priv {
> 
>  static const enum index item_ipv4[] = {
>  	ITEM_IPV4_TOS,
> +	ITEM_IPV4_FRAGMENT_OFFSET,
>  	ITEM_IPV4_TTL,
>  	ITEM_IPV4_PROTO,
>  	ITEM_IPV4_SRC,
> @@ -2093,6 +2095,13 @@ static int comp_set_raw_index(struct context *,
> const struct token *,
>  		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
>  					     hdr.type_of_service)),
>  	},
> +	[ITEM_IPV4_FRAGMENT_OFFSET] = {
> +		.name = "fragment_offset",
> +		.help = "fragmentation flags and fragment offset",
> +		.next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED),
> item_param),
> +		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
> +					     hdr.fragment_offset)),
> +	},
>  	[ITEM_IPV4_TTL] = {
>  		.name = "ttl",
>  		.help = "time to live",
> --
> 1.8.3.1

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

Patch

diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index 6263d30..0c964c1 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -129,6 +129,7 @@  enum index {
 	ITEM_VLAN_INNER_TYPE,
 	ITEM_IPV4,
 	ITEM_IPV4_TOS,
+	ITEM_IPV4_FRAGMENT_OFFSET,
 	ITEM_IPV4_TTL,
 	ITEM_IPV4_PROTO,
 	ITEM_IPV4_SRC,
@@ -871,6 +872,7 @@  struct parse_action_priv {
 
 static const enum index item_ipv4[] = {
 	ITEM_IPV4_TOS,
+	ITEM_IPV4_FRAGMENT_OFFSET,
 	ITEM_IPV4_TTL,
 	ITEM_IPV4_PROTO,
 	ITEM_IPV4_SRC,
@@ -2093,6 +2095,13 @@  static int comp_set_raw_index(struct context *, const struct token *,
 		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
 					     hdr.type_of_service)),
 	},
+	[ITEM_IPV4_FRAGMENT_OFFSET] = {
+		.name = "fragment_offset",
+		.help = "fragmentation flags and fragment offset",
+		.next = NEXT(item_ipv4, NEXT_ENTRY(UNSIGNED), item_param),
+		.args = ARGS(ARGS_ENTRY_HTON(struct rte_flow_item_ipv4,
+					     hdr.fragment_offset)),
+	},
 	[ITEM_IPV4_TTL] = {
 		.name = "ttl",
 		.help = "time to live",