]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftests/bpf: Migrate struct_ops_assoc test to KF_IMPLICIT_ARGS
authorIhor Solodrai <ihor.solodrai@linux.dev>
Tue, 20 Jan 2026 22:26:36 +0000 (14:26 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 21 Jan 2026 00:22:38 +0000 (16:22 -0800)
A test kfunc named bpf_kfunc_multi_st_ops_test_1_impl() is a user of
__prog suffix. Subsequent patch removes __prog support in favor of
KF_IMPLICIT_ARGS, so migrate this kfunc to use implicit argument.

Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Link: https://lore.kernel.org/r/20260120222638.3976562-12-ihor.solodrai@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/struct_ops_assoc.c
tools/testing/selftests/bpf/progs/struct_ops_assoc_in_timer.c
tools/testing/selftests/bpf/progs/struct_ops_assoc_reuse.c
tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h

index 8f1097903e22fff781fd7ec1f1dd839d6876518c..68842e3f936b9f5d69068a1d4c0c50a259291576 100644 (file)
@@ -32,7 +32,7 @@ int BPF_PROG(sys_enter_prog_a, struct pt_regs *regs, long id)
        if (!test_pid || task->pid != test_pid)
                return 0;
 
-       ret = bpf_kfunc_multi_st_ops_test_1_impl(&args, NULL);
+       ret = bpf_kfunc_multi_st_ops_test_1_assoc(&args);
        if (ret != MAP_A_MAGIC)
                test_err_a++;
 
@@ -45,7 +45,7 @@ int syscall_prog_a(void *ctx)
        struct st_ops_args args = {};
        int ret;
 
-       ret = bpf_kfunc_multi_st_ops_test_1_impl(&args, NULL);
+       ret = bpf_kfunc_multi_st_ops_test_1_assoc(&args);
        if (ret != MAP_A_MAGIC)
                test_err_a++;
 
@@ -79,7 +79,7 @@ int BPF_PROG(sys_enter_prog_b, struct pt_regs *regs, long id)
        if (!test_pid || task->pid != test_pid)
                return 0;
 
-       ret = bpf_kfunc_multi_st_ops_test_1_impl(&args, NULL);
+       ret = bpf_kfunc_multi_st_ops_test_1_assoc(&args);
        if (ret != MAP_B_MAGIC)
                test_err_b++;
 
@@ -92,7 +92,7 @@ int syscall_prog_b(void *ctx)
        struct st_ops_args args = {};
        int ret;
 
-       ret = bpf_kfunc_multi_st_ops_test_1_impl(&args, NULL);
+       ret = bpf_kfunc_multi_st_ops_test_1_assoc(&args);
        if (ret != MAP_B_MAGIC)
                test_err_b++;
 
index d5a2ea93428487ca2df56775b9b55dd7134609d5..0bed49e9f21701ef04d9454ca0cc549e9909c404 100644 (file)
@@ -31,7 +31,7 @@ __noinline static int timer_cb(void *map, int *key, struct bpf_timer *timer)
        struct st_ops_args args = {};
 
        recur++;
-       timer_test_1_ret = bpf_kfunc_multi_st_ops_test_1_impl(&args, NULL);
+       timer_test_1_ret = bpf_kfunc_multi_st_ops_test_1_assoc(&args);
        recur--;
 
        timer_cb_run++;
@@ -64,7 +64,7 @@ int syscall_prog(void *ctx)
        struct st_ops_args args = {};
        int ret;
 
-       ret = bpf_kfunc_multi_st_ops_test_1_impl(&args, NULL);
+       ret = bpf_kfunc_multi_st_ops_test_1_assoc(&args);
        if (ret != MAP_MAGIC)
                test_err++;
 
index 5bb6ebf5eed43c8f137117055dcd6d50b17ca656..396b3e58c72977d2bf1cf723f170b209316d2214 100644 (file)
@@ -23,7 +23,7 @@ int BPF_PROG(test_1_a, struct st_ops_args *args)
 
        if (!recur) {
                recur++;
-               ret = bpf_kfunc_multi_st_ops_test_1_impl(args, NULL);
+               ret = bpf_kfunc_multi_st_ops_test_1_assoc(args);
                if (ret != -1)
                        test_err_a++;
                recur--;
@@ -40,7 +40,7 @@ int syscall_prog_a(void *ctx)
        struct st_ops_args args = {};
        int ret;
 
-       ret = bpf_kfunc_multi_st_ops_test_1_impl(&args, NULL);
+       ret = bpf_kfunc_multi_st_ops_test_1_assoc(&args);
        if (ret != MAP_A_MAGIC)
                test_err_a++;
 
@@ -62,7 +62,7 @@ int syscall_prog_b(void *ctx)
        struct st_ops_args args = {};
        int ret;
 
-       ret = bpf_kfunc_multi_st_ops_test_1_impl(&args, NULL);
+       ret = bpf_kfunc_multi_st_ops_test_1_assoc(&args);
        if (ret != MAP_A_MAGIC)
                test_err_b++;
 
index a996b816ecc43c857015fa13f2f6f46b74c021b6..0d542ba643656313b5fa5f78e360ccf6ed62a50d 100644 (file)
@@ -1140,7 +1140,7 @@ __bpf_kfunc int bpf_kfunc_st_ops_inc10(struct st_ops_args *args)
 }
 
 __bpf_kfunc int bpf_kfunc_multi_st_ops_test_1(struct st_ops_args *args, u32 id);
-__bpf_kfunc int bpf_kfunc_multi_st_ops_test_1_impl(struct st_ops_args *args, void *aux_prog);
+__bpf_kfunc int bpf_kfunc_multi_st_ops_test_1_assoc(struct st_ops_args *args, struct bpf_prog_aux *aux);
 
 __bpf_kfunc int bpf_kfunc_implicit_arg(int a, struct bpf_prog_aux *aux);
 __bpf_kfunc int bpf_kfunc_implicit_arg_legacy(int a, int b, struct bpf_prog_aux *aux);
@@ -1187,7 +1187,7 @@ BTF_ID_FLAGS(func, bpf_kfunc_st_ops_test_epilogue, KF_SLEEPABLE)
 BTF_ID_FLAGS(func, bpf_kfunc_st_ops_test_pro_epilogue, KF_SLEEPABLE)
 BTF_ID_FLAGS(func, bpf_kfunc_st_ops_inc10)
 BTF_ID_FLAGS(func, bpf_kfunc_multi_st_ops_test_1)
-BTF_ID_FLAGS(func, bpf_kfunc_multi_st_ops_test_1_impl)
+BTF_ID_FLAGS(func, bpf_kfunc_multi_st_ops_test_1_assoc, KF_IMPLICIT_ARGS)
 BTF_ID_FLAGS(func, bpf_kfunc_implicit_arg, KF_IMPLICIT_ARGS)
 BTF_ID_FLAGS(func, bpf_kfunc_implicit_arg_legacy, KF_IMPLICIT_ARGS)
 BTF_ID_FLAGS(func, bpf_kfunc_implicit_arg_legacy_impl)
@@ -1669,13 +1669,12 @@ int bpf_kfunc_multi_st_ops_test_1(struct st_ops_args *args, u32 id)
 }
 
 /* Call test_1() of the associated struct_ops map */
-int bpf_kfunc_multi_st_ops_test_1_impl(struct st_ops_args *args, void *aux__prog)
+int bpf_kfunc_multi_st_ops_test_1_assoc(struct st_ops_args *args, struct bpf_prog_aux *aux)
 {
-       struct bpf_prog_aux *prog_aux = (struct bpf_prog_aux *)aux__prog;
        struct bpf_testmod_multi_st_ops *st_ops;
        int ret = -1;
 
-       st_ops = (struct bpf_testmod_multi_st_ops *)bpf_prog_get_assoc_struct_ops(prog_aux);
+       st_ops = (struct bpf_testmod_multi_st_ops *)bpf_prog_get_assoc_struct_ops(aux);
        if (st_ops)
                ret = st_ops->test_1(args);
 
index 2357a0340ffe81a3b9a7ea186d1bc910dabb2c2d..225ea30c4e3d8c0be1c3175b116bba8df86f847e 100644 (file)
@@ -161,7 +161,9 @@ void bpf_kfunc_rcu_task_test(struct task_struct *ptr) __ksym;
 struct task_struct *bpf_kfunc_ret_rcu_test(void) __ksym;
 int *bpf_kfunc_ret_rcu_test_nostruct(int rdonly_buf_size) __ksym;
 
-int bpf_kfunc_multi_st_ops_test_1(struct st_ops_args *args, u32 id) __ksym;
-int bpf_kfunc_multi_st_ops_test_1_impl(struct st_ops_args *args, void *aux__prog) __ksym;
+#ifndef __KERNEL__
+extern int bpf_kfunc_multi_st_ops_test_1(struct st_ops_args *args, u32 id) __weak __ksym;
+extern int bpf_kfunc_multi_st_ops_test_1_assoc(struct st_ops_args *args) __weak __ksym;
+#endif
 
 #endif /* _BPF_TESTMOD_KFUNC_H */