bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii@kernel.org>
To: <bpf@vger.kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>
Cc: <andrii@kernel.org>, <kernel-team@fb.com>
Subject: [PATCH bpf-next 6/7] libbpf: schedule open_opts.attach_prog_fd deprecation since v0.7
Date: Wed, 15 Sep 2021 18:58:35 -0700	[thread overview]
Message-ID: <20210916015836.1248906-7-andrii@kernel.org> (raw)
In-Reply-To: <20210916015836.1248906-1-andrii@kernel.org>

bpf_object_open_opts.attach_prog_fd makes a pretty strong assumption
that bpf_object contains either only single freplace BPF program or all
of BPF programs in BPF object are freplaces intended to replace
different subprograms of the same target BPF program. This seems both
a bit confusing, too assuming, and limiting.

We've had bpf_program__set_attach_target() API which allows more
fine-grained control over this, on a per-program level. As such, mark
open_opts.attach_prog_fd as deprecated starting from v0.7, so that we
have one more universal way of setting freplace targets. With previous
change to allow NULL attach_func_name argument, and especially combined
with BPF skeleton, arguable bpf_program__set_attach_target() is a more
convenient and explicit API as well.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
 tools/lib/bpf/libbpf.c        | 3 +++
 tools/lib/bpf/libbpf.h        | 2 ++
 tools/lib/bpf/libbpf_common.h | 5 +++++
 3 files changed, 10 insertions(+)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 552d05a85cbb..6aeeb0e82acc 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -6415,9 +6415,12 @@ static int bpf_object_init_progs(struct bpf_object *obj, const struct bpf_object
 		bpf_program__set_type(prog, prog->sec_def->prog_type);
 		bpf_program__set_expected_attach_type(prog, prog->sec_def->expected_attach_type);
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 		if (prog->sec_def->prog_type == BPF_PROG_TYPE_TRACING ||
 		    prog->sec_def->prog_type == BPF_PROG_TYPE_EXT)
 			prog->attach_prog_fd = OPTS_GET(opts, attach_prog_fd, 0);
+#pragma GCC diagnostic pop
 	}
 
 	return 0;
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 7111e8d651de..52b7ee090037 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -90,6 +90,8 @@ struct bpf_object_open_opts {
 	 * auto-pinned to that path on load; defaults to "/sys/fs/bpf".
 	 */
 	const char *pin_root_path;
+
+	LIBBPF_DEPRECATED_SINCE(0, 7, "use bpf_program__set_attach_target() on each individual bpf_program")
 	__u32 attach_prog_fd;
 	/* Additional kernel config content that augments and overrides
 	 * system Kconfig for CONFIG_xxx externs.
diff --git a/tools/lib/bpf/libbpf_common.h b/tools/lib/bpf/libbpf_common.h
index 36ac77f2bea2..aaa1efbf6f51 100644
--- a/tools/lib/bpf/libbpf_common.h
+++ b/tools/lib/bpf/libbpf_common.h
@@ -35,6 +35,11 @@
 #else
 #define __LIBBPF_MARK_DEPRECATED_0_6(X)
 #endif
+#if __LIBBPF_CURRENT_VERSION_GEQ(0, 7)
+#define __LIBBPF_MARK_DEPRECATED_0_7(X) X
+#else
+#define __LIBBPF_MARK_DEPRECATED_0_7(X)
+#endif
 
 /* Helper macro to declare and initialize libbpf options struct
  *
-- 
2.30.2


  parent reply	other threads:[~2021-09-16  1:59 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16  1:58 [PATCH bpf-next 0/7] Improve set_attach_target() and deprecate open_opts.attach_prog_fd Andrii Nakryiko
2021-09-16  1:58 ` [PATCH bpf-next 1/7] libbpf: use pre-setup sec_def in libbpf_find_attach_btf_id() Andrii Nakryiko
2021-09-16  2:52   ` Yonghong Song
2021-09-16  1:58 ` [PATCH bpf-next 2/7] selftests/bpf: stop using relaxed_core_relocs which has no effect Andrii Nakryiko
2021-09-16  2:57   ` Yonghong Song
2021-09-16  1:58 ` [PATCH bpf-next 3/7] libbpf: deprecated bpf_object_open_opts.relaxed_core_relocs Andrii Nakryiko
2021-09-16  2:57   ` Yonghong Song
2021-09-16  1:58 ` [PATCH bpf-next 4/7] libbpf: allow skipping attach_func_name in bpf_program__set_attach_target() Andrii Nakryiko
2021-09-16  4:17   ` Yonghong Song
2021-09-17 16:09     ` Alexei Starovoitov
2021-09-17 18:04       ` Andrii Nakryiko
2021-09-16  1:58 ` [PATCH bpf-next 5/7] selftests/bpf: switch fexit_bpf2bpf selftest to set_attach_target() API Andrii Nakryiko
2021-09-16  4:24   ` Yonghong Song
2021-09-16 17:14     ` Andrii Nakryiko
2021-09-16  1:58 ` Andrii Nakryiko [this message]
2021-09-16  4:26   ` [PATCH bpf-next 6/7] libbpf: schedule open_opts.attach_prog_fd deprecation since v0.7 Yonghong Song
2021-09-16  1:58 ` [PATCH bpf-next 7/7] libbpf: constify all high-level program attach APIs Andrii Nakryiko
2021-09-16  4:29   ` Yonghong Song
2021-09-17 16:10 ` [PATCH bpf-next 0/7] Improve set_attach_target() and deprecate open_opts.attach_prog_fd patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210916015836.1248906-7-andrii@kernel.org \
    --to=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).