bpftool: fix spurious batch file read error - #13427
bpftool: fix spurious batch file read error#13427kernel-patches-daemon-bpf[bot] wants to merge 1 commit into
Conversation
|
Upstream branch: 5e289c5 |
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: |
|
Forwarding comment 5393617942 via email |
71e031f to
909ca3a
Compare
|
Upstream branch: d83fba2 |
5fe483a to
89a453f
Compare
909ca3a to
b010507
Compare
|
Upstream branch: ce36e38 |
89a453f to
b8c3d37
Compare
b010507 to
975b11a
Compare
|
Upstream branch: 05ea1b6 |
b8c3d37 to
795b412
Compare
975b11a to
f8c8078
Compare
|
Upstream branch: 1555de3 |
795b412 to
4e312da
Compare
f8c8078 to
be2aea4
Compare
|
Upstream branch: 48b69cc |
do_batch() checks errno after the read loop to detect read failures, but fgets() does not clear errno on success, so a stale errno left by a previously executed command (e.g. map dump's EBADF from a double close) makes bpftool report a batch file read failure and exit with an error even though every command succeeded. Clear errno before each fgets() call, so the post-loop check only sees the outcome of the last read: zero on success or EOF, E2BIG for an overlong line, and a genuine errno when fgets() fails. Since errno is now reset before every read in batch mode, drop the USE_LIBCAP errno reset in main() that existed only to keep errno clean for the batch mode. Fixes: 71bb428 ("tools: bpf: add bpftool") Signed-off-by: Yuan Chen <chenyuan@kylinos.cn>
4e312da to
8d7725b
Compare
Pull request for series with
subject: bpftool: fix spurious batch file read error
version: 6
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1150744