Re: [PATCHv8 bpf-next 1/4] bpf: run devmap xdp_prog on flush instead of bulk enqueue

2021-04-20 Thread Martin KaFai Lau
On Tue, Apr 20, 2021 at 10:56:56PM +0200, Toke Høiland-Jørgensen wrote: > Martin KaFai Lau writes: > > > On Thu, Apr 15, 2021 at 09:53:17PM +0800, Hangbin Liu wrote: > >> From: Jesper Dangaard Brouer > >> > >> This changes the devmap XDP program suppor

Re: [PATCHv8 bpf-next 1/4] bpf: run devmap xdp_prog on flush instead of bulk enqueue

2021-04-20 Thread Martin KaFai Lau
On Thu, Apr 15, 2021 at 09:53:17PM +0800, Hangbin Liu wrote: > From: Jesper Dangaard Brouer > > This changes the devmap XDP program support to run the program when the > bulk queue is flushed instead of before the frame is enqueued. This has > a couple of benefits: > > - It "sorts" the packets b

Re: [PATCHv8 bpf-next 2/4] xdp: extend xdp_redirect_map with broadcast support

2021-04-20 Thread Martin KaFai Lau
rc4 + patch | redirect_map multi i40e->veth |1.7M | 10.9M > 5.12 rc4 + patch | redirect_map multi i40e->mlx4+veth |1.2M | 3.8M > > Acked-by: Toke Høiland-Jørgensen > Signed-off-by: Hangbin Liu > > --- > v8: > use hlist_for_each_entry_rcu() when looping the devmap hash ojbs Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v4 0/3] add batched ops for percpu array

2021-04-16 Thread Martin KaFai Lau
f this patchset. > > The tests were updated to reflect all the new changes. Acked-by: Martin KaFai Lau

Re: [PATCHv7 bpf-next 1/4] bpf: run devmap xdp_prog on flush instead of bulk enqueue

2021-04-16 Thread Martin KaFai Lau
On Fri, Apr 16, 2021 at 03:45:23PM +0200, Jesper Dangaard Brouer wrote: > On Thu, 15 Apr 2021 17:39:13 -0700 > Martin KaFai Lau wrote: > > > On Thu, Apr 15, 2021 at 10:29:40PM +0200, Toke Høiland-Jørgensen wrote: > > > Jesper Dangaard Brouer writes: > > > >

Re: [PATCHv7 bpf-next 1/4] bpf: run devmap xdp_prog on flush instead of bulk enqueue

2021-04-16 Thread Martin KaFai Lau
On Fri, Apr 16, 2021 at 12:03:41PM +0200, Toke Høiland-Jørgensen wrote: > Martin KaFai Lau writes: > > > On Thu, Apr 15, 2021 at 10:29:40PM +0200, Toke Høiland-Jørgensen wrote: > >> Jesper Dangaard Brouer writes: > >> > >> > On Thu, 15 Apr 2021 10:

Re: [PATCHv7 bpf-next 1/4] bpf: run devmap xdp_prog on flush instead of bulk enqueue

2021-04-15 Thread Martin KaFai Lau
On Thu, Apr 15, 2021 at 10:29:40PM +0200, Toke Høiland-Jørgensen wrote: > Jesper Dangaard Brouer writes: > > > On Thu, 15 Apr 2021 10:35:51 -0700 > > Martin KaFai Lau wrote: > > > >> On Thu, Apr 15, 2021 at 11:22:19AM +0200, Toke Høiland-Jørgensen

Re: [PATCHv7 bpf-next 1/4] bpf: run devmap xdp_prog on flush instead of bulk enqueue

