Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Lin <glin@suse.com>2019-11-06 17:49:33 +0800
committerGary Lin <glin@suse.com>2019-11-06 17:49:38 +0800
commit2b3b7a6b1d93a146b2ac26851dd696623542b8c7 (patch)
tree45588e2df8ae8df6462729b6f486a7bf28a0ae42
parentee39cd0578a5d09027c26a90bb91db262a38f504 (diff)
selftests/bpf: fix race in test_tcp_rtt test (bsc#1155518).
-rw-r--r--patches.suse/selftests-bpf-fix-race-in-test_tcp_rtt-test.patch95
-rw-r--r--series.conf1
2 files changed, 96 insertions, 0 deletions
diff --git a/patches.suse/selftests-bpf-fix-race-in-test_tcp_rtt-test.patch b/patches.suse/selftests-bpf-fix-race-in-test_tcp_rtt-test.patch
new file mode 100644
index 0000000000..9f53693330
--- /dev/null
+++ b/patches.suse/selftests-bpf-fix-race-in-test_tcp_rtt-test.patch
@@ -0,0 +1,95 @@
+From: Petar Penkov <ppenkov@google.com>
+Date: Fri, 16 Aug 2019 10:08:25 -0700
+Subject: selftests/bpf: fix race in test_tcp_rtt test
+Patch-mainline: v5.4-rc1
+Git-commit: fae55527ac1164b66bee983a4d82ade2bfedb332
+References: bsc#1155518
+
+There is a race in this test between receiving the ACK for the
+single-byte packet sent in the test, and reading the values from the
+map.
+
+This patch fixes this by having the client wait until there are no more
+unacknowledged packets.
+
+Before:
+for i in {1..1000}; do ../net/in_netns.sh ./test_tcp_rtt; \
+done | grep -c PASSED
+< trimmed error messages >
+993
+
+After:
+for i in {1..10000}; do ../net/in_netns.sh ./test_tcp_rtt; \
+done | grep -c PASSED
+10000
+
+Fixes: b55873984dab ("selftests/bpf: test BPF_SOCK_OPS_RTT_CB")
+Signed-off-by: Petar Penkov <ppenkov@google.com>
+Reviewed-by: Stanislav Fomichev <sdf@google.com>
+Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
+Acked-by: Gary Lin <glin@suse.com>
+---
+ tools/testing/selftests/bpf/test_tcp_rtt.c | 31 +++++++++++++++++++++++++++++
+ 1 file changed, 31 insertions(+)
+
+--- a/tools/testing/selftests/bpf/test_tcp_rtt.c
++++ b/tools/testing/selftests/bpf/test_tcp_rtt.c
+@@ -6,6 +6,7 @@
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
++#include <netinet/tcp.h>
+ #include <pthread.h>
+
+ #include <linux/filter.h>
+@@ -34,6 +35,30 @@ static void send_byte(int fd)
+ error(1, errno, "Failed to send single byte");
+ }
+
++static int wait_for_ack(int fd, int retries)
++{
++ struct tcp_info info;
++ socklen_t optlen;
++ int i, err;
++
++ for (i = 0; i < retries; i++) {
++ optlen = sizeof(info);
++ err = getsockopt(fd, SOL_TCP, TCP_INFO, &info, &optlen);
++ if (err < 0) {
++ log_err("Failed to lookup TCP stats");
++ return err;
++ }
++
++ if (info.tcpi_unacked == 0)
++ return 0;
++
++ usleep(10);
++ }
++
++ log_err("Did not receive ACK");
++ return -1;
++}
++
+ static int verify_sk(int map_fd, int client_fd, const char *msg, __u32 invoked,
+ __u32 dsack_dups, __u32 delivered, __u32 delivered_ce,
+ __u32 icsk_retransmits)
+@@ -149,6 +174,11 @@ static int run_test(int cgroup_fd, int s
+ /*icsk_retransmits=*/0);
+
+ send_byte(client_fd);
++ if (wait_for_ack(client_fd, 100) < 0) {
++ err = -1;
++ goto close_client_fd;
++ }
++
+
+ err += verify_sk(map_fd, client_fd, "first payload byte",
+ /*invoked=*/2,
+@@ -157,6 +187,7 @@ static int run_test(int cgroup_fd, int s
+ /*delivered_ce=*/0,
+ /*icsk_retransmits=*/0);
+
++close_client_fd:
+ close(client_fd);
+
+ close_bpf_object:
diff --git a/series.conf b/series.conf
index bc37788aa8..53d0301f77 100644
--- a/series.conf
+++ b/series.conf
@@ -1103,6 +1103,7 @@
patches.suse/net-mlx5e-Move-the-SW-XSK-code-from-NAPI-poll-to-a-s.patch
patches.suse/net-mlx5e-Add-AF_XDP-need_wakeup-support.patch
patches.suse/net-Don-t-call-XDP_SETUP_PROG-when-nothing-is-change.patch
+ patches.suse/selftests-bpf-fix-race-in-test_tcp_rtt-test.patch
patches.suse/bpf-export-bpf_map_inc_not_zero.patch
patches.suse/bpf-support-cloning-sk-storage-on-accept.patch
patches.suse/bpf-sync-bpf.h-to-tools-9e819ffc.patch