diff mbox series

genl: fix l_genl_family_cancel to wait for NLMSG_DONE

Message ID 20230518164715.275506-1-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series genl: fix l_genl_family_cancel to wait for NLMSG_DONE | expand

Commit Message

James Prestwood May 18, 2023, 4:47 p.m. UTC
If a genl request was already sent to the kernel a call to
l_genl_family_cancel would remove it from the pending list
immediately. This then allowed l_genl_family_send to queue
another message before the previous/canceled message was
completed. This is not how l_genl is intended to work.

Instead we can clean up the request immediately in
l_genl_family_cancel but not remove it from the queue. This
will prevent any more messages from being sent until NLMSG_DONE
was received for the canceled message.
---
 ell/genl.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

Denis Kenzior May 22, 2023, 2:20 p.m. UTC | #1
Hi James,

On 5/18/23 11:47, James Prestwood wrote:
> If a genl request was already sent to the kernel a call to
> l_genl_family_cancel would remove it from the pending list
> immediately. This then allowed l_genl_family_send to queue
> another message before the previous/canceled message was
> completed. This is not how l_genl is intended to work.
> 
> Instead we can clean up the request immediately in
> l_genl_family_cancel but not remove it from the queue. This
> will prevent any more messages from being sent until NLMSG_DONE
> was received for the canceled message.
> ---
>   ell/genl.c | 14 +++++++++++++-
>   1 file changed, 13 insertions(+), 1 deletion(-)
> 

Applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/ell/genl.c b/ell/genl.c
index 4ed95df..006edf2 100644
--- a/ell/genl.c
+++ b/ell/genl.c
@@ -1910,11 +1910,23 @@  LIB_EXPORT bool l_genl_family_cancel(struct l_genl_family *family,
 	if (request)
 		goto done;
 
-	request = l_queue_remove_if(genl->pending_list, match_request_id,
+	request = l_queue_find(genl->pending_list, match_request_id,
 							L_UINT_TO_PTR(id));
 	if (!request)
 		return false;
 
+	/*
+	 * A message in-flight still needs to wait for NLMSG_DONE so clean up
+	 * for the caller but keep the request queued until its done.
+	 */
+	if (request->destroy)
+		request->destroy(request->user_data);
+
+	request->callback = NULL;
+	request->destroy = NULL;
+
+	return true;
+
 done:
 	destroy_request(request);