2021-04-15 Thread Martin KaFai Lau
On Thu, Apr 15, 2021 at 11:22:19AM +0200, Toke Høiland-Jørgensen wrote: > Hangbin Liu writes: > > > On Wed, Apr 14, 2021 at 05:17:11PM -0700, Martin KaFai Lau wrote: > >> > static void bq_xmit_all(struct xdp_dev_bulk_queue *bq, u32 flags) > >> > { > &g

Re: [PATCH] tools/testing: Remove unused variable

2021-04-14 Thread Martin KaFai Lau
On Wed, Apr 14, 2021 at 10:16:39PM +0800, zuoqil...@163.com wrote: > From: zuoqilin > > Remove unused variable "ret2". Please tag the targeting branch in the future as described in Documentation/bpf/bpf_devel_QA.rst. This one belongs to bpf-next. Acked-by: Martin KaFai Lau

Re: [PATCHv7 bpf-next 2/4] xdp: extend xdp_redirect_map with broadcast support

2021-04-14 Thread Martin KaFai Lau
On Wed, Apr 14, 2021 at 08:26:08PM +0800, Hangbin Liu wrote: [ ... ] > +static __always_inline int __bpf_xdp_redirect_map(struct bpf_map *map, u32 > ifindex, > + u64 flags, u64 flag_mask, > void *lookup_

Re: [PATCHv7 bpf-next 1/4] bpf: run devmap xdp_prog on flush instead of bulk enqueue

2021-04-14 Thread Martin KaFai Lau
On Wed, Apr 14, 2021 at 08:26:07PM +0800, Hangbin Liu wrote: [ ... ] > diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c > index aa516472ce46..3980fb3bfb09 100644 > --- a/kernel/bpf/devmap.c > +++ b/kernel/bpf/devmap.c > @@ -57,6 +57,7 @@ struct xdp_dev_bulk_queue { > struct list_head f

Re: [PATCH bpf-next v3 3/3] bpf: selftests: update array map tests for per-cpu batched ops

2021-04-12 Thread Martin KaFai Lau
On Mon, Apr 12, 2021 at 04:40:01PM -0300, Pedro Tammela wrote: > Follows the same logic as the hashtable tests. > > Signed-off-by: Pedro Tammela > --- > .../bpf/map_tests/array_map_batch_ops.c | 110 +- > 1 file changed, 80 insertions(+), 30 deletions(-) > > diff --git a/t

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

2021-04-02 Thread Martin KaFai Lau
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(+) diff --git a/tools/testing/selftests/bpf/config b/tools/testing

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

2021-04-01 Thread Martin KaFai Lau
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: > > > On Mon, 29 Mar 2021 at 02:25,

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

2021-03-30 Thread Martin KaFai Lau
It will be difficult for others to follow. ] > On Tue, Mar 30, 2021 at 2:43 PM Martin KaFai Lau wrote: > > > > On Tue, Mar 30, 2021 at 12:58:22PM -0700, Cong Wang wrote: > > > On Tue, Mar 30, 2021 at 7:36 AM Alexei Starovoitov > > > wrote: > > > >

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

2021-03-30 Thread Martin KaFai Lau
On Tue, Mar 30, 2021 at 12:58:22PM -0700, Cong Wang wrote: > On Tue, Mar 30, 2021 at 7:36 AM Alexei Starovoitov > wrote: > > > > On Tue, Mar 30, 2021 at 2:43 AM Lorenz Bauer wrote: > > > > > > On Thu, 25 Mar 2021 at 01:52, Martin KaFai Lau wrote: > &g

[PATCH bpf-next 2/2] bpf: selftests: Update clang requirement in README.rst for testing kfunc call

2021-03-29 Thread Martin KaFai Lau
This patch updates the README.rst to specify the clang requirement to compile the bpf selftests that call kernel function. Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/README.rst | 14 ++ 1 file changed, 14 insertions(+) diff --git a/tools/testing/selftests/bpf

[PATCH bpf-next 1/2] bpf: Update bpf_design_QA.rst to clarify the kfunc call is not ABI

2021-03-29 Thread Martin KaFai Lau
This patch updates bpf_design_QA.rst to clarify that the kernel function callable by bpf program is not an ABI. Signed-off-by: Martin KaFai Lau --- Documentation/bpf/bpf_design_QA.rst | 15 +++ 1 file changed, 15 insertions(+) diff --git a/Documentation/bpf/bpf_design_QA.rst b

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

2021-03-29 Thread Martin KaFai Lau
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. Martin KaFai Lau (2): bpf: Update bpf_design_QA.rst to clarify the kfunc call is not ABI bpf: selftests: Update

[PATCH bpf-next] bpf: tcp: Limit calling some tcp cc functions to CONFIG_DYNAMIC_FTRACE

2021-03-29 Thread Martin KaFai Lau
Cong Wang Reported-by: Lorenz Bauer Signed-off-by: Martin KaFai Lau --- net/ipv4/bpf_tcp_ca.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv4/bpf_tcp_ca.c b/net/ipv4/bpf_tcp_ca.c index 6bb7b335ff9f..dff4f0eb96b0 100644 --- a/net/ipv4/bpf_tcp_ca.c +++ b/net/ipv4/bpf_tcp_ca.c @@ -18

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

2021-03-29 Thread Martin KaFai Lau
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 r

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

2021-03-28 Thread Martin KaFai Lau
On Sun, Mar 28, 2021 at 01:13:35PM -0700, Cong Wang wrote: > On Sat, Mar 27, 2021 at 3:54 PM Alexei Starovoitov > wrote: > > > > On Sat, Mar 27, 2021 at 3:08 PM Cong Wang wrote: > > > BTFIDS vmlinux > > > FAILED unresolved symbol cubictcp_state > > > make: *** [Makefile:1199: vmlinux] Error 25

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

2021-03-28 Thread Martin KaFai Lau
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 --- net/ipv4/bpf_tcp_ca.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff -

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

2021-03-25 Thread Martin KaFai Lau
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 exciting stuff! :) > >

Re: [PATCH bpf v2 2/2] bpf/selftests: test that kernel rejects a TCP CC with an invalid license

2021-03-25 Thread Martin KaFai Lau
return 0; > + } > + > + log_buf = va_arg(args, char *); > + if (!log_buf) > + goto out; > + if (err_str && strstr(log_buf, err_str) != NULL) > + found = true; > +out: > + printf(format, log_buf); > + return

Re: [PATCH bpf 2/2] bpf/selftests: test that kernel rejects a TCP CC with an invalid license

2021-03-25 Thread Martin KaFai Lau
On Thu, Mar 25, 2021 at 04:40:34PM +0100, Toke Høiland-Jørgensen wrote: > This adds a selftest to check that the verifier rejects a TCP CC struct_ops > with a non-GPL license. To save having to add a whole new BPF object just > for this, reuse the dctcp CC, but rewrite the license field before load

Re: [PATCH bpf 1/2] bpf: enforce that struct_ops programs be GPL-only

2021-03-25 Thread Martin KaFai Lau
GPL compatible > license\n"); > + return -EINVAL; > + } > + Thanks for the patch. A nit. Instead of sitting in between of the attach_btf_id check and expected_attach_type check, how about moving it to the beginning of this function. Checking attach_btf_id and expected_attach_type would make more sense to be done next to each other as in the current code. Acked-by: Martin KaFai Lau

[PATCH v2 bpf-next 14/14] bpf: selftests: Add kfunc_call test

2021-03-24 Thread Martin KaFai Lau
This patch adds a few kernel function bpf_kfunc_call_test*() for the selftest's test_run purpose. They will be allowed for tc_cls prog. The selftest calling the kernel function bpf_kfunc_call_test*() is also added in this patch. Signed-off-by: Martin KaFai Lau --- include/linux/

[PATCH v2 bpf-next 13/14] bpf: selftests: bpf_cubic and bpf_dctcp calling kernel functions

2021-03-24 Thread Martin KaFai Lau
() instead. Acked-by: Andrii Nakryiko Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/bpf_tcp_helpers.h | 29 ++- tools/testing/selftests/bpf/progs/bpf_cubic.c | 6 ++-- tools/testing/selftests/bpf/progs/bpf_dctcp.c | 22 -- 3 files changed, 11 insertions

[PATCH v2 bpf-next 12/14] bpf: selftests: Rename bictcp to bpf_cubic

2021-03-24 Thread Martin KaFai Lau
As a similar chanage in the kernel, this patch gives the proper name to the bpf cubic. Acked-by: Andrii Nakryiko Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/progs/bpf_cubic.c | 30 +-- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tools

[PATCH v2 bpf-next 11/14] libbpf: Support extern kernel function

2021-03-24 Thread Martin KaFai Lau
e required LLVM patch: https://reviews.llvm.org/D93563 Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/libbpf.c | 174 ++--- 1 file changed, 162 insertions(+), 12 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 23148566ab3a..c65

[PATCH v2 bpf-next 10/14] libbpf: Record extern sym relocation first

2021-03-24 Thread Martin KaFai Lau
existing is_ldimm64() helper is renamed to is_ldimm64_insn() for consistency. Acked-by: Andrii Nakryiko Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/libbpf.c | 63 +++--- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/tools/lib/bpf

[PATCH v2 bpf-next 09/14] libbpf: Rename RELO_EXTERN to RELO_EXTERN_VAR

2021-03-24 Thread Martin KaFai Lau
This patch renames RELO_EXTERN to RELO_EXTERN_VAR. It is to avoid the confusion with a later patch adding RELO_EXTERN_FUNC. Acked-by: Andrii Nakryiko Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/libbpf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/lib

[PATCH v2 bpf-next 08/14] libbpf: Refactor codes for finding btf id of a kernel symbol

2021-03-24 Thread Martin KaFai Lau
This patch refactors code, that finds kernel btf_id by kind and symbol name, to a new function find_ksym_btf_id(). It also adds a new helper __btf_kind_str() to return a string by the numeric kind value. Acked-by: Andrii Nakryiko Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/libbpf.c | 44

[PATCH v2 bpf-next 07/14] libbpf: Refactor bpf_object__resolve_ksyms_btf_id

2021-03-24 Thread Martin KaFai Lau
: Andrii Nakryiko Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/libbpf.c | 124 ++--- 1 file changed, 67 insertions(+), 57 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 058b643cbcb1..57123a2179b4 100644 --- a/tools/lib/bpf

[PATCH v2 bpf-next 06/14] bpf: tcp: Put some tcp cong functions in allowlist for bpf-tcp-cc

2021-03-24 Thread Martin KaFai Lau
. When any of them has changed, the bpf-tcp-cc program has to be changed like any in-tree/out-of-tree kernel tcp-cc implementations do also. Acked-by: Andrii Nakryiko Signed-off-by: Martin KaFai Lau --- net/ipv4/bpf_tcp_ca.c | 41 + 1 file changed, 41

[PATCH v2 bpf-next 05/14] tcp: Rename bictcp function prefix to cubictcp

2021-03-24 Thread Martin KaFai Lau
one to call during bpf prog load time. Signed-off-by: Martin KaFai Lau --- net/ipv4/tcp_cubic.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c index ffcbe46dacdb..4a30deaa9a37 100644 --- a/net/ipv4

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

2021-03-24 Thread Martin KaFai Lau
the same way as it displays other bpf helper calls. gpl_compatible program is required to call kernel function. This feature currently requires JIT. The verifier selftests are adjusted because of the changes in the verbose log in add_subprog_and_kfunc(). Signed-off-by: Martin KaFai Lau --- arch

[PATCH v2 bpf-next 04/14] bpf: Support kernel function call in x86-32

2021-03-24 Thread Martin KaFai Lau
This patch adds kernel function call support to the x86-32 bpf jit. Signed-off-by: Martin KaFai Lau --- arch/x86/net/bpf_jit_comp32.c | 198 ++ 1 file changed, 198 insertions(+) diff --git a/arch/x86/net/bpf_jit_comp32.c b/arch/x86/net/bpf_jit_comp32.c index

[PATCH v2 bpf-next 01/14] bpf: Simplify freeing logic in linfo and jited_linfo

2021-03-24 Thread Martin KaFai Lau
function call descriptors will also be done in the "bpf_prog_jit_attempt_done()". "bpf_prog_free_linfo()" is removed since it is only called by "__bpf_prog_put_noref()". The kvfree() are directly called instead. It also takes this chance to s/kcalloc/kvcalloc/ for

