Skip to content

Commit 9047811

Browse files
mustafakismailrleon
authored andcommitted
RDMA/core: Add wait/retry version of ibnl_unicast
Add a wait/retry version of ibnl_unicast, ibnl_unicast_wait, and modify ibnl_unicast to not wait/retry. This eliminates the undesirable wait for future users of ibnl_unicast. Change Portmapper calls originating from kernel to user-space to use ibnl_unicast_wait and take advantage of the wait/retry logic in netlink_unicast. Signed-off-by: Mustafa Ismail <[email protected]> Signed-off-by: Chien Tin Tung <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 913cc67 commit 9047811

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

drivers/infiniband/core/iwpm_msg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ int iwpm_add_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client)
174174
goto add_mapping_error;
175175
nlmsg_request->req_buffer = pm_msg;
176176

177-
ret = ibnl_unicast(skb, nlh, iwpm_user_pid);
177+
ret = ibnl_unicast_wait(skb, nlh, iwpm_user_pid);
178178
if (ret) {
179179
skb = NULL; /* skb is freed in the netlink send-op handling */
180180
iwpm_user_pid = IWPM_PID_UNDEFINED;
@@ -251,7 +251,7 @@ int iwpm_add_and_query_mapping(struct iwpm_sa_data *pm_msg, u8 nl_client)
251251
goto query_mapping_error;
252252
nlmsg_request->req_buffer = pm_msg;
253253

254-
ret = ibnl_unicast(skb, nlh, iwpm_user_pid);
254+
ret = ibnl_unicast_wait(skb, nlh, iwpm_user_pid);
255255
if (ret) {
256256
skb = NULL; /* skb is freed in the netlink send-op handling */
257257
err_str = "Unable to send a nlmsg";
@@ -312,7 +312,7 @@ int iwpm_remove_mapping(struct sockaddr_storage *local_addr, u8 nl_client)
312312
if (ret)
313313
goto remove_mapping_error;
314314

315-
ret = ibnl_unicast(skb, nlh, iwpm_user_pid);
315+
ret = ibnl_unicast_wait(skb, nlh, iwpm_user_pid);
316316
if (ret) {
317317
skb = NULL; /* skb is freed in the netlink send-op handling */
318318
iwpm_user_pid = IWPM_PID_UNDEFINED;

drivers/infiniband/core/netlink.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,21 @@ int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
232232
{
233233
int err;
234234

235-
err = netlink_unicast(nls, skb, pid, 0);
235+
err = netlink_unicast(nls, skb, pid, MSG_DONTWAIT);
236236
return (err < 0) ? err : 0;
237237
}
238238
EXPORT_SYMBOL(ibnl_unicast);
239239

240+
int ibnl_unicast_wait(struct sk_buff *skb, struct nlmsghdr *nlh,
241+
__u32 pid)
242+
{
243+
int err;
244+
245+
err = netlink_unicast(nls, skb, pid, 0);
246+
return (err < 0) ? err : 0;
247+
}
248+
EXPORT_SYMBOL(ibnl_unicast_wait);
249+
240250
int ibnl_multicast(struct sk_buff *skb, struct nlmsghdr *nlh,
241251
unsigned int group, gfp_t flags)
242252
{

include/rdma/rdma_netlink.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ int ibnl_put_attr(struct sk_buff *skb, struct nlmsghdr *nlh,
6363
int ibnl_unicast(struct sk_buff *skb, struct nlmsghdr *nlh,
6464
__u32 pid);
6565

66+
/**
67+
* Send, with wait/1 retry, the supplied skb to a specific userspace PID.
68+
* @skb: The netlink skb
69+
* @nlh: Header of the netlink message to send
70+
* @pid: Userspace netlink process ID
71+
* Returns 0 on success or a negative error code.
72+
*/
73+
int ibnl_unicast_wait(struct sk_buff *skb, struct nlmsghdr *nlh,
74+
__u32 pid);
75+
6676
/**
6777
* Send the supplied skb to a netlink group.
6878
* @skb: The netlink skb

0 commit comments

Comments
 (0)