From: Leon Hwang <leon.hwang@linux.dev>
To: bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
yonghong.song@linux.dev, song@kernel.org, eddyz87@gmail.com,
me@manjusaka.me, leon.hwang@linux.dev, kernel-patches-bot@fb.com
Subject: [PATCH bpf-next v4 0/4] bpf: Improve error reporting for freplace attachment failure
Date: Mon, 24 Feb 2025 23:33:48 +0800 [thread overview]
Message-ID: <20250224153352.64689-1-leon.hwang@linux.dev> (raw)
This patch series improves error reporting for BPF_LINK_CREATE when
attaching freplace programs. Inspired by the discussion in
"[PATCH bpf-next v2] bpf: Add bpf_check_attach_target_with_klog method to
output failure logs to kernel"[0], this series enhances that freplace
attachment failure returns meaningful logs to userspace, aiding debugging.
Patch breakdown:
1. bpf, verifier: Add missing newline of bpf_log in bpf_check_attach_target
* Add the missing newline in
bpf_log(log, "Target program bound device mismatch").
2. bpf: Improve error reporting for freplace attachment failure
* Extends BPF_LINK_CREATE to report detailed log.
3. bpf, libbpf: Capture error message of freplace attachment failure
* Modifies libbpf to capture freplace attachment failure log.
4. selftests/bpf: Add test case for freplace attachment failure log
* Introduces a selftest to validate error reporting.
Links:
[0] https://lore.kernel.org/bpf/CAEf4BzbbyojuFSS7xQ3+jZb=dHzOaZfMbtT+WnypW2LPwOUwRw@mail.gmail.com/
Changes:
v3 -> v4:
* Add libbpf API bpf_program__attach_freplace_opts() to use users'
supplied log buffer.
v2: https://lore.kernel.org/bpf/20240725051511.57112-1-me@manjusaka.me/
v2 -> v3:
* Address comment from Andrii:
* Report back the reason for declining freplace attachment instead of
logging in dmesg.
Leon Hwang (4):
bpf, verifier: Add missing newline of bpf_log in
bpf_check_attach_target
bpf: Improve error reporting for freplace attachment failure
bpf, libbpf: Capture error message of freplace attachment failure
selftests/bpf: Add test case for freplace attachment failure log
include/uapi/linux/bpf.h | 2 +
kernel/bpf/syscall.c | 51 ++++++++++++++++---
kernel/bpf/verifier.c | 2 +-
tools/include/uapi/linux/bpf.h | 2 +
tools/lib/bpf/bpf.c | 6 ++-
tools/lib/bpf/bpf.h | 2 +
tools/lib/bpf/libbpf.c | 29 +++++++++--
tools/lib/bpf/libbpf.h | 14 +++++
tools/lib/bpf/libbpf.map | 1 +
.../bpf/prog_tests/tracing_link_attach_log.c | 48 +++++++++++++++++
10 files changed, 143 insertions(+), 14 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/tracing_link_attach_log.c
--
2.47.1
next reply other threads:[~2025-02-24 15:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 15:33 Leon Hwang [this message]
2025-02-24 15:33 ` [PATCH bpf-next v4 1/4] bpf, verifier: Add missing newline of bpf_log in bpf_check_attach_target Leon Hwang
2025-02-24 15:33 ` [PATCH bpf-next v4 2/4] bpf: Improve error reporting for freplace attachment failure Leon Hwang
2025-02-24 19:41 ` Alexei Starovoitov
2025-02-24 22:08 ` Andrii Nakryiko
2025-02-25 13:59 ` Leon Hwang
2025-02-25 17:19 ` Andrii Nakryiko
2025-02-26 3:17 ` Alexei Starovoitov
2025-02-26 14:17 ` Leon Hwang
2025-02-25 13:50 ` Leon Hwang
2025-02-25 16:03 ` Alexei Starovoitov
2025-02-24 15:33 ` [PATCH bpf-next v4 3/4] bpf, libbpf: Capture error message of " Leon Hwang
2025-02-24 15:33 ` [PATCH bpf-next v4 4/4] selftests/bpf: Add test case for freplace attachment failure log Leon Hwang
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=20250224153352.64689-1-leon.hwang@linux.dev \
--to=leon.hwang@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=kernel-patches-bot@fb.com \
--cc=me@manjusaka.me \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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