examples/flow_filtering: fix destination IP mask

Message ID 20250112075200.5020-1-shperetz@nvidia.com (mailing list archive)
State Accepted
Delegated to: Thomas Monjalon
Headers
Series examples/flow_filtering: fix destination IP mask |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-compile-arm64-testing pending Testing pending
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS

Commit Message

Shani Peretz Jan. 12, 2025, 7:52 a.m. UTC
This patch corrects the destination IP address mask to
restore the previous implementation's behavior.

Also it fixes a misuse of rte_flow_item_tcp struct.
Replace it with the appropriate rte_flow_item_ipv4 struct,
as the code in this context filters ipv4 traffic.

Fixes: 16158f349000 ("examples/flow_filtering: introduce use cases snippets")

Signed-off-by: Shani Peretz <shperetz@nvidia.com>
---
 examples/flow_filtering/snippets/snippet_match_ipv4.c | 10 +++++-----
 examples/flow_filtering/snippets/snippet_match_ipv4.h |  1 -
 2 files changed, 5 insertions(+), 6 deletions(-)
  

Comments

Thomas Monjalon Feb. 19, 2025, 3:19 p.m. UTC | #1
12/01/2025 08:52, Shani Peretz:
> This patch corrects the destination IP address mask to
> restore the previous implementation's behavior.
> 
> Also it fixes a misuse of rte_flow_item_tcp struct.
> Replace it with the appropriate rte_flow_item_ipv4 struct,
> as the code in this context filters ipv4 traffic.
> 
> Fixes: 16158f349000 ("examples/flow_filtering: introduce use cases snippets")
> 
> Signed-off-by: Shani Peretz <shperetz@nvidia.com>
[...]
> @@ -77,7 +77,7 @@ snippet_ipv4_flow_create_actions_template(uint16_t port_id, struct rte_flow_erro
>  	};
>  
>  	tactions[0].type = RTE_FLOW_ACTION_TYPE_QUEUE;
> -	tactions[0].type = RTE_FLOW_ACTION_TYPE_END;
> +	tactions[1].type = RTE_FLOW_ACTION_TYPE_END;

It is a revert of this recent commit:
https://git.dpdk.org/dpdk/commit/?id=7d73fa47f4

Do you confirm you want to keep RTE_FLOW_ACTION_TYPE_QUEUE here?
  
