Re: [PATCH v3 bpf-next 11/11] bpf: Test BPF_SK_REUSEPORT_SELECT_OR_MIGRATE.

2021-04-20 Thread Andrii Nakryiko
On Tue, Apr 20, 2021 at 8:45 AM Kuniyuki Iwashima wrote: > > This patch adds a test for BPF_SK_REUSEPORT_SELECT_OR_MIGRATE and > removes 'static' from settimeo() in network_helpers.c. > > Signed-off-by: Kuniyuki Iwashima > --- Almost everything in prog_tests/migrate_reuseport.c should be static,

Re: [PATCH bpf-next v4 2/3] bpf: selftests: remove percpu macros from bpf_util.h

2021-04-20 Thread Andrii Nakryiko
On Tue, Apr 20, 2021 at 8:58 AM Daniel Borkmann wrote: > > On 4/20/21 3:17 AM, Alexei Starovoitov wrote: > > On Thu, Apr 15, 2021 at 10:47 AM Pedro Tammela wrote: > >> > >> Andrii suggested to remove this abstraction layer and have the percpu > >> handling

Re: [PATCHv2 RFC bpf-next 0/7] bpf: Add support for ftrace probe

2021-04-19 Thread Andrii Nakryiko
> > > > Masami, you may want to use lore.kernel.org to read the history of this > > thread. > > ] > > > > On Thu, 15 Apr 2021 13:45:06 -0700 > > Andrii Nakryiko wrote: > > > > > > I don't know how the BPF code does it, but if you a

Re: [PATCH bpf-next v2 4/4] libbpf: add selftests for TC-BPF API

2021-04-19 Thread Andrii Nakryiko
On Mon, Apr 19, 2021 at 5:18 AM Kumar Kartikeya Dwivedi wrote: > > This adds some basic tests for the low level bpf_tc_cls_* API. > > Reviewed-by: Toke Høiland-Jørgensen > Signed-off-by: Kumar Kartikeya Dwivedi > --- > .../selftests/bpf/prog_tests/test_tc_bpf.c| 112 ++ > ..

[PATCH v2 bpf-next 12/17] libbpf: support extern resolution for BTF-defined maps in .maps section

2021-04-16 Thread Andrii Nakryiko
. In the follow up patches this most probably will be relaxed, with __weak map definitions being able to differ between each other (with non-weak definition always winning, of course). Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/linker.c | 132 + 1 file

[PATCH v2 bpf-next 16/17] selftests/bpf: add global variables linking selftest

2021-04-16 Thread Andrii Nakryiko
-by: Andrii Nakryiko --- tools/testing/selftests/bpf/Makefile | 3 +- .../selftests/bpf/prog_tests/linked_vars.c| 43 +++ .../selftests/bpf/progs/linked_vars1.c| 54 ++ .../selftests/bpf/progs/linked_vars2.c| 55 +++ 4 files

[PATCH v2 bpf-next 17/17] sleftests/bpf: add map linking selftest

2021-04-16 Thread Andrii Nakryiko
-off-by: Andrii Nakryiko --- tools/testing/selftests/bpf/Makefile | 4 +- .../selftests/bpf/prog_tests/linked_maps.c| 30 +++ .../selftests/bpf/progs/linked_maps1.c| 82 +++ .../selftests/bpf/progs/linked_maps2.c| 76 + 4 files

[PATCH v2 bpf-next 13/17] selftests/bpf: use -O0 instead of -Og in selftests builds

2021-04-16 Thread Andrii Nakryiko
turns off any optimization and provides the best debugging experience. Signed-off-by: Andrii Nakryiko --- tools/testing/selftests/bpf/Makefile | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile

[PATCH v2 bpf-next 15/17] selftests/bpf: add function linking selftest

2021-04-16 Thread Andrii Nakryiko
weak function that "lost" (it leaves gaps in code with no ELF symbols); - correct handling of hidden visibility to turn global function into "static" for the purpose of BPF verification. Signed-off-by: Andrii Nakryiko --- tools/testing/selftests/bpf/Makefile |

[PATCH v2 bpf-next 14/17] selftests/bpf: omit skeleton generation for multi-linked BPF object files

2021-04-16 Thread Andrii Nakryiko
n. This is by design, so skip individual BPF skeletons and only validate them as part of their linked final BPF object file and skeleton. Signed-off-by: Andrii Nakryiko --- tools/testing/selftests/bpf/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/testing

[PATCH v2 bpf-next 11/17] libbpf: add linker extern resolution support for functions and global variables

2021-04-16 Thread Andrii Nakryiko
e whole process, but keeps the other parts much simpler due to stability of sec_var and VAR/FUNC types, as well as ELF symbol, so please keep that in mind while reviewing. BTF-defined maps require some extra custom logic and is addressed separate in the next patch, so that to keep this one smalle

[PATCH v2 bpf-next 07/17] libbpf: factor out symtab and relos sanity checks

2021-04-16 Thread Andrii Nakryiko
. No functional changes are intended. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/linker.c | 233 ++--- 1 file changed, 127 insertions(+), 106 deletions(-) diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c index 4e08bc07e635..0bb927226370 100644

[PATCH v2 bpf-next 08/17] libbpf: make few internal helpers available outside of libbpf.c

2021-04-16 Thread Andrii Nakryiko
Make skip_mods_and_typedefs(), btf_kind_str(), and btf_func_linkage() helpers available outside of libbpf.c, to be used by static linker code. Also do few cleanups (error code fixes, comment clean up, etc) that don't deserve their own commit. Signed-off-by: Andrii Nakryiko --- tools/li

[PATCH v2 bpf-next 10/17] libbpf: tighten BTF type ID rewriting with error checking

