summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFeng Zhou <zhoufeng.zf@bytedance.com>2021-08-01 14:07:09 +0800
committerStephen Hemminger <stephen@networkplumber.org>2021-08-10 19:53:54 -0700
commitbe99929d60436d131aad1cf09b9216971846e32e (patch)
treecf5132959bd0a0ce26626a47e675121b8e06223e /lib
parentc06d313d86c1acb8dd72589816301853ff5a4ac4 (diff)
downloadiproute2-be99929d60436d131aad1cf09b9216971846e32e.tar.gz
lib/bpf: Fix btf_load error lead to enable debug log
Use tc with no verbose, when bpf_btf_attach fail, the conditions: "if (fd < 0 && (errno == ENOSPC || !ctx->log_size))" will make ctx->log_size != 0. And then, bpf_prog_attach, ctx->log_size != 0. so enable debug log. The verifier log sometimes is so chatty on larger programs. bpf_prog_attach is failed. "Log buffer too small to dump verifier log 16777215 bytes (9 tries)!" BTF load failure does not affect prog load. prog still work. So when BTF/PROG load fail, enlarge log_size and re-fail with having verbose. Signed-off-by: Feng Zhou <zhoufeng.zf@bytedance.com> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/bpf_legacy.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/bpf_legacy.c b/lib/bpf_legacy.c
index d57d2635..e8a41e6f 100644
--- a/lib/bpf_legacy.c
+++ b/lib/bpf_legacy.c
@@ -1531,7 +1531,7 @@ retry:
* into our buffer. Still, try to give a debuggable error
* log for the user, so enlarge it and re-fail.
*/
- if (fd < 0 && (errno == ENOSPC || !ctx->log_size)) {
+ if (fd < 0 && errno == ENOSPC) {
if (tries++ < 10 && !bpf_log_realloc(ctx))
goto retry;
@@ -2069,7 +2069,7 @@ retry:
fd = bpf_btf_load(ctx->btf_data->d_buf, ctx->btf_data->d_size,
ctx->log, ctx->log_size);
if (fd < 0 || ctx->verbose) {
- if (fd < 0 && (errno == ENOSPC || !ctx->log_size)) {
+ if (fd < 0 && errno == ENOSPC) {
if (tries++ < 10 && !bpf_log_realloc(ctx))
goto retry;