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

2021-04-20 Thread Alexei Starovoitov
On Tue, Apr 20, 2021 at 9:52 AM Jiri Olsa wrote: > > On Tue, Apr 20, 2021 at 08:33:43AM -0700, Alexei Starovoitov wrote: > > On Tue, Apr 20, 2021 at 5:51 AM Jiri Olsa wrote: > > > > > > On Fri, Apr 16, 2021 at 12:48:34PM -0400, Steven Rostedt wrote: > > &g

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

2021-04-20 Thread Alexei Starovoitov
On Tue, Apr 20, 2021 at 5:51 AM Jiri Olsa wrote: > > On Fri, Apr 16, 2021 at 12:48:34PM -0400, Steven Rostedt wrote: > > On Sat, 17 Apr 2021 00:03:04 +0900 > > Masami Hiramatsu wrote: > > > > > > Anyway, IIRC, Masami wasn't sure that the full regs was ever needed for > > > > the > > > > return (

Re: [PATCH bpf-next 1/2] bpf: Remove bpf_jit_enable=2 debugging mode

2021-04-19 Thread Alexei Starovoitov
On Sat, Apr 17, 2021 at 1:16 AM Christophe Leroy wrote: > > > > Le 16/04/2021 à 01:49, Alexei Starovoitov a écrit : > > On Thu, Apr 15, 2021 at 8:41 AM Quentin Monnet > > wrote: > >> > >> 2021-04-15 16:37 UTC+0200 ~ Daniel Borkmann > >>

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

2021-04-19 Thread Alexei Starovoitov
On Thu, Apr 15, 2021 at 10:47 AM Pedro Tammela wrote: > > Andrii suggested to remove this abstraction layer and have the percpu > handling more explicit[1]. > > This patch also updates the tests that relied on the macros. > > [1] > https://lore.kernel.org/bpf/caef4bzymj_zpdq8zi4dbntbojkrpu2tvopys

Re: [PATCH] bpf: fix errno code for unsupported batch ops

2021-04-19 Thread Alexei Starovoitov
On Mon, Apr 19, 2021 at 6:52 AM Pedro Tammela wrote: > > Em dom., 18 de abr. de 2021 às 19:56, Alexei Starovoitov > escreveu: > > > > On Sun, Apr 18, 2021 at 1:03 PM Pedro Tammela wrote: > > > > > > ENOTSUPP is not a valid userland errno[1], which is a

Re: [PATCH] bpf: fix errno code for unsupported batch ops

2021-04-18 Thread Alexei Starovoitov
On Sun, Apr 18, 2021 at 1:03 PM Pedro Tammela wrote: > > ENOTSUPP is not a valid userland errno[1], which is annoying for > userland applications that implement a fallback to iterative, report > errors via 'strerror()' or both. > > The batched ops return this errno whenever an operation > is not i

Re: [PATCH bpf-next 11/15] bpf: Add bpf_sys_close() helper.

2021-04-17 Thread Alexei Starovoitov
On Sat, Apr 17, 2021 at 04:48:53PM +, Al Viro wrote: > On Sat, Apr 17, 2021 at 07:36:39AM -0700, Alexei Starovoitov wrote: > > > The kernel will perform the same work with FDs. The same locks are held > > and the same execution conditions are in both cases. The LSM hooks,

Re: [PATCH bpf-next 11/15] bpf: Add bpf_sys_close() helper.

2021-04-17 Thread Alexei Starovoitov
On Fri, Apr 16, 2021 at 10:01:43PM -0700, Alexei Starovoitov wrote: > On Fri, Apr 16, 2021 at 9:04 PM Al Viro wrote: > > > > On Fri, Apr 16, 2021 at 08:46:05PM -0700, Alexei Starovoitov wrote: > > > On Fri, Apr 16, 2021 at 8:42 PM Al Viro wrote: > > > > > &

Re: [PATCH bpf-next 11/15] bpf: Add bpf_sys_close() helper.

2021-04-16 Thread Alexei Starovoitov
On Fri, Apr 16, 2021 at 9:04 PM Al Viro wrote: > > On Fri, Apr 16, 2021 at 08:46:05PM -0700, Alexei Starovoitov wrote: > > On Fri, Apr 16, 2021 at 8:42 PM Al Viro wrote: > > > > > > On Fri, Apr 16, 2021 at 08:32:20PM -0700, Alexei Starovoitov wrote: &g

Re: [PATCH bpf-next 11/15] bpf: Add bpf_sys_close() helper.

2021-04-16 Thread Alexei Starovoitov
On Fri, Apr 16, 2021 at 8:42 PM Al Viro wrote: > > On Fri, Apr 16, 2021 at 08:32:20PM -0700, Alexei Starovoitov wrote: > > From: Alexei Starovoitov > > > > Add bpf_sys_close() helper to be used by the syscall/loader program to close > > intermediate FDs and othe

[PATCH bpf-next 15/15] selftests/bpf: Convert few tests to light skeleton.

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov Convert few tests that don't use CO-RE to light skeleton. Signed-off-by: Alexei Starovoitov --- tools/testing/selftests/bpf/.gitignore| 1 + tools/testing/selftests/bpf/Makefile | 15 ++- .../selftests/bpf/prog_

