RE: [PATCH rdma-next v1 14/15] RDMA/core: Allow port_groups to be used with namespaces

From: Parav Pandit
Date: Mon Jun 07 2021 - 09:30:08 EST




> From: Leon Romanovsky <leon@xxxxxxxxxx>
> Sent: Monday, June 7, 2021 1:48 PM
>
> From: Jason Gunthorpe <jgg@xxxxxxxxxx>
>
> Now that the port_groups data is being destroyed and managed by the core
> code this restriction is no longer needed. All the ib_port_attrs are compatible
> with the core's sysfs lifecycle.
>
> Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxx>
> Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
> ---
> drivers/infiniband/core/device.c | 10 ++++------
> drivers/infiniband/core/sysfs.c | 17 ++++++-----------
> 2 files changed, 10 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/infiniband/core/device.c
> b/drivers/infiniband/core/device.c
> index 2cbd77933ea5..92f224a97481 100644
> --- a/drivers/infiniband/core/device.c
> +++ b/drivers/infiniband/core/device.c
> @@ -1698,13 +1698,11 @@ int ib_device_set_netns_put(struct sk_buff
> *skb,
> }
>
> /*
> - * Currently supported only for those providers which support
> - * disassociation and don't do port specific sysfs init. Once a
> - * port_cleanup infrastructure is implemented, this limitation will be
> - * removed.
> + * All the ib_clients, including uverbs, are reset when the namespace
> is
> + * changed and this cannot be blocked waiting for userspace to do
> + * something, so disassociation is mandatory.
> */
> - if (!dev->ops.disassociate_ucontext || dev->ops.port_groups ||
> - ib_devices_shared_netns) {
> + if (!dev->ops.disassociate_ucontext || ib_devices_shared_netns) {
> ret = -EOPNOTSUPP;
> goto ns_err;
> }
> diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
> index 09a2e1066df0..f42034fcf3d9 100644
> --- a/drivers/infiniband/core/sysfs.c
> +++ b/drivers/infiniband/core/sysfs.c
> @@ -1236,11 +1236,9 @@ static struct ib_port *setup_port(struct
> ib_core_device *coredev, int port_num,
> ret = sysfs_create_groups(&p->kobj, p->groups_list);
> if (ret)
> goto err_del;
> - if (is_full_dev) {
> - ret = sysfs_create_groups(&p->kobj, device-
> >ops.port_groups);
> - if (ret)
> - goto err_groups;
> - }
> + ret = sysfs_create_groups(&p->kobj, device->ops.port_groups);
> + if (ret)
> + goto err_groups;
>
This will expose counters in all net namespaces in shared mode (default case).
Application running in one net namespace will be able to monitor counters of other net namespace.
This should be avoided.