]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/bpf: drop the unused kTLS program from test_sockmap
authorJakub Kicinski <kuba@kernel.org>
Sun, 14 Jun 2026 01:40:59 +0000 (18:40 -0700)
committerJakub Kicinski <kuba@kernel.org>
Tue, 16 Jun 2026 15:55:41 +0000 (08:55 -0700)
With the sockmap + kTLS tests gone, the BPF-side support in test_sockmap
is dead: the tls_sock_map map and bpf_prog3 (which redirected skbs into
it) are no longer referenced. Remove them, along with the now-unused
bpf_write_pass() helper.

bpf_prog3 was progs[2], so renumber the progs[] users in test_sockmap.c:
the sockops program drops to progs[2] and the sk_msg tx programs to
progs[3..7]. Shrink the map/prog arrays from 9 to 8 and drop the
tls_sock_map entry (the last one) from map_names[] to match.

Link: https://patch.msgid.link/20260614014102.461064-5-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/bpf/progs/test_sockmap_kern.h
tools/testing/selftests/bpf/test_sockmap.c

index f48f85f1bd7028e8b7a3a140268eec7d4f127d9c..284a2f2e50cffafb3fe902515bc12f5684bd4e36 100644 (file)
@@ -85,13 +85,6 @@ struct {
        __type(value, int);
 } sock_skb_opts SEC(".maps");
 
-struct {
-       __uint(type, TEST_MAP_TYPE);
-       __uint(max_entries, 20);
-       __uint(key_size, sizeof(int));
-       __uint(value_size, sizeof(int));
-} tls_sock_map SEC(".maps");
-
 SEC("sk_skb/stream_parser")
 int bpf_prog1(struct __sk_buff *skb)
 {
@@ -135,55 +128,6 @@ int bpf_prog2(struct __sk_buff *skb)
 
 }
 
-static inline void bpf_write_pass(struct __sk_buff *skb, int offset)
-{
-       int err = bpf_skb_pull_data(skb, 6 + offset);
-       void *data_end;
-       char *c;
-
-       if (err)
-               return;
-
-       c = (char *)(long)skb->data;
-       data_end = (void *)(long)skb->data_end;
-
-       if (c + 5 + offset < data_end)
-               memcpy(c + offset, "PASS", 4);
-}
-
-SEC("sk_skb/stream_verdict")
-int bpf_prog3(struct __sk_buff *skb)
-{
-       int err, *f, ret = SK_PASS;
-       const int one = 1;
-
-       f = bpf_map_lookup_elem(&sock_skb_opts, &one);
-       if (f && *f) {
-               __u64 flags = 0;
-
-               ret = 0;
-               flags = *f;
-
-               err = bpf_skb_adjust_room(skb, -13, 0, 0);
-               if (err)
-                       return SK_DROP;
-               err = bpf_skb_adjust_room(skb, 4, 0, 0);
-               if (err)
-                       return SK_DROP;
-               bpf_write_pass(skb, 0);
-#ifdef SOCKMAP
-               return bpf_sk_redirect_map(skb, &tls_sock_map, ret, flags);
-#else
-               return bpf_sk_redirect_hash(skb, &tls_sock_map, &ret, flags);
-#endif
-       }
-       err = bpf_skb_adjust_room(skb, 4, 0, 0);
-       if (err)
-               return SK_DROP;
-       bpf_write_pass(skb, 13);
-       return ret;
-}
-
 SEC("sockops")
 int bpf_sockmap(struct bpf_sock_ops *skops)
 {
index 32d6068df4b359d0c1ba885fb7f69cf8f8b179a0..ac814eb63edb62c127c4ca517e69a9350ce0da85 100644 (file)
@@ -55,10 +55,10 @@ int s1, s2, c1, c2, p1, p2;
 int test_cnt;
 int passed;
 int failed;
-int map_fd[9];
-struct bpf_map *maps[9];
-struct bpf_program *progs[9];
-struct bpf_link *links[9];
+int map_fd[8];
+struct bpf_map *maps[8];
+struct bpf_program *progs[8];
+struct bpf_link *links[8];
 
 int txmsg_pass;
 int txmsg_redir;
@@ -967,7 +967,7 @@ static int run_options(struct sockmap_options *options, int cg_fd,  int test)
        }
 
        /* Attach to cgroups */
-       err = bpf_prog_attach(bpf_program__fd(progs[3]), cg_fd, BPF_CGROUP_SOCK_OPS, 0);
+       err = bpf_prog_attach(bpf_program__fd(progs[2]), cg_fd, BPF_CGROUP_SOCK_OPS, 0);
        if (err) {
                fprintf(stderr, "ERROR: bpf_prog_attach (groups): %d (%s)\n",
                        err, strerror(errno));
@@ -983,15 +983,15 @@ run:
 
        /* Attach txmsg program to sockmap */
        if (txmsg_pass)
-               tx_prog = progs[4];
+               tx_prog = progs[3];
        else if (txmsg_redir)
-               tx_prog = progs[5];
+               tx_prog = progs[4];
        else if (txmsg_apply)
-               tx_prog = progs[6];
+               tx_prog = progs[5];
        else if (txmsg_cork)
-               tx_prog = progs[7];
+               tx_prog = progs[6];
        else if (txmsg_drop)
-               tx_prog = progs[8];
+               tx_prog = progs[7];
        else
                tx_prog = NULL;
 
@@ -1218,7 +1218,7 @@ run:
                fprintf(stderr, "unknown test\n");
 out:
        /* Detach and zero all the maps */
-       bpf_prog_detach2(bpf_program__fd(progs[3]), cg_fd, BPF_CGROUP_SOCK_OPS);
+       bpf_prog_detach2(bpf_program__fd(progs[2]), cg_fd, BPF_CGROUP_SOCK_OPS);
 
        for (i = 0; i < ARRAY_SIZE(links); i++) {
                if (links[i])
@@ -1724,7 +1724,6 @@ char *map_names[] = {
        "sock_bytes",
        "sock_redir_flags",
        "sock_skb_opts",
-       "tls_sock_map",
 };
 
 static int populate_progs(char *bpf_file)