Shani Peretz March 10, 2025, 6:48 a.m. UTC | #2
> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Wednesday, 19 February 2025 17:20
> To: Shani Peretz <shperetz@nvidia.com>
> Cc: dev@dpdk.org; ferruh.yigit@amd.com; Ori Kam <orika@nvidia.com>;
> Stephen Hemminger <stephen@networkplumber.org>
> Subject: Re: [PATCH] examples/flow_filtering: fix destination IP mask
> 
> External email: Use caution opening links or attachments
> 
> 
> 12/01/2025 08:52, Shani Peretz:
> > This patch corrects the destination IP address mask to restore the
> > previous implementation's behavior.
> >
> > Also it fixes a misuse of rte_flow_item_tcp struct.
> > Replace it with the appropriate rte_flow_item_ipv4 struct, as the code
> > in this context filters ipv4 traffic.
> >
> > Fixes: 16158f349000 ("examples/flow_filtering: introduce use cases
> > snippets")
> >
> > Signed-off-by: Shani Peretz <shperetz@nvidia.com>
> [...]
> > @@ -77,7 +77,7 @@ snippet_ipv4_flow_create_actions_template(uint16_t
> port_id, struct rte_flow_erro
> >       };
> >
> >       tactions[0].type = RTE_FLOW_ACTION_TYPE_QUEUE;
> > -     tactions[0].type = RTE_FLOW_ACTION_TYPE_END;
> > +     tactions[1].type = RTE_FLOW_ACTION_TYPE_END;
> 
> It is a revert of this recent commit:
> https://git.dpdk.org/dpdk/commit/?id=7d73fa47f4
> 
> Do you confirm you want to keep RTE_FLOW_ACTION_TYPE_QUEUE here?
> 

Yes to be consistent with the non-template API.
  
Thomas Monjalon March 19, 2025, 3:13 a.m. UTC | #3
10/03/2025 07:48, Shani Peretz:
> From: Thomas Monjalon <thomas@monjalon.net>
> > 12/01/2025 08:52, Shani Peretz:
> > > This patch corrects the destination IP address mask to restore the
> > > previous implementation's behavior.
> > >
> > > Also it fixes a misuse of rte_flow_item_tcp struct.
> > > Replace it with the appropriate rte_flow_item_ipv4 struct, as the code
> > > in this context filters ipv4 traffic.
> > >
> > > Fixes: 16158f349000 ("examples/flow_filtering: introduce use cases
> > > snippets")
> > >
> > > Signed-off-by: Shani Peretz <shperetz@nvidia.com>
> > [...]
> > > @@ -77,7 +77,7 @@ snippet_ipv4_flow_create_actions_template(uint16_t
> > port_id, struct rte_flow_erro
> > >       };
> > >
> > >       tactions[0].type = RTE_FLOW_ACTION_TYPE_QUEUE;
> > > -     tactions[0].type = RTE_FLOW_ACTION_TYPE_END;
> > > +     tactions[1].type = RTE_FLOW_ACTION_TYPE_END;
> > 
> > It is a revert of this recent commit:
> > https://git.dpdk.org/dpdk/commit/?id=7d73fa47f4
> > 
> > Do you confirm you want to keep RTE_FLOW_ACTION_TYPE_QUEUE here?
> > 
> 
> Yes to be consistent with the non-template API.

Applied, thanks.
  

Patch

diff --git a/examples/flow_filtering/snippets/snippet_match_ipv4.c b/examples/flow_filtering/snippets/snippet_match_ipv4.c
index 808208e7b0..d32f4ebfdc 100644
--- a/examples/flow_filtering/snippets/snippet_match_ipv4.c
+++ b/examples/flow_filtering/snippets/snippet_match_ipv4.c
@@ -55,7 +55,7 @@  snippet_ipv4_flow_create_patterns(struct rte_flow_item *patterns)
 		fprintf(stderr, "Failed to allocate memory for ip_mask\n");
 
 	ip_spec->hdr.dst_addr = htonl(DEST_IP); /* The dest ip value to match the input packet. */
-	ip_mask->hdr.dst_addr = DEST_MASK; /* The mask to apply to the dest ip. */
+	ip_mask->hdr.dst_addr = FULL_MASK; /* The mask to apply to the dest ip. */
 	ip_spec->hdr.src_addr = htonl(SRC_IP); /* The src ip value to match the input packet. */
 	ip_mask->hdr.src_addr = EMPTY_MASK; /* The mask to apply to the src ip. */
 	patterns[1].spec = ip_spec;
@@ -77,7 +77,7 @@  snippet_ipv4_flow_create_actions_template(uint16_t port_id, struct rte_flow_erro
 	};
 
 	tactions[0].type = RTE_FLOW_ACTION_TYPE_QUEUE;
-	tactions[0].type = RTE_FLOW_ACTION_TYPE_END;
+	tactions[1].type = RTE_FLOW_ACTION_TYPE_END;
 
 	/* This sets the masks to match the actions, indicating that all fields of the actions
 	 * should be considered as part of the template.
@@ -93,7 +93,7 @@  static struct rte_flow_pattern_template *
 snippet_ipv4_flow_create_pattern_template(uint16_t port_id, struct rte_flow_error *error)
 {
 	struct rte_flow_item titems[MAX_PATTERN_NUM] = {0};
-	struct rte_flow_item_tcp ip_mask = {0};
+	struct rte_flow_item_ipv4 ip_mask = {0};
 
 	struct rte_flow_pattern_template_attr attr = {
 			.relaxed_matching = 1,
@@ -102,8 +102,8 @@  snippet_ipv4_flow_create_pattern_template(uint16_t port_id, struct rte_flow_erro
 
 	titems[0].type = RTE_FLOW_ITEM_TYPE_ETH;
 	titems[1].type = RTE_FLOW_ITEM_TYPE_IPV4;
-	ip_mask.hdr.src_port = EMPTY_MASK;
-	ip_mask.hdr.dst_port = DEST_MASK;
+	ip_mask.hdr.src_addr = EMPTY_MASK;
+	ip_mask.hdr.dst_addr = FULL_MASK;
 	titems[1].mask = &ip_mask;
 	titems[2].type = RTE_FLOW_ITEM_TYPE_END;
 
diff --git a/examples/flow_filtering/snippets/snippet_match_ipv4.h b/examples/flow_filtering/snippets/snippet_match_ipv4.h
index 847784beef..597a1c954e 100644
--- a/examples/flow_filtering/snippets/snippet_match_ipv4.h
+++ b/examples/flow_filtering/snippets/snippet_match_ipv4.h
@@ -13,7 +13,6 @@ 
 #define DEST_IP ((192<<24) + (168<<16) + (1<<8) + 1) /* dest ip = 192.168.1.1 */
 #define FULL_MASK 0xffffffff /* full mask */
 #define EMPTY_MASK 0x0 /* empty mask */
-#define DEST_MASK 0xffff /* full mask */
 
 #define MAX_PATTERN_NUM		3 /* Maximal number of patterns for this example. */
 #define MAX_ACTION_NUM		2 /* Maximal number of actions for this example. */