IB/core: Work on the caller socket net namespace in nldev_newlink()
authorParav Pandit <parav@mellanox.com>
Thu, 4 Jul 2019 13:04:01 +0000 (16:04 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Mon, 8 Jul 2019 20:03:35 +0000 (17:03 -0300)
While creating new RDMA devices based on netdevice name, consider the net
namespace of the caller skb's socket similar to rest of the doit()
callbacks and nldev_dellink() which deletes the RDMA device created using
nldev_newlink().

Fixes: 3856ec4b93c94 ("RDMA/core: Add RDMA_NLDEV_CMD_NEWLINK/DELLINK support")
Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/nldev.c

index d9f2a30e64677d98409efed8bf7c6f3689b37c7d..783e465e7c412988903088911fa655c4aa169346 100644 (file)
@@ -1476,7 +1476,7 @@ static int nldev_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
        nla_strlcpy(ndev_name, tb[RDMA_NLDEV_ATTR_NDEV_NAME],
                    sizeof(ndev_name));
 
-       ndev = dev_get_by_name(&init_net, ndev_name);
+       ndev = dev_get_by_name(sock_net(skb->sk), ndev_name);
        if (!ndev)
                return -ENODEV;