bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] libbpf: relax check whether BTF is mandatory
@ 2020-02-20  6:26 Andrii Nakryiko
  2020-02-20 19:05 ` Alexei Starovoitov
  0 siblings, 1 reply; 2+ messages in thread
From: Andrii Nakryiko @ 2020-02-20  6:26 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel, hex
  Cc: andrii.nakryiko, kernel-team, Andrii Nakryiko

If BPF program is using BTF-defined maps, BTF is required only for
libbpf itself to process map definitions. If after that BTF fails to
be loaded into kernel (e.g., if it doesn't support BTF at all), this
shouldn't prevent valid BPF program from loading. Existing
retry-without-BTF logic for creating maps will succeed to create such
maps without any problems. So, presence of .maps section shouldn't make
BTF required for kernel. Update the check accordingly.

Validated by ensuring simple BPF program with BTF-defined maps is still
loaded on old kernel without BTF support and map is correctly parsed and
created.

Fixes: abd29c931459 ("libbpf: allow specifying map definitions using BTF")
Reported-by: Julia Kartseva <hex@fb.com>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
---
 tools/lib/bpf/libbpf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 514b1a524abb..0eb10b681413 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -2280,9 +2280,7 @@ static void bpf_object__sanitize_btf_ext(struct bpf_object *obj)
 
 static bool bpf_object__is_btf_mandatory(const struct bpf_object *obj)
 {
-	return obj->efile.btf_maps_shndx >= 0 ||
-		obj->efile.st_ops_shndx >= 0 ||
-		obj->nr_extern > 0;
+	return obj->efile.st_ops_shndx >= 0 || obj->nr_extern > 0;
 }
 
 static int bpf_object__init_btf(struct bpf_object *obj,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf-next] libbpf: relax check whether BTF is mandatory
  2020-02-20  6:26 [PATCH bpf-next] libbpf: relax check whether BTF is mandatory Andrii Nakryiko
@ 2020-02-20 19:05 ` Alexei Starovoitov
  0 siblings, 0 replies; 2+ messages in thread
From: Alexei Starovoitov @ 2020-02-20 19:05 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: bpf, Network Development, Alexei Starovoitov, Daniel Borkmann,
	Julia Kartseva, Andrii Nakryiko, Kernel Team

On Wed, Feb 19, 2020 at 10:27 PM Andrii Nakryiko <andriin@fb.com> wrote:
>
> If BPF program is using BTF-defined maps, BTF is required only for
> libbpf itself to process map definitions. If after that BTF fails to
> be loaded into kernel (e.g., if it doesn't support BTF at all), this
> shouldn't prevent valid BPF program from loading. Existing
> retry-without-BTF logic for creating maps will succeed to create such
> maps without any problems. So, presence of .maps section shouldn't make
> BTF required for kernel. Update the check accordingly.
>
> Validated by ensuring simple BPF program with BTF-defined maps is still
> loaded on old kernel without BTF support and map is correctly parsed and
> created.
>
> Fixes: abd29c931459 ("libbpf: allow specifying map definitions using BTF")
> Reported-by: Julia Kartseva <hex@fb.com>
> Signed-off-by: Andrii Nakryiko <andriin@fb.com>

Applied. Thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-02-20 19:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-20  6:26 [PATCH bpf-next] libbpf: relax check whether BTF is mandatory Andrii Nakryiko
2020-02-20 19:05 ` Alexei Starovoitov

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).