DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>
Cc: Cristian Dumitrescu <cristian.dumitrescu@intel.com>,
	Aman Singh <aman.deep.singh@intel.com>,
	Sunil Kumar Kori <skori@marvell.com>,
	dev@dpdk.org, stable@dpdk.org
Subject: Re: [PATCH] app/testpmd: validate dscp and vlan table entries for meter creation
Date: Tue, 26 Aug 2025 07:00:31 -0700	[thread overview]
Message-ID: <20250826070031.3428054f@hermes.local> (raw)
In-Reply-To: <20250822121430.2228507-1-14pwcse1224@uetpeshawar.edu.pk>

On Fri, 22 Aug 2025 08:14:30 -0400
Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> wrote:

> 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;

Useless initialization

> +	token = strtok_r(str, PARSE_DELIMITER, &str);
> +	for (i = 0; token != NULL; i++)
> +		token = strtok_r(str, PARSE_DELIMITER, &str);

Rather than parsing all the way to the end, why not put the max test inside the loop

> +	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;
> +

On error, this leaks the temporary string created (temp_str).



  reply	other threads:[~2025-08-26 14:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-22 12:14 Khadem Ullah
2025-08-26 14:00 ` Stephen Hemminger [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=20250826070031.3428054f@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=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).