[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f4e53471-aa20-3579-6d44-85e6b3524b9f@bytedance.com>
Date: Thu, 29 Jul 2021 12:02:20 +0800
From: zhoufeng <zhoufeng.zf@...edance.com>
To: netdev@...r.kernel.org
Cc: stephen@...workplumber.org, kuznet@....inr.ac.ru,
duanxiongchun@...edance.com, wangdongdong.6@...edance.com,
chenzhuowen.simon@...edance.com
Subject: Re: [PATCH] lib/bpf: Fix btf_load error lead to enable debug log
在 2021/7/28 下午5:33, Feng zhou 写道:
> From: Feng Zhou <zhoufeng.zf@...edance.com>
>
> 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@...edance.com>
> ---
> lib/bpf_legacy.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/lib/bpf_legacy.c b/lib/bpf_legacy.c
> index 8a03b9c2..80c49f08 100644
> --- a/lib/bpf_legacy.c
> +++ b/lib/bpf_legacy.c
> @@ -1525,13 +1525,13 @@ retry:
> fd = bpf_prog_load_dev(prog->type, prog->insns, prog->size,
> prog->license, ctx->ifindex,
> ctx->log, ctx->log_size);
> - if (fd < 0 || ctx->verbose) {
> + if (fd < 0 && ctx->verbose) {
> /* The verifier log is pretty chatty, sometimes so chatty
> * on larger programs, that we could fail to dump everything
> * 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 (errno == ENOSPC) {
> if (tries++ < 10 && !bpf_log_realloc(ctx))
> goto retry;
>
> @@ -2068,8 +2068,8 @@ retry:
> errno = 0;
> 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 && ctx->verbose) {
> + if (errno == ENOSPC) {
> if (tries++ < 10 && !bpf_log_realloc(ctx))
> goto retry;
>
>
Sorry, this patch is wrong. please ignore it. I will send a new one.
Powered by blists - more mailing lists