From: Shung-Hsi Yu <shung-hsi.yu@suse.com>
To: David Ahern <dsahern@kernel.org>
Cc: netdev@vger.kernel.org,
"Stephen Hemminger" <stephen@networkplumber.org>,
"Toke Høiland-Jørgensen" <toke@redhat.com>
Subject: Re: [PATCH iproute2-next 2/2] bpf: increase verifier verbosity when in verbose mode
Date: Thu, 19 Oct 2023 09:18:18 +0800 [thread overview]
Message-ID: <ZTCD2v7RuQojbkn-@u94a> (raw)
In-Reply-To: <5a7efbd1-f05b-4b49-d9a8-ef5c4c6b8ee0@kernel.org>
On Wed, Oct 18, 2023 at 08:35:30AM -0600, David Ahern wrote:
> On 10/18/23 12:22 AM, Shung-Hsi Yu wrote:
> > diff --git a/lib/bpf_libbpf.c b/lib/bpf_libbpf.c
> > index f678a710..08692d30 100644
> > --- a/lib/bpf_libbpf.c
> > +++ b/lib/bpf_libbpf.c
> > @@ -285,11 +285,14 @@ static int load_bpf_object(struct bpf_cfg_in *cfg)
> > DECLARE_LIBBPF_OPTS(bpf_object_open_opts, open_opts,
> > .relaxed_maps = true,
> > .pin_root_path = root_path,
> > -#ifdef (LIBBPF_MAJOR_VERSION > 0) || (LIBBPF_MINOR_VERSION >= 7)
> > - .kernel_log_level = 1,
> > -#endif
> > );
> >
> > +#if (LIBBPF_MAJOR_VERSION > 0) || (LIBBPF_MINOR_VERSION >= 7)
> > + open_opts.kernel_log_level = 1;
> > + if (cfg->verbose)
> > + open_opts.kernel_log_level |= 2;
> > +#endif
> > +
> > obj = bpf_object__open_file(cfg->object, &open_opts);
> > if (libbpf_get_error(obj)) {
> > fprintf(stderr, "ERROR: opening BPF object file failed\n");
>
> Why have the first patch if you redo the code here?
Ah, good point. I was trying to separate out libbpf-related changes from
verbosity-increasing changes, hence the first patch. And there I add the
.kernel_log_level field within DECLARE_LIBBPF_OPTS() because that seems to
be how it's usually done.
In the second patch I tried to make log-level changes consistent, having
them all done with `|= 2`, which isn't possible within
DECLARE_LIBBPF_OPTS().
Maybe I should have just have `open_opts.kernel_log_level = 1;` outside of
DECLARE_LIBBPF_OPTS() in the first patch to begin with.
+#if (LIBBPF_MAJOR_VERSION > 0) || (LIBBPF_MINOR_VERSION >= 7)
+ open_opts.kernel_log_level = 1;
+#endif
Followed by
#if (LIBBPF_MAJOR_VERSION > 0) || (LIBBPF_MINOR_VERSION >= 7)
open_opts.kernel_log_level = 1;
+ if (cfg->verbose)
+ open_opts.kernel_log_level |= 2;
#endif
Would be better than
DECLARE_LIBBPF_OPTS(bpf_object_open_opts, open_opts,
.relaxed_maps = true,
.pin_root_path = root_path,
+#ifdef (LIBBPF_MAJOR_VERSION > 0) || (LIBBPF_MINOR_VERSION >= 7)
+ .kernel_log_level = 1,
+#endif
);
Followed by
DECLARE_LIBBPF_OPTS(bpf_object_open_opts, open_opts,
.relaxed_maps = true,
.pin_root_path = root_path,
#ifdef (LIBBPF_MAJOR_VERSION > 0) || (LIBBPF_MINOR_VERSION >= 7)
- .kernel_log_level = 1,
+ .kernel_log_level = cfg->verbose ? (2 | 1) : 1,
#endif
);
I suppose. What do you think?
next prev parent reply other threads:[~2023-10-19 1:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-18 6:22 [PATCH iproute2-next 0/2] Increase BPF verifier verbosity when in verbose mode Shung-Hsi Yu
2023-10-18 6:22 ` [PATCH iproute2-next 1/2] libbpf: set kernel_log_level when available Shung-Hsi Yu
2023-10-18 6:22 ` [PATCH iproute2-next 2/2] bpf: increase verifier verbosity when in verbose mode Shung-Hsi Yu
2023-10-18 14:35 ` David Ahern
2023-10-19 1:18 ` Shung-Hsi Yu [this message]
2023-10-19 19:44 ` David Ahern
2023-10-20 12:09 ` Shung-Hsi Yu
2023-10-18 13:59 ` [PATCH iproute2-next 0/2] Increase BPF " Shung-Hsi Yu
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=ZTCD2v7RuQojbkn-@u94a \
--to=shung-hsi.yu@suse.com \
--cc=dsahern@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
--cc=toke@redhat.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;
as well as URLs for NNTP newsgroup(s).