* [PATCH] examples/flow_filtering: fix destination IP mask
@ 2025-01-12 7:52 Shani Peretz
0 siblings, 0 replies; only message in thread
From: Shani Peretz @ 2025-01-12 7:52 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit, shperetz, Ori Kam, Stephen Hemminger
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(-)
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. */
--
2.34.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-01-12 7:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-12 7:52 [PATCH] examples/flow_filtering: fix destination IP mask Shani Peretz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).