[PATCH v2 bpf-next 02/14] bpf: Refactor btf_check_func_arg_match

2021-03-24 Thread Martin KaFai Lau
mprove the indentation which will be useful for a later patch. Some of the "btf_kind_str[]" usages is replaced with the shortcut "btf_type_str(t)". Signed-off-by: Martin KaFai Lau --- include/linux/bpf.h | 4 +- include/linux/btf.h | 5 +

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

2021-03-24 Thread Martin KaFai Lau
ii) - Move btf_func_linkage() from btf.h to libbpf.c in patch 11. (Andrii) - Fixed the linker error when CONFIG_BPF_SYSCALL is not defined. Moved the check_kfunc_call from filter.c to test_run.c in patch 14. (kernel test robot) Martin KaFai Lau (14): bpf: Simplify freeing logic in linfo and jited_l

Re: [PATCH bpf-next 02/15] bpf: btf: Support parsing extern func

2021-03-22 Thread Martin KaFai Lau
On Sat, Mar 20, 2021 at 10:18:36AM -0700, Andrii Nakryiko wrote: > > From test_ksyms.c: > > [22] DATASEC '.ksyms' size=0 vlen=5 > > type_id=12 offset=0 size=1 > > type_id=13 offset=0 size=1 > > > > For extern, does it make sense for the libbpf to assign 0 to > > both var offset and size s

Re: Design for sk_lookup helper function in context of sk_lookup hook

2021-03-22 Thread Martin KaFai Lau
On Fri, Mar 19, 2021 at 06:05:20PM +0100, Shanti Lombard née Bouchez-Mongardé wrote: > Le 19/03/2021 à 17:55, Martin KaFai Lau a écrit : > > On Wed, Mar 17, 2021 at 10:04:18AM +0100, Shanti Lombard née > > Bouchez-Mongardé wrote: > > > Q1: How do we prevent socket lo

Re: [PATCH bpf-next 02/15] bpf: btf: Support parsing extern func

2021-03-19 Thread Martin KaFai Lau
On Fri, Mar 19, 2021 at 04:02:27PM -0700, Andrii Nakryiko wrote: > On Fri, Mar 19, 2021 at 3:45 PM Martin KaFai Lau wrote: > > > > On Fri, Mar 19, 2021 at 03:29:57PM -0700, Andrii Nakryiko wrote: > > > On Fri, Mar 19, 2021 at 3:19 PM Martin KaFai Lau wrote: > > &g

Re: [PATCH bpf-next 02/15] bpf: btf: Support parsing extern func

2021-03-19 Thread Martin KaFai Lau
On Fri, Mar 19, 2021 at 03:29:57PM -0700, Andrii Nakryiko wrote: > On Fri, Mar 19, 2021 at 3:19 PM Martin KaFai Lau wrote: > > > > On Fri, Mar 19, 2021 at 02:27:13PM -0700, Andrii Nakryiko wrote: > > > On Thu, Mar 18, 2021 at 10:29 PM Martin KaFai Lau wrote: > > &g

Re: [PATCH bpf-next 02/15] bpf: btf: Support parsing extern func

2021-03-19 Thread Martin KaFai Lau
On Fri, Mar 19, 2021 at 02:27:13PM -0700, Andrii Nakryiko wrote: > On Thu, Mar 18, 2021 at 10:29 PM Martin KaFai Lau wrote: > > > > On Thu, Mar 18, 2021 at 09:13:56PM -0700, Andrii Nakryiko wrote: > > > On Thu, Mar 18, 2021 at 4:39 PM Martin KaFai Lau wrote: > > &g

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

2021-03-19 Thread Martin KaFai Lau
On Thu, Mar 18, 2021 at 06:03:49PM -0700, Andrii Nakryiko wrote: > On Tue, Mar 16, 2021 at 12:01 AM Martin KaFai Lau wrote: > > > > This patch adds support to BPF verifier to allow bpf program calling > > kernel function directly. > > > > The use case included i

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

2021-03-19 Thread Martin KaFai Lau
On Thu, Mar 18, 2021 at 04:32:47PM -0700, Andrii Nakryiko wrote: > On Tue, Mar 16, 2021 at 12:01 AM Martin KaFai Lau wrote: > > > > This patch refactors the core logic of "btf_check_func_arg_match()" > > into a new function "do_btf_check_func_arg_match()".

Re: Design for sk_lookup helper function in context of sk_lookup hook

2021-03-19 Thread Martin KaFai Lau
On Wed, Mar 17, 2021 at 10:04:18AM +0100, Shanti Lombard née Bouchez-Mongardé wrote: > Hello everyone, > > Background discussion: > https://lore.kernel.org/bpf/CAADnVQJnX-+9u--px_VnhrMTPB=o9y0lh9t7rjbqzflchbu...@mail.gmail.com/ > > In a previous e-mail I was explaining that sk_lookup BPF progra

Re: [PATCH bpf-next 15/15] bpf: selftest: Add kfunc_call test

2021-03-18 Thread Martin KaFai Lau
On Thu, Mar 18, 2021 at 09:21:08PM -0700, Andrii Nakryiko wrote: > > --- /dev/null > > +++ b/tools/testing/selftests/bpf/prog_tests/kfunc_call.c > > @@ -0,0 +1,61 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* Copyright (c) 2021 Facebook */ > > +#include > > +#include > > +#include "kfunc_ca

Re: [PATCH bpf-next 02/15] bpf: btf: Support parsing extern func

2021-03-18 Thread Martin KaFai Lau
On Thu, Mar 18, 2021 at 09:13:56PM -0700, Andrii Nakryiko wrote: > On Thu, Mar 18, 2021 at 4:39 PM Martin KaFai Lau wrote: > > > > On Thu, Mar 18, 2021 at 03:53:38PM -0700, Andrii Nakryiko wrote: > > > On Tue, Mar 16, 2021 at 12:01 AM Martin KaFai Lau wrote: > > &g

Re: [PATCH bpf-next 12/15] libbpf: Support extern kernel function

2021-03-18 Thread Martin KaFai Lau
On Thu, Mar 18, 2021 at 09:11:39PM -0700, Andrii Nakryiko wrote: > On Tue, Mar 16, 2021 at 12:02 AM Martin KaFai Lau wrote: > > > > This patch is to make libbpf able to handle the following extern > > kernel function declaration and do the needed relocations before > >

Re: [PATCH bpf-next 02/15] bpf: btf: Support parsing extern func

2021-03-18 Thread Martin KaFai Lau
On Thu, Mar 18, 2021 at 03:53:38PM -0700, Andrii Nakryiko wrote: > On Tue, Mar 16, 2021 at 12:01 AM Martin KaFai Lau wrote: > > > > This patch makes BTF verifier to accept extern func. It is used for > > allowing bpf program to call a limited set of kernel functions

[PATCH bpf-next 14/15] bpf: selftest: bpf_cubic and bpf_dctcp calling kernel functions

2021-03-15 Thread Martin KaFai Lau
() instead. Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/bpf_tcp_helpers.h | 29 ++- tools/testing/selftests/bpf/progs/bpf_cubic.c | 6 ++-- tools/testing/selftests/bpf/progs/bpf_dctcp.c | 22 -- 3 files changed, 11 insertions(+), 46 deletions(-) diff

[PATCH bpf-next 15/15] bpf: selftest: Add kfunc_call test

2021-03-15 Thread Martin KaFai Lau
This patch adds two kernel function bpf_kfunc_call_test[12]() for the selftest's test_run purpose. They will be allowed for tc_cls prog. The selftest calling the kernel function bpf_kfunc_call_test[12]() is also added in this patch. Signed-off-by: Martin KaFai Lau --- net/bpf/test_

[PATCH bpf-next 13/15] bpf: selftests: Rename bictcp to bpf_cubic

2021-03-15 Thread Martin KaFai Lau
As a similar chanage in the kernel, this patch gives the proper name to the bpf cubic. Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/progs/bpf_cubic.c | 30 +-- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/bpf/progs

[PATCH bpf-next 12/15] libbpf: Support extern kernel function

2021-03-15 Thread Martin KaFai Lau
are vars. It also takes this chance to remove the "if (... || (t->size && t->size != size)) { return -ENOENT; }" test because t->size is zero at the point. The required LLVM patch: https://reviews.llvm.org/D93563 Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/bt

[PATCH bpf-next 08/15] libbpf: Refactor bpf_object__resolve_ksyms_btf_id

2021-03-15 Thread Martin KaFai Lau
: Martin KaFai Lau --- tools/lib/bpf/libbpf.c | 125 ++--- 1 file changed, 68 insertions(+), 57 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 2f351d3ad3e7..7d5f9b7877bc 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf

[PATCH bpf-next 07/15] bpf: tcp: White list some tcp cong functions to be called by bpf-tcp-cc

2021-03-15 Thread Martin KaFai Lau
fixed ABI contract. When any of them has changed, the bpf-tcp-cc program has to be changed like any in-tree/out-of-tree kernel tcp-cc implementations do also. Signed-off-by: Martin KaFai Lau --- net/ipv4/bpf_tcp_ca.c | 41 + 1 file changed, 41 insertions

[PATCH bpf-next 10/15] libbpf: Rename RELO_EXTERN to RELO_EXTERN_VAR

2021-03-15 Thread Martin KaFai Lau
This patch renames RELO_EXTERN to RELO_EXTERN_VAR. It is to avoid the confusion with a later patch adding RELO_EXTERN_FUNC. Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/libbpf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf

[PATCH bpf-next 11/15] libbpf: Record extern sym relocation first

2021-03-15 Thread Martin KaFai Lau
This patch records the extern sym relocs first before recording subprog relocs. The later patch will have relocs for extern kernel function call which is also using BPF_JMP | BPF_CALL. It will be easier to handle the extern symbols first in the later patch. Signed-off-by: Martin KaFai Lau

[PATCH bpf-next 09/15] libbpf: Refactor codes for finding btf id of a kernel symbol

2021-03-15 Thread Martin KaFai Lau
This patch refactors code, that finds kernel btf_id by kind and symbol name, to a new function find_ksym_btf_id(). It also adds a new helper __btf_kind_str() to return a string by the numeric kind value. Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/libbpf.c | 44

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

2021-03-15 Thread Martin KaFai Lau
; will be able to display the kernel function calls the same way as it displays other bpf helper calls. gpl_compatible program is required to call kernel function. This feature currently requires JIT. Signed-off-by: Martin KaFai Lau --- arch/x86/net/bpf_jit_comp.c | 5 + include/lin

[PATCH bpf-next 06/15] tcp: Rename bictcp function prefix to cubictcp

