From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
To: Ferruh Yigit <ferruh.yigit@intel.com>,
Thomas Monjalon <thomas@monjalon.net>,
Gaetan Rivet <grive@u256.net>,
Stephen Hemminger <stephen@networkplumber.org>,
Qi Zhang <qi.z.zhang@intel.com>,
Ali Alnubani <alialnu@mellanox.com>,
Yuanhan Liu <yuanhan.liu@linux.intel.com>,
Matan Azrad <matan@mellanox.com>,
Konstantin Ananyev <konstantin.ananyev@intel.com>,
Zhiyong Yang <zhiyong.yang@intel.com>,
Adrien Mazarguil <adrien.mazarguil@6wind.com>
Cc: dev@dpdk.org, "Min Hu (Connor)" <humin29@huawei.com>,
stable@dpdk.org, Kevin Traynor <ktraynor@redhat.com>
Subject: Re: [dpdk-dev] [PATCH v9] ethdev: add sanity checks in control APIs
Date: Wed, 21 Apr 2021 16:50:34 +0300 [thread overview]
Message-ID: <0adf6e17-e627-e3b0-6bf0-6ffe94cae3dc@oktetlabs.ru> (raw)
In-Reply-To: <ab2af88c-0fb0-916e-d742-90e33fb4e36f@intel.com>
On 4/21/21 4:40 PM, Ferruh Yigit wrote:
> On 4/21/2021 2:19 PM, Ferruh Yigit wrote:
>> On 4/21/2021 12:28 PM, Andrew Rybchenko wrote:
>>> On 4/21/21 5:36 AM, Ferruh Yigit wrote:
>>>> From: "Min Hu (Connor)" <humin29@huawei.com>
>>>>
>>>> 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
>>>>
>>>> Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
>>>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>>>> Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
>>>> Acked-by: Kevin Traynor <ktraynor@redhat.com>
>>>
>>> Few nits below.
>>> Other than that I confirm my "Reviewed-by".
>>>
>>> The patch is really long. It would be better to split it into
>>> few:
>>> - relocate dev assignment
>>> - empty lines mangling (when it is unrelated to previous item)
>>> - ops check before usage (combined with related style checks)
>>> - error logs refinement
>>>
>>> However, since the patch is already reviewed this way, may
>>> be it is better to push as is after review notes processing.
>>>
>>>> @@ -817,7 +859,12 @@ rte_eth_dev_get_port_by_name(const char *name,
>>>> uint16_t *port_id)
>>>> uint16_t pid;
>>>> if (name == NULL) {
>>>> - RTE_ETHDEV_LOG(ERR, "Null pointer is specified\n");
>>>> + RTE_ETHDEV_LOG(ERR, "Cannot get port ID from NULL name");
>>>> + return -EINVAL;
>>>> + }
>>>> +
>>>> + if (port_id == NULL) {
>>>> + RTE_ETHDEV_LOG(ERR, "Cannot get port ID to NULL\n");
>>>
>>> Since name is already checked above, I think it would be useful
>>> to log 'name' here to provide context.
>>>
>>>> return -EINVAL;
>>>> }
>>>
>>> [snip]
>>>
>>>> @@ -3256,6 +3370,20 @@ rte_eth_dev_fw_version_get(uint16_t port_id,
>>>> char *fw_version, size_t fw_size)
>>>> RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
>>>> dev = &rte_eth_devices[port_id];
>>>> + if (fw_version == NULL) {
>>>> + RTE_ETHDEV_LOG(ERR,
>>>> + "Cannot get ethdev port %u FW version to NULL\n",
>>>> + port_id);
>>>> + return -EINVAL;
>>>> + }
>>>> +
>>>> + if (fw_size == 0) {
>>>> + RTE_ETHDEV_LOG(ERR,
>>>> + "Cannot get ethdev port %u FW version to buffer with
>>>> zero size\n",
>>>> + port_id);
>>>> + return -EINVAL;
>>>> + }
>>>> +
>>>
>>> The only error condition is NULL fw_version with positive
>>> fw_size. Othwerwise, it could be just a call to get required
>>> size of buffer for FW version.
>>>
>>
>> Right, above is wrong.
>>
>> Agree that "fw_version == NULL && fw_size > 0" is error condition,
>> but is it clear if how this API should behave on
>> "fw_version == NULL && fw_size == 0"?
>>
>> Like sfc has following,
>> if ((fw_version == NULL) || (fw_size == 0))
>> return -EINVAL;
>
> axgbe, qede also returns error when fw_version is NULL, independent from
> fw_size.
>
> But I think taking "fw_version == NULL && fw_size > 0" as only error
> condition is reasonable, although some PMDs will be behaving wrong.
> I can send a separate patch to unify the behavior.
Many thanks, please, let me know if you need help with net/sfc.
next prev parent reply other threads:[~2021-04-21 13:50 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)
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 [this message]
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=0adf6e17-e627-e3b0-6bf0-6ffe94cae3dc@oktetlabs.ru \
--to=andrew.rybchenko@oktetlabs.ru \
--cc=adrien.mazarguil@6wind.com \
--cc=alialnu@mellanox.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=grive@u256.net \
--cc=humin29@huawei.com \
--cc=konstantin.ananyev@intel.com \
--cc=ktraynor@redhat.com \
--cc=matan@mellanox.com \
--cc=qi.z.zhang@intel.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
--cc=thomas@monjalon.net \
--cc=yuanhan.liu@linux.intel.com \
--cc=zhiyong.yang@intel.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).