Commit f43cb0d6 authored by Lorenz Bauer's avatar Lorenz Bauer Committed by Daniel Borkmann

selftests: bpf: Fix detach from sockmap tests

Fix sockmap tests which rely on old bpf_prog_dispatch behaviour.
In the first case, the tests check that detaching without giving
a program succeeds. Since these are not the desired semantics,
invert the condition. In the second case, the clean up code doesn't
supply the necessary program fds.

Fixes: bb0de313 ("bpf: sockmap: Require attach_bpf_fd when detaching a program")
Reported-by: default avatarMartin KaFai Lau <kafai@fb.com>
Signed-off-by: default avatarLorenz Bauer <lmb@cloudflare.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Reviewed-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/20200709115151.75829-1-lmb@cloudflare.com
parent c9a368f1
...@@ -789,19 +789,19 @@ static void test_sockmap(unsigned int tasks, void *data) ...@@ -789,19 +789,19 @@ static void test_sockmap(unsigned int tasks, void *data)
} }
err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_PARSER); err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_PARSER);
if (err) { if (!err) {
printf("Failed empty parser prog detach\n"); printf("Failed empty parser prog detach\n");
goto out_sockmap; goto out_sockmap;
} }
err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_VERDICT); err = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_VERDICT);
if (err) { if (!err) {
printf("Failed empty verdict prog detach\n"); printf("Failed empty verdict prog detach\n");
goto out_sockmap; goto out_sockmap;
} }
err = bpf_prog_detach(fd, BPF_SK_MSG_VERDICT); err = bpf_prog_detach(fd, BPF_SK_MSG_VERDICT);
if (err) { if (!err) {
printf("Failed empty msg verdict prog detach\n"); printf("Failed empty msg verdict prog detach\n");
goto out_sockmap; goto out_sockmap;
} }
...@@ -1090,19 +1090,19 @@ static void test_sockmap(unsigned int tasks, void *data) ...@@ -1090,19 +1090,19 @@ static void test_sockmap(unsigned int tasks, void *data)
assert(status == 0); assert(status == 0);
} }
err = bpf_prog_detach(map_fd_rx, __MAX_BPF_ATTACH_TYPE); err = bpf_prog_detach2(parse_prog, map_fd_rx, __MAX_BPF_ATTACH_TYPE);
if (!err) { if (!err) {
printf("Detached an invalid prog type.\n"); printf("Detached an invalid prog type.\n");
goto out_sockmap; goto out_sockmap;
} }
err = bpf_prog_detach(map_fd_rx, BPF_SK_SKB_STREAM_PARSER); err = bpf_prog_detach2(parse_prog, map_fd_rx, BPF_SK_SKB_STREAM_PARSER);
if (err) { if (err) {
printf("Failed parser prog detach\n"); printf("Failed parser prog detach\n");
goto out_sockmap; goto out_sockmap;
} }
err = bpf_prog_detach(map_fd_rx, BPF_SK_SKB_STREAM_VERDICT); err = bpf_prog_detach2(verdict_prog, map_fd_rx, BPF_SK_SKB_STREAM_VERDICT);
if (err) { if (err) {
printf("Failed parser prog detach\n"); printf("Failed parser prog detach\n");
goto out_sockmap; goto out_sockmap;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment