mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
selftests/bpf: Migrate struct_ops_assoc test to KF_IMPLICIT_ARGS
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>
This commit is contained in:
parent
d806f31012
commit
bd06b977e0
|
|
@ -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++;
|
||||
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
|
||||
|
|
|
|||
|
|
@ -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++;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user