* [for-rc] RDMA/core: Make sure the netdev is not already associated
@ 2022-12-12 9:22 Kamal Heib
2022-12-12 10:16 ` Leon Romanovsky
2022-12-12 12:51 ` Jason Gunthorpe
0 siblings, 2 replies; 4+ messages in thread
From: Kamal Heib @ 2022-12-12 9:22 UTC (permalink / raw)
To: linux-rdma; +Cc: Jason Gunthorpe, Leon Romanovsky, Kamal Heib
Make sure that the requested net_device is not already associated with
an ib_device before trying to create a new ib_device that will be
associated with the same net_device, this is needed to avoid creating
siw and rxe devices that will be associated with the same net_device.
Fixes: 3856ec4b93c9 ("RDMA/core: Add RDMA_NLDEV_CMD_NEWLINK/DELLINK support")
Signed-off-by: Kamal Heib <kheib@redhat.com>
---
drivers/infiniband/core/nldev.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index a981ac2f0975..376c9e158556 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -1696,6 +1696,7 @@ static int nldev_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
const struct rdma_link_ops *ops;
char ndev_name[IFNAMSIZ];
struct net_device *ndev;
+ struct ib_device *ibdev;
char type[IFNAMSIZ];
int err;
@@ -1718,6 +1719,12 @@ static int nldev_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
if (!ndev)
return -ENODEV;
+ ibdev = ib_device_get_by_netdev(ndev, RDMA_DRIVER_UNKNOWN);
+ if (ibdev) {
+ ib_device_put(ibdev);
+ return -EINVAL;
+ }
+
down_read(&link_ops_rwsem);
ops = link_ops_get(type);
#ifdef CONFIG_MODULES
--
2.38.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [for-rc] RDMA/core: Make sure the netdev is not already associated
2022-12-12 9:22 [for-rc] RDMA/core: Make sure the netdev is not already associated Kamal Heib
@ 2022-12-12 10:16 ` Leon Romanovsky
2022-12-12 12:51 ` Jason Gunthorpe
1 sibling, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2022-12-12 10:16 UTC (permalink / raw)
To: Kamal Heib; +Cc: linux-rdma, Jason Gunthorpe
On Mon, Dec 12, 2022 at 11:22:40AM +0200, Kamal Heib wrote:
> Make sure that the requested net_device is not already associated with
> an ib_device before trying to create a new ib_device that will be
> associated with the same net_device, this is needed to avoid creating
> siw and rxe devices that will be associated with the same net_device.
>
> Fixes: 3856ec4b93c9 ("RDMA/core: Add RDMA_NLDEV_CMD_NEWLINK/DELLINK support")
> Signed-off-by: Kamal Heib <kheib@redhat.com>
> ---
> drivers/infiniband/core/nldev.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [for-rc] RDMA/core: Make sure the netdev is not already associated
2022-12-12 9:22 [for-rc] RDMA/core: Make sure the netdev is not already associated Kamal Heib
2022-12-12 10:16 ` Leon Romanovsky
@ 2022-12-12 12:51 ` Jason Gunthorpe
2022-12-12 13:18 ` Leon Romanovsky
1 sibling, 1 reply; 4+ messages in thread
From: Jason Gunthorpe @ 2022-12-12 12:51 UTC (permalink / raw)
To: Kamal Heib; +Cc: linux-rdma, Leon Romanovsky
On Mon, Dec 12, 2022 at 11:22:40AM +0200, Kamal Heib wrote:
> Make sure that the requested net_device is not already associated with
> an ib_device before trying to create a new ib_device that will be
> associated with the same net_device, this is needed to avoid creating
> siw and rxe devices that will be associated with the same net_device.
>
> Fixes: 3856ec4b93c9 ("RDMA/core: Add RDMA_NLDEV_CMD_NEWLINK/DELLINK support")
> Signed-off-by: Kamal Heib <kheib@redhat.com>
> ---
> drivers/infiniband/core/nldev.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
> index a981ac2f0975..376c9e158556 100644
> --- a/drivers/infiniband/core/nldev.c
> +++ b/drivers/infiniband/core/nldev.c
> @@ -1696,6 +1696,7 @@ static int nldev_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
> const struct rdma_link_ops *ops;
> char ndev_name[IFNAMSIZ];
> struct net_device *ndev;
> + struct ib_device *ibdev;
> char type[IFNAMSIZ];
> int err;
>
> @@ -1718,6 +1719,12 @@ static int nldev_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
> if (!ndev)
> return -ENODEV;
>
> + ibdev = ib_device_get_by_netdev(ndev, RDMA_DRIVER_UNKNOWN);
> + if (ibdev) {
> + ib_device_put(ibdev);
> + return -EINVAL;
> + }
This is racy
What is wrong with creating two IB devices on top of the same net device?
Jason
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [for-rc] RDMA/core: Make sure the netdev is not already associated
2022-12-12 12:51 ` Jason Gunthorpe
@ 2022-12-12 13:18 ` Leon Romanovsky
0 siblings, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2022-12-12 13:18 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: Kamal Heib, linux-rdma
On Mon, Dec 12, 2022 at 08:51:19AM -0400, Jason Gunthorpe wrote:
> On Mon, Dec 12, 2022 at 11:22:40AM +0200, Kamal Heib wrote:
> > Make sure that the requested net_device is not already associated with
> > an ib_device before trying to create a new ib_device that will be
> > associated with the same net_device, this is needed to avoid creating
> > siw and rxe devices that will be associated with the same net_device.
> >
> > Fixes: 3856ec4b93c9 ("RDMA/core: Add RDMA_NLDEV_CMD_NEWLINK/DELLINK support")
> > Signed-off-by: Kamal Heib <kheib@redhat.com>
> > ---
> > drivers/infiniband/core/nldev.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
> > index a981ac2f0975..376c9e158556 100644
> > --- a/drivers/infiniband/core/nldev.c
> > +++ b/drivers/infiniband/core/nldev.c
> > @@ -1696,6 +1696,7 @@ static int nldev_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
> > const struct rdma_link_ops *ops;
> > char ndev_name[IFNAMSIZ];
> > struct net_device *ndev;
> > + struct ib_device *ibdev;
> > char type[IFNAMSIZ];
> > int err;
> >
> > @@ -1718,6 +1719,12 @@ static int nldev_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
> > if (!ndev)
> > return -ENODEV;
> >
> > + ibdev = ib_device_get_by_netdev(ndev, RDMA_DRIVER_UNKNOWN);
> > + if (ibdev) {
> > + ib_device_put(ibdev);
> > + return -EINVAL;
> > + }
>
> This is racy
It can be seen as best effort.
>
> What is wrong with creating two IB devices on top of the same net device?
Any place where we need to convert from ndev to ib will return random answer.
>
> Jason
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-12-12 13:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-12 9:22 [for-rc] RDMA/core: Make sure the netdev is not already associated Kamal Heib
2022-12-12 10:16 ` Leon Romanovsky
2022-12-12 12:51 ` Jason Gunthorpe
2022-12-12 13:18 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox