Re: [PATCH v2 bpf-next] libbpf: add perf_buffer APIs for better integration with outside epoll loop

2020-08-21 Thread Alexei Starovoitov
On Fri, Aug 21, 2020 at 10:06 AM Andrii Nakryiko wrote: > > Add a set of APIs to perf_buffer manage to allow applications to integrate > perf buffer polling into existing epoll-based infrastructure. One example is > applications using libevent already and wanting to plug perf_buffer polling, > ins

Re: [PATCH bpf-next v4 0/3] bpf: implement link_query for bpf iterators

2020-08-21 Thread Alexei Starovoitov
On Fri, Aug 21, 2020 at 12:04 PM Andrii Nakryiko wrote: > > On Fri, Aug 21, 2020 at 11:44 AM Yonghong Song wrote: > > > > "link" has been an important concept for bpf ecosystem to connect > > bpf program with other properties. Currently, the information related > > information can be queried from

Re: [PATCH v2 bpf 1/2] bpf: verifier: check for packet data access based on target prog

2020-08-21 Thread Alexei Starovoitov
On Fri, Aug 21, 2020 at 1:53 PM Yonghong Song wrote: > > > > On 8/21/20 12:07 PM, Udip Pant wrote: > > > > > > > On 8/20/20, 11:17 PM, "Yonghong Song" wrote: > >> > >> > >> > >> On 8/20/20 11:13 PM, Yonghong Song wrote: > >>> > >>> > >>> On 8/20/20 5:28 PM, Udip Pant wrote: > While using dy

pull-request: bpf 2020-08-21

2020-08-21 Thread Alexei Starovoitov
Hi David, The following pull-request contains BPF updates for your *net* tree. We've added 11 non-merge commits during the last 5 day(s) which contain a total of 12 files changed, 78 insertions(+), 24 deletions(-). The main changes are: 1) three fixes in BPF task iterator logic, from Yonghong.

Re: [PATCH] bpf: fix two typos in uapi/linux/bpf.h

2020-08-21 Thread Alexei Starovoitov
On Fri, Aug 21, 2020 at 6:36 AM Tobias Klauser wrote: > > Also remove trailing whitespaces in bpf_skb_get_tunnel_key example code. > > Signed-off-by: Tobias Klauser Applied to bpf tree. Thanks Please include destination tree in the subject line next time.

Re: [PATCH bpf-next v4 28/30] bpf: eliminate rlimit-based memory accounting infra for bpf maps

2020-08-21 Thread Alexei Starovoitov
On Fri, Aug 21, 2020 at 08:01:32AM -0700, Roman Gushchin wrote: > > diff --git a/tools/testing/selftests/bpf/progs/map_ptr_kern.c > b/tools/testing/selftests/bpf/progs/map_ptr_kern.c > index 473665cac67e..49d1dcaf7999 100644 > --- a/tools/testing/selftests/bpf/progs/map_ptr_kern.c > +++ b/tools/

Re: [PATCH bpf-next 1/3] bpf: implement link_query for bpf iterators

2020-08-20 Thread Alexei Starovoitov
On Thu, Aug 20, 2020 at 09:15:30AM -0700, Yonghong Song wrote: > > > On 8/20/20 8:07 AM, Jakub Kicinski wrote: > > On Wed, 19 Aug 2020 17:13:23 -0700 Yonghong Song wrote: > > > + fill_link_info = iter_link->tinfo->reg_info->fill_link_info; > > > + if (fill_link_info) > > > + return fill_l

Re: BPF sk_lookup v5 - TCP SYN and UDP 0-len flood benchmarks

2020-08-20 Thread Alexei Starovoitov
On Thu, Aug 20, 2020 at 3:29 AM Jakub Sitnicki wrote: > > On Tue, Aug 18, 2020 at 08:19 PM CEST, Alexei Starovoitov wrote: > > On Tue, Aug 18, 2020 at 8:49 AM Jakub Sitnicki wrote: > >> : rcu_read_lock(); > >> :

Re: [RFC PATCH bpf-next 2/4] bpf: make BTF show support generic, apply to seq files/bpf_trace_printk

2020-08-20 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 10:12:05AM +0100, Alan Maguire wrote: > > Fair enough. I'm thinking a helper like > > long bpf_btf_snprintf(char *str, u32 str_size, struct btf_ptr *ptr, > u32 ptr_size, u64 flags); > > Then the user can choose perf event or ringbuf interfaces > to sha

Re: [PATCH v6 bpf-next] bpf/selftests: fold test_current_pid_tgid_new_ns into test_progs.

2020-08-20 Thread Alexei Starovoitov
On Thu, Aug 20, 2020 at 7:27 AM Carlos Neira wrote: > > Currently tests for bpf_get_ns_current_pid_tgid() are outside test_progs. > This change folds both tests into test_progs. > > Changes from V5: > - Fold both tests into test_progs. > > Signed-off-by: Carlos Neira It doesn't apply. Pls rebas

Re: [PATCH bpf-next v1 1/8] bpf: Introduce pseudo_btf_id

2020-08-20 Thread Alexei Starovoitov
On Wed, Aug 19, 2020 at 03:40:23PM -0700, Hao Luo wrote: > + > /* verify BPF_LD_IMM64 instruction */ > static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn) > { > @@ -7234,6 +7296,9 @@ static int check_ld_imm(struct bpf_verifier_env *env, > struct bpf_insn *insn) >

Re: [PATCH bpf] bpf: xdp: fix XDP mode when no mode flags specified

2020-08-20 Thread Alexei Starovoitov
On Thu, Aug 20, 2020 at 1:24 AM Lorenzo Bianconi wrote: > > > 7f0a838254bd ("bpf, xdp: Maintain info on attached XDP BPF programs in > > net_device") > > inadvertently changed which XDP mode is assumed when no mode flags are > > specified explicitly. Previously, driver mode was preferred, if driv

Re: [PATCH bpf-next] tools/resolve_btfids: Fix sections with wrong alignment

2020-08-20 Thread Alexei Starovoitov
On Thu, Aug 20, 2020 at 10:54 AM Yonghong Song wrote: > > > > On 8/20/20 10:36 AM, Mark Wielaard wrote: > > Hi > > > > On Thu, 2020-08-20 at 08:51 -0700, Yonghong Song wrote: > Do you think we could skip these .debug_* sections somehow in elf > parsing in resolve_btfids? resolve_btfids d

Re: [PATCH v3 bpf-next 0/5] Add libbpf support for type- and enum value-based CO-RE relocations

2020-08-19 Thread Alexei Starovoitov
On Wed, Aug 19, 2020 at 12:45:14PM -0700, Andrii Nakryiko wrote: > > Selftests are added for all the new features. Selftests utilizing new Clang > built-ins are designed such that they will compile with older Clangs and will > be skipped during test runs. So this shouldn't cause any build and test

Re: [PATCH bpf-next] net-veth: add type safety to veth_xdp_to_ptr() and veth_ptr_to_xdp()

2020-08-19 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 7:00 PM Maciej Żenczykowski wrote: > > From: Maciej Żenczykowski > > This reduces likelihood of incorrect use. > > Test: builds I kept this in the commit log though it's a pointless comment. Please reconsider for the future. If you want to mention how you've tested it, pl

Re: [PATCH bpf-next 1/2] net-tun: add type safety to tun_xdp_to_ptr() and tun_ptr_to_xdp()

2020-08-19 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 6:07 PM Maciej Żenczykowski wrote: > > From: Maciej Żenczykowski > > This reduces likelihood of incorrect use. > > Test: builds > Signed-off-by: Maciej Żenczykowski Applied. Thanks

Re: [PATCH bpf-next 4/7] libbpf: sanitize BPF program code for bpf_probe_read_{kernel,user}[_str]

2020-08-19 Thread Alexei Starovoitov
On Wed, Aug 19, 2020 at 1:13 PM Andrii Nakryiko wrote: > > On Tue, Aug 18, 2020 at 6:42 PM Yonghong Song wrote: > > > > > > > > On 8/18/20 2:33 PM, Andrii Nakryiko wrote: > > > Add BPF program code sanitization pass, replacing calls to BPF > > > bpf_probe_read_{kernel,user}[_str]() helpers with b

[PATCH v6 bpf-next 4/4] selftests/bpf: Add bpffs preload test.

2020-08-18 Thread Alexei Starovoitov
From: Alexei Starovoitov Add a test that mounts two bpffs instances and checks progs.debug and maps.debug for sanity data. Signed-off-by: Alexei Starovoitov --- .../selftests/bpf/prog_tests/test_bpffs.c | 94 +++ 1 file changed, 94 insertions(+) create mode 100644 tools

[PATCH v6 bpf-next 0/4] bpf: Populate bpffs with map and prog iterators

2020-08-18 Thread Alexei Starovoitov
From: Alexei Starovoitov v5->v6: - refactored Makefiles with Andrii's help - switched to explicit $(MAKE) style - switched to userldlibs instead of userldflags - fixed build issue with libbpf Makefile due to invocation from kbuild - fixed menuconfig order as spotted by Daniel - in

[PATCH v6 bpf-next 1/4] bpf: Factor out bpf_link_by_id() helper.

2020-08-18 Thread Alexei Starovoitov
From: Alexei Starovoitov Refactor the code a bit to extract bpf_link_by_id() helper. It's similar to existing bpf_prog_by_id(). Signed-off-by: Alexei Starovoitov Acked-by: Andrii Nakryiko Acked-by: Song Liu --- include/linux/bpf.h | 1 + kernel/bpf/syscall.c

[PATCH v6 bpf-next 3/4] bpf: Add kernel module with user mode driver that populates bpffs.

2020-08-18 Thread Alexei Starovoitov
From: Alexei Starovoitov Add kernel module with user mode driver that populates bpffs with BPF iterators. $ mount bpffs /my/bpffs/ -t bpf $ ls -la /my/bpffs/ total 4 drwxrwxrwt 2 root root0 Jul 2 00:27 . drwxr-xr-x 19 root root 4096 Jul 2 00:09 .. -rw--- 1 root root0 Jul 2 00

[PATCH v6 bpf-next 2/4] bpf: Add BPF program and map iterators as built-in BPF programs.

2020-08-18 Thread Alexei Starovoitov
From: Alexei Starovoitov The program and map iterators work similar to seq_file-s. Once the program is pinned in bpffs it can be read with "cat" tool to print human readable output. In this case about BPF programs and maps. For example: $ cat /sys/fs/bpf/progs.debug id name

Re: [PATCH v3 bpf-next 0/4] libbpf: minimize feature detection (reallocarray, libelf-mmap)

2020-08-18 Thread Alexei Starovoitov
On 8/18/20 6:36 PM, Andrii Nakryiko wrote: Get rid of two feature detectors: reallocarray and libelf-mmap. Optional feature detections complicate libbpf Makefile and cause more troubles for various applications that want to integrate libbpf as part of their build. Patch #1 replaces all reallocar

Re: [PATCH bpf-next 0/9] Add support for type-based and enum value-based CO-RE relocations

2020-08-18 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 06:31:51PM -0700, Andrii Nakryiko wrote: > On Tue, Aug 18, 2020 at 6:21 PM Alexei Starovoitov > wrote: > > > > On Tue, Aug 18, 2020 at 03:39:12PM -0700, Andrii Nakryiko wrote: > > > This patch set adds libbpf support to two new classes

Re: [PATCH v2 bpf-next 0/4] libbpf: minimize feature detection (reallocarray, libelf-mmap)

2020-08-18 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 6:24 PM Andrii Nakryiko wrote: > > Get rid of two feature detectors: reallocarray and libelf-mmap. Optional > feature detections complicate libbpf Makefile and cause more troubles for > various applications that want to integrate libbpf as part of their build. > > Patch #1

Re: [PATCH bpf-next 0/9] Add support for type-based and enum value-based CO-RE relocations

2020-08-18 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 03:39:12PM -0700, Andrii Nakryiko wrote: > This patch set adds libbpf support to two new classes of CO-RE relocations: > type-based (TYPE_EXISTS/TYPE_SIZE/TYPE_ID_LOCAL/TYPE_ID_TARGET) and enum > value-vased (ENUMVAL_EXISTS/ENUMVAL_VALUE): > > LLVM patches adding these relo

Re: [PATCH bpf-next 4/4] tools: remove feature-libelf-mmap feature detection

2020-08-18 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 02:59:08PM -0700, Andrii Nakryiko wrote: > It's trivial to handle missing ELF_C_MMAP_READ support in libelf the way that > objtool has solved it in > ("774bec3fddcc objtool: Add fallback from ELF_C_READ_MMAP to ELF_C_READ"). > > So instead of having an entire feature detect

Re: [PATCH bpf v2 1/3] bpf: fix a rcu_sched stall issue with bpf task/task_file iterator

2020-08-18 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 05:30:37PM -0700, Yonghong Song wrote: > > > On 8/18/20 5:05 PM, Alexei Starovoitov wrote: > > On Tue, Aug 18, 2020 at 03:23:09PM -0700, Yonghong Song wrote: > > > > > > We did not use cond_resched() since for some iterators, e.g.,

Re: [PATCH bpf-next 0/7] libbpf feature probing and sanitization improvements

2020-08-18 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 02:33:49PM -0700, Andrii Nakryiko wrote: > This patch set refactors libbpf feature probing to be done lazily on as-needed > basis, instead of proactively testing all possible features libbpf knows > about. This allows to scale such detections and mitigations better, without

Re: [PATCH bpf] net-tun: add type safety to tun_xdp_to_ptr() and tun_ptr_to_xdp()

2020-08-18 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 1:39 AM Maciej Żenczykowski wrote: > > From: Maciej Żenczykowski > > Test: builds > Signed-off-by: Maciej Żenczykowski I know it's a trivial patch, but please provide a proper commit log and explain _why_ this type safety is necessary. Also pls use email subject with [PA

Re: [PATCH] libbpf: convert comma to semicolon

2020-08-18 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 8:54 AM Yonghong Song wrote: > > > > On 8/18/20 12:16 AM, Xu Wang wrote: > > Replace a comma between expression statements by a semicolon. > > > > Signed-off-by: Xu Wang > > Acked-by: Yonghong Song Applied. Thanks

Re: [PATCH bpf-next] samples: bpf: Fix broken bpf programs due to removed symbol

2020-08-18 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 9:01 AM Yonghong Song wrote: > > > > On 8/17/20 10:16 PM, Daniel T. Lee wrote: > > From commit f1394b798814 ("block: mark blk_account_io_completion > > static") symbol blk_account_io_completion() has been marked as static, > > which makes it no longer possible to attach kp

Re: [PATCH bpf v2 1/3] bpf: fix a rcu_sched stall issue with bpf task/task_file iterator

2020-08-18 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 03:23:09PM -0700, Yonghong Song wrote: > > We did not use cond_resched() since for some iterators, e.g., > netlink iterator, where rcu read_lock critical section spans between > consecutive seq_ops->next(), which makes impossible to do cond_resched() > in the key while loop

Re: BPF sk_lookup v5 - TCP SYN and UDP 0-len flood benchmarks

2020-08-18 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 8:49 AM Jakub Sitnicki wrote: > : rcu_read_lock(); > : run_array = > rcu_dereference(net->bpf.run_array[NETNS_BPF_SK_LOOKUP]); > 0.01 : 817f8624: mov0xd68(%r12),%rsi > :

Re: [PATCH bpf 1/2] bpf: fix a rcu_sched stall issue with bpf task/task_file iterator

2020-08-18 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 9:24 AM Yonghong Song wrote: > index f21b5e1e4540..885b14cab2c0 100644 > --- a/kernel/bpf/task_iter.c > +++ b/kernel/bpf/task_iter.c > @@ -27,6 +27,8 @@ static struct task_struct *task_seq_get_next(struct > pid_namespace *ns, > struct task_struct *task = NULL; >

Re: [PATCH bpf] libbpf: fix build on ppc64le architecture

2020-08-18 Thread Alexei Starovoitov
On Tue, Aug 18, 2020 at 9:47 AM Andrii Nakryiko wrote: > > On ppc64le we get the following warning: > > In file included from btf_dump.c:16:0: > btf_dump.c: In function ‘btf_dump_emit_struct_def’: > ../include/linux/kernel.h:20:17: error: comparison of distinct pointer > types lacks a cast

Re: [PATCH bpf] bpf: use get_file_rcu() instead of get_file() for task_file iterator

2020-08-17 Thread Alexei Starovoitov
On Mon, Aug 17, 2020 at 11:27 AM Josef Bacik wrote: > > On 8/17/20 1:42 PM, Yonghong Song wrote: > > With latest `bpftool prog` command, we observed the following kernel > > panic. > > BUG: kernel NULL pointer dereference, address: > > > > This patch used get_file_rcu() which

Re: [RFC PATCH bpf-next 2/4] bpf: make BTF show support generic, apply to seq files/bpf_trace_printk

2020-08-14 Thread Alexei Starovoitov
On Fri, Aug 14, 2020 at 02:06:37PM +0100, Alan Maguire wrote: > On Wed, 12 Aug 2020, Alexei Starovoitov wrote: > > > On Thu, Aug 06, 2020 at 03:42:23PM +0100, Alan Maguire wrote: > > > > > > The bpf_trace_printk tracepoint is augmented with a "trace_i

Re: [PATCH v3 bpf 0/9] Fix various issues with 32-bit libbpf

2020-08-13 Thread Alexei Starovoitov
On Thu, Aug 13, 2020 at 01:49:36PM -0700, Andrii Nakryiko wrote: > This patch set contains fixes to libbpf, bpftool, and selftests that were > found while testing libbpf and selftests built in 32-bit mode. 64-bit nature > of BPF target and 32-bit host environment don't always mix together well > wi

Re: [PATCH bpf 0/9] Fix various issues with 32-bit libbpf

2020-08-13 Thread Alexei Starovoitov
On Thu, Aug 13, 2020 at 12:17:13AM -0700, Andrii Nakryiko wrote: > This patch set contains fixes to libbpf, bpftool, and selftests that were > found while testing libbpf and selftests built in 32-bit mode. 64-bit nature > of BPF target and 32-bit host environment don't always mix together well > wi

Re: [RFC PATCH bpf-next 2/4] bpf: make BTF show support generic, apply to seq files/bpf_trace_printk

2020-08-12 Thread Alexei Starovoitov
On Thu, Aug 06, 2020 at 03:42:23PM +0100, Alan Maguire wrote: > > The bpf_trace_printk tracepoint is augmented with a "trace_id" > field; it is used to allow tracepoint filtering as typed display > information can easily be interspersed with other tracing data, > making it hard to read. Specifyin

Re: [RFC PATCH bpf-next] bpf: Iterate through all PT_NOTE sections when looking for build id

2020-08-12 Thread Alexei Starovoitov
On Wed, Aug 12, 2020 at 8:27 AM Song Liu wrote: > > > > > On Aug 12, 2020, at 5:31 AM, Jiri Olsa wrote: > > > > Currently when we look for build id within bpf_get_stackid helper > > call, we check the first NOTE section and we fail if build id is > > not there. > > > > However on some system (Fed

Re: [PATCH bpf] tools/bpftool: make skeleton code C++17-friendly by dropping typeof()

2020-08-12 Thread Alexei Starovoitov
On Wed, Aug 12, 2020 at 8:35 AM Song Liu wrote: > > > > > On Aug 11, 2020, at 7:59 PM, Andrii Nakryiko wrote: > > > > Seems like C++17 standard mode doesn't recognize typeof() anymore. This can > > be tested by compiling test_cpp test with -std=c++17 or -std=c++1z options. > > The use of typeof i

Re: [PATCH bpf] bpf: fix XDP FD-based attach/detach logic around XDP_FLAGS_UPDATE_IF_NOEXIST

2020-08-12 Thread Alexei Starovoitov
On Wed, Aug 12, 2020 at 8:48 AM Stanislav Fomichev wrote: > > On Wed, Aug 12, 2020 at 2:24 AM Toke Høiland-Jørgensen > wrote: > > > > Andrii Nakryiko writes: > > > > > Enforce XDP_FLAGS_UPDATE_IF_NOEXIST only if new BPF program to be > > > attached is > > > non-NULL (i.e., we are not detaching

Re: [PATCH v10 bpf-next 00/14] bpf: Add d_path helper

2020-08-07 Thread Alexei Starovoitov
On Fri, Aug 07, 2020 at 11:45:45AM +0200, Jiri Olsa wrote: > hi, > adding d_path helper function that returns full path for > given 'struct path' object, which needs to be the kernel > BTF 'path' object. The path is returned in buffer provided > 'buf' of size 'sz' and is zero terminated. > > lon

Re: [RFC PATCH bpf-next 7/9] selftests/bpf: add CO-RE relo test for TYPE_ID_LOCAL/TYPE_ID_TARGET

2020-08-06 Thread Alexei Starovoitov
On Thu, Aug 06, 2020 at 04:48:27PM -0700, Andrii Nakryiko wrote: > On Thu, Aug 6, 2020 at 3:30 PM Alexei Starovoitov > wrote: > > > > On Tue, Aug 04, 2020 at 11:24:07AM -0700, Andrii Nakryiko wrote: > > > + > > > +SEC("raw_tracepoint/sys_enter

Re: [PATCH bpf-next v2] bpf: fix compilation warning of selftests

2020-08-06 Thread Alexei Starovoitov
On Thu, Aug 6, 2020 at 3:46 AM Jianlin Lv wrote: > > Clang compiler version: 12.0.0 > The following warning appears during the selftests/bpf compilation: > > prog_tests/send_signal.c:51:3: warning: ignoring return value of ‘write’, > declared with attribute warn_unused_result [-Wunused-result] >

Re: [PATCH bpf] selftests: bpf: switch off timeout

2020-08-06 Thread Alexei Starovoitov
On Thu, Aug 6, 2020 at 11:42 AM Jiri Benc wrote: > > Several bpf tests are interrupted by the default timeout of 45 seconds added > by commit 852c8cbf34d3 ("selftests/kselftest/runner.sh: Add 45 second > timeout per test"). In my case it was test_progs, test_tunnel.sh, > test_lwt_ip_encap.sh and t

Re: [PATCH bpf] bpf: remove inline from bpf_do_trace_printk

2020-08-06 Thread Alexei Starovoitov
On Thu, Aug 6, 2020 at 11:26 AM Stanislav Fomichev wrote: > > I get the following error during compilation on my side: > kernel/trace/bpf_trace.c: In function 'bpf_do_trace_printk': > kernel/trace/bpf_trace.c:386:34: error: function 'bpf_do_trace_printk' can > never be inlined because it uses var

Re: [PATCH bpf] bpf: add missing return to resolve_btfids

2020-08-06 Thread Alexei Starovoitov
On Thu, Aug 6, 2020 at 11:22 AM wrote: > > On 08/06, Stanislav Fomichev wrote: > > int sets_patch(struct object *obj) doesn't have a 'return 0' at the end. > > > Signed-off-by: Stanislav Fomichev > > --- > > tools/bpf/resolve_btfids/main.c | 1 + > > 1 file changed, 1 insertion(+) > > > diff -

Re: [PATCH bpf-next] libbf: fix uninitialized pointer at btf__parse_raw()

2020-08-06 Thread Alexei Starovoitov
On Wed, Aug 5, 2020 at 11:22 PM John Fastabend wrote: > > Daniel T. Lee wrote: > > Recently, from commit 94a1fedd63ed ("libbpf: Add btf__parse_raw() and > > generic btf__parse() APIs"), new API has been added to libbpf that > > allows to parse BTF from raw data file (btf__parse_raw()). > > > > The

Re: [PATCH bpf v4 0/2] bpf: change uapi for bpf iterator map elements

2020-08-06 Thread Alexei Starovoitov
On Tue, Aug 4, 2020 at 10:51 PM Yonghong Song wrote: > > Andrii raised a concern that current uapi for bpf iterator map > element is a little restrictive and not suitable for future potential > complex customization. This is a valid suggestion, considering people > may indeed add more complex cust

Re: [PATCH bpf] selftests/bpf: prevent runqslower from racing on building bpftool

2020-08-06 Thread Alexei Starovoitov
On Wed, Aug 5, 2020 at 11:27 PM John Fastabend wrote: > > Andrii Nakryiko wrote: > > runqslower's Makefile is building/installing bpftool into > > $(OUTPUT)/sbin/bpftool, which coincides with $(DEFAULT_BPFTOOL). In practice > > this means that often when building selftests from scratch (after `mak

Re: [RFC PATCH bpf-next 7/9] selftests/bpf: add CO-RE relo test for TYPE_ID_LOCAL/TYPE_ID_TARGET

2020-08-06 Thread Alexei Starovoitov
On Tue, Aug 04, 2020 at 11:24:07AM -0700, Andrii Nakryiko wrote: > + > +SEC("raw_tracepoint/sys_enter") > +int test_core_type_id(void *ctx) > +{ > + struct core_reloc_type_id_output *out = (void *)&data.out; > + > + out->local_anon_struct = bpf_core_type_id_local(struct { int > marker_fiel

Re: [PATCH bpf-next 0/3] Add generic and raw BTF parsing APIs to libbpf

2020-08-06 Thread Alexei Starovoitov
On Thu, Aug 6, 2020 at 10:51 AM Andrii Nakryiko wrote: > > I haven't checked which of the patches, or some in other series caused > > this on Clear Linux: > > > > 21 clearlinux:latest : FAIL gcc (Clear Linux OS for Intel > > Architecture) 10.2.1 20200723 releases/gcc-10.2.0-3-g677b8

BPF office hours via google meet. Was: BPF program metadata

2020-08-06 Thread Alexei Starovoitov
On Wed, Aug 5, 2020 at 4:10 PM wrote: > > Since google folks have trouble with zoom I've added google meets link > > to the spreadsheet. Let's try it tomorrow. Today we held BPF office hours via google meet and it worked well. So we will be using it for future meetings. zoom link has been removed

Re: [PATCH bpf-next 5/5] selftests/bpf: add benchmark for uprobe vs. user_prog

2020-08-05 Thread Alexei Starovoitov
On Wed, Aug 05, 2020 at 06:56:26PM +, Song Liu wrote: > > > > On Aug 5, 2020, at 10:16 AM, Alexei Starovoitov > > wrote: > > > > On Wed, Aug 05, 2020 at 04:47:30AM +, Song Liu wrote: > >> > >> Being able to trigger BPF program on a di

Re: [PATCH bpf-next 5/5] selftests/bpf: add benchmark for uprobe vs. user_prog

2020-08-05 Thread Alexei Starovoitov
On Wed, Aug 05, 2020 at 10:27:28AM -0700, Andrii Nakryiko wrote: > On Wed, Aug 5, 2020 at 10:16 AM Alexei Starovoitov > wrote: > > > > On Wed, Aug 05, 2020 at 04:47:30AM +, Song Liu wrote: > > > > > > Being able to trigger BPF program on a different CPU c

Re: [PATCH bpf-next 5/5] selftests/bpf: add benchmark for uprobe vs. user_prog

2020-08-05 Thread Alexei Starovoitov
On Wed, Aug 05, 2020 at 04:47:30AM +, Song Liu wrote: > > Being able to trigger BPF program on a different CPU could enable many > use cases and optimizations. The use case I am looking at is to access > perf_event and percpu maps on the target CPU. For example: > 0. trigger the program

Re: [PATCH v5 bpf-next 3/4] bpf: Add kernel module with user mode driver that populates bpffs.

2020-08-03 Thread Alexei Starovoitov
On Mon, Aug 3, 2020 at 10:40 AM Daniel Borkmann wrote: > > On 8/3/20 7:34 PM, Daniel Borkmann wrote: > > On 8/3/20 7:15 PM, Daniel Borkmann wrote: > >> On 8/3/20 12:29 AM, Alexei Starovoitov wrote: > >>> From: Alexei Starovoitov > >>> > >>&g

Re: [PATCH bpf-next v5 1/2] bpf: setup socket family and addresses in bpf_prog_test_run_skb

2020-08-02 Thread Alexei Starovoitov
On Mon, Aug 03, 2020 at 12:36:30AM +0300, Dmitry Yakunin wrote: > Now it's impossible to test all branches of cgroup_skb bpf program which > accesses skb->family and skb->{local,remote}_ip{4,6} fields because they > are zeroed during socket allocation. This commit fills socket family and > addresse

[PATCH v5 bpf-next 1/4] bpf: Factor out bpf_link_by_id() helper.

2020-08-02 Thread Alexei Starovoitov
From: Alexei Starovoitov Refactor the code a bit to extract bpf_link_by_id() helper. It's similar to existing bpf_prog_by_id(). Signed-off-by: Alexei Starovoitov Acked-by: Andrii Nakryiko Acked-by: Song Liu --- include/linux/bpf.h | 1 + kernel/bpf/syscall.c

[PATCH v5 bpf-next 3/4] bpf: Add kernel module with user mode driver that populates bpffs.

2020-08-02 Thread Alexei Starovoitov
From: Alexei Starovoitov Add kernel module with user mode driver that populates bpffs with BPF iterators. $ mount bpffs /my/bpffs/ -t bpf $ ls -la /my/bpffs/ total 4 drwxrwxrwt 2 root root0 Jul 2 00:27 . drwxr-xr-x 19 root root 4096 Jul 2 00:09 .. -rw--- 1 root root0 Jul 2 00

[PATCH v5 bpf-next 0/4] bpf: Populate bpffs with map and prog iterators

2020-08-02 Thread Alexei Starovoitov
From: Alexei Starovoitov v4->v5: - addressed Song and Andrii feedback. s/pages/max_entries/ v3->v4: - took THIS_MODULE in patch 3 as suggested by Daniel to simplify the code. - converted BPF iterator to use BTF (when available) to print full BPF program name instead of 16-byte tru

[PATCH v5 bpf-next 2/4] bpf: Add BPF program and map iterators as built-in BPF programs.

2020-08-02 Thread Alexei Starovoitov
From: Alexei Starovoitov The program and map iterators work similar to seq_file-s. Once the program is pinned in bpffs it can be read with "cat" tool to print human readable output. In this case about BPF programs and maps. For example: $ cat /sys/fs/bpf/progs.debug id name

[PATCH v5 bpf-next 4/4] selftests/bpf: Add bpffs preload test.

2020-08-02 Thread Alexei Starovoitov
From: Alexei Starovoitov Add a test that mounts two bpffs instances and checks progs.debug and maps.debug for sanity data. Signed-off-by: Alexei Starovoitov --- .../selftests/bpf/prog_tests/test_bpffs.c | 94 +++ 1 file changed, 94 insertions(+) create mode 100644 tools

Re: [PATCH bpf-next] selftests/bpf: fix spurious test failures in core_retro selftest

2020-08-01 Thread Alexei Starovoitov
On Fri, Jul 31, 2020 at 2:55 PM John Fastabend wrote: > > Andrii Nakryiko wrote: > > core_retro selftest uses BPF program that's triggered on sys_enter > > system-wide, but has no protection from some unrelated process doing syscall > > while selftest is running. This leads to occasional test fail

Re: [PATCH v2 bpf-next 0/5] BPF link force-detach support

2020-08-01 Thread Alexei Starovoitov
On Fri, Jul 31, 2020 at 11:29 AM Andrii Nakryiko wrote: > > This patch set adds new BPF link operation, LINK_DETACH, allowing processes > with BPF link FD to force-detach it from respective BPF hook, similarly how > BPF link is auto-detached when such BPF hook (e.g., cgroup, net_device, netns, > e

Re: [PATCH bpf-next] tools build: propagate build failures from tools/build/Makefile.build

2020-08-01 Thread Alexei Starovoitov
On Thu, Jul 30, 2020 at 7:44 PM Andrii Nakryiko wrote: > > The '&&' command seems to have a bad effect when $(cmd_$(1)) exits with > non-zero effect: the command failure is masked (despite `set -e`) and all but > the first command of $(dep-cmd) is executed (successfully, as they are mostly > print

Re: [PATCH v9 bpf-next 10/14] bpf: Add d_path helper

2020-08-01 Thread Alexei Starovoitov
On Sat, Aug 01, 2020 at 07:03:18PM +0200, Jiri Olsa wrote: > Adding d_path helper function that returns full path for > given 'struct path' object, which needs to be the kernel > BTF 'path' object. The path is returned in buffer provided > 'buf' of size 'sz' and is zero terminated. > > bpf_d_pat

Re: [PATCH v6 bpf-next 0/6] bpf: tailcalls in BPF subprograms

2020-08-01 Thread Alexei Starovoitov
On Sat, Aug 01, 2020 at 09:13:57AM +0200, Maciej Fijalkowski wrote: > On Sat, Aug 01, 2020 at 03:03:19AM +0200, Daniel Borkmann wrote: > > On 7/31/20 2:03 AM, Maciej Fijalkowski wrote: > > > v5->v6: > > > - propagate only those poke descriptors that individual subprogram is > > >actually using

Re: [PATCH net] net/bpfilter: initialize pos in __bpfilter_process_sockopt

2020-08-01 Thread Alexei Starovoitov
On Fri, Jul 31, 2020 at 02:07:42AM +0200, Daniel Borkmann wrote: > On 7/30/20 6:13 PM, Christian Brauner wrote: > > On Thu, Jul 30, 2020 at 06:09:00PM +0200, Christoph Hellwig wrote: > > > __bpfilter_process_sockopt never initialized the pos variable passed to > > > the pipe write. This has been m

Re: [PATCH v4 bpf-next 0/9] BPF XDP link

2020-07-25 Thread Alexei Starovoitov
On Tue, Jul 21, 2020 at 11:46 PM Andrii Nakryiko wrote: > > Following cgroup and netns examples, implement bpf_link support for XDP. > > The semantics is described in patch #2. Program and link attachments are > mutually exclusive, in the sense that neither link can replace attached > program nor

Re: [PATCH bpf-next] udp: reduce merge conflict on udp[46]_lib_lookup2

2020-07-25 Thread Alexei Starovoitov
On Sat, Jul 25, 2020 at 3:58 AM Kuniyuki Iwashima wrote: > > From: Willem de Bruijn > Date: Fri, 24 Jul 2020 22:54:57 -0400 > > From: Willem de Bruijn > > > > Commit efc6b6f6c311 ("udp: Improve load balancing for SO_REUSEPORT.") > > > > in net conflicts with > > > > Commit 72f7e9440e9b ("udp

Re: [PATCH bpf-next] bpf: fix build on architectures with special bpf_user_pt_regs_t

2020-07-25 Thread Alexei Starovoitov
On Fri, Jul 24, 2020 at 1:08 PM Song Liu wrote: > > Architectures like s390, powerpc, arm64, riscv have speical definition of > bpf_user_pt_regs_t. So we need to cast the pointer before passing it to > bpf_get_stack(). This is similar to bpf_get_stack_tp(). > > Fixes: 03d42fd2d83f ("bpf: Separate

[PATCH v4 bpf-next 4/4] selftests/bpf: Add bpffs preload test.

2020-07-24 Thread Alexei Starovoitov
From: Alexei Starovoitov Add a test that mounts two bpffs instances and checks progs.debug and maps.debug for sanity data. Signed-off-by: Alexei Starovoitov --- .../selftests/bpf/prog_tests/test_bpffs.c | 94 +++ 1 file changed, 94 insertions(+) create mode 100644 tools

[PATCH v4 bpf-next 0/4] bpf: Populate bpffs with map and prog iterators

2020-07-24 Thread Alexei Starovoitov
From: Alexei Starovoitov v3->v4: - took THIS_MODULE in patch 3 as suggested by Daniel to simplify the code. - converted BPF iterator to use BTF (when available) to print full BPF program name instead of 16-byte truncated version. This is something I've been using drgn scripts for. Tak

[PATCH v4 bpf-next 3/4] bpf: Add kernel module with user mode driver that populates bpffs.

2020-07-24 Thread Alexei Starovoitov
From: Alexei Starovoitov Add kernel module with user mode driver that populates bpffs with BPF iterators. $ mount bpffs /my/bpffs/ -t bpf $ ls -la /my/bpffs/ total 4 drwxrwxrwt 2 root root0 Jul 2 00:27 . drwxr-xr-x 19 root root 4096 Jul 2 00:09 .. -rw--- 1 root root0 Jul 2 00

[PATCH v4 bpf-next 2/4] bpf: Add BPF program and map iterators as built-in BPF programs.

2020-07-24 Thread Alexei Starovoitov
From: Alexei Starovoitov The program and map iterators work similar to seq_file-s. Once the program is pinned in bpffs it can be read with "cat" tool to print human readable output. In this case about BPF programs and maps. For example: $ cat /sys/fs/bpf/progs.debug id name

[PATCH v4 bpf-next 1/4] bpf: Factor out bpf_link_get_by_id() helper.

2020-07-24 Thread Alexei Starovoitov
From: Alexei Starovoitov Refactor the code a bit to extract bpf_link_get_by_id() helper. It's similar to existing bpf_prog_by_id(). Signed-off-by: Alexei Starovoitov Acked-by: Andrii Nakryiko --- include/linux/bpf.h | 1 + kernel/bpf/syscall.c

Re: [PATCH net] udp: Remove an unnecessary variable in udp[46]_lib_lookup2().

2020-07-24 Thread Alexei Starovoitov
On Fri, Jul 24, 2020 at 6:38 AM Willem de Bruijn wrote: > > On Fri, Jul 24, 2020 at 2:13 AM Kuniyuki Iwashima wrote: > > > > From: David Miller > > Date: Thu, 23 Jul 2020 15:10:51 -0700 (PDT) > > > From: Kuniyuki Iwashima > > > Date: Thu, 23 Jul 2020 01:52:27 +0900 > > > > > > > This patch

Re: [PATCH v3 bpf-next 3/4] bpf: Add kernel module with user mode driver that populates bpffs.

2020-07-24 Thread Alexei Starovoitov
On Fri, Jul 24, 2020 at 04:53:47PM +0200, Daniel Borkmann wrote: > > static const struct bpf_preload_umd_ops umd_ops = { > .preload= do_preload, > .finish = do_finish, > .owner = THIS_MODULE, > }; Thanks for the suggestion. It helped to get rid of

[PATCH v3 bpf-next 1/4] bpf: Factor out bpf_link_get_by_id() helper.

2020-07-23 Thread Alexei Starovoitov
From: Alexei Starovoitov Refactor the code a bit to extract bpf_link_get_by_id() helper. It's similar to existing bpf_prog_by_id(). Signed-off-by: Alexei Starovoitov Acked-by: Andrii Nakryiko --- include/linux/bpf.h | 1 + kernel/bpf/syscall.c

[PATCH v3 bpf-next 2/4] bpf: Add BPF program and map iterators as built-in BPF programs.

2020-07-23 Thread Alexei Starovoitov
From: Alexei Starovoitov The program and map iterators work similar to seq_file-s. Once the program is pinned in bpffs it can be read with "cat" tool to print human readable output. In this case about BPF programs and maps. For example: $ cat /sys/fs/bpf/progs.debug id name

[PATCH v3 bpf-next 3/4] bpf: Add kernel module with user mode driver that populates bpffs.

2020-07-23 Thread Alexei Starovoitov
From: Alexei Starovoitov Add kernel module with user mode driver that populates bpffs with BPF iterators. $ mount bpffs /my/bpffs/ -t bpf $ ls -la /my/bpffs/ total 4 drwxrwxrwt 2 root root0 Jul 2 00:27 . drwxr-xr-x 19 root root 4096 Jul 2 00:09 .. -rw--- 1 root root0 Jul 2 00

[PATCH v3 bpf-next 0/4] bpf: Populate bpffs with map and prog iterators

2020-07-23 Thread Alexei Starovoitov
From: Alexei Starovoitov v2->v3: - fixed module unload race (Daniel) - added selftest (Daniel) - fixed build bot warning v1->v2: - changed names to 'progs.debug' and 'maps.debug' to hopefully better indicate instability of the text output. Having dot in the name al

[PATCH v3 bpf-next 4/4] selftests/bpf: Add bpffs preload test.

2020-07-23 Thread Alexei Starovoitov
From: Alexei Starovoitov Add a test that mounts two bpffs instances and checks progs.debug and maps.debug for sanity data. Signed-off-by: Alexei Starovoitov --- .../selftests/bpf/prog_tests/test_bpffs.c | 94 +++ 1 file changed, 94 insertions(+) create mode 100644 tools

Re: [PATCH v5 bpf-next 5/5] selftests/bpf: add get_stackid_cannot_attach

2020-07-23 Thread Alexei Starovoitov
On Thu, Jul 23, 2020 at 11:06:48AM -0700, Song Liu wrote: > + pmu_fd = syscall(__NR_perf_event_open, &attr, -1 /* pid */, > + 0 /* cpu 0 */, -1 /* group id */, > + 0 /* flags */); > + if (pmu_fd < 0 && errno == ENOENT) { > + printf("%s:S

Re: [PATCH bpf-next v4 00/13] bpf: implement bpf iterator for map elements

2020-07-23 Thread Alexei Starovoitov
On Thu, Jul 23, 2020 at 11:41:08AM -0700, Yonghong Song wrote: > Bpf iterator has been implemented for task, task_file, > bpf_map, ipv6_route, netlink, tcp and udp so far. > > For map elements, there are two ways to traverse all elements from > user space: > 1. using BPF_MAP_GET_NEXT_KEY bpf sub

Re: [PATCH] bpf: BPF_SYSCALL depends INET

2020-07-23 Thread Alexei Starovoitov
On Thu, Jul 23, 2020 at 7:19 AM wrote: > > From: Tom Rix > > A link error > > kernel/bpf/net_namespace.o: In function `bpf_netns_link_release': > net_namespace.c: undefined reference to `bpf_sk_lookup_enabled' > > bpf_sk_lookup_enabled is defined with INET > net_namespace is controlled by BPF_SYS

Re: [PATCH v4 bpf-next 2/4] bpf: fail PERF_EVENT_IOC_SET_BPF when bpf_get_[stack|stackid] cannot work

2020-07-23 Thread Alexei Starovoitov
On Wed, Jul 22, 2020 at 11:20 PM Song Liu wrote: > > > > > On Jul 22, 2020, at 10:55 PM, Alexei Starovoitov > > wrote: > > > > On Wed, Jul 22, 2020 at 11:42:08AM -0700, Song Liu wrote: > >> diff --git a/kernel/events/core.c b/kernel/events/core.c >

Re: [PATCH bpf-next v3 00/13] bpf: implement bpf iterator for map elements

2020-07-22 Thread Alexei Starovoitov
On Wed, Jul 22, 2020 at 11:15:33PM -0700, Yonghong Song wrote: > Bpf iterator has been implemented for task, task_file, > bpf_map, ipv6_route, netlink, tcp and udp so far. > > For map elements, there are two ways to traverse all elements from > user space: > 1. using BPF_MAP_GET_NEXT_KEY bpf sub

Re: [PATCH v4 bpf-next 2/4] bpf: fail PERF_EVENT_IOC_SET_BPF when bpf_get_[stack|stackid] cannot work

2020-07-22 Thread Alexei Starovoitov
On Wed, Jul 22, 2020 at 11:42:08AM -0700, Song Liu wrote: > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 856d98c36f562..f77d009fcce95 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -9544,6 +9544,24 @@ static int perf_event_set_bpf_handler(struct > perf_ev

Re: [PATCH bpf-next v2 01/13] bpf: refactor bpf_iter_reg to have separate seq_info member

2020-07-22 Thread Alexei Starovoitov
On Wed, Jul 22, 2020 at 11:49:45AM -0700, Yonghong Song wrote: > diff --git a/kernel/bpf/map_iter.c b/kernel/bpf/map_iter.c > index 8a7af11b411f..5812dd465c49 100644 > --- a/kernel/bpf/map_iter.c > +++ b/kernel/bpf/map_iter.c > @@ -85,17 +85,21 @@ static const struct seq_operations bpf_map_seq_ops

Re: [PATCH bpf-next 0/2] Fix BPF socket lookup with reuseport groups with connections

2020-07-22 Thread Alexei Starovoitov
On Wed, Jul 22, 2020 at 9:59 AM Kuniyuki Iwashima wrote: > > From: Jakub Sitnicki > Date: Wed, 22 Jul 2020 18:17:18 +0200 > > This mini series contains a fix for a bug noticed when analyzing a reported > > merge conflict between bpf-next and net tree [0]. > > > > Apart from fixing a corner-ca

Re: [PATCH bpf-next] tools/bpftool: strip BPF .o files before skeleton generation

2020-07-22 Thread Alexei Starovoitov
On Wed, Jul 22, 2020 at 1:21 AM Quentin Monnet wrote: > > On 22/07/2020 05:38, Andrii Nakryiko wrote: > > Strip away DWARF info from .bpf.o files, before generating BPF skeletons. > > This reduces bpftool binary size from 3.43MB to 2.58MB. > > > > Signed-off-by: Andrii Nakryiko > Acked-by: Quenti

Re: [PATCH bpf-next v2 3/6] bpf: support attaching freplace programs to multiple attach points

2020-07-22 Thread Alexei Starovoitov
On Tue, Jul 21, 2020 at 11:02:04PM -0700, Andrii Nakryiko wrote: > > Just one technical moment, let me double-check my understanding again. > You seem to be favoring pre-creating bpf_tracing_link because there is > both tgt_prog (that we refcnt on EXT prog load) and we also lookup and > initialize

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

2020-07-22 Thread Alexei Starovoitov
On Wed, Jul 22, 2020 at 8:50 AM Willem de Bruijn wrote: > > > TBH, I don't what is the preferred way to handle it. Perhaps DaveM or > > Alexei/Daniel can say what would make their life easiest? > > Good point. > > With the above, there still remains a merge conflict, of course. But > then we can t

Re: get rid of the address_space override in setsockopt

2020-07-22 Thread Alexei Starovoitov
On Wed, Jul 22, 2020 at 12:56 AM Christoph Hellwig wrote: > > On Mon, Jul 20, 2020 at 01:47:56PM -0700, Alexei Starovoitov wrote: > > > a kernel pointer. This is something that works for most common sockopts > > > (and is something that the ePBF support relies on), bu

pull-request: bpf-next 2020-07-21

2020-07-21 Thread Alexei Starovoitov
ou to fetch changes up to 9165e1d70fb34ce438e78aad90408cfa86e4c2d0: bpftool: Use only nftw for file tree parsing (2020-07-21 23:42:56 +0200) Alexei Starovoitov (3): Merge branch 'bpf-socket-lookup' Merge bra

<    1   2   3   4   5   6   7   8   9   10   >