2021-03-15 Thread Martin KaFai Lau
one to call during bpf prog load time. Signed-off-by: Martin KaFai Lau --- net/ipv4/tcp_cubic.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c index ffcbe46dacdb..4a30deaa9a37 100644 --- a/net/ipv4

[PATCH bpf-next 05/15] bpf: Support kernel function call in x86-32

2021-03-15 Thread Martin KaFai Lau
This patch adds kernel function call support to the x86-32 bpf jit. Signed-off-by: Martin KaFai Lau --- arch/x86/net/bpf_jit_comp32.c | 198 ++ 1 file changed, 198 insertions(+) diff --git a/arch/x86/net/bpf_jit_comp32.c b/arch/x86/net/bpf_jit_comp32.c index

[PATCH bpf-next 02/15] bpf: btf: Support parsing extern func

2021-03-15 Thread Martin KaFai Lau
NC 'foo' type_id=24 linkage=extern This patch allows BTF_FUNC_EXTERN in btf_func_check_meta(). Also extern kernel function declaration does not necessary have arg name. Another change in btf_func_check() is to allow extern function having no arg name. The btf selftest is adjusted accordingly.

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

2021-03-15 Thread Martin KaFai Lau
to improve the indentation which will be useful for a later patch. Some of the "btf_kind_str[]" usages is replaced with the shortcut "btf_type_str(t)". Signed-off-by: Martin KaFai Lau --- include/linux/btf.h | 5 ++ kernel/bpf/btf.c| 159 +++

[PATCH bpf-next 01/15] bpf: Simplify freeing logic in linfo and jited_linfo

2021-03-15 Thread Martin KaFai Lau
function call descriptors will also be done in the "bpf_prog_jit_attempt_done()". "bpf_prog_free_linfo()" is removed since it is only called by "__bpf_prog_put_noref()". The kvfree() are directly called instead. It also takes this chance to s/kcalloc/kvcalloc/ for

[PATCH bpf-next 00/15] Support calling kernel function

2021-03-15 Thread Martin KaFai Lau
ee and out-of-tree kernel tcp-cc implementations have to be changed. The same goes for the struct_ops bpf-tcp-cc programs which have to be adjusted accordingly. Please see individual patch for details. Martin KaFai Lau (15): bpf: Simplify freeing logic in linfo and jited_linfo bpf: btf: Suppo

Re: [PATCH bpf-next] tools/runqslower: allow substituting custom vmlinux.h for the build

2021-03-02 Thread Martin KaFai Lau
ux.h for selftests build"), > allow to provide pre-generated vmlinux.h for runqslower build. Acked-by: Martin KaFai Lau

Re: [PATCH v6 bpf-next 0/6] bpf: enable task local storage for tracing programs

2021-02-25 Thread Martin KaFai Lau
tches. Acked-by: Martin KaFai Lau

Re: [PATCH v6 bpf-next 2/6] bpf: prevent deadlock from recursive bpf_task_storage_[get|delete]

2021-02-25 Thread Martin KaFai Lau
owner of the counter, it is still possible to > trigger deadlock on the other lock. For example, if bpf_local_storage_map > owns the counters, it cannot prevent deadlock on bpf_local_storage->lock > when two maps are used. Acked-by: Martin KaFai Lau

Re: [PATCH v5 bpf-next 1/6] bpf: enable task local storage for tracing programs

2021-02-25 Thread Martin KaFai Lau
n the task free path, e.g. > exit_creds(). To avoid allocating task local storage after > bpf_task_storage_free(). bpf_task_storage_get() is updated to not allocate > new storage when the task is not refcounted (task->usage == 0). Acked-by: Martin KaFai Lau

Re: [PATCH v4 bpf-next 6/6] bpf: runqslower: use task local storage

2021-02-23 Thread Martin KaFai Lau
On Mon, Feb 22, 2021 at 05:20:14PM -0800, Song Liu wrote: > Replace hashtab with task local storage in runqslower. This improves the > performance of these BPF programs. The following table summarizes average > runtime of these programs, in nanoseconds: > > task-local h

Re: [PATCH v4 bpf-next 5/6] bpf: runqslower: prefer using local vmlimux to generate vmlinux.h

2021-02-23 Thread Martin KaFai Lau
On Mon, Feb 22, 2021 at 05:20:13PM -0800, Song Liu wrote: > Update the Makefile to prefer using $(O)/mvlinux, $(KBUILD_OUTPUT)/vmlinux s/mvlinux/vmlinux/

Re: [PATCH v4 bpf-next 1/6] bpf: enable task local storage for tracing programs

2021-02-23 Thread Martin KaFai Lau
On Mon, Feb 22, 2021 at 05:20:09PM -0800, Song Liu wrote: [ ... ] > diff --git a/kernel/bpf/bpf_task_storage.c b/kernel/bpf/bpf_task_storage.c > index e0da0258b732d..2034019966d44 100644 > --- a/kernel/bpf/bpf_task_storage.c > +++ b/kernel/bpf/bpf_task_storage.c > @@ -15,7 +15,6 @@ > #include >

Re: [PATCH v4 bpf-next] Add CONFIG_DEBUG_INFO_BTF and CONFIG_DEBUG_INFO_BTF_MODULES check to bpftool feature command

2021-02-22 Thread Martin KaFai Lau
; definition differences between kernels. Acked-by: Martin KaFai Lau [ Acked-by and Reviewed-by can be carried over to the following revisions if the change is obvious. Also, it is useful to comment on what has changed between revisions. There is no need to resend this patch just for this though. ]

