OSDN Git Service

RDMA/netlink: Simplify netlink listener existence check
authorLeon Romanovsky <leonro@mellanox.com>
Tue, 2 Oct 2018 08:49:24 +0000 (11:49 +0300)
committerJason Gunthorpe <jgg@mellanox.com>
Wed, 3 Oct 2018 22:06:07 +0000 (16:06 -0600)
All users of rdma_nl_chk_listeners() are interested to get boolean answer
if netlink socket has listeners, so update all places to boolean function.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/core/addr.c
drivers/infiniband/core/netlink.c
drivers/infiniband/core/sa_query.c
include/rdma/rdma_netlink.h

index c2ca9e4..1400a9d 100644 (file)
@@ -315,7 +315,7 @@ static void queue_req(struct addr_req *req)
 static int ib_nl_fetch_ha(struct rdma_dev_addr *dev_addr,
                          const void *daddr, u32 seq, u16 family)
 {
-       if (rdma_nl_chk_listeners(RDMA_NL_GROUP_LS))
+       if (!rdma_nl_chk_listeners(RDMA_NL_GROUP_LS))
                return -EADDRNOTAVAIL;
 
        return ib_nl_ip_send_msg(dev_addr, daddr, seq, family);
index 3ccaae1..724f5a6 100644 (file)
@@ -47,9 +47,9 @@ static struct {
        const struct rdma_nl_cbs   *cb_table;
 } rdma_nl_types[RDMA_NL_NUM_CLIENTS];
 
-int rdma_nl_chk_listeners(unsigned int group)
+bool rdma_nl_chk_listeners(unsigned int group)
 {
-       return (netlink_has_listeners(nls, group)) ? 0 : -1;
+       return netlink_has_listeners(nls, group);
 }
 EXPORT_SYMBOL(rdma_nl_chk_listeners);
 
index a5e76d4..f28f6fd 100644 (file)
@@ -1384,7 +1384,7 @@ static int send_mad(struct ib_sa_query *query, int timeout_ms, gfp_t gfp_mask)
 
        if ((query->flags & IB_SA_ENABLE_LOCAL_SERVICE) &&
            (!(query->flags & IB_SA_QUERY_OPA))) {
-               if (!rdma_nl_chk_listeners(RDMA_NL_GROUP_LS)) {
+               if (rdma_nl_chk_listeners(RDMA_NL_GROUP_LS)) {
                        if (!ib_nl_make_request(query, gfp_mask))
                                return id;
                }
index c369703..70218e6 100644 (file)
@@ -96,7 +96,7 @@ int rdma_nl_multicast(struct sk_buff *skb, unsigned int group, gfp_t flags);
 /**
  * Check if there are any listeners to the netlink group
  * @group: the netlink group ID
- * Returns 0 on success or a negative for no listeners.
+ * Returns true on success or false if no listeners.
  */
-int rdma_nl_chk_listeners(unsigned int group);
+bool rdma_nl_chk_listeners(unsigned int group);
 #endif /* _RDMA_NETLINK_H */