* [PATCH bpf] bpf: selftest: Fix flaky tcp_hdr_options test when adding addr to lo
@ 2020-10-12 23:49 Martin KaFai Lau
2020-10-13 21:59 ` Andrii Nakryiko
0 siblings, 1 reply; 2+ messages in thread
From: Martin KaFai Lau @ 2020-10-12 23:49 UTC (permalink / raw)
To: bpf
Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team, netdev,
Andrii Nakryiko
The tcp_hdr_options test adds a "::eB9F" addr to the lo dev.
However, this non loopback address will have a race on ipv6 dad
which may lead to EADDRNOTAVAIL error from time to time.
Even nodad is used in the iproute2 command, there is still a race in
when the route will be added. This will then lead to ENETUNREACH from
time to time.
To avoid the above, this patch uses the default loopback address "::1"
to do the test.
Fixes: ad2f8eb0095e ("bpf: selftests: Tcp header options")
Reported-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
---
.../bpf/prog_tests/tcp_hdr_options.c | 26 +------------------
.../bpf/progs/test_misc_tcp_hdr_options.c | 2 +-
2 files changed, 2 insertions(+), 26 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/tcp_hdr_options.c b/tools/testing/selftests/bpf/prog_tests/tcp_hdr_options.c
index c86e67214a9e..c85174cdcb77 100644
--- a/tools/testing/selftests/bpf/prog_tests/tcp_hdr_options.c
+++ b/tools/testing/selftests/bpf/prog_tests/tcp_hdr_options.c
@@ -15,7 +15,7 @@
#include "test_tcp_hdr_options.skel.h"
#include "test_misc_tcp_hdr_options.skel.h"
-#define LO_ADDR6 "::eB9F"
+#define LO_ADDR6 "::1"
#define CG_NAME "/tcpbpf-hdr-opt-test"
struct bpf_test_option exp_passive_estab_in;
@@ -40,27 +40,6 @@ struct sk_fds {
int active_lport;
};
-static int add_lo_addr(void)
-{
- char ip_addr_cmd[256];
- int cmdlen;
-
- cmdlen = snprintf(ip_addr_cmd, sizeof(ip_addr_cmd),
- "ip -6 addr add %s/128 dev lo scope host",
- LO_ADDR6);
-
- if (CHECK(cmdlen >= sizeof(ip_addr_cmd), "compile ip cmd",
- "failed to add host addr %s to lo. ip cmdlen is too long\n",
- LO_ADDR6))
- return -1;
-
- if (CHECK(system(ip_addr_cmd), "run ip cmd",
- "failed to add host addr %s to lo\n", LO_ADDR6))
- return -1;
-
- return 0;
-}
-
static int create_netns(void)
{
if (CHECK(unshare(CLONE_NEWNET), "create netns",
@@ -72,9 +51,6 @@ static int create_netns(void)
"failed to bring lo link up\n"))
return -1;
- if (add_lo_addr())
- return -1;
-
return 0;
}
diff --git a/tools/testing/selftests/bpf/progs/test_misc_tcp_hdr_options.c b/tools/testing/selftests/bpf/progs/test_misc_tcp_hdr_options.c
index 72ec0178f653..6077a025092c 100644
--- a/tools/testing/selftests/bpf/progs/test_misc_tcp_hdr_options.c
+++ b/tools/testing/selftests/bpf/progs/test_misc_tcp_hdr_options.c
@@ -16,7 +16,7 @@
#define BPF_PROG_TEST_TCP_HDR_OPTIONS
#include "test_tcp_hdr_options.h"
-__u16 last_addr16_n = __bpf_htons(0xeB9F);
+__u16 last_addr16_n = __bpf_htons(1);
__u16 active_lport_n = 0;
__u16 active_lport_h = 0;
__u16 passive_lport_n = 0;
--
2.24.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH bpf] bpf: selftest: Fix flaky tcp_hdr_options test when adding addr to lo
2020-10-12 23:49 [PATCH bpf] bpf: selftest: Fix flaky tcp_hdr_options test when adding addr to lo Martin KaFai Lau
@ 2020-10-13 21:59 ` Andrii Nakryiko
0 siblings, 0 replies; 2+ messages in thread
From: Andrii Nakryiko @ 2020-10-13 21:59 UTC (permalink / raw)
To: Martin KaFai Lau
Cc: bpf, Alexei Starovoitov, Daniel Borkmann, Kernel Team,
Networking, Andrii Nakryiko
On Tue, Oct 13, 2020 at 4:13 AM Martin KaFai Lau <kafai@fb.com> wrote:
>
> The tcp_hdr_options test adds a "::eB9F" addr to the lo dev.
> However, this non loopback address will have a race on ipv6 dad
> which may lead to EADDRNOTAVAIL error from time to time.
>
> Even nodad is used in the iproute2 command, there is still a race in
> when the route will be added. This will then lead to ENETUNREACH from
> time to time.
>
> To avoid the above, this patch uses the default loopback address "::1"
> to do the test.
>
> Fixes: ad2f8eb0095e ("bpf: selftests: Tcp header options")
> Reported-by: Andrii Nakryiko <andriin@fb.com>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> ---
Less shelling out is always good :)
Acked-by: Andrii Nakryiko <andrii@kernel.org>
> .../bpf/prog_tests/tcp_hdr_options.c | 26 +------------------
> .../bpf/progs/test_misc_tcp_hdr_options.c | 2 +-
> 2 files changed, 2 insertions(+), 26 deletions(-)
>
[...]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-14 9:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-12 23:49 [PATCH bpf] bpf: selftest: Fix flaky tcp_hdr_options test when adding addr to lo Martin KaFai Lau
2020-10-13 21:59 ` Andrii Nakryiko
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).