DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>, <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>, <thomas@monjalon.net>
Subject: Re: [dpdk-dev] [PATCH v3] ethdev: add sanity checks in control APIs
Date: Thu, 15 Apr 2021 08:52:39 +0800	[thread overview]
Message-ID: <d7470e52-ff1e-5bc2-afd9-53af121031ac@huawei.com> (raw)
In-Reply-To: <535dc494-bf3a-f213-3d9e-e5174c1baccc@oktetlabs.ru>

Hi, Andrew,
	All has been fixed in v4, check it out, thanks.

在 2021/4/14 20:00, Andrew Rybchenko 写道:
> On 4/14/21 2:11 PM, Min Hu (Connor) wrote:
>> This patch adds more sanity checks in control path APIs.
>>
>> Fixes: 214ed1acd125 ("ethdev: add iterator to match devargs input")
>> Fixes: 3d98f921fbe9 ("ethdev: unify prefix for static functions and variables")
>> Fixes: 0366137722a0 ("ethdev: check for invalid device name")
>> Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model")
>> Fixes: 5b7ba31148a8 ("ethdev: add port ownership")
>> Fixes: f8244c6399d9 ("ethdev: increase port id range")
>> Cc: stable@dpdk.org
> 
> Please, see below. Error logging is missing in few cases and
> I'd like to understand why.
> 
>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>> ---
>> v3:
>> * set port_id checked first.
>> * add error logging.
>>
>> v2:
>> * Removed unnecessary checks.
>> * Deleted checks in internal API.
>> * Added documentation in the header file.
>> ---
>>   lib/librte_ethdev/rte_ethdev.c | 274 ++++++++++++++++++++++++++++++++++++++---
>>   lib/librte_ethdev/rte_ethdev.h |  20 ++-
>>   2 files changed, 271 insertions(+), 23 deletions(-)
>>
>> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
>> index 6b5cfd6..dfebcc9 100644
>> --- a/lib/librte_ethdev/rte_ethdev.c
>> +++ b/lib/librte_ethdev/rte_ethdev.c
>> @@ -199,6 +199,9 @@ rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs_str)
>>   	char *cls_str = NULL;
>>   	int str_size;
>>   
>> +	if (iter == NULL || devargs_str == NULL)
>> +		return -EINVAL;
>> +
> 
> Is error logging skipped here intentially? Why?
> 
>>   	memset(iter, 0, sizeof(*iter));
>>   
>>   	/*
>> @@ -293,7 +296,7 @@ rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs_str)
>>   uint16_t
>>   rte_eth_iterator_next(struct rte_dev_iterator *iter)
>>   {
>> -	if (iter->cls == NULL) /* invalid ethdev iterator */
>> +	if (iter == NULL || iter->cls == NULL) /* invalid ethdev iterator */
>>   		return RTE_MAX_ETHPORTS;
> 
> Is error logging skipped here intentially? Why?
> 
>>   
>>   	do { /* loop to try all matching rte_device */
>> @@ -322,7 +325,7 @@ rte_eth_iterator_next(struct rte_dev_iterator *iter)
>>   void
>>   rte_eth_iterator_cleanup(struct rte_dev_iterator *iter)
>>   {
>> -	if (iter->bus_str == NULL)
>> +	if (iter == NULL || iter->bus_str == NULL)
>>   		return; /* nothing to free in pure class filter */
> 
> Is error logging skipped here intentially? Why?
> 
>>   	free(RTE_CAST_FIELD(iter, bus_str, char *)); /* workaround const */
>>   	free(RTE_CAST_FIELD(iter, cls_str, char *)); /* workaround const */
> 
> [snip]
> 
>> @@ -2491,6 +2536,12 @@ rte_eth_tx_done_cleanup(uint16_t port_id, uint16_t queue_id, uint32_t free_cnt)
>>   	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
>>   	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->tx_done_cleanup, -ENOTSUP);
>>   
>> +	if (queue_id >= dev->data->nb_tx_queues) {
>> +		RTE_ETHDEV_LOG(ERR, "Queue id should be < %u.",
>> +			       dev->data->nb_tx_queues);
>> +		return -EINVAL;
>> +	}
>> +
> 
> Again, it is not always a control path. So, I'm not sure that we should
> add the check there.
> 
>>   	/* Call driver to free pending mbufs. */
>>   	ret = (*dev->dev_ops->tx_done_cleanup)(dev->data->tx_queues[queue_id],
>>   					       free_cnt);
> 
> [snip]
> 
>> @@ -2667,6 +2732,9 @@ rte_eth_link_speed_to_str(uint32_t link_speed)
>>   int
>>   rte_eth_link_to_str(char *str, size_t len, const struct rte_eth_link *eth_link)
>>   {
>> +	if (str == NULL || eth_link == NULL)
>> +		return -EINVAL;
>> +
> 
> Is error logging skipped here intentionally? Why?
> 
>>   	if (eth_link->link_status == ETH_LINK_DOWN)
>>   		return snprintf(str, len, "Link down");
>>   	else
> 
> [snip]
> 
>> @@ -4602,6 +4784,9 @@ rte_eth_dma_zone_free(const struct rte_eth_dev *dev, const char *ring_name,
>>   	const struct rte_memzone *mz;
>>   	int rc = 0;
>>   
>> +	if (dev == NULL || ring_name == NULL)
>> +		return -EINVAL;
>> +
> 
> Same question about logging here.
> 
>>   	rc = eth_dev_dma_mzone_name(z_name, sizeof(z_name), dev->data->port_id,
>>   			queue_id, ring_name);
>>   	if (rc >= RTE_MEMZONE_NAMESIZE) {
> 
> [snip]
> 
>> @@ -5629,6 +5861,8 @@ rte_eth_representor_id_get(const struct rte_eth_dev *ethdev,
>>   	struct rte_eth_representor_info *info = NULL;
>>   	size_t size;
>>   
>> +	if (ethdev == NULL)
>> +		return -EINVAL;
> 
> Question about logging here as well.
> 
>>   	if (type == RTE_ETH_REPRESENTOR_NONE)
>>   		return 0;
>>   	if (repr_id == NULL)
> 
> [snip]
> .
> 

  reply	other threads:[~2021-04-15  0:52 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-10  9:18 [dpdk-dev] [PATCH] " Min Hu (Connor)
2021-04-12 23:08 ` Ferruh Yigit
2021-04-13  3:23   ` Min Hu (Connor)
2021-04-13  3:22 ` [dpdk-dev] [PATCH v2] " Min Hu (Connor)
2021-04-13  8:44   ` Andrew Rybchenko
2021-04-13  8:58     ` Thomas Monjalon
2021-04-13  9:24       ` Ferruh Yigit
2021-04-14 11:12     ` Min Hu (Connor)
2021-04-29 17:48   ` Tyler Retzlaff
2021-04-29 18:18     ` Stephen Hemminger
2021-04-14 11:11 ` [dpdk-dev] [PATCH v3] " Min Hu (Connor)
2021-04-14 12:00   ` Andrew Rybchenko
2021-04-15  0:52     ` Min Hu (Connor) [this message]
2021-04-15  0:52 ` [dpdk-dev] [PATCH v4] " Min Hu (Connor)
2021-04-15  8:15   ` Andrew Rybchenko
2021-04-15 11:09     ` Min Hu (Connor)
2021-04-15 11:57     ` Thomas Monjalon
2021-04-15 12:03       ` Andrew Rybchenko
2021-04-15 12:20         ` Thomas Monjalon
2021-04-15 12:43           ` Andrew Rybchenko
2021-04-15 12:04   ` Kevin Traynor
2021-04-15 12:15     ` Thomas Monjalon
2021-04-16  7:01       ` Min Hu (Connor)
2021-04-16  7:00     ` Min Hu (Connor)
2021-04-16 10:09       ` Kevin Traynor
2021-04-16 10:44         ` Min Hu (Connor)
2021-04-15 11:09 ` [dpdk-dev] [PATCH v5] " Min Hu (Connor)
2021-04-15 15:38   ` Ferruh Yigit
2021-04-16  7:02     ` Min Hu (Connor)
2021-04-16 16:19     ` Stephen Hemminger
2021-04-15 15:45   ` Ferruh Yigit
2021-04-15 16:21     ` Thomas Monjalon
2021-04-16  7:04       ` Min Hu (Connor)
2021-04-16 16:25   ` Stephen Hemminger
2021-04-16  6:52 ` [dpdk-dev] [PATCH v6] " Min Hu (Connor)
2021-04-16 10:22   ` Kevin Traynor
2021-04-16 11:00     ` Min Hu (Connor)
2021-04-16 16:28     ` Stephen Hemminger
2021-04-17  0:28       ` Min Hu (Connor)
2021-04-17 21:37         ` Thomas Monjalon
2021-04-19  0:34           ` Min Hu (Connor)
2021-04-17  7:42       ` Min Hu (Connor)
2021-04-16 11:00 ` [dpdk-dev] [PATCH v7] " Min Hu (Connor)
2021-04-16 11:31   ` Ferruh Yigit
2021-04-16 12:02   ` Thomas Monjalon
2021-04-17  7:39     ` Min Hu (Connor)
2021-04-17  7:39 ` [dpdk-dev] [PATCH v8] " Min Hu (Connor)
2021-04-20 10:04   ` Thomas Monjalon
2021-04-20 13:59     ` Ferruh Yigit
2021-04-20 14:20     ` Kevin Traynor
2021-04-20 14:33       ` Thomas Monjalon
2021-04-21  2:36   ` [dpdk-dev] [PATCH v9] " Ferruh Yigit
2021-04-21 10:48     ` Thomas Monjalon
2021-04-21 11:28     ` Andrew Rybchenko
2021-04-21 12:36       ` Min Hu (Connor)
2021-04-21 12:38       ` Kevin Traynor
2021-04-21 13:19       ` Ferruh Yigit
2021-04-21 13:40         ` Ferruh Yigit
2021-04-21 13:50           ` Andrew Rybchenko
2021-04-21 13:50         ` Andrew Rybchenko
2021-04-21 14:17       ` Ferruh Yigit
2021-04-21 12:36 ` [dpdk-dev] [PATCH v10] " Min Hu (Connor)
2021-04-21 14:19   ` Ferruh Yigit
2021-04-21 16:22     ` Ferruh Yigit
2021-04-21 17:16       ` 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=d7470e52-ff1e-5bc2-afd9-53af121031ac@huawei.com \
    --to=humin29@huawei.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=thomas@monjalon.net \
    /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).