ell.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: ell@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH] genl: fix l_genl_family_cancel to wait for NLMSG_DONE
Date: Thu, 18 May 2023 09:47:15 -0700	[thread overview]
Message-ID: <20230518164715.275506-1-prestwoj@gmail.com> (raw)

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(-)

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);
 
-- 
2.25.1


             reply	other threads:[~2023-05-18 16:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-18 16:47 James Prestwood [this message]
2023-05-22 14:20 ` [PATCH] genl: fix l_genl_family_cancel to wait for NLMSG_DONE Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230518164715.275506-1-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=ell@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).