summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2019-09-27 10:23:32 -0400
committerDavid S. Miller <davem@davemloft.net>2019-09-27 10:23:32 -0400
commit3c30819dc68ab9498216421b6846123900c0a6d3 (patch)
tree2da4d8143b0a9f171cb38ba70ca9c1f339b24cef /tools/testing/selftests
parent5c7ff18149fe9f2302f6910cacc80b6183fb0729 (diff)
parent768fb61fcc13b2acaca758275d54c09a65e2968b (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf
Daniel Borkmann says: ==================== pull-request: bpf 2019-09-27 The following pull-request contains BPF updates for your *net* tree. The main changes are: 1) Fix libbpf's BTF dumper to not skip anonymous enum definitions, from Andrii. 2) Fix BTF verifier issues when handling the BTF of vmlinux, from Alexei. 3) Fix nested calls into bpf_event_output() from TCP sockops BPF programs, from Allan. 4) Fix NULL pointer dereference in AF_XDP's xsk map creation when allocation fails, from Jonathan. 5) Remove unneeded 64 byte alignment requirement of the AF_XDP UMEM headroom, from Bjorn. 6) Remove unused XDP_OPTIONS getsockopt() call which results in an error on older kernels, from Toke. 7) Fix a client/server race in tcp_rtt BPF kselftest case, from Stanislav. 8) Fix indentation issue in BTF's btf_enum_check_kflag_member(), from Colin. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools/testing/selftests')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/tcp_rtt.c21
-rw-r--r--tools/testing/selftests/bpf/progs/strobemeta.h5
-rw-r--r--tools/testing/selftests/bpf/test_sysctl.c1
3 files changed, 23 insertions, 4 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/tcp_rtt.c b/tools/testing/selftests/bpf/prog_tests/tcp_rtt.c
index fdc0b3614a9e..a82da555b1b0 100644
--- a/tools/testing/selftests/bpf/prog_tests/tcp_rtt.c
+++ b/tools/testing/selftests/bpf/prog_tests/tcp_rtt.c
@@ -203,14 +203,24 @@ static int start_server(void)
203 return fd; 203 return fd;
204} 204}
205 205
206static pthread_mutex_t server_started_mtx = PTHREAD_MUTEX_INITIALIZER;
207static pthread_cond_t server_started = PTHREAD_COND_INITIALIZER;
208
206static void *server_thread(void *arg) 209static void *server_thread(void *arg)
207{ 210{
208 struct sockaddr_storage addr; 211 struct sockaddr_storage addr;
209 socklen_t len = sizeof(addr); 212 socklen_t len = sizeof(addr);
210 int fd = *(int *)arg; 213 int fd = *(int *)arg;
211 int client_fd; 214 int client_fd;
215 int err;
216
217 err = listen(fd, 1);
218
219 pthread_mutex_lock(&server_started_mtx);
220 pthread_cond_signal(&server_started);
221 pthread_mutex_unlock(&server_started_mtx);
212 222
213 if (CHECK_FAIL(listen(fd, 1)) < 0) { 223 if (CHECK_FAIL(err < 0)) {
214 perror("Failed to listed on socket"); 224 perror("Failed to listed on socket");
215 return NULL; 225 return NULL;
216 } 226 }
@@ -248,7 +258,14 @@ void test_tcp_rtt(void)
248 if (CHECK_FAIL(server_fd < 0)) 258 if (CHECK_FAIL(server_fd < 0))
249 goto close_cgroup_fd; 259 goto close_cgroup_fd;
250 260
251 pthread_create(&tid, NULL, server_thread, (void *)&server_fd); 261 if (CHECK_FAIL(pthread_create(&tid, NULL, server_thread,
262 (void *)&server_fd)))
263 goto close_cgroup_fd;
264
265 pthread_mutex_lock(&server_started_mtx);
266 pthread_cond_wait(&server_started, &server_started_mtx);
267 pthread_mutex_unlock(&server_started_mtx);
268
252 CHECK_FAIL(run_test(cgroup_fd, server_fd)); 269 CHECK_FAIL(run_test(cgroup_fd, server_fd));
253 close(server_fd); 270 close(server_fd);
254close_cgroup_fd: 271close_cgroup_fd:
diff --git a/tools/testing/selftests/bpf/progs/strobemeta.h b/tools/testing/selftests/bpf/progs/strobemeta.h
index 8a399bdfd920..067eb625d01c 100644
--- a/tools/testing/selftests/bpf/progs/strobemeta.h
+++ b/tools/testing/selftests/bpf/progs/strobemeta.h
@@ -413,7 +413,10 @@ static __always_inline void *read_map_var(struct strobemeta_cfg *cfg,
413#else 413#else
414#pragma unroll 414#pragma unroll
415#endif 415#endif
416 for (int i = 0; i < STROBE_MAX_MAP_ENTRIES && i < map.cnt; ++i) { 416 for (int i = 0; i < STROBE_MAX_MAP_ENTRIES; ++i) {
417 if (i >= map.cnt)
418 break;
419
417 descr->key_lens[i] = 0; 420 descr->key_lens[i] = 0;
418 len = bpf_probe_read_str(payload, STROBE_MAX_STR_LEN, 421 len = bpf_probe_read_str(payload, STROBE_MAX_STR_LEN,
419 map.entries[i].key); 422 map.entries[i].key);
diff --git a/tools/testing/selftests/bpf/test_sysctl.c b/tools/testing/selftests/bpf/test_sysctl.c
index 4f8ec1f10a80..a320e3844b17 100644
--- a/tools/testing/selftests/bpf/test_sysctl.c
+++ b/tools/testing/selftests/bpf/test_sysctl.c
@@ -1385,7 +1385,6 @@ static int fixup_sysctl_value(const char *buf, size_t buf_len,
1385 uint8_t raw[sizeof(uint64_t)]; 1385 uint8_t raw[sizeof(uint64_t)];
1386 uint64_t num; 1386 uint64_t num;
1387 } value = {}; 1387 } value = {};
1388 uint8_t c, i;
1389 1388
1390 if (buf_len > sizeof(value)) { 1389 if (buf_len > sizeof(value)) {
1391 log_err("Value is too big (%zd) to use in fixup", buf_len); 1390 log_err("Value is too big (%zd) to use in fixup", buf_len);