[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <012dea67-8ebd-ab03-a221-e303ce5b7b0f@gmail.com>
Date: Thu, 10 Sep 2020 09:02:34 -0600
From: David Ahern <dsahern@...il.com>
To: Parav Pandit <parav@...lanox.com>, kuba@...nel.org,
davem@...emloft.net, netdev@...r.kernel.org
Cc: Parav Pandit <parav@...dia.com>, Jiri Pirko <jiri@...dia.com>
Subject: Re: [PATCH net-next v3 6/6] devlink: Use controller while building
phys_port_name
On 9/8/20 10:50 PM, Parav Pandit wrote:
> $ devlink port show pci/0000:06:00.0/2
> pci/0000:06:00.0/2: type eth netdev ens2f0c1pf0vf1 flavour pcivf controller 1 pfnum 0 vfnum 1 external true splittable false
> function:
> hw_addr 00:00:00:00:00:00
>
> $ devlink port show pci/0000:06:00.0/2 -jp
> {
> "port": {
> "pci/0000:06:00.0/2": {
> "type": "eth",
> "netdev": "ens2f0c1pf0vf1",
That strlen is 14 chars. Any 2 ids go to a second digit and you overrrun
the IFNAMSZ which means ...
> diff --git a/net/core/devlink.c b/net/core/devlink.c
> index 9cf5b118253b..91c12612f2b7 100644
> --- a/net/core/devlink.c
> +++ b/net/core/devlink.c
> @@ -7793,9 +7793,23 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
> WARN_ON(1);
> return -EINVAL;
> case DEVLINK_PORT_FLAVOUR_PCI_PF:
> + if (attrs->pci_pf.external) {
> + n = snprintf(name, len, "c%u", attrs->pci_pf.controller);
> + if (n >= len)
> + return -EINVAL;
... this function returns EINVAL which is going to be confusing to users.
> + len -= n;
> + name += n;
> + }
> n = snprintf(name, len, "pf%u", attrs->pci_pf.pf);
> break;
> case DEVLINK_PORT_FLAVOUR_PCI_VF:
> + if (attrs->pci_vf.external) {
> + n = snprintf(name, len, "c%u", attrs->pci_vf.controller);
> + if (n >= len)
> + return -EINVAL;
> + len -= n;
> + name += n;
> + }
> n = snprintf(name, len, "pf%uvf%u",
> attrs->pci_vf.pf, attrs->pci_vf.vf);
> break;
>
Powered by blists - more mailing lists