All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RDMA/netlink] RDMA/netlink: Adhere to returning zero on success
@ 2019-12-11 10:34 Håkon Bugge
  2019-12-11 10:42 ` Håkon Bugge
  2019-12-11 12:39 ` Leon Romanovsky
  0 siblings, 2 replies; 10+ messages in thread
From: Håkon Bugge @ 2019-12-11 10:34 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe; +Cc: linux-rdma, Mark Haywood

In rdma_nl_rcv_skb(), the local variable err is assigned the return
value of the supplied callback function, which could be one of
ib_nl_handle_resolve_resp(), ib_nl_handle_set_timeout(), or
ib_nl_handle_ip_res_resp(). These three functions all return skb->len
on success.

rdma_nl_rcv_skb() is merely a copy of netlink_rcv_skb(). The callback
functions used by the latter have the convention: "Returns 0 on
success or a negative error code".

In particular, the statement (equal for both functions):

   if (nlh->nlmsg_flags & NLM_F_ACK || err)

implies that rdma_nl_rcv_skb() always will ack a message, independent
of the NLM_F_ACK being set in nlmsg_flags or not.

The fix could be to change the above statement, but it is better to
keep the two *_rcv_skb() functions equal in this respect and instead
change the callback functions in the rdma subsystem to the correct
convention.

Suggested-by: Mark Haywood <mark.haywood@oracle.com>
Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
Tested-by: Mark Haywood <mark.haywood@oracle.com>
---
 drivers/infiniband/core/addr.c     | 2 +-
 drivers/infiniband/core/sa_query.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 606fa6d86685..9449ed2536fa 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -139,7 +139,7 @@ int ib_nl_handle_ip_res_resp(struct sk_buff *skb,
 	if (ib_nl_is_good_ip_resp(nlh))
 		ib_nl_process_good_ip_rsep(nlh);
 
-	return skb->len;
+	return skb->len > 0 ? 0 : skb->len;
 }
 
 static int ib_nl_ip_send_msg(struct rdma_dev_addr *dev_addr,
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 8917125ea16d..dc249e382367 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -1068,7 +1068,7 @@ int ib_nl_handle_set_timeout(struct sk_buff *skb,
 	}
 
 settimeout_out:
-	return skb->len;
+	return skb->len > 0 ? 0 : skb->len;
 }
 
 static inline int ib_nl_is_good_resolve_resp(const struct nlmsghdr *nlh)
@@ -1139,7 +1139,7 @@ int ib_nl_handle_resolve_resp(struct sk_buff *skb,
 	}
 
 resp_out:
-	return skb->len;
+	return skb->len > 0 ? 0 : skb->len;
 }
 
 static void free_sm_ah(struct kref *kref)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2019-12-13 20:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-11 10:34 [PATCH RDMA/netlink] RDMA/netlink: Adhere to returning zero on success Håkon Bugge
2019-12-11 10:42 ` Håkon Bugge
2019-12-11 12:39 ` Leon Romanovsky
2019-12-11 13:13   ` Håkon Bugge
2019-12-11 19:31     ` Håkon Bugge
2019-12-12 11:40       ` Leon Romanovsky
     [not found]         ` <AD5EE341-4238-439A-A078-299F00C61B85@oracle.com>
     [not found]           ` <20191212121020.GZ67461@unreal>
     [not found]             ` <CB8FC366-9983-417D-8280-DD1EB0DCB778@oracle.com>
2019-12-12 12:22               ` Håkon Bugge
     [not found]               ` <20191212122719.GA67461@unreal>
2019-12-12 12:37                 ` Håkon Bugge
2019-12-12 14:14                   ` Mark Haywood
2019-12-13 16:51                     ` Mark Haywood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.