diff mbox series

[bpf-next,v2,4/4] libbpf: Deprecate bpf_prog_test_run_xattr and bpf_prog_test_run

Message ID 20220128012319.2494472-5-delyank@fb.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series migrate from bpf_prog_test_run{,_xattr} | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR success PR summary
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 9 maintainers not CCed: bjorn@kernel.org kpsingh@kernel.org magnus.karlsson@intel.com john.fastabend@gmail.com kafai@fb.com songliubraving@fb.com jonathan.lemon@gmail.com yhs@fb.com netdev@vger.kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning CHECK: Alignment should match open parenthesis
netdev/kdoc success Errors and warnings before: 8 this patch: 8
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next success VM_Test

Commit Message

Delyan Kratunov Jan. 28, 2022, 1:23 a.m. UTC
Closes: https://github.com/libbpf/libbpf/issues/286
Signed-off-by: Delyan Kratunov <delyank@fb.com>
---
 tools/lib/bpf/bpf.h |  8 +++++---
 tools/lib/bpf/xsk.c | 11 +++++++----
 2 files changed, 12 insertions(+), 7 deletions(-)

Comments

Andrii Nakryiko Feb. 1, 2022, 1:37 a.m. UTC | #1
On Thu, Jan 27, 2022 at 5:23 PM Delyan Kratunov <delyank@fb.com> 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@fb.com>
> ---
>  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
>
diff mbox series

Patch

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")
+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
@@ -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);