From: Avinesh Kumar via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] uevent02: Make wait_for_uevents() order-independent
Date: Tue, 25 Aug 2026 19:14:01 +0200 [thread overview]
Message-ID: <20260825171405.123011-1-avinesh.kumar@suse.com> (raw)
From: Avinesh Kumar <avinesh.kumar@suse.com>
Commit 8e63c9e6179a ("net: Defer netdev KOBJ_ADD uevent until the
device is published")[0] in kernel v7.2 changed register_netdevice()
to emit a network interface's own "add" uevent only after the
interface is fully registered, instead of before its queue kobjects
are created. This flips the uevent order for tun device creation from:
add(net), add(rx queue), add(tx queue)
to:
add(rx queue), add(tx queue), add(net)
wait_for_uevents() matched events strictly in the order given in the
uevents array, so on kernels with the reordered uevents the "add(net)"
event only matches once the rx/tx queue events have already been
consumed from the socket, leaving wait_for_uevents() stuck waiting for
events that already went by, until uevent02 times out and fails.
Since the relative order of unrelated uevents is a kernel
implementation detail the test should not depend on, make
wait_for_uevents() track the still-unmatched events in a pending set
and match incoming uevents against any of them, regardless of
position.
[0] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8e63c9e6179a
Signed-off-by: Avinesh Kumar <avinesh.kumar@suse.com>
---
testcases/kernel/uevents/uevent.h | 37 ++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 8 deletions(-)
diff --git a/testcases/kernel/uevents/uevent.h b/testcases/kernel/uevents/uevent.h
index 1ad092d5ea39..b4e4fce2b2f5 100644
--- a/testcases/kernel/uevents/uevent.h
+++ b/testcases/kernel/uevents/uevent.h
@@ -117,15 +117,30 @@ static inline int open_uevent_netlink(void)
return fd;
}
+#define UEVENT_MAX_PENDING 16
+
/*
* Reads events from uevent netlink socket until all expected events passed in
- * the uevent array are matched.
+ * the uevent array are matched. Events do not have to arrive in the order
+ * they are listed in the uevents array, since the kernel is free to reorder
+ * unrelated uevents, e.g. commit 8e63c9e6179a ("net: Defer netdev KOBJ_ADD
+ * uevent until the device is published") changed the order in which a
+ * network interface and its queues announce themselves.
*/
static inline void wait_for_uevents(int fd, const struct uevent_desc *const uevents[])
{
- int i = 0;
+ const struct uevent_desc *pending[UEVENT_MAX_PENDING];
+ int i, cnt = 0, remaining;
+
+ while (uevents[cnt]) {
+ if (cnt >= UEVENT_MAX_PENDING)
+ tst_brk(TBROK, "Too many expected uevents, increase UEVENT_MAX_PENDING");
+ pending[cnt] = uevents[cnt];
+ cnt++;
+ }
+ remaining = cnt;
- while (1) {
+ while (remaining) {
int len;
char buf[4096];
@@ -136,14 +151,20 @@ static inline void wait_for_uevents(int fd, const struct uevent_desc *const ueve
print_uevent(buf, len);
- if (uevent_match(buf, len, uevents[i])) {
- tst_res(TPASS, "Got expected UEVENT");
- if (!uevents[++i]) {
- close(fd);
- return;
+ for (i = 0; i < cnt; i++) {
+ if (!pending[i])
+ continue;
+
+ if (uevent_match(buf, len, pending[i])) {
+ tst_res(TPASS, "Got expected UEVENT");
+ pending[i] = NULL;
+ remaining--;
+ break;
}
}
}
+
+ close(fd);
}
/*
--
2.55.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next reply other threads:[~2026-08-25 17:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 17:14 Avinesh Kumar via ltp [this message]
2026-08-25 17:36 ` [LTP] uevent02: Make wait_for_uevents() order-independent linuxtestproject.agent
2026-08-28 15:26 ` [LTP] [PATCH v2] " Avinesh Kumar via ltp
2026-08-28 21:09 ` [LTP] " linuxtestproject.agent
2026-09-03 13:25 ` [LTP] [PATCH v2] " Andrea Cervesato via ltp
2026-09-03 14:42 ` Cyril Hrubis
2026-09-07 19:44 ` [LTP] [PATCH v3] " Avinesh Kumar via ltp
2026-09-07 22:01 ` [LTP] " linuxtestproject.agent
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=20260825171405.123011-1-avinesh.kumar@suse.com \
--to=ltp@lists.linux.it \
--cc=avinesh.kumar@suse.com \
/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 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.