[PATCH bpf-next v1 3/6] selftests/bpf: update bpf_wq_set_callback macro

Ihor Solodrai
2025-09-24T21:17:46Z

Subsequent patch introduces bpf_wq_set_callback kfunc with an
implicit bpf_prog_aux argument.

To ensure backward compatibility add a weak declaration and make
bpf_wq_set_callback macro to check for the new kfunc first.

Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
---
tools/testing/selftests/bpf/bpf_experimental.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/bpf_experimental.h b/tools/testing/selftests/bpf/bpf_experimental.h
index d89eda3fd8a3..341408d017ea 100644
--- a/tools/testing/selftests/bpf/bpf_experimental.h
+++ b/tools/testing/selftests/bpf/bpf_experimental.h
@@ -583,8 +583,13 @@ extern int bpf_wq_start(struct bpf_wq *wq, unsigned int flags) __weak __ksym;
extern int bpf_wq_set_callback_impl(struct bpf_wq *wq,
int (callback_fn)(void *map, int *key, void *value),
unsigned int flags__k, void *aux__ign) __ksym;
+extern int bpf_wq_set_callback(struct bpf_wq *wq,
+ int (callback_fn)(void *map, int *key, void *value),
+ unsigned int flags) __weak __ksym;
#define bpf_wq_set_callback(timer, cb, flags) \
- bpf_wq_set_callback_impl(timer, cb, flags, NULL)
+ (bpf_wq_set_callback ? \
+ bpf_wq_set_callback(timer, cb, flags) : \
+ bpf_wq_set_callback_impl(timer, cb, flags, NULL))

struct bpf_iter_kmem_cache;
extern int bpf_iter_kmem_cache_new(struct bpf_iter_kmem_cache *it) __weak __ksym;
--
2.51.0