On Thu, Jan 27, 2022 at 5:23 PM Delyan Kratunov <delyank@xxxxxx> wrote: > > Closes: https://github.com/libbpf/libbpf/issues/286 As Daniel mentioned, please add non-empty commit message. As for the "Closes: ", it's not one of "supported" tags in Linux repo, so we've been using a "reference" syntax to introduce it. So something like this commit message would do the trick: Deprecate non-extendable bpf_prog_test_run_xattr() in favor of OPTS-based bpf_prog_test_run_opts() ([0]). [0] Closes: https://github.com/libbpf/libbpf/issues/286 > Signed-off-by: Delyan Kratunov <delyank@xxxxxx> > --- > tools/lib/bpf/bpf.h | 8 +++++--- > tools/lib/bpf/xsk.c | 11 +++++++---- > 2 files changed, 12 insertions(+), 7 deletions(-) > > diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h > index c2e8327010f9..e3d87b35435d 100644 > --- a/tools/lib/bpf/bpf.h > +++ b/tools/lib/bpf/bpf.h > @@ -453,13 +453,15 @@ struct bpf_prog_test_run_attr { > * out: length of cxt_out */ > }; > > -LIBBPF_API int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *test_attr); > +LIBBPF_DEPRECATED_SINCE(0, 7, "use bpf_prog_test_run_opts() instead") please don't remove LIBBPF_API, it still has to be marked with LIBBPF_API for proper shared library visibility > +int bpf_prog_test_run_xattr(struct bpf_prog_test_run_attr *test_attr); > > /* > * bpf_prog_test_run does not check that data_out is large enough. Consider > - * using bpf_prog_test_run_xattr instead. > + * using bpf_prog_test_run_opts instead. > */ > -LIBBPF_API int bpf_prog_test_run(int prog_fd, int repeat, void *data, > +LIBBPF_DEPRECATED_SINCE(0, 7, "use bpf_prog_test_run_opts() instead") > +int bpf_prog_test_run(int prog_fd, int repeat, void *data, > __u32 size, void *data_out, __u32 *size_out, > __u32 *retval, __u32 *duration); > LIBBPF_API int bpf_prog_get_next_id(__u32 start_id, __u32 *next_id); > diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c > index edafe56664f3..843d03b8f58c 100644 > --- a/tools/lib/bpf/xsk.c > +++ b/tools/lib/bpf/xsk.c don't bother with xsk.c, entire file is marked as deprecated and will be removed in libbpf v1.0. It already has deprecation suppressing pragma, so you shouldn't see any compilation warning. > @@ -369,8 +369,7 @@ int xsk_umem__create_v0_0_2(struct xsk_umem **umem_ptr, void *umem_area, > static enum xsk_prog get_xsk_prog(void) > { > enum xsk_prog detected = XSK_PROG_FALLBACK; > - __u32 size_out, retval, duration; > - char data_in = 0, data_out; > + char data_in = 0; > struct bpf_insn insns[] = { > BPF_LD_MAP_FD(BPF_REG_1, 0), > BPF_MOV64_IMM(BPF_REG_2, 0), > @@ -378,6 +377,10 @@ static enum xsk_prog get_xsk_prog(void) > BPF_EMIT_CALL(BPF_FUNC_redirect_map), > BPF_EXIT_INSN(), > }; > + LIBBPF_OPTS(bpf_test_run_opts, test_opts, > + .data_in = &data_in, > + .data_size_in = 1, > + ); > int prog_fd, map_fd, ret, insn_cnt = ARRAY_SIZE(insns); > > map_fd = bpf_map_create(BPF_MAP_TYPE_XSKMAP, NULL, sizeof(int), sizeof(int), 1, NULL); > @@ -392,8 +395,8 @@ static enum xsk_prog get_xsk_prog(void) > return detected; > } > > - ret = bpf_prog_test_run(prog_fd, 0, &data_in, 1, &data_out, &size_out, &retval, &duration); > - if (!ret && retval == XDP_PASS) > + ret = bpf_prog_test_run_opts(prog_fd, &test_opts); > + if (!ret && test_opts.retval == XDP_PASS) > detected = XSK_PROG_REDIRECT_FLAGS; > close(prog_fd); > close(map_fd); > -- > 2.30.2 >