From: Shani Peretz <shperetz@nvidia.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@amd.com>, <shperetz@nvidia.com>,
Ori Kam <orika@nvidia.com>,
Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH] examples/flow_filtering: fix destination IP mask
Date: Sun, 12 Jan 2025 09:52:00 +0200 [thread overview]
Message-ID: <20250112075200.5020-1-shperetz@nvidia.com> (raw)
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
reply other threads:[~2025-01-12 7:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250112075200.5020-1-shperetz@nvidia.com \
--to=shperetz@nvidia.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=orika@nvidia.com \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).