From: Hao Luo <haoluo@google.com>
To: Andrii Nakryiko <andriin@fb.com>
Cc: bpf <bpf@vger.kernel.org>, Networking <netdev@vger.kernel.org>,
Alexei Starovoitov <ast@fb.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii.nakryiko@gmail.com>,
Kernel Team <kernel-team@fb.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Song Liu <songliubraving@fb.com>,
Quentin Monnet <quentin@isovalent.com>
Subject: Re: [PATCH bpf-next 1/9] libbpf: generalize libbpf externs support
Date: Thu, 18 Jun 2020 00:38:27 -0700 [thread overview]
Message-ID: <CA+khW7i2vjHuqExnkgAYMeHe9e556pUccjZXti3DxuTjPjiQQQ@mail.gmail.com> (raw)
In-Reply-To: <20200617161832.1438371-2-andriin@fb.com>
On Wed, Jun 17, 2020 at 9:21 AM Andrii Nakryiko <andriin@fb.com> wrote:
>
> Switch existing Kconfig externs to be just one of few possible kinds of more
> generic externs. This refactoring is in preparation for ksymbol extern
> support, added in the follow up patch. There are no functional changes
> intended.
>
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>
> ---
[...]
> @@ -5572,30 +5635,33 @@ static int bpf_object__resolve_externs(struct bpf_object *obj,
> {
> bool need_config = false;
> struct extern_desc *ext;
> + void *kcfg_data;
> int err, i;
> - void *data;
>
> if (obj->nr_extern == 0)
> return 0;
>
> - data = obj->maps[obj->kconfig_map_idx].mmaped;
> + if (obj->kconfig_map_idx >= 0)
> + kcfg_data = obj->maps[obj->kconfig_map_idx].mmaped;
>
> for (i = 0; i < obj->nr_extern; i++) {
> ext = &obj->externs[i];
>
> - if (strcmp(ext->name, "LINUX_KERNEL_VERSION") == 0) {
> - void *ext_val = data + ext->data_off;
> + if (ext->type == EXT_KCFG &&
> + strcmp(ext->name, "LINUX_KERNEL_VERSION") == 0) {
> + void *ext_val = kcfg_data + ext->kcfg.data_off;
> __u32 kver = get_kernel_version();
>
> if (!kver) {
> pr_warn("failed to get kernel version\n");
> return -EINVAL;
> }
> - err = set_ext_value_num(ext, ext_val, kver);
> + err = set_kcfg_value_num(ext, ext_val, kver);
> if (err)
> return err;
> - pr_debug("extern %s=0x%x\n", ext->name, kver);
> - } else if (strncmp(ext->name, "CONFIG_", 7) == 0) {
> + pr_debug("extern (kcfg) %s=0x%x\n", ext->name, kver);
> + } else if (ext->type == EXT_KCFG &&
> + strncmp(ext->name, "CONFIG_", 7) == 0) {
> need_config = true;
> } else {
> pr_warn("unrecognized extern '%s'\n", ext->name);
Ah, we need to initialize kcfg_data, otherwise the compiler will give
a warning on potentially uninitialized data.
next prev parent reply other threads:[~2020-06-18 7:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-17 16:18 [PATCH bpf-next 0/9] libbpf ksym support and bpftool show PIDs Andrii Nakryiko
2020-06-17 16:18 ` [PATCH bpf-next 1/9] libbpf: generalize libbpf externs support Andrii Nakryiko
2020-06-18 7:38 ` Hao Luo [this message]
2020-06-18 17:51 ` Andrii Nakryiko
2020-06-17 16:18 ` [PATCH bpf-next 2/9] libbpf: add support for extracting kernel symbol addresses Andrii Nakryiko
2020-06-17 16:18 ` [PATCH bpf-next 3/9] selftests/bpf: add __ksym extern selftest Andrii Nakryiko
2020-06-17 16:18 ` [PATCH bpf-next 4/9] tools/bpftool: move map/prog parsing logic into common Andrii Nakryiko
2020-06-18 0:30 ` Quentin Monnet
2020-06-17 16:18 ` [PATCH bpf-next 5/9] tools/bpftool: minimize bootstrap bpftool Andrii Nakryiko
2020-06-18 0:30 ` Quentin Monnet
2020-06-17 16:18 ` [PATCH bpf-next 6/9] tools/bpftool: generalize BPF skeleton support and generate vmlinux.h Andrii Nakryiko
2020-06-18 0:30 ` Quentin Monnet
2020-06-17 16:18 ` [PATCH bpf-next 7/9] libbpf: wrap source argument of BPF_CORE_READ macro in parentheses Andrii Nakryiko
2020-06-17 16:18 ` [PATCH bpf-next 8/9] tools/bpftool: show info for processes holding BPF map/prog/link/btf FDs Andrii Nakryiko
2020-06-18 0:24 ` Quentin Monnet
2020-06-18 6:01 ` Andrii Nakryiko
2020-06-18 7:51 ` Quentin Monnet
2020-06-18 17:53 ` Andrii Nakryiko
2020-06-17 16:18 ` [PATCH bpf-next 9/9] tools/bpftool: add documentation and sample output for process info Andrii Nakryiko
2020-06-18 0:25 ` Quentin Monnet
2020-06-18 5:51 ` Andrii Nakryiko
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=CA+khW7i2vjHuqExnkgAYMeHe9e556pUccjZXti3DxuTjPjiQQQ@mail.gmail.com \
--to=haoluo@google.com \
--cc=acme@kernel.org \
--cc=andrii.nakryiko@gmail.com \
--cc=andriin@fb.com \
--cc=ast@fb.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
--cc=quentin@isovalent.com \
--cc=songliubraving@fb.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).