DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: "Wei Hu (Xavier)" <huwei013@chinasoftinc.com>, dev@dpdk.org
Cc: xavier.huwei@huawei.com
Subject: Re: [dpdk-dev] [PATCH v3] ethdev: check if queue setupped in queue-related APIs
Date: Mon, 12 Oct 2020 16:12:24 +0100
Message-ID: <d8ed3544-93dc-5880-5efe-5be74cff073d@intel.com> (raw)
In-Reply-To: <20201012073244.7447-1-huwei013@chinasoftinc.com>

On 10/12/2020 8:32 AM, Wei Hu (Xavier) wrote:
> From: Chengchang Tang <tangchengchang@huawei.com>
> 
> This patch adds checking whether the related Tx or Rx queue has been
> setupped in the queue-related API functions to avoid illegal address
> access. And validity check of the queue_id is also added in the API
> functions rte_eth_dev_rx_intr_enable and rte_eth_dev_rx_intr_disable.
> 
> Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
> Signed-off-by: Wei Hu (Xavier) <xavier.huwei@huawei.com>
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> ---
> v2 -> v3:
> 	 don't break lines in format strings.
> v1 -> v2:
> 	 1. replace %"PRIu16" with %u.
> 	 2. extact two common functions which validate RXQ/TXQ ids and
> 	    whether it has been set up or not.
> ---
>   lib/librte_ethdev/rte_ethdev.c | 92 ++++++++++++++++++++++++++++++++++--------
>   lib/librte_ethdev/rte_ethdev.h |  3 +-
>   2 files changed, 78 insertions(+), 17 deletions(-)
> 
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
> index 892c246..34eec97 100644
> --- a/lib/librte_ethdev/rte_ethdev.c
> +++ b/lib/librte_ethdev/rte_ethdev.c
> @@ -877,10 +877,59 @@ rte_eth_dev_rx_queue_config(struct rte_eth_dev *dev, uint16_t nb_queues)
>   	return 0;
>   }
>   
> +static inline int
> +rte_eth_dev_validate_rx_queue(uint16_t port_id, uint16_t rx_queue_id)
> +{
> +	struct rte_eth_dev *dev;
> +
> +	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
> +
> +	dev = &rte_eth_devices[port_id];
> +

Since these are static (internal) functions, why not get "struct rte_eth_dev 
*dev" as parameter and drop the port_id validation?

Also for same reason, although there is not convention around it, what do you 
think dropping the 'rte_' prefix from the funcitons names, to prevent them 
confused by ethdev APIs?

<...>

> @@ -4721,7 +4721,8 @@ rte_eth_rx_queue_count(uint16_t port_id, uint16_t queue_id)
>   	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
>   	dev = &rte_eth_devices[port_id];
>   	RTE_FUNC_PTR_OR_ERR_RET(*dev->rx_queue_count, -ENOTSUP);
> -	if (queue_id >= dev->data->nb_rx_queues)
> +	if (queue_id >= dev->data->nb_rx_queues ||
> +	    dev->data->rx_queues[queue_id] == NULL)
>   		return -EINVAL;

This will bring additional check for the datapath, but I guess this check is 
reasonable since this is an API.


  reply	other threads:[~2020-10-12 15:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-10  7:12 [dpdk-dev] [PATCH] " Wei Hu (Xavier)
2020-10-10 15:24 ` Stephen Hemminger
2020-10-12  3:21   ` Wei Hu (Xavier)
2020-10-10 16:38 ` Kalesh Anakkur Purayil
2020-10-12  3:22   ` Wei Hu (Xavier)
2020-10-12  3:19 ` [dpdk-dev] [PATCH v2] " Wei Hu (Xavier)
2020-10-12  6:29   ` Stephen Hemminger
2020-10-12  7:32 ` [dpdk-dev] [PATCH v3] " Wei Hu (Xavier)
2020-10-12 15:12   ` Ferruh Yigit [this message]
2020-10-12 15:15   ` Stephen Hemminger
2020-10-13  2:41 ` [dpdk-dev] [PATCH v4] ethdev: check if queue setup " Wei Hu (Xavier)
2020-10-13  4:28   ` Kalesh Anakkur Purayil
2020-10-13  8:08   ` Andrew Rybchenko
2020-10-13 11:50 ` [dpdk-dev] [PATCH v5 0/3] check queue id " Wei Hu (Xavier)
2020-10-13 11:50   ` [dpdk-dev] [PATCH v5 1/3] ethdev: extract checking queue id into common functions Wei Hu (Xavier)
2020-10-13 12:49     ` Andrew Rybchenko
2020-10-13 11:50   ` [dpdk-dev] [PATCH v5 2/3] ethdev: check if queue setup in queue-related APIs Wei Hu (Xavier)
2020-10-13 11:50   ` [dpdk-dev] [PATCH v5 3/3] ethdev: check queue id in Rx interrupt control routine Wei Hu (Xavier)
2020-10-13 13:17   ` [dpdk-dev] [PATCH v5 0/3] check queue id in queue-related APIs Ferruh Yigit
2020-10-13 14:13     ` Ferruh Yigit

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=d8ed3544-93dc-5880-5efe-5be74cff073d@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=huwei013@chinasoftinc.com \
    --cc=xavier.huwei@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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git