summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/network_helpers.c
diff options
context:
space:
mode:
authorStanislav Fomichev <sdf@google.com>2021-08-04 13:55:24 -0700
committerAndrii Nakryiko <andrii@kernel.org>2021-08-04 16:18:48 -0700
commit372642ea83ff1c71a5d567a704c912359eb59776 (patch)
tree2c14635ce0f301b5000866d151e277400fc1e5c7 /tools/testing/selftests/bpf/network_helpers.c
parent34ad6d9d8c27293e1895b448af7d6cf5d351ad8d (diff)
selftests/bpf: Move netcnt test under test_progs
Rewrite to skel and ASSERT macros as well while we are at it. v3: - replace -f with -A to make it work with busybox ping. -A is available on both busybox and iputils, from the man page: On networks with low RTT this mode is essentially equivalent to flood mode. v2: - don't check result of bpf_map__fd (Yonghong Song) - remove from .gitignore (Andrii Nakryiko) - move ping_command into network_helpers (Andrii Nakryiko) - remove assert() (Andrii Nakryiko) Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/bpf/20210804205524.3748709-1-sdf@google.com
Diffstat (limited to 'tools/testing/selftests/bpf/network_helpers.c')
-rw-r--r--tools/testing/selftests/bpf/network_helpers.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c
index 26468a8f44f3..d6857683397f 100644
--- a/tools/testing/selftests/bpf/network_helpers.c
+++ b/tools/testing/selftests/bpf/network_helpers.c
@@ -310,3 +310,15 @@ int make_sockaddr(int family, const char *addr_str, __u16 port,
}
return -1;
}
+
+char *ping_command(int family)
+{
+ if (family == AF_INET6) {
+ /* On some systems 'ping' doesn't support IPv6, so use ping6 if it is present. */
+ if (!system("which ping6 >/dev/null 2>&1"))
+ return "ping6";
+ else
+ return "ping -6";
+ }
+ return "ping";
+}