From: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>
To: Cristian Dumitrescu <cristian.dumitrescu@intel.com>,
Aman Singh <aman.deep.singh@intel.com>,
Sunil Kumar Kori <skori@marvell.com>
Cc: dev@dpdk.org, Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>,
stable@dpdk.org
Subject: [PATCH] app/testpmd: validate dscp and vlan table entries for meter creation
Date: Fri, 22 Aug 2025 08:14:30 -0400 [thread overview]
Message-ID: <20250822121430.2228507-1-14pwcse1224@uetpeshawar.edu.pk> (raw)
Add validation mechanism for meter creation. The maximum
possible entries are
[<dscp_tbl_entry0> <dscp_tbl_entry1> ...<dscp_tbl_entry63>]
[<vlan_tbl_entry0> <vlan_tbl_entry1> ... <vlan_tbl_entry15>].
Currently, testpmd allows any input table entries for dscp
and vlan tables.
This patch validates the maximum possible dscp and vlan table
entries for meter creation.
Fixes: 9f5488e326d3b ("app/testpmd: support different input color method")
Cc: stable@dpdk.org
Signed-off-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>
---
app/test-pmd/cmdline_mtr.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index e16c5b268f..1435645c1a 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -85,14 +85,33 @@ parse_uint(uint64_t *value, const char *str)
return 0;
}
+static int
+validate_input_color_table_entries(char *str)
+{
+ char *token;
+ int i = 0;
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+ for (i = 0; token != NULL; i++)
+ token = strtok_r(str, PARSE_DELIMITER, &str);
+
+ if (i > (MAX_DSCP_TABLE_ENTRIES + MAX_VLAN_TABLE_ENTRIES))
+ return -1;
+ else
+ return 0;
+}
+
static int
parse_input_color_table_entries(char *str, enum rte_color **dscp_table,
enum rte_color **vlan_table)
{
enum rte_color *vlan, *dscp;
char *token;
+ char *temp_str = strdup(str);
int i = 0;
+ if (validate_input_color_table_entries(temp_str))
+ return -1;
+
token = strtok_r(str, PARSE_DELIMITER, &str);
if (token == NULL)
return 0;
--
2.43.0
next reply other threads:[~2025-08-22 12:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-22 12:14 Khadem Ullah [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-08-22 12:06 Khadem Ullah
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=20250822121430.2228507-1-14pwcse1224@uetpeshawar.edu.pk \
--to=14pwcse1224@uetpeshawar.edu.pk \
--cc=aman.deep.singh@intel.com \
--cc=cristian.dumitrescu@intel.com \
--cc=dev@dpdk.org \
--cc=skori@marvell.com \
--cc=stable@dpdk.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).