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 2/9] libbpf: add API to get/set log_level at per-program level
Date: Wed, 1 Dec 2021 15:28:17 -0800 [thread overview]
Message-ID: <20211201232824.3166325-3-andrii@kernel.org> (raw)
In-Reply-To: <20211201232824.3166325-1-andrii@kernel.org>
Add bpf_program__set_log_level() and bpf_program__log_level() to fetch
and adjust log_level sent during BPF_PROG_LOAD command. This allows to
selectively request more or less verbose output in BPF verifier log.
Also bump libbpf version to 0.7 and make these APIs the first in v0.7.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
tools/lib/bpf/libbpf.c | 14 ++++++++++++++
tools/lib/bpf/libbpf.h | 2 ++
tools/lib/bpf/libbpf.map | 6 ++++++
tools/lib/bpf/libbpf_version.h | 2 +-
4 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 5a2f5a6ae2f9..d40c83cc7152 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -8422,6 +8422,20 @@ int bpf_program__set_flags(struct bpf_program *prog, __u32 flags)
return 0;
}
+__u32 bpf_program__log_level(const struct bpf_program *prog)
+{
+ return prog->log_level;
+}
+
+int bpf_program__set_log_level(struct bpf_program *prog, __u32 log_level)
+{
+ if (prog->obj->loaded)
+ return libbpf_err(-EBUSY);
+
+ prog->log_level = log_level;
+ return 0;
+}
+
#define SEC_DEF(sec_pfx, ptype, atype, flags, ...) { \
.sec = sec_pfx, \
.prog_type = BPF_PROG_TYPE_##ptype, \
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index d02139fec4ac..148fa85bab33 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -499,6 +499,8 @@ bpf_program__set_expected_attach_type(struct bpf_program *prog,
LIBBPF_API __u32 bpf_program__flags(const struct bpf_program *prog);
LIBBPF_API int bpf_program__set_flags(struct bpf_program *prog, __u32 flags);
+LIBBPF_API __u32 bpf_program__log_level(const struct bpf_program *prog);
+LIBBPF_API int bpf_program__set_log_level(struct bpf_program *prog, __u32 log_level);
LIBBPF_API int
bpf_program__set_attach_target(struct bpf_program *prog, int attach_prog_fd,
diff --git a/tools/lib/bpf/libbpf.map b/tools/lib/bpf/libbpf.map
index 623002b83b2b..715df3a27389 100644
--- a/tools/lib/bpf/libbpf.map
+++ b/tools/lib/bpf/libbpf.map
@@ -419,3 +419,9 @@ LIBBPF_0.6.0 {
perf_buffer__new_raw;
perf_buffer__new_raw_deprecated;
} LIBBPF_0.5.0;
+
+LIBBPF_0.7.0 {
+ global:
+ bpf_program__log_level;
+ bpf_program__set_log_level;
+};
diff --git a/tools/lib/bpf/libbpf_version.h b/tools/lib/bpf/libbpf_version.h
index dd56d76f291c..0fefefc3500b 100644
--- a/tools/lib/bpf/libbpf_version.h
+++ b/tools/lib/bpf/libbpf_version.h
@@ -4,6 +4,6 @@
#define __LIBBPF_VERSION_H
#define LIBBPF_MAJOR_VERSION 0
-#define LIBBPF_MINOR_VERSION 6
+#define LIBBPF_MINOR_VERSION 7
#endif /* __LIBBPF_VERSION_H */
--
2.30.2
next prev parent reply other threads:[~2021-12-01 23:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-01 23:28 [PATCH bpf-next 0/9] Deprecate bpf_prog_load_xattr() API Andrii Nakryiko
2021-12-01 23:28 ` [PATCH bpf-next 1/9] libbpf: use __u32 fields in bpf_map_create_opts Andrii Nakryiko
2021-12-02 23:28 ` Alexei Starovoitov
2021-12-02 23:40 ` Andrii Nakryiko
2021-12-01 23:28 ` Andrii Nakryiko [this message]
2021-12-01 23:28 ` [PATCH bpf-next 3/9] bpftool: migrate off of deprecated bpf_create_map_xattr() API Andrii Nakryiko
2021-12-01 23:28 ` [PATCH bpf-next 4/9] selftests/bpf: remove recently reintroduced legacy btf__dedup() use Andrii Nakryiko
2021-12-01 23:28 ` [PATCH bpf-next 5/9] selftests/bpf: mute xdpxceiver.c's deprecation warnings Andrii Nakryiko
2021-12-01 23:28 ` [PATCH bpf-next 6/9] selftests/bpf: remove all the uses of deprecated bpf_prog_load_xattr() Andrii Nakryiko
2021-12-01 23:28 ` [PATCH bpf-next 7/9] samples/bpf: clean up samples/bpf build failes Andrii Nakryiko
2021-12-01 23:28 ` [PATCH bpf-next 8/9] samples/bpf: get rid of deprecated libbpf API uses Andrii Nakryiko
2021-12-01 23:28 ` [PATCH bpf-next 9/9] libbpf: deprecate bpf_prog_load_xattr() API Andrii Nakryiko
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=20211201232824.3166325-3-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