2021-04-16 Thread Andrii Nakryiko
It should never fail, but if it does, it's better to know about this rather than end up with nonsensical type IDs. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/linker.c | 9 + 1 file changed, 9 insertions(+) diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c

[PATCH v2 bpf-next 09/17] libbpf: extend sanity checking ELF symbols with externs validation

2021-04-16 Thread Andrii Nakryiko
Add logic to validate extern symbols, plus some other minor extra checks, like ELF symbol #0 validation, general symbol visibility and binding validations. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/linker.c | 43 +- 1 file changed, 34 insertions

[PATCH v2 bpf-next 04/17] libbpf: mark BPF subprogs with hidden visibility as static for BPF verifier

2021-04-16 Thread Andrii Nakryiko
ore information (caller's context) into account during a subprogram validation. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/bpf_helpers.h | 8 ++ tools/lib/bpf/btf.c | 5 tools/lib/bpf/libbpf.c | 45 - tools/lib/bpf/li

[PATCH v2 bpf-next 01/17] bpftool: support dumping BTF VAR's "extern" linkage

2021-04-16 Thread Andrii Nakryiko
Add dumping of "extern" linkage for BTF VAR kind. Also shorten "global-allocated" to "global" to be in line with FUNC's "global". Signed-off-by: Andrii Nakryiko --- tools/bpf/bpftool/btf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) dif

[PATCH v2 bpf-next 03/17] libbpf: suppress compiler warning when using SEC() macro with externs

2021-04-16 Thread Andrii Nakryiko
When used on externs SEC() macro will trigger compilation warning about inapplicable `__attribute__((used))`. That's expected for extern declarations, so suppress it with the corresponding _Pragma. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/bpf_helpers.h | 11 +-- 1 file ch

[PATCH v2 bpf-next 06/17] libbpf: refactor BTF map definition parsing

2021-04-16 Thread Andrii Nakryiko
that, but it could be useful for backwards compatibility reasons later. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/libbpf.c | 256 ++-- tools/lib/bpf/libbpf_internal.h | 32 2 files changed, 177 insertions(+), 111 deletions(-) diff --git a/tools/li

[PATCH v2 bpf-next 05/17] libbpf: allow gaps in BPF program sections to support overriden weak functions

2021-04-16 Thread Andrii Nakryiko
iscover all available BPF subprograms and programs. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/libbpf.c | 56 -- 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index ce5558d0a61b..a0e6d6bc47f3 1

[PATCH v2 bpf-next 02/17] bpftool: dump more info about DATASEC members

2021-04-16 Thread Andrii Nakryiko
'bpf_link_fops') [39] DATASEC '.rodata' size=0 vlen=2 type_id=12 offset=0 size=4 (VAR 'input_rodata1') type_id=15 offset=0 size=4 (VAR 'input_rodata_weak') [40] DATASEC 'license' size=0 vlen=1 type_id=24 offset=0 size=4 (VAR 'LICENS

[PATCH v2 bpf-next 00/17] BPF static linker: support externs

2021-04-16 Thread Andrii Nakryiko
addressed in a follow up. Andrii Nakryiko (17): bpftool: support dumping BTF VAR's "extern" linkage bpftool: dump more info about DATASEC members libbpf: suppress compiler warning when using SEC() macro with externs libbpf: mark BPF subprogs with hidden visibility as

Re: [PATCHv5 bpf-next 7/7] selftests/bpf: Use ASSERT macros in lsm test

2021-04-15 Thread Andrii Nakryiko
On Wed, Apr 14, 2021 at 12:52 PM Jiri Olsa wrote: > > Replacing CHECK with ASSERT macros. > > Suggested-by: Andrii Nakryiko > Signed-off-by: Jiri Olsa > --- thanks! Acked-by: Andrii Nakryiko > .../selftests/bpf/prog_tests/test_lsm.c | 27 +++

Re: [PATCHv5 bpf-next 2/7] selftests/bpf: Add missing semicolon

2021-04-15 Thread Andrii Nakryiko
On Wed, Apr 14, 2021 at 5:43 PM Jiri Olsa wrote: > > Adding missing semicolon. > > Fixes: 22ba36351631 ("selftests/bpf: Move and extend ASSERT_xxx() testing > macros") > Signed-off-by: Jiri Olsa > --- this is already fixed by 1969b3c60db6 ("selftests/bpf: Fix the ASSERT_ERR_PTR macro") > tool

Re: [PATCHv5 bpf-next 1/7] bpf: Allow trampoline re-attach for tracing and lsm programs

2021-04-15 Thread Andrii Nakryiko
programs. > > Fixing missing unlock with proper cleanup goto jump reported > by Julia. > > Reported-by: kernel test robot > Reported-by: Julia Lawall > Acked-by: Toke Høiland-Jørgensen > Signed-off-by: Jiri Olsa > --- Acked-by: Andrii Nakryiko > kernel/bpf/sy

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-04-15 Thread Andrii Nakryiko
On Thu, Apr 15, 2021 at 3:10 PM Daniel Borkmann wrote: > > On 4/15/21 1:58 AM, Andrii Nakryiko wrote: > > On Wed, Apr 14, 2021 at 4:32 PM Daniel Borkmann > > wrote: > >> On 4/15/21 1:19 AM, Andrii Nakryiko wrote: > >>> On Wed, Apr 14, 2021 at 3:51

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-04-15 Thread Andrii Nakryiko
On Thu, Apr 15, 2021 at 8:57 AM Toke Høiland-Jørgensen wrote: > > Andrii Nakryiko writes: > > > On Wed, Apr 14, 2021 at 3:51 PM Toke Høiland-Jørgensen > > wrote: > >> > >> Andrii Nakryiko writes: > >> > >> > On Wed, A

Re: [PATCHv2 RFC bpf-next 0/7] bpf: Add support for ftrace probe

2021-04-15 Thread Andrii Nakryiko
On Thu, Apr 15, 2021 at 8:10 AM Steven Rostedt wrote: > > On Wed, 14 Apr 2021 15:46:49 -0700 > Andrii Nakryiko wrote: > > > On Wed, Apr 14, 2021 at 5:19 AM Jiri Olsa wrote: > > > > > > On Tue, Apr 13, 2021 at 06:04:05PM -0700, Andrii Nakryiko wrote: > >

Re: [PATCH bpf-next 12/17] libbpf: support extern resolution for BTF-defined maps in .maps section

2021-04-15 Thread Andrii Nakryiko
On Wed, Apr 14, 2021 at 7:01 PM Alexei Starovoitov wrote: > > On Wed, Apr 14, 2021 at 04:48:25PM -0700, Andrii Nakryiko wrote: > > On Wed, Apr 14, 2021 at 3:00 PM Alexei Starovoitov wrote: > > > > > > On 4/14/21 1:01 PM, Andrii Nakryiko wrote: > > > > A

Re: [PATCH bpf-next 00/17] BPF static linker: support externs

2021-04-14 Thread Andrii Nakryiko
On Wed, Apr 14, 2021 at 1:02 PM Andrii Nakryiko wrote: > > Add BPF static linker support for extern resolution of global variables, > functions, and BTF-defined maps. > > This patch set consists of 4 parts: > - few patches are extending bpftool to simplify working with BTF

Re: [PATCH bpf-next 13/17] selftests/bpf: use -O0 instead of -Og in selftests builds

2021-04-14 Thread Andrii Nakryiko
On Wed, Apr 14, 2021 at 3:15 PM David Laight wrote: > > From: Andrii Nakryiko > > Sent: 14 April 2021 21:02 > > > > While -Og is designed to work well with debugger, it's still inferior to -O0 > > in terms of debuggability experience. It will cause some variabl

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-04-14 Thread Andrii Nakryiko
On Wed, Apr 14, 2021 at 4:32 PM Daniel Borkmann wrote: > > On 4/15/21 1:19 AM, Andrii Nakryiko wrote: > > On Wed, Apr 14, 2021 at 3:51 PM Toke Høiland-Jørgensen > > wrote: > >> Andrii Nakryiko writes: > >>> On Wed, Apr 14, 2021 at 3:58 AM Toke Høiland

Re: [PATCH bpf-next 12/17] libbpf: support extern resolution for BTF-defined maps in .maps section

2021-04-14 Thread Andrii Nakryiko
On Wed, Apr 14, 2021 at 3:00 PM Alexei Starovoitov wrote: > > On 4/14/21 1:01 PM, Andrii Nakryiko wrote: > > Add extra logic to handle map externs (only BTF-defined maps are supported > > for > > linking). Re-use the map parsing logic used during bpf_object__open(). Map &

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-04-14 Thread Andrii Nakryiko
On Wed, Apr 14, 2021 at 3:51 PM Toke Høiland-Jørgensen wrote: > > Andrii Nakryiko writes: > > > On Wed, Apr 14, 2021 at 3:58 AM Toke Høiland-Jørgensen > > wrote: > >> > >> Andrii Nakryiko writes: > >> > >> > On Tue,

Re: [PATCHv2 RFC bpf-next 0/7] bpf: Add support for ftrace probe

2021-04-14 Thread Andrii Nakryiko
On Wed, Apr 14, 2021 at 5:19 AM Jiri Olsa wrote: > > On Tue, Apr 13, 2021 at 06:04:05PM -0700, Andrii Nakryiko wrote: > > On Tue, Apr 13, 2021 at 7:57 AM Jiri Olsa wrote: > > > > > > hi, > > > sending another attempt on speeding up load of multiple probe

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-04-14 Thread Andrii Nakryiko
On Wed, Apr 14, 2021 at 3:58 AM Toke Høiland-Jørgensen wrote: > > Andrii Nakryiko writes: > > > On Tue, Apr 6, 2021 at 3:06 AM Toke Høiland-Jørgensen > > wrote: > >> > >> Andrii Nakryiko writes: > >> > >> > On Sat, Apr 3, 2021 at 1

Re: [PATCHv4 bpf-next 2/5] selftests/bpf: Add re-attach test to fentry_test

2021-04-14 Thread Andrii Nakryiko
On Wed, Apr 14, 2021 at 3:57 AM Jiri Olsa wrote: > > On Tue, Apr 13, 2021 at 02:54:10PM -0700, Andrii Nakryiko wrote: > > SNIP > > > > __u32 duration = 0, retval; > > > + struct bpf_link *link; > > > __u64 *result; > > > >

[PATCH bpf-next 10/17] libbpf: tighten BTF type ID rewriting with error checking

2021-04-14 Thread Andrii Nakryiko
It should never fail, but if it does, it's better to know about this rather than end up with nonsensical type IDs. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/linker.c | 9 + 1 file changed, 9 insertions(+) diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c

[PATCH bpf-next 16/17] selftests/bpf: add global variables linking selftest

2021-04-14 Thread Andrii Nakryiko
-by: Andrii Nakryiko --- tools/testing/selftests/bpf/Makefile | 3 +- .../selftests/bpf/prog_tests/linked_vars.c| 43 + .../selftests/bpf/progs/linked_vars1.c| 60 ++ .../selftests/bpf/progs/linked_vars2.c| 61 +++ 4 files

[PATCH bpf-next 17/17] sleftests/bpf: add map linking selftest

2021-04-14 Thread Andrii Nakryiko
-off-by: Andrii Nakryiko --- tools/testing/selftests/bpf/Makefile | 4 +- .../selftests/bpf/prog_tests/linked_maps.c| 33 ++ .../selftests/bpf/progs/linked_maps1.c| 102 .../selftests/bpf/progs/linked_maps2.c| 112 ++ 4 files

[PATCH bpf-next 14/17] selftests/bpf: omit skeleton generation for multi-linked BPF object files

2021-04-14 Thread Andrii Nakryiko
n. This is by design, so skip individual BPF skeletons and only validate them as part of their linked final BPF object file and skeleton. Signed-off-by: Andrii Nakryiko --- tools/testing/selftests/bpf/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/testing

[PATCH bpf-next 15/17] selftests/bpf: add function linking selftest

2021-04-14 Thread Andrii Nakryiko
weak function that "lost" (it leaves gaps in code with no ELF symbols); - correct handling of hidden visibility to turn global function into "static" for the purpose of BPF verification. Signed-off-by: Andrii Nakryiko --- tools/testing/selftests/bpf/Makefile |

[PATCH bpf-next 13/17] selftests/bpf: use -O0 instead of -Og in selftests builds

2021-04-14 Thread Andrii Nakryiko
turns off any optimization and provides the best debugging experience. Signed-off-by: Andrii Nakryiko --- tools/testing/selftests/bpf/Makefile | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile

[PATCH bpf-next 11/17] libbpf: add linker extern resolution support for functions and global variables

2021-04-14 Thread Andrii Nakryiko
e whole process, but keeps the other parts much simpler due to stability of sec_var and VAR/FUNC types, as well as ELF symbol, so please keep that in mind while reviewing. BTF-defined maps require some extra custom logic and is addressed separate in the next patch, so that to keep this one smalle

[PATCH bpf-next 12/17] libbpf: support extern resolution for BTF-defined maps in .maps section

2021-04-14 Thread Andrii Nakryiko
, so I want to document it here. Otherwise extern maps behave intuitively, just like extern vars and funcs. Weak definitions are also supported. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/linker.c | 167 + 1 file changed, 167 insertions(+) diff --git

[PATCH bpf-next 08/17] libbpf: make few internal helpers available outside of libbpf.c

2021-04-14 Thread Andrii Nakryiko
Make skip_mods_and_typedefs(), btf_kind_str(), and btf_func_linkage() helpers available outside of libbpf.c, to be used by static linker code. Also do few cleanups (error code fixes, comment clean up, etc) that don't deserve their own commit. Signed-off-by: Andrii Nakryiko --- tools/li

[PATCH bpf-next 09/17] libbpf: extend sanity checking ELF symbols with externs validation

2021-04-14 Thread Andrii Nakryiko
Add logic to validate extern symbols, plus some other minor extra checks, like ELF symbol #0 validation, general symbol visibility and binding validations. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/linker.c | 43 +- 1 file changed, 34 insertions

[PATCH bpf-next 05/17] libbpf: allow gaps in BPF program sections to support overriden weak functions

2021-04-14 Thread Andrii Nakryiko
iscover all available BPF subprograms and programs. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/libbpf.c | 56 -- 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index b6a7f62521a6..38c78195ce57 1

[PATCH bpf-next 04/17] libbpf: mark BPF subprogs with hidden visibility as static for BPF verifier

2021-04-14 Thread Andrii Nakryiko
ore information (caller's context) into account during a subprogram validation. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/bpf_helpers.h | 8 ++ tools/lib/bpf/btf.c | 5 tools/lib/bpf/libbpf.c | 45 - tools/lib/bpf/li

[PATCH bpf-next 07/17] libbpf: factor out symtab and relos sanity checks

2021-04-14 Thread Andrii Nakryiko
. No functional changes are intended. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/linker.c | 233 ++--- 1 file changed, 127 insertions(+), 106 deletions(-) diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c index 4e08bc07e635..0bb927226370 100644

[PATCH bpf-next 06/17] libbpf: refactor BTF map definition parsing

2021-04-14 Thread Andrii Nakryiko
that, but it could be useful for backwards compatibility reasons later. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/libbpf.c | 256 ++-- tools/lib/bpf/libbpf_internal.h | 32 2 files changed, 177 insertions(+), 111 deletions(-) diff --git a/tools/li

[PATCH bpf-next 02/17] bpftool: dump more info about DATASEC members

2021-04-14 Thread Andrii Nakryiko
'bpf_link_fops') [39] DATASEC '.rodata' size=0 vlen=2 type_id=12 offset=0 size=4 (VAR 'input_rodata1') type_id=15 offset=0 size=4 (VAR 'input_rodata_weak') [40] DATASEC 'license' size=0 vlen=1 type_id=24 offset=0 size=4 (VAR 'LICENS

[PATCH bpf-next 03/17] libbpf: suppress compiler warning when using SEC() macro with externs

2021-04-14 Thread Andrii Nakryiko
When used on externs SEC() macro will trigger compilation warning about inapplicable `__attribute__((used))`. That's expected for extern declarations, so suppress it with the corresponding _Pragma. Signed-off-by: Andrii Nakryiko --- tools/lib/bpf/bpf_helpers.h | 11 +-- 1 file ch

[PATCH bpf-next 01/17] bpftool: support dumping BTF VAR's "extern" linkage

2021-04-14 Thread Andrii Nakryiko
Add dumping of "extern" linkage for BTF VAR kind. Also shorten "global-allocated" to "global" to be in line with FUNC's "global". Signed-off-by: Andrii Nakryiko --- tools/bpf/bpftool/btf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) dif

[PATCH bpf-next 00/17] BPF static linker: support externs

2021-04-14 Thread Andrii Nakryiko
d there is little reason to do that anyways). This and few other things will be the topic of the next set of patches. Andrii Nakryiko (17): bpftool: support dumping BTF VAR's "extern" linkage bpftool: dump more info about DATASEC members libbpf: suppress compiler warning wh

Re: [PATCHv2 RFC bpf-next 0/7] bpf: Add support for ftrace probe

2021-04-13 Thread Andrii Nakryiko
On Tue, Apr 13, 2021 at 7:57 AM Jiri Olsa wrote: > > hi, > sending another attempt on speeding up load of multiple probes > for bpftrace and possibly other tools (first post in [1]). > > This patchset adds support to attach bpf program directly to > ftrace probe as suggested by Steven and it speed

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-04-13 Thread Andrii Nakryiko
On Tue, Apr 6, 2021 at 3:06 AM Toke Høiland-Jørgensen wrote: > > Andrii Nakryiko writes: > > > On Sat, Apr 3, 2021 at 10:47 AM Alexei Starovoitov > > wrote: > >> > >> On Sat, Apr 03, 2021 at 12:38:06AM +0530, Kumar Kartikeya Dwivedi wrote: > >>

Re: mmotm 2021-04-11-20-47 uploaded (bpf: xsk.c)

2021-04-13 Thread Andrii Nakryiko
On Mon, Apr 12, 2021 at 9:38 AM Randy Dunlap wrote: > > On 4/11/21 8:48 PM, a...@linux-foundation.org wrote: > > The mm-of-the-moment snapshot 2021-04-11-20-47 has been uploaded to > > > >https://www.ozlabs.org/~akpm/mmotm/ > > > > mmotm-readme.txt says > > > > README for mm-of-the-moment: > >

Re: [PATCHv4 bpf-next 1/5] bpf: Allow trampoline re-attach for tracing and lsm programs

2021-04-13 Thread Andrii Nakryiko
On Mon, Apr 12, 2021 at 9:28 AM Jiri Olsa wrote: > > Currently we don't allow re-attaching of trampolines. Once > it's detached, it can't be re-attach even when the program > is still loaded. > > Adding the possibility to re-attach the loaded tracing and > lsm programs. > > Fixing missing unlock w

Re: [PATCHv4 bpf-next 4/5] selftests/bpf: Add re-attach test to lsm test

2021-04-13 Thread Andrii Nakryiko
ests/test_lsm.c | 48 +++ > 1 file changed, 38 insertions(+), 10 deletions(-) > Surprised you didn't switch this one to ASSERT, but ok, we can do it some other time ;) Acked-by: Andrii Nakryiko > diff --git a/tools/testing/selftests/bpf/prog_tests/test_lsm.c > b/tools/testing/

Re: [PATCHv4 bpf-next 3/5] selftests/bpf: Add re-attach test to fexit_test

2021-04-13 Thread Andrii Nakryiko
On Mon, Apr 12, 2021 at 9:30 AM Jiri Olsa wrote: > > Adding the test to re-attach (detach/attach again) tracing > fexit programs, plus check that already linked program can't > be attached again. > > Also switching to ASSERT* macros. > > Signed-off-by: Jiri Olsa > --- > .../selftests/bpf/prog_te

Re: [PATCHv4 bpf-next 2/5] selftests/bpf: Add re-attach test to fentry_test

2021-04-13 Thread Andrii Nakryiko
On Mon, Apr 12, 2021 at 9:29 AM Jiri Olsa wrote: > > Adding the test to re-attach (detach/attach again) tracing > fentry programs, plus check that already linked program can't > be attached again. > > Also switching to ASSERT* macros and adding missing ';' in > ASSERT_ERR_PTR macro. > > Signed-off

Re: [PATCH bpf-next v2] libbpf: clarify flags in ringbuf helpers

2021-04-12 Thread Andrii Nakryiko
On Mon, Apr 12, 2021 at 12:25 PM Pedro Tammela wrote: > > In 'bpf_ringbuf_reserve()' we require the flag to '0' at the moment. > > For 'bpf_ringbuf_{discard,submit,output}' a flag of '0' might send a > notification to the process if needed. > > Signed-off-by: Pedro Tammela > --- Great, thanks! A

Re: memory leak in bpf

2021-04-07 Thread Andrii Nakryiko
n both functions were executed and memory was freed > > > > > > > > > > i am marking this one as: > > > > > #syz invalid > > > > > > > > Hi Rustam, > > > > > > > > Thanks for looking into this. > > >

Re: [PATCHv2 bpf-next 5/5] selftests/bpf: Test that module can't be unloaded with attached trampoline

2021-04-07 Thread Andrii Nakryiko
K() usage (please do consider updating to ASSERT): Acked-by: Andrii Nakryiko > .../selftests/bpf/prog_tests/module_attach.c | 23 +++ > 1 file changed, 23 insertions(+) > > diff --git a/tools/testing/selftests/bpf/prog_tests/module_attach.c > b/tools/testin

Re: [PATCHv2 bpf-next 3/5] selftests/bpf: Add re-attach test to fexit_test

2021-04-07 Thread Andrii Nakryiko
On Wed, Apr 7, 2021 at 4:21 AM Jiri Olsa wrote: > > Adding the test to re-attach (detach/attach again) tracing > fexit programs, plus check that already linked program can't > be attached again. > > Fixing the number of check-ed results, which should be 8. > > Signed-off-by: Jiri Olsa > --- > ..

Re: [PATCHv2 bpf-next 2/5] selftests/bpf: Add re-attach test to fentry_test

2021-04-07 Thread Andrii Nakryiko
On Wed, Apr 7, 2021 at 4:21 AM Jiri Olsa wrote: > > Adding the test to re-attach (detach/attach again) tracing > fentry programs, plus check that already linked program can't > be attached again. > > Fixing the number of check-ed results, which should be 8. > > Signed-off-by: Jiri Olsa > --- > .

Re: [PATCH bpf-next] libbpf: clarify flags in ringbuf helpers

2021-04-07 Thread Andrii Nakryiko
On Wed, Apr 7, 2021 at 1:10 PM Pedro Tammela wrote: > > Em qua., 7 de abr. de 2021 às 16:58, Andrii Nakryiko > escreveu: > > > > On Wed, Apr 7, 2021 at 11:43 AM Joe Stringer wrote: > > > > > > Hi Pedro, > > > > > > On Tue, Apr 6,

Re: [PATCH bpf-next] libbpf: clarify flags in ringbuf helpers

2021-04-07 Thread Andrii Nakryiko
On Wed, Apr 7, 2021 at 11:43 AM Joe Stringer wrote: > > Hi Pedro, > > On Tue, Apr 6, 2021 at 11:58 AM Pedro Tammela wrote: > > > > In 'bpf_ringbuf_reserve()' we require the flag to '0' at the moment. > > > > For 'bpf_ringbuf_{discard,submit,output}' a flag of '0' might send a > > notification to

Re: [PATCH bpf-next v2 2/3] libbpf: selftests: refactor 'BPF_PERCPU_TYPE()' and 'bpf_percpu()' macros

2021-04-07 Thread Andrii Nakryiko
On Wed, Apr 7, 2021 at 12:30 PM Pedro Tammela wrote: > > Em qua., 7 de abr. de 2021 às 15:31, Andrii Nakryiko > escreveu: > > > > On Tue, Apr 6, 2021 at 11:55 AM Pedro Tammela wrote: > > > > > > This macro was refactored out of the bpf selftests. > &g

Re: [syzbot] memory leak in bpf (2)

2021-04-07 Thread Andrii Nakryiko
On Wed, Mar 31, 2021 at 6:08 PM syzbot wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit:0f4498ce Merge tag 'for-5.12/dm-fixes-2' of git://git.kern.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=1250e126d0 > kernel config:

Re: [PATCH bpf-next v2 2/3] libbpf: selftests: refactor 'BPF_PERCPU_TYPE()' and 'bpf_percpu()' macros

2021-04-07 Thread Andrii Nakryiko
On Tue, Apr 6, 2021 at 11:55 AM Pedro Tammela wrote: > > This macro was refactored out of the bpf selftests. > > Since percpu values are rounded up to '8' in the kernel, a careless > user in userspace might encounter unexpected values when parsing the > output of the batched operations. I wonder

Re: [PATCH v4 bpf 2/3] libbpf: restore umem state after socket create failure

2021-04-07 Thread Andrii Nakryiko
On Tue, Mar 30, 2021 at 11:45 PM Ciara Loftus wrote: > > If the call to xsk_socket__create fails, the user may want to retry the > socket creation using the same umem. Ensure that the umem is in the > same state on exit if the call fails by: > 1. ensuring the umem _save pointers are unmodified. >

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-04-05 Thread Andrii Nakryiko
On Sat, Apr 3, 2021 at 10:47 AM Alexei Starovoitov wrote: > > On Sat, Apr 03, 2021 at 12:38:06AM +0530, Kumar Kartikeya Dwivedi wrote: > > On Sat, Apr 03, 2021 at 12:02:14AM IST, Alexei Starovoitov wrote: > > > On Fri, Apr 2, 2021 at 8:27 AM Kumar Kartikeya Dwivedi > > > wrote: > > > > [...] > >

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-04-05 Thread Andrii Nakryiko
On Fri, Apr 2, 2021 at 8:27 AM Kumar Kartikeya Dwivedi wrote: > > On Fri, Apr 02, 2021 at 05:49:29AM IST, Daniel Borkmann wrote: > > On 3/31/21 11:44 AM, Kumar Kartikeya Dwivedi wrote: > > > On Wed, Mar 31, 2021 at 02:55:47AM IST, Daniel Borkmann wrote: > > > > Do we even need the _block variant?

Re: [PATCH bpf-next] libbpf: Fix KERNEL_VERSION macro

2021-04-05 Thread Andrii Nakryiko
On Sun, Apr 4, 2021 at 9:01 PM Hengqi Chen wrote: > > Add missing ')' for KERNEL_VERSION macro. > > Signed-off-by: Hengqi Chen > --- Applied to bpf-next, thanks. > tools/lib/bpf/bpf_helpers.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/lib/bpf/bpf_helpers.h b

Re: [PATCH] libbpf: Fix KERNEL_VERSION macro

2021-04-04 Thread Andrii Nakryiko
On Sun, Apr 4, 2021 at 2:53 AM Hengqi Chen wrote: > > Add missing ')' for KERNEL_VERSION macro. > > Signed-off-by: Hengqi Chen > --- The fix looks good, thank you. But your patch didn't make it into bpf/netdev patchworks instance ([0]) most probably due to too long CC list. Can you please re-sen

Re: [PATCH bpf-next] bpf: selftests: Specify CONFIG_DYNAMIC_FTRACE in the testing config

2021-04-03 Thread Andrii Nakryiko
On Fri, Apr 2, 2021 at 5:31 PM Martin KaFai Lau wrote: > > The tracing test and the recent kfunc call test require > CONFIG_DYNAMIC_FTRACE. This patch adds it to the config file. > > Signed-off-by: Martin KaFai Lau > --- > tools/testing/selftests/bpf/config | 1 + > 1 file changed, 1 insertion(

Re: [PATCH bpf-next v2] bpf: check flags in 'bpf_ringbuf_discard()' and 'bpf_ringbuf_submit()'

2021-04-03 Thread Andrii Nakryiko
On Sat, Apr 3, 2021 at 6:29 AM Pedro Tammela wrote: > > Em qua., 31 de mar. de 2021 às 04:02, Andrii Nakryiko > escreveu: > > > > On Tue, Mar 30, 2021 at 4:16 PM Alexei Starovoitov > > wrote: > > > > > > On Tue, Mar 30, 2021 at 3:54 PM Pedr

Re: [PATCH bpf-next] bpf: add 'BPF_RB_MAY_WAKEUP' flag

2021-04-03 Thread Andrii Nakryiko
On Sat, Apr 3, 2021 at 6:34 AM Pedro Tammela wrote: > > Em qua., 31 de mar. de 2021 às 03:54, Andrii Nakryiko > escreveu: > > > > On Sun, Mar 28, 2021 at 9:11 AM Pedro Tammela wrote: > > > > > > The current way to provide a no-op flag to 'bpf_ringbuf_

Re: [PATCH v2 bpf-next 00/14] bpf: Support calling kernel function

2021-04-01 Thread Andrii Nakryiko
On Thu, Apr 1, 2021 at 12:51 PM Martin KaFai Lau wrote: > > On Tue, Mar 30, 2021 at 11:44:39PM -0700, Andrii Nakryiko wrote: > > On Mon, Mar 29, 2021 at 12:11 PM Martin KaFai Lau wrote: > > > > > > On Mon, Mar 29, 2021 at 05:06:26PM +0100, Lorenz Bauer wrote: > &

Re: [PATCH v3 bpf-next] tools/resolve_btfids: Fix warnings

2021-03-31 Thread Andrii Nakryiko
On Mon, Mar 29, 2021 at 3:34 PM Stanislav Fomichev wrote: > > * make eprintf static, used only in main.c > * initialize ret in eprintf > * remove unused *tmp > > v3: > * remove another err (Song Liu) > > v2: > * remove unused 'int err = -1' > > Cc: Song Liu > Signed-off-by: Stanislav Fomichev >

Re: [PATCH] selftests/bpf: add LDFLAGS when building test_verifier

2021-03-31 Thread Andrii Nakryiko
On Mon, Mar 29, 2021 at 11:11 AM Jisheng Zhang wrote: > > From: Jisheng Zhang > > This is useful for cross compile process to point linker to the > correct libelf, libcap, libz path. Is this enough to make cross-compilation of selftests/bpf work? I think there was a discussion another day about

Re: [PATCH bpf-next] libbpf: Add '_wait()' and '_nowait()' macros for 'bpf_ring_buffer__poll()'

2021-03-31 Thread Andrii Nakryiko
On Mon, Mar 29, 2021 at 9:28 AM Song Liu wrote: > > > > > On Mar 28, 2021, at 9:10 AM, Pedro Tammela wrote: > > > > 'bpf_ring_buffer__poll()' abstracts the polling method, so abstract the > > constants that make the implementation don't wait or wait indefinetly > > for data. > > > > Signed-off-by

Re: [PATCH bpf-next v2] bpf: check flags in 'bpf_ringbuf_discard()' and 'bpf_ringbuf_submit()'

2021-03-31 Thread Andrii Nakryiko
On Tue, Mar 30, 2021 at 4:16 PM Alexei Starovoitov wrote: > > On Tue, Mar 30, 2021 at 3:54 PM Pedro Tammela wrote: > > > > BPF_CALL_2(bpf_ringbuf_submit, void *, sample, u64, flags) > > { > > + if (unlikely(flags & ~(BPF_RB_NO_WAKEUP | BPF_RB_FORCE_WAKEUP))) > > + return -EI

Re: [PATCH bpf-next] bpf: check flags in 'bpf_ringbuf_discard()' and 'bpf_ringbuf_submit()'

2021-03-30 Thread Andrii Nakryiko
On Sun, Mar 28, 2021 at 9:12 AM Pedro Tammela wrote: > > The current code only checks flags in 'bpf_ringbuf_output()'. > > Signed-off-by: Pedro Tammela > --- > include/uapi/linux/bpf.h | 8 > kernel/bpf/ringbuf.c | 13 +++-- > tools/include/uapi/linux/bpf.h | 8

Re: [PATCH bpf-next] bpf: add 'BPF_RB_MAY_WAKEUP' flag

2021-03-30 Thread Andrii Nakryiko
On Sun, Mar 28, 2021 at 9:11 AM Pedro Tammela wrote: > > The current way to provide a no-op flag to 'bpf_ringbuf_submit()', > 'bpf_ringbuf_discard()' and 'bpf_ringbuf_output()' is to provide a '0' > value. > > A '0' value might notify the consumer if it already caught up in processing, > so let's

Re: [PATCH v2 bpf-next 00/14] bpf: Support calling kernel function

2021-03-30 Thread Andrii Nakryiko
On Mon, Mar 29, 2021 at 12:11 PM Martin KaFai Lau wrote: > > On Mon, Mar 29, 2021 at 05:06:26PM +0100, Lorenz Bauer wrote: > > On Mon, 29 Mar 2021 at 02:25, Martin KaFai Lau wrote: > > > > > > > > > > > > > > > # pahole --version > > > > > > v1.17 > > > > > > > > > > That is the most likely reaso

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-03-30 Thread Andrii Nakryiko
On Sun, Mar 28, 2021 at 1:11 AM Kumar Kartikeya Dwivedi wrote: > > On Sun, Mar 28, 2021 at 10:12:40AM IST, Andrii Nakryiko wrote: > > Is there some succinct but complete enough documentation/tutorial/etc > > that I can reasonably read to understand kernel APIs provided by TC &

Re: [PATCH bpf-next 5/5] libbpf: add selftests for TC-BPF API

2021-03-30 Thread Andrii Nakryiko
On Mon, Mar 29, 2021 at 8:28 PM Alexei Starovoitov wrote: > > On Sun, Mar 28, 2021 at 07:38:42PM -0700, Andrii Nakryiko wrote: > > > > See above. I don't know which hassle is libbpf for users today. You > > were implying code size used for functionality users mi

Re: [PATCH bpf-next 3/3] selftests/bpf: allow compiling BPF objects without BTF

2021-03-30 Thread Andrii Nakryiko
On Mon, Mar 29, 2021 at 11:56 AM Alexei Starovoitov wrote: > > On Sun, Mar 28, 2021 at 11:09:23PM -0700, Andrii Nakryiko wrote: > > > > BPF skeleton works just fine without BTF, if BPF programs don't use > > global data. I have no way of knowing how BPF skeleton

Re: [PATCH bpf-next 3/3] selftests/bpf: allow compiling BPF objects without BTF

2021-03-28 Thread Andrii Nakryiko
On Sun, Mar 28, 2021 at 6:16 PM Alexei Starovoitov wrote: > > On Fri, Mar 26, 2021 at 9:44 AM Andrii Nakryiko > wrote: > > > Because they double the maintenance cost now and double the support > > > forever. > > > We never needed to worry about skeleton wit

Re: [PATCH bpf-next 5/5] libbpf: add selftests for TC-BPF API

2021-03-28 Thread Andrii Nakryiko
On Sun, Mar 28, 2021 at 6:40 PM Alexei Starovoitov wrote: > > On Sat, Mar 27, 2021 at 09:32:58PM -0700, Andrii Nakryiko wrote: > > > I think it's better to start with new library for tc/xdp and have > > > libbpf as a dependency on that new lib. > > > For ex

Re: [PATCH v4 bpf-next 07/12] libbpf: add BPF static linker BTF and BTF.ext support

2021-03-28 Thread Andrii Nakryiko
On Sun, Mar 28, 2021 at 5:03 AM Jiri Olsa wrote: > > On Fri, Mar 19, 2021 at 07:58:13PM +0100, Jiri Olsa wrote: > > On Fri, Mar 19, 2021 at 11:39:01AM -0700, Andrii Nakryiko wrote: > > > On Fri, Mar 19, 2021 at 9:23 AM Jiri Olsa wrote: > > > > > > >

Re: [PATCH bpf v2 2/2] bpf: program: refuse non-O_RDWR flags in BPF_OBJ_GET

2021-03-27 Thread Andrii Nakryiko
t; few > lines above? Map does use f_flags, so we need to let them through. Or did you mean to do a (type != BPF_TYPE_MAP && f_flags != O_RDWR) check? Either way is fine with me, so: Acked-by: Andrii Nakryiko > > Thanks, > Song > > > > > if (type == BP

Re: [PATCH bpf v2 1/2] bpf: link: refuse non-O_RDWR flags in BPF_OBJ_GET

2021-03-27 Thread Andrii Nakryiko
a way to override this behaviour for programs > and links. > > Fixes: 70ed506c3bbc ("bpf: Introduce pinnable bpf_link abstraction") > Signed-off-by: Lorenz Bauer > --- LGTM. Acked-by: Andrii Nakryiko > kernel/bpf/inode.c | 2 +- > 1 file changed, 1 insertion(+), 1

Re: [PATCH bpf-next 3/5] libbpf: add low level TC-BPF API

2021-03-27 Thread Andrii Nakryiko
On Thu, Mar 25, 2021 at 5:02 AM Kumar Kartikeya Dwivedi wrote: > > This adds functions that wrap the netlink API used for adding, > manipulating, and removing filters and actions. These functions operate > directly on the loaded prog's fd, and return a handle to the filter and > action using an ou

Re: [PATCH bpf-next 5/5] libbpf: add selftests for TC-BPF API

2021-03-27 Thread Andrii Nakryiko
On Fri, Mar 26, 2021 at 7:15 PM Alexei Starovoitov wrote: > > On Thu, Mar 25, 2021 at 05:30:03PM +0530, Kumar Kartikeya Dwivedi wrote: > > This adds some basic tests for the low level bpf_tc_* API and its > > bpf_program__attach_tc_* wrapper on top. > > *_block() apis from patch 3 and 4 are not co

[PATCH bpf-next] libbpf: fix memory leak when emitting final btf_ext

2021-03-26 Thread Andrii Nakryiko
Free temporary allocated memory used to construct finalized .BTF.ext data. Found by Coverity static analysis on libbpf's Github repo. Fixes: 8fd27bf69b86 ("libbpf: Add BPF static linker BTF and BTF.ext support") Signed-off-by: Andrii Nakryiko --- tools/lib/bp

Re: [PATCH bpf-next 1/5] tools pkt_cls.h: sync with kernel sources

2021-03-26 Thread Andrii Nakryiko
On Fri, Mar 26, 2021 at 8:54 PM Kumar Kartikeya Dwivedi wrote: > > On Sat, Mar 27, 2021 at 04:55:51AM IST, Andrii Nakryiko wrote: > > On Thu, Mar 25, 2021 at 5:01 AM Kumar Kartikeya Dwivedi > > wrote: > > > > > > Update the header file so we can use the new

  1   2   3   4   5   6   7   8   9   10   >