summaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests
diff options
context:
space:
mode:
authorGeliang Tang <tanggeliang@kylinos.cn>2024-05-23 08:50:01 +0200
committerDaniel Borkmann <daniel@iogearbox.net>2024-06-03 19:32:54 +0200
commit467a0c79b5514d7301ae679770380679a8e32668 (patch)
tree224e364f59fa778004b52221f7184f725633d3f2 /tools/testing/selftests
parentselftests/bpf: Replace tx_prog_fd with tx_prog in test_sockmap (diff)
downloadlinux-467a0c79b5514d7301ae679770380679a8e32668.tar.xz
linux-467a0c79b5514d7301ae679770380679a8e32668.zip
selftests/bpf: Drop prog_fd array in test_sockmap
The program fds can be got by using bpf_program__fd(progs[]), then prog_fd becomes useless. This patch drops it. Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Tested-by: Jakub Sitnicki <jakub@cloudflare.com> Acked-by: John Fastabend <john.fastabend@gmail.com> Link: https://lore.kernel.org/bpf/9a6335e4d8dbab23c0d8906074457ceddd61e74b.1716446893.git.tanggeliang@kylinos.cn
Diffstat (limited to 'tools/testing/selftests')
-rw-r--r--tools/testing/selftests/bpf/test_sockmap.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
index c185c4242abb..64b38a1a1b60 100644
--- a/tools/testing/selftests/bpf/test_sockmap.c
+++ b/tools/testing/selftests/bpf/test_sockmap.c
@@ -63,7 +63,6 @@ int passed;
int failed;
int map_fd[9];
struct bpf_map *maps[9];
-int prog_fd[9];
struct bpf_program *progs[9];
struct bpf_link *links[9];
@@ -1000,7 +999,7 @@ static int run_options(struct sockmap_options *options, int cg_fd, int test)
}
/* Attach to cgroups */
- err = bpf_prog_attach(prog_fd[3], cg_fd, BPF_CGROUP_SOCK_OPS, 0);
+ err = bpf_prog_attach(bpf_program__fd(progs[3]), cg_fd, BPF_CGROUP_SOCK_OPS, 0);
if (err) {
fprintf(stderr, "ERROR: bpf_prog_attach (groups): %d (%s)\n",
err, strerror(errno));
@@ -1279,7 +1278,7 @@ run:
fprintf(stderr, "unknown test\n");
out:
/* Detatch and zero all the maps */
- bpf_prog_detach2(prog_fd[3], cg_fd, BPF_CGROUP_SOCK_OPS);
+ bpf_prog_detach2(bpf_program__fd(progs[3]), cg_fd, BPF_CGROUP_SOCK_OPS);
for (i = 0; i < ARRAY_SIZE(links); i++) {
if (links[i])
@@ -1803,7 +1802,6 @@ static int populate_progs(char *bpf_file)
i = 0;
bpf_object__for_each_program(prog, obj) {
progs[i] = prog;
- prog_fd[i] = bpf_program__fd(prog);
i++;
}