examples/flow_filtering: fix destination IP mask
PATCH 1/1 examples/flow_filtering: fix destination IP mask
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.
--- 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(-)
examples/flow_filtering/snippets/snippet_match_ipv4.c +5 -5
@@ -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 ;
examples/flow_filtering/snippets/snippet_match_ipv4.h +0 -1
@@ -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. */
Signature · 1 line
2.34.1
12/01/2025 08:52, Shani Peretz:
Quoted 10 lines
This patch corrects the destination IP address mask to restore the previous implementation's behavior.
Also it fixes a misuse of
rte_flow_item_tcpstruct. Replace it with the appropriaterte_flow_item_ipv4struct, as the code in this context filters ipv4 traffic.Fixes 16158f349000 ("examples/flow_filtering: introduce use cases snippets")Signed-off-by Shani Peretz <[email protected]>
[...]
examples/flow_filtering/snippets/snippet_match_ipv4.c snippet_ipv4_flow_create_actions_template(uint16_t port_id, struct rte_flow_erro · line 80
Quoted 6 lines
examples/flow_filtering/snippets/snippet_match_ipv4.c +1
-1@@ -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?
Quoted 30 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, 19 February 2025 17:20
To: Shani Peretz <[email protected]>
Cc: [email protected]; [email protected]; Ori Kam <[email protected]>; Stephen Hemminger <[email protected]>
Subject: Re: [PATCH] examples/flow_filtering: fix destination IP maskExternal email: Use caution opening links or attachments
12/01/2025 08:52, Shani Peretz:
Quoted 11 lines
This patch corrects the destination IP address mask to restore the previous implementation's behavior.
Also it fixes a misuse of
rte_flow_item_tcpstruct.
Replace it with the appropriaterte_flow_item_ipv4struct, as the code in this context filters ipv4 traffic.Fixes 16158f349000 ("examples/flow_filtering: introduce use casessnippets")
Signed-off-by Shani Peretz <[email protected]>[...]
Review snippet_ipv4_flow_create_actions_template(uint16_t
Quoted 1 line
(quoted diff) +0
-0@@ -77,7 +77,7 @@ snippet_ipv4_flow_create_actions_template(uint16_t
port_id, structrte_flow_erroQuoted 2 lines
(quoted diff) +0
-0};
Quoted 9 lines
examples/flow_filtering/snippets/snippet_match_ipv4.c snippet_ipv4_flow_create_actions_template(uint16_t port_id, struct rte_flow_erro · line 80
Quoted 3 lines
examples/flow_filtering/snippets/snippet_match_ipv4.c +1
-1tactions[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=7d73fa47f4Do you confirm you want to keep
RTE_FLOW_ACTION_TYPE_QUEUEhere?
Yes to be consistent with the non-template API.
Thomas Monjalon
Applied10/03/2025 07:48, Shani Peretz:
Quoted 22 lines
From: Thomas Monjalon <[email protected]>
Quoted 21 lines
12/01/2025 08:52, Shani Peretz:
Quoted 11 lines
This patch corrects the destination IP address mask to restore the previous implementation's behavior.
Also it fixes a misuse of
rte_flow_item_tcpstruct.
Replace it with the appropriaterte_flow_item_ipv4struct, as the code in this context filters ipv4 traffic.Fixes 16158f349000 ("examples/flow_filtering: introduce use casessnippets")
Signed-off-by Shani Peretz <[email protected]>[...]
Review snippet_ipv4_flow_create_actions_template(uint16_t
Quoted 1 line
(quoted diff) +0
-0@@ -77,7 +77,7 @@ snippet_ipv4_flow_create_actions_template(uint16_t
port_id, structrte_flow_erroQuoted 5 lines
examples/flow_filtering/snippets/snippet_match_ipv4.c +1
-1}; tactions[0 ].type =RTE_FLOW_ACTION_TYPE_QUEUE ; - tactions[0 ].type =RTE_FLOW_ACTION_TYPE_END ; + tactions[1 ].type =RTE_FLOW_ACTION_TYPE_END ;
Quoted 7 lines
Quoted 5 lines
It is a revert of this recent commit:
https://git.dpdk.org/dpdk/commit/?id=7d73fa47f4Do you confirm you want to keep
RTE_FLOW_ACTION_TYPE_QUEUEhere?Yes to be consistent with the non-template API.
Applied, thanks.