[LTP] [PATCH] netns_netlink: ensure child opens socket before parent creates tap if
Jan Stancek
jstancek@redhat.com
Fri Apr 8 13:26:36 CEST 2022
There's a race, that allows parent to create/destroy tap interface
before child manages to open a netlink socket, and then child
will miss all events and test fails:
tst_kconfig.c:82: TINFO: Parsing kernel config '/lib/modules/5.18.0-rc1/build/.config'
tst_test.c:1456: TINFO: Timeout per run is 0h 10m 00s
netns_netlink.c:88: TFAIL: failed to detect interface changes
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
testcases/kernel/containers/netns/netns_netlink.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/testcases/kernel/containers/netns/netns_netlink.c b/testcases/kernel/containers/netns/netns_netlink.c
index 7c90fb075ff9..6f60ff94ef6c 100644
--- a/testcases/kernel/containers/netns/netns_netlink.c
+++ b/testcases/kernel/containers/netns/netns_netlink.c
@@ -57,7 +57,7 @@ static void child_func(void)
SAFE_BIND(fd, (struct sockaddr *) &sa, sizeof(sa));
/* waits for parent to create an interface */
- TST_CHECKPOINT_WAIT(0);
+ TST_CHECKPOINT_WAKE_AND_WAIT(0);
/*
* To get rid of "resource temporarily unavailable" errors
@@ -98,6 +98,9 @@ static void test_netns_netlink(void)
if (SAFE_FORK() == 0)
child_func();
+ /* wait until child opens netlink socket */
+ TST_CHECKPOINT_WAIT(0);
+
/* creates TAP network interface dummy0 */
if (WEXITSTATUS(system("ip tuntap add dev dummy0 mode tap")))
tst_brk(TBROK, "adding interface failed");
--
2.27.0
More information about the ltp
mailing list