Re: [PATCH v3 bpf-next] Add CONFIG_DEBUG_INFO_BTF check to bpftool feature command

2021-02-22 Thread Martin KaFai Lau
ween kernels. Acked-by: Martin KaFai Lau

[PATCH v2 bpf 2/2] bpf: selftests: Add non function pointer test to struct_ops

2021-02-11 Thread Martin KaFai Lau
This patch adds a "void *owner" member. The existing bpf_tcp_ca test will ensure the bpf_cubic.o and bpf_dctcp.o can be loaded. Acked-by: Andrii Nakryiko Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/bpf_tcp_helpers.h | 1 + 1 file changed, 1 insertion(+) diff --g

[PATCH v2 bpf 1/2] libbpf: Ignore non function pointer member in struct_ops

2021-02-11 Thread Martin KaFai Lau
type is no longer needed. Remove: "skip_mods_and_typedefs(btf, mtype->type, &mtype_id)" - Do "if (!prog)" test before skip_mods_and_typedefs. Fixes: 590a00888250 ("bpf: libbpf: Add STRUCT_OPS support") Acked-by: Andrii Nakryiko Signed-off-by: Martin KaFai Lau

Re: [PATCH bpf 2/2] bpf: selftests: Add non function pointer test to struct_ops

2021-02-10 Thread Martin KaFai Lau
On Wed, Feb 10, 2021 at 06:07:04PM -0800, Andrii Nakryiko wrote: > On Wed, Feb 10, 2021 at 5:55 PM Martin KaFai Lau wrote: > > > > On Wed, Feb 10, 2021 at 02:54:40PM -0800, Andrii Nakryiko wrote: > > > On Wed, Feb 10, 2021 at 1:17 PM Martin KaFai Lau wrote: > > &g

Re: [PATCH bpf 2/2] bpf: selftests: Add non function pointer test to struct_ops

2021-02-10 Thread Martin KaFai Lau
On Wed, Feb 10, 2021 at 02:54:40PM -0800, Andrii Nakryiko wrote: > On Wed, Feb 10, 2021 at 1:17 PM Martin KaFai Lau wrote: > > > > On Wed, Feb 10, 2021 at 12:27:38PM -0800, Andrii Nakryiko wrote: > > > On Tue, Feb 9, 2021 at 12:11 PM Martin KaFai Lau wrote: > >

Re: [PATCH bpf 1/2] libbpf: Ignore non function pointer member in struct_ops

2021-02-10 Thread Martin KaFai Lau
On Wed, Feb 10, 2021 at 12:26:20PM -0800, Andrii Nakryiko wrote: > On Tue, Feb 9, 2021 at 12:40 PM Martin KaFai Lau wrote: > > > > When libbpf initializes the kernel's struct_ops in > > "bpf_map__init_kern_struct_ops()", it enforces all > > pointer ty

Re: [PATCH bpf 2/2] bpf: selftests: Add non function pointer test to struct_ops

2021-02-10 Thread Martin KaFai Lau
On Wed, Feb 10, 2021 at 12:27:38PM -0800, Andrii Nakryiko wrote: > On Tue, Feb 9, 2021 at 12:11 PM Martin KaFai Lau wrote: > > > > This patch adds a "void *owner" member. The existing > > bpf_tcp_ca test will ensure the bpf_cubic.o and bpf_dctcp.o > > can be

Re: [PATCH] bpf_lru_list: Read double-checked variable once without lock

