DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: "Min Hu (Connor)" <humin29@huawei.com>, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH v3] net/bonding: fix socket id check
Date: Tue, 27 Apr 2021 12:06:01 +0100	[thread overview]
Message-ID: <90356c3e-a4b5-be4b-1a42-12695738927c@intel.com> (raw)
In-Reply-To: <1619520847-43907-1-git-send-email-humin29@huawei.com>

On 4/27/2021 11:54 AM, Min Hu (Connor) wrote:
> From: Chengchang Tang <tangchengchang@huawei.com>
> 
> The socket ID entered by user is cast to an unsigned integer. However,
> the value may be an illegal negative value, which may cause some
> problems. In this case, an error should be returned.
> 
> In addition, the socket ID may be an invalid positive number, which is
> also processed in this patch.
> 
> Fixes: 2efb58cbab6e ("bond: new link bonding library")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
> ---
> v3:
> * changed type of socket id.
> 
> v2:
> * fixed socket id type.
> ---
>  drivers/net/bonding/rte_eth_bond_args.c | 6 +++---
>  drivers/net/bonding/rte_eth_bond_pmd.c  | 4 ++--
>  2 files changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c
> index 8c5f90d..977f3fe 100644
> --- a/drivers/net/bonding/rte_eth_bond_args.c
> +++ b/drivers/net/bonding/rte_eth_bond_args.c
> @@ -207,13 +207,13 @@ bond_ethdev_parse_socket_id_kvarg(const char *key __rte_unused,
>  		return -1;
>  
>  	errno = 0;
> -	socket_id = (uint8_t)strtol(value, &endptr, 10);
> +	socket_id = (int)strtol(value, &endptr, 10);
>  	if (*endptr != 0 || errno != 0)
>  		return -1;
>  
>  	/* validate socket id value */
> -	if (socket_id >= 0) {
> -		*(uint8_t *)extra_args = (uint8_t)socket_id;
> +	if (socket_id >= 0 && socket_id < RTE_MAX_NUMA_NODES) {
> +		*(int *)extra_args = socket_id;

What do you think to keep this local 'socket_id' variable as "long int" as
reasons commented on previous versions.

>  		return 0;
>  	}
>  	return -1;
> diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c
> index 2e9cea5..4fad563 100644
> --- a/drivers/net/bonding/rte_eth_bond_pmd.c
> +++ b/drivers/net/bonding/rte_eth_bond_pmd.c
> @@ -3333,8 +3333,8 @@ bond_probe(struct rte_vdev_device *dev)
>  	const char *name;
>  	struct bond_dev_private *internals;
>  	struct rte_kvargs *kvlist;
> -	uint8_t bonding_mode, socket_id/*, agg_mode*/;
> -	int  arg_count, port_id;
> +	uint8_t bonding_mode /*, agg_mode*/;

Can you please cleanup the 'agg_mode' while you are touching this.

> +	int  arg_count, port_id, socket_id;

Can you add it into new line, instead of appending?

>  	uint8_t agg_mode;
>  	struct rte_eth_dev *eth_dev;
>  
> 


      reply	other threads:[~2021-04-27 11:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27 10:54 Min Hu (Connor)
2021-04-27 11:06 ` Ferruh Yigit [this message]

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=90356c3e-a4b5-be4b-1a42-12695738927c@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=humin29@huawei.com \
    /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).