[PATCH bpf-next 11/15] bpf: Add bpf_sys_close() helper.

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov Add bpf_sys_close() helper to be used by the syscall/loader program to close intermediate FDs and other cleanup. Signed-off-by: Alexei Starovoitov --- include/uapi/linux/bpf.h | 7 +++ kernel/bpf/syscall.c | 14 ++ tools/include/uapi

[PATCH bpf-next 12/15] libbpf: Change the order of data and text relocations.

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov In order to be able to generate loader program in the later patches change the order of data and text relocations. Also improve the test to include data relos. Signed-off-by: Alexei Starovoitov --- tools/lib/bpf/libbpf.c| 82

[PATCH bpf-next 14/15] bpftool: Use syscall/loader program in "prog load" and "gen skeleton" command.

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov Add -L flag to bpftool to use libbpf gen_trace facility and syscall/loader program for skeleton generation and program loading. "bpftool gen skeleton -L" command will generate a "light skeleton" or "loader skeleton" that is similar to

[PATCH bpf-next 08/15] bpf: Introduce fd_idx

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov Typical program loading sequence involves creating bpf maps and applying map FDs into bpf instructions in various places in the bpf program. This job is done by libbpf that is using compiler generated ELF relocations to patch certain instruction after maps are created

[PATCH bpf-next 09/15] libbpf: Support for fd_idx

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov Add support for FD_IDX make libbpf prefer that approach to loading programs. Signed-off-by: Alexei Starovoitov --- tools/lib/bpf/bpf.c | 1 + tools/lib/bpf/libbpf.c | 70 + tools/lib/bpf/libbpf_internal.h | 1 + 3

[PATCH bpf-next 13/15] libbpf: Generate loader program out of BPF ELF file.

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov The BPF program loading process performed by libbpf is quite complex and consists of the following steps: "open" phase: - parse elf file and remember relocations, sections - collect externs and ksyms including their btf_ids in prog's BTF - patch BTF data

[PATCH bpf-next 07/15] selftests/bpf: Test for btf_load command.

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov Improve selftest to check that btf_load is working from bpf program. Signed-off-by: Alexei Starovoitov --- tools/testing/selftests/bpf/progs/syscall.c | 48 + 1 file changed, 48 insertions(+) diff --git a/tools/testing/selftests/bpf/progs

[PATCH bpf-next 06/15] bpf: Make btf_load command to be bpfptr_t compatible.

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov Similar to prog_load make btf_load command to be availble to bpf_prog_type_syscall program. Signed-off-by: Alexei Starovoitov --- include/linux/btf.h | 2 +- kernel/bpf/btf.c | 8 kernel/bpf/syscall.c | 7 --- 3 files changed, 9 insertions(+), 8

[PATCH bpf-next 10/15] bpf: Add bpf_btf_find_by_name_kind() helper.

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov Add bpf_btf_find_by_name_kind() helper. Signed-off-by: Alexei Starovoitov --- include/linux/bpf.h| 1 + include/uapi/linux/bpf.h | 8 ++ kernel/bpf/btf.c | 51 ++ kernel/bpf/syscall.c | 2

[PATCH bpf-next 05/15] selftests/bpf: Test for syscall program type

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov bpf_prog_type_syscall is a program that creates a bpf map, updates it, and loads another bpf program using bpf_sys_bpf() helper. Signed-off-by: Alexei Starovoitov --- tools/testing/selftests/bpf/Makefile | 1 + .../selftests/bpf/prog_tests/syscall.c

[PATCH bpf-next 03/15] bpf: Prepare bpf syscall to be used from kernel and user space.

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov With the help from bpfptr_t prepare relevant bpf syscall commands to be used from kernel and user space. Signed-off-by: Alexei Starovoitov --- include/linux/bpf.h | 8 +-- kernel/bpf/bpf_iter.c | 13 ++--- kernel/bpf/syscall.c | 110

[PATCH bpf-next 04/15] libbpf: Support for syscall program type

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov Trivial support for syscall program type. Signed-off-by: Alexei Starovoitov --- tools/lib/bpf/libbpf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 9cc2d45b0080..254a0c9aa6cf 100644 --- a/tools/lib/bpf

[PATCH bpf-next 02/15] bpf: Introduce bpfptr_t user/kernel pointer.

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov Similar to sockptr_t introduce bpfptr_t with few additions: make_bpfptr() creates new user/kernel pointer in the same address space as existing user/kernel pointer. bpfptr_add() advances the user/kernel pointer. Signed-off-by: Alexei Starovoitov --- include/linux

[PATCH bpf-next 00/15] bpf: syscall program, FD array, loader program, light skeleton.

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov This is a first step towards signed bpf programs and the third approach of that kind. The first approach was to bring libbpf into the kernel as a user-mode-driver. The second approach was to invent a new file format and let kernel execute that format as a sequence of

[PATCH bpf-next 01/15] bpf: Introduce bpf_sys_bpf() helper and program type.

