Skip to content

Commit a7d322f

Browse files
Yonghong Songgregkh
Yonghong Song
authored andcommitted
selftests/bpf: Fix flaky selftest lwt_redirect/lwt_reroute
[ Upstream commit e7f3187 ] Recently, when running './test_progs -j', I occasionally hit the following errors: test_lwt_redirect:PASS:pthread_create 0 nsec test_lwt_redirect_run:FAIL:netns_create unexpected error: 256 (errno 0) torvalds#142/2 lwt_redirect/lwt_redirect_normal_nomac:FAIL torvalds#142 lwt_redirect:FAIL test_lwt_reroute:PASS:pthread_create 0 nsec test_lwt_reroute_run:FAIL:netns_create unexpected error: 256 (errno 0) test_lwt_reroute:PASS:pthread_join 0 nsec torvalds#143/2 lwt_reroute/lwt_reroute_qdisc_dropped:FAIL torvalds#143 lwt_reroute:FAIL The netns_create() definition looks like below: #define NETNS "ns_lwt" static inline int netns_create(void) { return system("ip netns add " NETNS); } One possibility is that both lwt_redirect and lwt_reroute create netns with the same name "ns_lwt" which may cause conflict. I tried the following example: $ sudo ip netns add abc $ echo $? 0 $ sudo ip netns add abc Cannot create namespace file "/var/run/netns/abc": File exists $ echo $? 1 $ The return code for above netns_create() is 256. The internet search suggests that the return value for 'ip netns add ns_lwt' is 1, which matches the above 'sudo ip netns add abc' example. This patch tried to use different netns names for two tests to avoid 'ip netns add <name>' failure. I ran './test_progs -j' 10 times and all succeeded with lwt_redirect/lwt_reroute tests. Signed-off-by: Yonghong Song <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Tested-by: Eduard Zingerman <[email protected]> Link: https://lore.kernel.org/bpf/[email protected] Stable-dep-of: 16b795c ("selftests/bpf: Fix redefinition errors compiling lwt_reroute.c") Signed-off-by: Sasha Levin <[email protected]>
1 parent fb99b10 commit a7d322f

File tree

3 files changed

+2
-2
lines changed

3 files changed

+2
-2
lines changed

tools/testing/selftests/bpf/prog_tests/lwt_helpers.h

-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
} \
2828
})
2929

30-
#define NETNS "ns_lwt"
31-
3230
static inline int netns_create(void)
3331
{
3432
return system("ip netns add " NETNS);

tools/testing/selftests/bpf/prog_tests/lwt_redirect.c

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
#include <stdbool.h>
5454
#include <stdlib.h>
5555

56+
#define NETNS "ns_lwt_redirect"
5657
#include "lwt_helpers.h"
5758
#include "test_progs.h"
5859
#include "network_helpers.h"

tools/testing/selftests/bpf/prog_tests/lwt_reroute.c

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
* For case 2, force UDP packets to overflow fq limit. As long as kernel
4949
* is not crashed, it is considered successful.
5050
*/
51+
#define NETNS "ns_lwt_reroute"
5152
#include "lwt_helpers.h"
5253
#include "network_helpers.h"
5354
#include <linux/net_tstamp.h>

0 commit comments

Comments
 (0)