2021-02-09 Thread Martin KaFai Lau
urn; > > - if (node->type == BPF_LRU_LOCAL_LIST_T_PENDING) { > + if (node_type == BPF_LRU_LOCAL_LIST_T_PENDING) { I think this can be bpf-next. Acked-by: Martin KaFai Lau

[PATCH bpf 1/2] libbpf: Ignore non function pointer member in struct_ops

2021-02-09 Thread Martin KaFai Lau
if (!prog) { continue; }". The "btf_is_func_proto(mtype)" has already been guaranteed in "bpf_object__collect_st_ops_relos()" which has been run before "bpf_map__init_kern_struct_ops()". Thus, this check is removed. Fixes: 590a00888250 ("bpf: libbpf:

[PATCH bpf 2/2] bpf: selftests: Add non function pointer test to struct_ops

2021-02-09 Thread Martin KaFai Lau
This patch adds a "void *owner" member. The existing bpf_tcp_ca test will ensure the bpf_cubic.o and bpf_dctcp.o can be loaded. Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/bpf_tcp_helpers.h | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/sel

Re: [PATCH bpf-next v3 2/2] selftests/bpf: verify that rebinding to port < 1024 from BPF works

2021-01-27 Thread Martin KaFai Lau
On Tue, Jan 26, 2021 at 08:51:04AM -0800, Stanislav Fomichev wrote: > Return 3 to indicate that permission check for port 111 > should be skipped. > [ ... ] > +void cap_net_bind_service(cap_flag_value_t flag) > +{ > + const cap_value_t cap_net_bind_service = CAP_NET_BIND_SERVICE; > + cap

Re: [PATCH bpf-next v3 1/2] bpf: allow rewriting to ports under ip_unprivileged_port_start

2021-01-27 Thread Martin KaFai Lau
v3: > - Update description (Martin KaFai Lau) > - Fix capability restore in selftest (Martin KaFai Lau) > > v2: > - Switch to explicit return code (Martin KaFai Lau) > [ ... ] > @@ -499,7 +501,8 @@ int __inet_bind(struct sock *sk, struct sockaddr *uaddr, > int addr_len

Re: [PATCH bpf-next v4 2/2] selftests/bpf: verify that rebinding to port < 1024 from BPF works

2021-01-26 Thread Martin KaFai Lau
On Tue, Jan 26, 2021 at 11:35:44AM -0800, Stanislav Fomichev wrote: > Return 3 to indicate that permission check for port 111 > should be skipped. Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v4 1/2] bpf: allow rewriting to ports under ip_unprivileged_port_start

2021-01-26 Thread Martin KaFai Lau
v4: > - Add missing IPv6 support (Martin KaFai Lau) > > v3: > - Update description (Martin KaFai Lau) > - Fix capability restore in selftest (Martin KaFai Lau) > > v2: > - Switch to explicit return code (Martin KaFai Lau) Reviewed-by: Martin KaFai Lau

Re: [PATCH bpf-next v2 1/2] bpf: allow rewriting to ports under ip_unprivileged_port_start

2021-01-25 Thread Martin KaFai Lau
On Mon, Jan 25, 2021 at 03:32:53PM -0800, Stanislav Fomichev wrote: > On Mon, Jan 25, 2021 at 3:25 PM Martin KaFai Lau wrote: > > > > On Mon, Jan 25, 2021 at 09:26:40AM -0800, Stanislav Fomichev wrote: > > > At the moment, BPF_CGROUP_INET{4,6}_BIND hooks can rewrit

Re: [PATCH bpf-next v2 2/2] selftests/bpf: verify that rebinding to port < 1024 from BPF works

2021-01-25 Thread Martin KaFai Lau
> > Cc: Andrey Ignatov > Cc: Martin KaFai Lau > Signed-off-by: Stanislav Fomichev > --- > .../selftests/bpf/prog_tests/bind_perm.c | 85 +++ > tools/testing/selftests/bpf/progs/bind_perm.c | 36 > 2 files changed, 121 insertions(+) > c

Re: [PATCH bpf-next v2 1/2] bpf: allow rewriting to ports under ip_unprivileged_port_start

2021-01-25 Thread Martin KaFai Lau
On Mon, Jan 25, 2021 at 09:26:40AM -0800, Stanislav Fomichev wrote: > At the moment, BPF_CGROUP_INET{4,6}_BIND hooks can rewrite user_port > to the privileged ones (< ip_unprivileged_port_start), but it will > be rejected later on in the __inet_bind or __inet6_bind. > > Let's export 'port_changed'

Re: [PATCH bpf-next 2/2] selftests/bpf: verify that rebinding to port < 1024 from BPF works

2021-01-22 Thread Martin KaFai Lau
On Fri, Jan 22, 2021 at 08:16:40AM -0800, s...@google.com wrote: > On 01/21, Martin KaFai Lau wrote: > > On Thu, Jan 21, 2021 at 04:30:08PM -0800, s...@google.com wrote: > > > On 01/21, Martin KaFai Lau wrote: > > > > On Thu, Jan 21, 2021 at 02:57:44PM -0800, s...@goo

Re: [PATCH bpf-next 2/2] selftests/bpf: verify that rebinding to port < 1024 from BPF works

2021-01-21 Thread Martin KaFai Lau
On Thu, Jan 21, 2021 at 04:30:08PM -0800, s...@google.com wrote: > On 01/21, Martin KaFai Lau wrote: > > On Thu, Jan 21, 2021 at 02:57:44PM -0800, s...@google.com wrote: > > > On 01/21, Martin KaFai Lau wrote: > > > > On Wed, Jan 20, 2021 at 05:22:41PM -

Re: [PATCH bpf-next 2/2] selftests/bpf: verify that rebinding to port < 1024 from BPF works

2021-01-21 Thread Martin KaFai Lau
On Thu, Jan 21, 2021 at 02:57:44PM -0800, s...@google.com wrote: > On 01/21, Martin KaFai Lau wrote: > > On Wed, Jan 20, 2021 at 05:22:41PM -0800, Stanislav Fomichev wrote: > > > BPF rewrites from 111 to 111, but it still should mark the port as > > > "changed&quo

Re: [PATCH bpf-next 2/2] selftests/bpf: verify that rebinding to port < 1024 from BPF works

2021-01-21 Thread Martin KaFai Lau
On Wed, Jan 20, 2021 at 05:22:41PM -0800, Stanislav Fomichev wrote: > BPF rewrites from 111 to 111, but it still should mark the port as > "changed". > We also verify that if port isn't touched by BPF, it's still prohibited. > > Signed-off-by: Stanislav Fomichev > --- > .../selftests/bpf/prog_te

Re: More flexible BPF socket inet_lookup hooking after listening sockets are dispatched

2021-01-21 Thread Martin KaFai Lau
On Thu, Jan 21, 2021 at 09:40:19PM +0100, Shanti Lombard wrote: > Le 2021-01-21 12:14, Jakub Sitnicki a écrit : > > On Wed, Jan 20, 2021 at 10:06 PM CET, Alexei Starovoitov wrote: > > > > There is also documentation in the kernel: > > > > https://www.kernel.org/doc/html/latest/bpf/prog_sk_lookup.

  1   2   3   4   5   6   7   8   9   10   >