2021-04-16 Thread Alexei Starovoitov
From: Alexei Starovoitov Add placeholders for bpf_sys_bpf() helper and new program type. Signed-off-by: Alexei Starovoitov --- include/linux/bpf.h| 10 include/linux/bpf_types.h | 2 ++ include/uapi/linux/bpf.h | 8 ++ kernel/bpf/syscall.c | 46

Re: [PATCH bpf-next 1/2] bpf: Remove bpf_jit_enable=2 debugging mode

2021-04-15 Thread Alexei Starovoitov
On Thu, Apr 15, 2021 at 8:41 AM Quentin Monnet wrote: > > 2021-04-15 16:37 UTC+0200 ~ Daniel Borkmann > > On 4/15/21 11:32 AM, Jianlin Lv wrote: > >> For debugging JITs, dumping the JITed image to kernel log is discouraged, > >> "bpftool prog dump jited" is much better way to examine JITed dumps.

Re: [PATCHv5 bpf-next 0/7] bpf: Tracing and lsm programs re-attach

2021-04-15 Thread Alexei Starovoitov
On Wed, Apr 14, 2021 at 12:52 PM Jiri Olsa wrote: > > hi, > while adding test for pinning the module while there's > trampoline attach to it, I noticed that we don't allow > link detach and following re-attach for trampolines. > Adding that for tracing and lsm programs. > > You need to have patch

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

2021-04-15 Thread Alexei Starovoitov
On 4/15/21 1:35 PM, Andrii Nakryiko wrote: How about we start in the most restrictive way first. Each extern would need to specify all the attributes that should match the map definition. That includes max_entries. That way the typedef struct { ... } my_map_t re-use will work right out of the bo

Re: [RFC Patch bpf-next] bpf: introduce bpf timer

2021-04-14 Thread Alexei Starovoitov
On Wed, Apr 14, 2021 at 9:02 PM Cong Wang wrote: > > On Mon, Apr 12, 2021 at 4:01 PM Alexei Starovoitov > wrote: > > > > On Mon, Apr 05, 2021 at 05:36:27PM -0700, Cong Wang wrote: > > > On Fri, Apr 2, 2021 at 4:45 PM Alexei Starovoitov > > > wrote: > &

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

