]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
RDMA/cma: Use rdma_read_gid_attr_ndev_rcu to access netdev
authorParav Pandit <parav@mellanox.com>
Thu, 2 May 2019 07:48:04 +0000 (10:48 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Fri, 3 May 2019 14:10:03 +0000 (11:10 -0300)
To access the netdevice of the GID attribute, use an existing API
rdma_read_gid_attr_ndev_rcu().

This further reduces dependency on open access to netdevice of GID
attribute.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/addr.c
drivers/infiniband/core/cache.c
drivers/infiniband/core/cma.c
include/rdma/ib_cache.h

index 0dce94e3c495619e1d825e9f0ee300da8ea2e779..2b791ce7597f20f458bd36c46dc4decc0071321c 100644 (file)
@@ -45,6 +45,7 @@
 #include <net/addrconf.h>
 #include <net/ip6_route.h>
 #include <rdma/ib_addr.h>
+#include <rdma/ib_cache.h>
 #include <rdma/ib_sa.h>
 #include <rdma/ib.h>
 #include <rdma/rdma_netlink.h>
index c164e377e5636937dda36f29701352719b2d10c3..a53c7713d77a1750c25175f356c408e75b92bab1 100644 (file)
@@ -1249,6 +1249,7 @@ struct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr)
        read_unlock_irqrestore(&table->rwlock, flags);
        return ndev;
 }
+EXPORT_SYMBOL(rdma_read_gid_attr_ndev_rcu);
 
 static int get_lower_dev_vlan(struct net_device *lower_dev, void *data)
 {
index 088b5495e1999ed67f9b1bae0039c975a6a81c40..19f1730a4f2442a175536f290ae40941d3bf954c 100644 (file)
@@ -1486,6 +1486,7 @@ static struct net_device *
 roce_get_net_dev_by_cm_event(const struct ib_cm_event *ib_event)
 {
        const struct ib_gid_attr *sgid_attr = NULL;
+       struct net_device *ndev;
 
        if (ib_event->event == IB_CM_REQ_RECEIVED)
                sgid_attr = ib_event->param.req_rcvd.ppath_sgid_attr;
@@ -1494,8 +1495,15 @@ roce_get_net_dev_by_cm_event(const struct ib_cm_event *ib_event)
 
        if (!sgid_attr)
                return NULL;
-       dev_hold(sgid_attr->ndev);
-       return sgid_attr->ndev;
+
+       rcu_read_lock();
+       ndev = rdma_read_gid_attr_ndev_rcu(sgid_attr);
+       if (IS_ERR(ndev))
+               ndev = NULL;
+       else
+               dev_hold(ndev);
+       rcu_read_unlock();
+       return ndev;
 }
 
 static struct net_device *cma_get_net_dev(const struct ib_cm_event *ib_event,
index 730a65ad8c74d9384d29f962dc446c6941114cd8..870b5e6c06db04d668f78a5941a6bb21b395e8c5 100644 (file)
@@ -56,6 +56,7 @@ const struct ib_gid_attr *rdma_find_gid_by_filter(
 
 int rdma_read_gid_l2_fields(const struct ib_gid_attr *attr,
                            u16 *vlan_id, u8 *smac);
+struct net_device *rdma_read_gid_attr_ndev_rcu(const struct ib_gid_attr *attr);
 
 /**
  * ib_get_cached_pkey - Returns a cached PKey table entry