2021-04-14 Thread Alexei Starovoitov
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: > > > Add extra logic to handle map externs (only BTF-defined maps are > > > support

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

2021-04-14 Thread Alexei Starovoitov
On 4/14/21 1:01 PM, Andrii Nakryiko wrote: While -Og is designed to work well with debugger, it's still inferior to -O0 in terms of debuggability experience. It will cause some variables to still be inlined, it will also prevent single-stepping some statements and otherwise interfere with debuggi

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

2021-04-14 Thread Alexei Starovoitov
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 externs are currently restricted to always and only specify map type, key type and/or size, and valu

Re: [PATCH] selftests/bpf: use !E instead of comparing with NULL

2021-04-13 Thread Alexei Starovoitov
On Tue, Apr 13, 2021 at 9:32 AM wrote: > > > -Original Message- > > From: Alexei Starovoitov > > > > On Tue, Apr 13, 2021 at 9:19 AM wrote: > > > > > > > -Original Message- > > > > From: Alexei Starovo

Re: [PATCH] selftests/bpf: use !E instead of comparing with NULL

2021-04-13 Thread Alexei Starovoitov
On Tue, Apr 13, 2021 at 9:19 AM wrote: > > > -Original Message- > > From: Alexei Starovoitov > > > > On Tue, Apr 13, 2021 at 9:10 AM wrote: > > > > > > > > > > > > > -Original Message- > > > > Fro

Re: [PATCH] selftests/bpf: use !E instead of comparing with NULL

2021-04-13 Thread Alexei Starovoitov
On Tue, Apr 13, 2021 at 9:10 AM wrote: > > > > > -Original Message- > > From: Alexei Starovoitov > > > > On Tue, Apr 13, 2021 at 2:52 AM Yang Li wrote: > > > > > > Fix the following coccicheck warnings: > > > ./tools/

Re: [PATCH] selftests/bpf: use !E instead of comparing with NULL

2021-04-13 Thread Alexei Starovoitov
On Tue, Apr 13, 2021 at 2:52 AM Yang Li wrote: > > Fix the following coccicheck warnings: > ./tools/testing/selftests/bpf/progs/profiler.inc.h:189:7-11: WARNING > comparing pointer to 0, suggest !E > ./tools/testing/selftests/bpf/progs/profiler.inc.h:361:7-11: WARNING > comparing pointer to 0, sug

Re: [RFC Patch bpf-next] bpf: introduce bpf timer

2021-04-12 Thread Alexei Starovoitov
On Mon, Apr 05, 2021 at 05:36:27PM -0700, Cong Wang wrote: > On Fri, Apr 2, 2021 at 4:45 PM Alexei Starovoitov > wrote: > > > > On Fri, Apr 02, 2021 at 02:24:51PM -0700, Cong Wang wrote: > > > > > where the key is the timer ID and the value is the timer expire >

Re: BUG: unable to handle kernel paging request in bpf_check

2021-04-12 Thread Alexei Starovoitov
On Mon, Apr 12, 2021 at 12:11 AM Hao Sun wrote: > > Besides, another similar bug occurred while fault injection was enabled. > > BUG: unable to handle kernel paging request in bpf_prog_alloc_no_stats > > RAX: ffda RBX: 0

Re: [RFC PATCH bpf-next 1/4] bpf: Allow trampoline re-attach

2021-04-03 Thread Alexei Starovoitov
On Sat, Apr 03, 2021 at 01:24:12PM +0200, Toke Høiland-Jørgensen wrote: > > if (!prog->aux->dst_trampoline && !tgt_prog) { > > - err = -ENOENT; > > - goto out_unlock; > > + /* > > +* Allow re-attach for tracing programs, if it's currently > > +

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

2021-04-03 Thread Alexei Starovoitov
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: > > > [...] > > > > All of these things are mess

Re: [Patch bpf-next v8 11/16] udp: implement ->read_sock() for sockmap

2021-04-02 Thread Alexei Starovoitov
On Fri, Apr 2, 2021 at 10:12 PM Cong Wang wrote: > > On Wed, Mar 31, 2021 at 11:01 PM John Fastabend > wrote: > > This 'else if' is always true if above is false right? Would be > > impler and clearer IMO as, > > > >if (used <= 0) { > > if (!copied) > >

Re: [RFC Patch bpf-next] bpf: introduce bpf timer

2021-04-02 Thread Alexei Starovoitov
On Fri, Apr 02, 2021 at 02:24:51PM -0700, Cong Wang wrote: > > > where the key is the timer ID and the value is the timer expire > > > timer. > > > > The timer ID is unnecessary. We cannot introduce new IDR for every new > > bpf object. It doesn't scale. > > The IDR is per map, not per timer. Per

Re: [RFC Patch bpf-next] bpf: introduce bpf timer

2021-04-02 Thread Alexei Starovoitov
On Wed, Mar 31, 2021 at 09:26:35PM -0700, Cong Wang wrote: > This patch introduces a bpf timer map and a syscall to create bpf timer > from user-space. That will severely limit timer api usability. I agree with Song here. If user space has to create it there is no reason to introduce new sys_bpf

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

2021-04-02 Thread Alexei Starovoitov
On Fri, Apr 2, 2021 at 8:27 AM Kumar Kartikeya Dwivedi wrote: > > This would be fine, because it's not a fast path or anything, but right now we > return the id using the netlink response, otherwise for query we have to open > the socket, prepare the msg, send and recv again. So it's a minor > op

pull-request: bpf-next 2021-04-01

2021-04-01 Thread Alexei Starovoitov
from: git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git Thanks a lot! Also thanks to reporters, reviewers and testers of commits in this pull-request: Alexei Starovoitov, Andrii Nakryiko, Cong Wang, Jakub Sitnicki, John Fastabend, Lorenz Bauer, Roman Gushchin, Song Liu, Yonghong

pull-request: bpf 2021-04-01

2021-04-01 Thread Alexei Starovoitov
Merge branch 'AF_XDP Socket Creation Fixes' (2021-04-01 14:45:52 -0700) -------- Alexei Starovoitov (1): Merge branch 'AF_XDP Socket Creation Fixes' Ciara Loftus (3): libbpf: Ensure umem pointer is non-NUL

Re: [PATCH v4 bpf 0/3] AF_XDP Socket Creation Fixes

2021-04-01 Thread Alexei Starovoitov
On Wed, Mar 31, 2021 at 12:06 AM Björn Töpel wrote: > > On Wed, 31 Mar 2021 at 08:43, Ciara Loftus wrote: > > > > This series fixes some issues around socket creation for AF_XDP. > > > > Patch 1 fixes a potential NULL pointer dereference in > > xsk_socket__create_shared. > > > > Patch 2 ensures t

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

2021-04-01 Thread Alexei Starovoitov
On Wed, Mar 31, 2021 at 7:04 AM Lorenz Bauer wrote: > > On Fri, 26 Mar 2021 at 16:05, Lorenz Bauer wrote: > > > > Invoking BPF_OBJ_GET on a pinned bpf_link checks the path access > > permissions based on file_flags, but the returned fd ignores flags. > > This means that any user can acquire a "re

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

2021-04-01 Thread Alexei Starovoitov
On Wed, Mar 31, 2021 at 7:04 AM Lorenz Bauer wrote: > > On Fri, 26 Mar 2021 at 16:05, Lorenz Bauer wrote: > > > > Invoking BPF_OBJ_GET on a pinned bpf_link checks the path access > > permissions based on file_flags, but the returned fd ignores flags. > > This means that any user can acquire a "re

Re: [Patch bpf-next v8 00/16] sockmap: introduce BPF_SK_SKB_VERDICT and support UDP

2021-04-01 Thread Alexei Starovoitov
On Thu, Apr 1, 2021 at 10:52 AM John Fastabend wrote: > > Cong Wang wrote: > > From: Cong Wang > > > > We have thousands of services connected to a daemon on every host > > via AF_UNIX dgram sockets, after they are moved into VM, we have to > > add a proxy to forward these communications from VM

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

2021-03-30 Thread Alexei Starovoitov
On Tue, Mar 30, 2021 at 2:26 PM Daniel Borkmann wrote: > > On 3/30/21 10:39 PM, Andrii Nakryiko wrote: > > 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 docume

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

2021-03-30 Thread Alexei Starovoitov
On Tue, Mar 30, 2021 at 1:28 PM Andrii Nakryiko wrote: > > > > In the other thread you've proposed to copy paste hash implemenation > > into pahole. That's not ideal. If we had libbpfutil other projects > > could have used that without copy-paste. > > I know it's not ideal. But I don't think libbp

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

2021-03-30 Thread Alexei Starovoitov
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 -EINVAL; > + > bpf_ringbuf_commit(sample, flags, false /* discard */

Re: [PATCH v5 bpf-next 00/17] AF_XDP selftests improvements & bpf_link

2021-03-30 Thread Alexei Starovoitov
On Mon, Mar 29, 2021 at 3:54 PM Maciej Fijalkowski wrote: > > Changes since v4 (all in patch 6): > - do not close potentially invalid bpf_link fd (Toke) > - fix misspelling in label (Toke) > - mask out XDP_FLAGS_UPDATE_IF_NOEXIST and XDP_FLAGS_REPLACE explicitly when > creating bpf_link (Toke)

Re: [PATCH bpf-next 0/2] bpf: Update doc about calling kernel function

2021-03-30 Thread Alexei Starovoitov
On Mon, Mar 29, 2021 at 10:41 PM Martin KaFai Lau wrote: > > This set updates the document about the bpf program calling kernel > function. In particular, updates are regarding to the clang > requirement in selftests and kfunc-call not an ABI. Applied.

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

2021-03-30 Thread Alexei Starovoitov
On 3/26/21 9:25 PM, Andrii Nakryiko wrote: 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 Applied.

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

2021-03-30 Thread Alexei Starovoitov
On Tue, Mar 30, 2021 at 5:06 AM 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. > 2

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

2021-03-30 Thread Alexei Starovoitov
On Tue, Mar 30, 2021 at 2:43 AM Lorenz Bauer wrote: > > On Thu, 25 Mar 2021 at 01:52, Martin KaFai Lau wrote: > > > > This series adds support to allow bpf program calling kernel function. > > I think there are more build problems with this. Has anyone hit this before? > > $ CLANG=clang-12 O=../k

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

2021-03-29 Thread Alexei Starovoitov
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 might not use > (e.g., linker). Libbpf is a very small library, <300KB. There are > users building tools f

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

2021-03-29 Thread Alexei Starovoitov
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 is used in the > wild, and specifically whether it is used without BTF and > .data/.rodata. No way of k

Re: [PATCH v2 bpf 3/3] libbpf: ignore return values of setsockopt for XDP rings.

2021-03-29 Thread Alexei Starovoitov
On Mon, Mar 29, 2021 at 1:41 AM Loftus, Ciara wrote: > > > > > On Fri, Mar 26, 2021 at 02:29:46PM +, Ciara Loftus wrote: > > > During xsk_socket__create the XDP_RX_RING and XDP_TX_RING > > setsockopts > > > are called to create the rx and tx rings for the AF_XDP socket. If the > > > ring > >

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

2021-03-28 Thread Alexei Starovoitov
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 example we can add it as subdir in tools/lib/bpf/. > > > > Similarly I think integerating static linking into li

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

2021-03-28 Thread Alexei Starovoitov
On Sat, Mar 27, 2021 at 04:17:16PM +0100, Toke Høiland-Jørgensen wrote: > Alexei Starovoitov writes: > > > 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_progr

Re: [PATCH bpf-next] bpf: tcp: Fix an error in the bpf_tcp_ca_kfunc_ids list

2021-03-28 Thread Alexei Starovoitov
On Sun, Mar 28, 2021 at 5:32 PM Martin KaFai Lau wrote: > > There is a typo in the bbr function, s/even/event/. > This patch fixes it. > > Fixes: e78aea8b2170 ("bpf: tcp: Put some tcp cong functions in allowlist for > bpf-tcp-cc") > Signed-off-by: Martin KaFai Lau Applied.

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

2021-03-28 Thread Alexei Starovoitov
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 without BTF and now it would be > > a thing ? So all tests realistically need to be doubled: with and without > > BTF

Re: [Patch bpf-next v7 00/13] sockmap: introduce BPF_SK_SKB_VERDICT and support UDP

2021-03-28 Thread Alexei Starovoitov
On Sun, Mar 28, 2021 at 01:20:00PM -0700, Cong Wang wrote: > From: Cong Wang > > We have thousands of services connected to a daemon on every host > via AF_UNIX dgram sockets, after they are moved into VM, we have to > add a proxy to forward these communications from VM to host, because > rewriti

Re: [PATCH bpf-next] bpf: tcp: Remove comma which is causing build error

2021-03-28 Thread Alexei Starovoitov
On Sun, Mar 28, 2021 at 5:05 AM Atul Gopinathan wrote: > > Currently, building the bpf-next source with the CONFIG_BPF_SYSCALL > enabled is causing a compilation error: > > "net/ipv4/bpf_tcp_ca.c:209:28: error: expected identifier or '(' before > ',' token" > > Fix this by removing an unnecessary

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

2021-03-27 Thread Alexei Starovoitov
On Sat, Mar 27, 2021 at 3:08 PM Cong Wang wrote: > BTFIDS vmlinux > FAILED unresolved symbol cubictcp_state > make: *** [Makefile:1199: vmlinux] Error 255 > > I suspect it is related to the kernel config or linker version. > > # grep TCP_CONG .config > CONFIG_TCP_CONG_ADVANCED=y > CONFIG_TCP_CO

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

2021-03-27 Thread Alexei Starovoitov
On Sat, Mar 27, 2021 at 2:25 PM Cong Wang wrote: > > Hi, > > On Wed, Mar 24, 2021 at 8:40 PM Martin KaFai Lau wrote: > > Martin KaFai Lau (14): > > bpf: Simplify freeing logic in linfo and jited_linfo > > bpf: Refactor btf_check_func_arg_match > > bpf: Support bpf program calling kernel fun

Re: [PATCH bpf-next] bpf: trace jit code when enable BPF_JIT_ALWAYS_ON

2021-03-27 Thread Alexei Starovoitov
On Sat, Mar 27, 2021 at 1:19 AM Jianlin Lv wrote: > > > On Fri, Mar 26, 2021 at 5:40 AM Jianlin Lv wrote: > > > > > > When CONFIG_BPF_JIT_ALWAYS_ON is enabled, the value of > > bpf_jit_enable > > > in /proc/sys is limited to SYSCTL_ONE. This is not convenient for > > > debugging. > > > This patc

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

2021-03-26 Thread Alexei Starovoitov
On Wed, Mar 24, 2021 at 06:51:42PM -0700, Martin KaFai Lau wrote: > ref_tname = btf_name_by_offset(btf, ref_t->name_off); > - if (btf_get_prog_ctx_type(log, btf, t, env->prog->type, i)) { > + if (btf_is_kernel(btf)) { > + const struct btf_ty

Re: [PATCHv3 bpf] bpf: Take module reference for trampoline in module

2021-03-26 Thread Alexei Starovoitov
On Fri, Mar 26, 2021 at 11:59:00AM +0100, Jiri Olsa wrote: > Currently module can be unloaded even if there's a trampoline > register in it. It's easily reproduced by running in parallel: > > # while :; do ./test_progs -t module_attach; done > # while :; do rmmod bpf_testmod; sleep 0.5; done >

Re: [PATCH v2 bpf 3/3] libbpf: ignore return values of setsockopt for XDP rings.

2021-03-26 Thread Alexei Starovoitov
On Fri, Mar 26, 2021 at 02:29:46PM +, Ciara Loftus wrote: > During xsk_socket__create the XDP_RX_RING and XDP_TX_RING setsockopts > are called to create the rx and tx rings for the AF_XDP socket. If the ring > has already been set up, the setsockopt will return an error. However, > in the event

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

2021-03-26 Thread Alexei Starovoitov
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 covered by this selftest. Why were they added ? And how were they tested

Re: [PATCH bpf-next] bpf: trace jit code when enable BPF_JIT_ALWAYS_ON

2021-03-26 Thread Alexei Starovoitov
On Fri, Mar 26, 2021 at 5:40 AM Jianlin Lv wrote: > > When CONFIG_BPF_JIT_ALWAYS_ON is enabled, the value of bpf_jit_enable in > /proc/sys is limited to SYSCTL_ONE. This is not convenient for debugging. > This patch modifies the value of extra2 (max) to 2 that support developers > to emit traces o

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

2021-03-26 Thread Alexei Starovoitov
On 3/26/21 3:11 AM, Toke Høiland-Jørgensen wrote: Martin KaFai Lau writes: On Thu, Mar 25, 2021 at 11:02:23PM +0100, Toke Høiland-Jørgensen wrote: Martin KaFai Lau writes: This patch adds support to BPF verifier to allow bpf program calling kernel function directly. Hi Martin This is ex

pull-request: bpf-next 2021-03-24

2021-03-24 Thread Alexei Starovoitov
r you to fetch changes up to e2c69f3a5b4edfbcade2c38862c1839fc371c5d5: bpf: Avoid old-style declaration warnings (2021-03-24 09:32:28 -0700) Alexei Starovoitov (3): Merge branch 'Build BPF selftests and its libbpf,

Re: [PATCH bpf] bpf: Take module reference for ip in module code

2021-03-23 Thread Alexei Starovoitov
On Tue, Mar 23, 2021 at 10:15:33PM +0100, Jiri Olsa wrote: > Currently module can be unloaded even if there's a trampoline > register in it. It's easily reproduced by running in parallel: > > # while :; do ./test_progs -t module_attach; done > # while :; do ./test_progs -t fentry_test; done >

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

2021-03-22 Thread Alexei Starovoitov
On Mon, Mar 22, 2021 at 09:56:19AM -0700, Andrii Nakryiko wrote: > On Sun, Mar 21, 2021 at 6:07 PM Alexei Starovoitov > wrote: > > > > On Sat, Mar 20, 2021 at 10:00:57AM -0700, Andrii Nakryiko wrote: > > > On Fri, Mar 19, 2021 at 7:22 PM Alexei Starovoitov > >

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

2021-03-21 Thread Alexei Starovoitov
On Sat, Mar 20, 2021 at 10:00:57AM -0700, Andrii Nakryiko wrote: > On Fri, Mar 19, 2021 at 7:22 PM Alexei Starovoitov > wrote: > > > > On Fri, Mar 19, 2021 at 01:59:09PM -0700, Andrii Nakryiko wrote: > > > Add ability to skip BTF generation for some BPF object files.

pull-request: bpf 2021-03-20

2021-03-20 Thread Alexei Starovoitov
b/scm/linux/kernel/git/bpf/bpf.git for you to fetch changes up to b9082970478009b778aa9b22d5561eef35b53b63: bpf: Use NOP_ATOMIC5 instead of emit_nops(&prog, 5) for BPF_TRAMP_F_CALL_ORIG (2021-03-19 19:25:39 -0700) ---- Alexei St

Re: [PATCH bpf] bpf: use NOP_ATOMIC5 instead of emit_nops(&prog, 5) for BPF_TRAMP_F_CALL_ORIG

2021-03-19 Thread Alexei Starovoitov
On Fri, Mar 19, 2021 at 6:40 PM Stanislav Fomichev wrote: > > On Fri, Mar 19, 2021 at 5:33 PM Alexei Starovoitov > wrote: > > > > On Fri, Mar 19, 2021 at 5:25 PM Stanislav Fomichev wrote: > > > > > > On Fri, Mar 19, 2021 at 5:14 PM Alexei Starovoitov >

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

2021-03-19 Thread Alexei Starovoitov
On Fri, Mar 19, 2021 at 01:59:09PM -0700, Andrii Nakryiko wrote: > Add ability to skip BTF generation for some BPF object files. This is done > through using a convention of .nobtf.c file name suffix. > > Also add third statically linked file to static_linked selftest. This file has > no BTF, caus

Re: [PATCH bpf] bpf: use NOP_ATOMIC5 instead of emit_nops(&prog, 5) for BPF_TRAMP_F_CALL_ORIG

2021-03-19 Thread Alexei Starovoitov
On Fri, Mar 19, 2021 at 5:25 PM Stanislav Fomichev wrote: > > On Fri, Mar 19, 2021 at 5:14 PM Alexei Starovoitov > wrote: > > > > On Fri, Mar 19, 2021 at 5:00 PM Stanislav Fomichev wrote: > > > > > > __bpf_arch_text_poke does rewrite only for atomic

Re: [PATCH bpf] bpf: use NOP_ATOMIC5 instead of emit_nops(&prog, 5) for BPF_TRAMP_F_CALL_ORIG

2021-03-19 Thread Alexei Starovoitov
On Fri, Mar 19, 2021 at 5:00 PM Stanislav Fomichev wrote: > > __bpf_arch_text_poke does rewrite only for atomic nop5, emit_nops(xxx, 5) > emits non-atomic one which breaks fentry/fexit with k8 atomics: > > P6_NOP5 == P6_NOP5_ATOMIC (0f1f44 == 0f1f44) > K8_NOP5 != K8_NOP5_ATOMIC (906690

Re: [PATCH bpf-next 03/15] bpf: Refactor btf_check_func_arg_match

2021-03-19 Thread Alexei Starovoitov
On 3/19/21 2:51 PM, Andrii Nakryiko wrote: It's a matter of taste, I suppose. I'd probably disagree with you on the readability of those verifier parts ;) So it's up to you, of course, but for me this code pattern: for (...) { if (A) { handleA; } else if (B) { handle

Re: linux-next: manual merge of the net-next tree with the net tree

2021-03-19 Thread Alexei Starovoitov
On Fri, Mar 19, 2021 at 8:17 AM Yonghong Song wrote: > > > > On 3/19/21 12:21 AM, Daniel Borkmann wrote: > > On 3/19/21 3:11 AM, Piotr Krysiuk wrote: > >> Hi Daniel, > >> > >> On Fri, Mar 19, 2021 at 12:16 AM Stephen Rothwell > >> wrote: > >> > >>> diff --cc kernel/bpf/verifier.c > >>> index 44e4

Re: [PATCH bpf-next 04/15] bpf: Support bpf program calling kernel function

2021-03-18 Thread Alexei Starovoitov
On 3/18/21 6:03 PM, Andrii Nakryiko wrote: + desc->imm = BPF_CAST_CALL(addr) - __bpf_call_base; Is this difference guaranteed to always fit within s32? we have this restriction in many places: JIT, dispatcher, trampoline, and bpf interpreter. Modules and kernel .text are in the same 4G

Re: [PATCH v4 bpf-next 00/12] BPF static linking

2021-03-18 Thread Alexei Starovoitov
On Thu, Mar 18, 2021 at 12:42 PM Andrii Nakryiko wrote: > > This patch set adds new libbpf APIs and their bpftool integration that allows > to perform static linking of BPF object files. Currently no extern resolution > across object files is performed. This is going to be the focus of the follow

Re: [PATCH v3 bpf-next 0/2] Provide NULL and KERNEL_VERSION macros in bpf_helpers.h

2021-03-17 Thread Alexei Starovoitov
On 3/17/21 1:05 PM, Andrii Nakryiko wrote: Provide NULL and KERNEL_VERSION macros in bpf_helpers.h. Patch #2 removes such custom NULL definition from one of the selftests. v2->v3: - instead of vmlinux.h, do this in bpf_helpers.h; - added KERNEL_VERSION, which comes up periodically as well;

Re: [PATCH v2 bpf-next 10/11] selftests/bpf: pass all BPF .o's through BPF static linker

2021-03-17 Thread Alexei Starovoitov
On Wed, Mar 17, 2021 at 1:47 PM Andrii Nakryiko wrote: > > On Tue, Mar 16, 2021 at 10:34 PM Alexei Starovoitov > wrote: > > > > On Sat, Mar 13, 2021 at 11:35:36AM -0800, Andrii Nakryiko wrote: > > > > > > -$(TRUNNER

Re: [PATCH bpf-next] bpf: Simplify expression for identify bpf mem type

2021-03-17 Thread Alexei Starovoitov
On Wed, Mar 17, 2021 at 5:52 AM Jianlin Lv wrote: > return BPF_CLASS(meta->insn.code); > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h > index 2d3036e292a9..5d77675e7112 100644 > --- a/include/uapi/linux/bpf.h > +++ b/include/uapi/linux/bpf.h > @@ -21,6 +21,7 @@ > #defi

Re: [PATCH v2 bpf-next 1/4] bpftool: generate NULL definition in vmlinux.h

2021-03-17 Thread Alexei Starovoitov
On Wed, Mar 17, 2021 at 10:38 AM Andrii Nakryiko wrote: > > diff --git a/tools/bpf/bpftool/btf.c b/tools/bpf/bpftool/btf.c > > index 62953bbf68b4..ff6a76632873 100644 > > --- a/tools/bpf/bpftool/btf.c > > +++ b/tools/bpf/bpftool/btf.c > > @@ -405,6 +405,8 @@ static int dump_btf_c(const struct btf

Re: [PATCH v2 bpf-next 10/11] selftests/bpf: pass all BPF .o's through BPF static linker

2021-03-16 Thread Alexei Starovoitov
On Sat, Mar 13, 2021 at 11:35:36AM -0800, Andrii Nakryiko wrote: > > -$(TRUNNER_BPF_SKELS): $(TRUNNER_OUTPUT)/%.skel.h:\ > - $(TRUNNER_OUTPUT)/%.o \ > - $(BPFTOOL)\ > -

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

2021-03-16 Thread Alexei Starovoitov
On Sat, Mar 13, 2021 at 11:35:33AM -0800, Andrii Nakryiko wrote: > + for (j = 0; j < n; j++, src_var++) { > + void *sec_vars = dst_sec->sec_vars; > + > + sec_vars = libbpf_reallocarray(sec_vars, > +

Re: [PATCH v2 bpf-next 0/4] Build BPF selftests and its libbpf, bpftool in debug mode

2021-03-16 Thread Alexei Starovoitov
On 3/13/21 1:09 PM, Andrii Nakryiko wrote: Build BPF selftests and libbpf and bpftool, that are used as part of selftests, in debug mode (specifically, -Og). This makes it much simpler and nicer to do development and/or bug fixing. See patch #4 for some unscientific measurements. This patch set

Re: [PATCH bpf-next 05/10] libbpf: add BPF static linker APIs

2021-03-10 Thread Alexei Starovoitov
On Tue, Mar 09, 2021 at 08:04:26PM -0800, Andrii Nakryiko wrote: > + > + struct btf *strtab_btf; /* we use struct btf to manage strings */ ... > + str_off = btf__add_str(linker->strtab_btf, sec->sec_name); > + sec->shdr->sh_name = str_off; That bit took me an hour to grok. That single

pull-request: bpf-next 2021-03-09

2021-03-09 Thread Alexei Starovoitov
g IFF_PHONY_HEADROOM self-definition xsk: Respect device's headroom and tailroom on generic xmit path Alexei Starovoitov (8): Merge branch 'bpf: enable task local storage for tracing' Merge branch 'selftests/bpf: xsk improvements and new stats' Merg

Re: [PATCH] net: add net namespace inode for all net_dev events

2021-03-09 Thread Alexei Starovoitov
On Tue, Mar 9, 2021 at 12:37 PM Steven Rostedt wrote: > > The size of the fields and order changes all the time in various events. I > recommend doing so *all the time*. If you upgrade a kernel, then all the bpf > programs you have for that kernel should also be updated. You can't rely on > fields

  1   2   3   4   5   6   7   8   9   10   >