Re: [PATCH bpf 2/2] net/flow_dissector: correctly cap nhoff and thoff in case of BPF

2018-12-06 Thread Song Liu
;flow_dissector: properly cap thoff field")'. > > Signed-off-by: Stanislav Fomichev Acked-by: Song Liu > --- > net/core/flow_dissector.c | 5 - > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector

Re: [PATCH bpf 1/2] selftests/bpf: use thoff instead of nhoff in BPF flow dissector

2018-12-06 Thread Song Liu
ds confusion, when by the time bpf flow dissector exits, > nhoff == thoff, which doesn't make much sense. > > Signed-off-by: Stanislav Fomichev Acked-by: Song Liu > --- > net/core/flow_dissector.c | 1 + > tools/testing/selftests/bpf/bpf_flow.c | 36 -

Re: [PATCH bpf-next v2 0/5] support flow dissector in BPF_PROG_TEST_RUN

2018-12-05 Thread Song Liu
; tools/testing/selftests/bpf/test_progs.c | 78 +++- > 10 files changed, 289 insertions(+), 94 deletions(-) > create mode 100644 tools/testing/selftests/bpf/flow_dissector_load.h > > -- > 2.20.0.rc1.387.gf8505762e3-goog > For the series: Acked-by: Song Liu

Re: [PATCH bpf-next v2 3/5] selftests/bpf: use thoff instead of nhoff in BPF flow dissector

2018-12-05 Thread Song Liu
On Tue, Dec 4, 2018 at 3:26 PM Stanislav Fomichev wrote: > > On 12/04, Song Liu wrote: > > On Mon, Dec 3, 2018 at 8:01 PM Stanislav Fomichev wrote: > > > > > > We are returning thoff from the flow dissector, not the nhoff. Pass > > > thoff along with nh

Re: [PATCH bpf-next 2/3] bpf: add BPF_PROG_TEST_RUN support for flow dissector

2018-12-04 Thread Song Liu
On Mon, Dec 3, 2018 at 3:08 PM Stanislav Fomichev wrote: > > On 12/03, Song Liu wrote: > > On Mon, Dec 3, 2018 at 11:00 AM Stanislav Fomichev wrote: > > > > > > The input is packet data, the output is struct bpf_flow_key. This should > > > make it easy

Re: [PATCH bpf-next v2 4/5] net/flow_dissector: correctly cap nhoff and thoff in case of BPF

2018-12-04 Thread Song Liu
off = min_t(u16, key_control->thoff, > - skb->len); > rcu_read_unlock(); > return ret; > } > -- > 2.20.0.rc1.387.gf8505762e3-goog > Same question as 3/5: Do we need this fix without this set? If yes, do we need it for bpf tree as well? Thanks, Song

Re: [PATCH bpf-next v2 3/5] selftests/bpf: use thoff instead of nhoff in BPF flow dissector

2018-12-04 Thread Song Liu
etwork_offset(skb); > + flow_keys->thoff = flow_keys->nhoff; Do we need this fix without this set? If yes, do we need it for bpf tree as well? Thanks, Song > > bpf_compute_data_pointers((struct sk_buff *)skb); > result = BPF_PROG_RUN(prog, skb); > diff

Re: [PATCH bpf-next 2/3] bpf: add BPF_PROG_TEST_RUN support for flow dissector

2018-12-03 Thread Song Liu
t = __skb_flow_bpf_dissect(prog, ctx, _keys_dissector, > +flow_keys); > + break; > + default: > + ret = BPF_PROG_RUN(prog, ctx); > + break; > + } > + Is it possible to fold the

Re: [PATCH v2] samples: bpf: fix: seg fault with NULL pointer arg

2018-12-03 Thread Song Liu
Signed-off-by: Daniel T. Lee Acked-by: Song Liu > --- > samples/bpf/bpf_load.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c > index 434ea34a5954..eae7b635343d 100644 > --- a/samples/bpf/bpf_loa

Re: [PATCH bpf] mips: bpf: fix encoding bug for mm_srlv32_op

2018-12-02 Thread Song Liu
Binutils libopcode > implementation which is using 0x50 for srlv and 0x90 for srav. > > Fixes: f31318fdf324 ("MIPS: uasm: Add srlv uasm instruction") > CC: Markos Chandras > CC: Paul Burton > Acked-by: Jakub Kicinski > Signed-off-by: Jiong Wang Acked-by: Song Liu >

Re: [PATCH] samples: bpf: fix: seg fault with NULL pointer arg

2018-12-02 Thread Song Liu
es/bpf/bpf_load.c > @@ -58,7 +58,9 @@ static int write_kprobe_events(const char *val) > { > int fd, ret, flags; > > - if ((val != NULL) && (val[0] == '\0')) > + if (val == NULL) > + return -1; > + else if ((val != NULL) && (val[0] == '\0')) We only need + else if (val[0] == '\0') right? Thanks, Song

Re: [PATCH bpf-next] libbpf: Fix license in README.rst

2018-12-02 Thread Song Liu
gt; permissions should be needed. > > Fixes: 76d1b894c515 ("libbpf: Document API and ABI conventions") > Signed-off-by: Andrey Ignatov Acked-by: Song Liu > --- > tools/lib/bpf/README.rst | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/to

Re: [PATCH bpf-next v2] bpf: allow BPF read access to qdisc pkt_len

2018-12-02 Thread Song Liu
as wire_len. > > Changes v1->v2 > - Rename pkt_len to wire_len > > Signed-off-by: Petar Penkov > Signed-off-by: Vlad Dumitrescu > Signed-off-by: Willem de Bruijn Acked-by: Song Liu > --- > include/uapi/linux/bpf.h| 1 + > net/core/filter.

Re: [PATCH net] bpf: uninitialized variables in test code

2018-11-30 Thread Song Liu
n. The functions require CAP_SYS_ADMIN so it's not really an > information leak. > > Fixes: 1cf1cae963c2 ("bpf: introduce BPF_PROG_TEST_RUN command") > Signed-off-by: Dan Carpenter Acked-by: Song Liu > --- > net/bpf/test_run.c | 4 ++-- > 1 file changed, 2 insertions(

Re: [PATCH bpf-next] bpf: allow BPF read access to qdisc pkt_len

2018-11-30 Thread Song Liu
> 4 files changed, 50 insertions(+) Please split this into 3 patches: 1 for include/uapi/linux/bpf.h and filter.c 1 for tools/include/uapi/linux/bpf.h 1 for tools/testing/selftests/bpf/test_verifier.c Other than this Acked-by: Song Liu > > diff --git a/include/uapi/l

[PATCH bpf-next v2] tools/bpf: make libbpf _GNU_SOURCE friendly

2018-11-29 Thread Yonghong Song
nu version of strerror_r is expected. Signed-off-by: Yonghong Song --- tools/lib/bpf/libbpf.c | 2 ++ tools/lib/bpf/libbpf_errno.c | 1 + 2 files changed, 3 insertions(+) Changelog: v1 -> v2: . undef _GNU_SOURCE instead of multiversioning strerror_r, suggested by Jakub. diff --gi

Re: [PATCH bpf-next] tools/bpf: make libbpf _GNU_SOURCE friendly

2018-11-29 Thread Yonghong Song
On 11/29/18 1:00 PM, Jakub Kicinski wrote: > On Thu, 29 Nov 2018 12:38:03 -0800, Yonghong Song wrote: >> diff --git a/tools/lib/bpf/libbpf_errno.c b/tools/lib/bpf/libbpf_errno.c >> index d83b17f8435c..286e497c50ec 100644 >> --- a/tools/lib/bpf/libbpf_errno.c >> +++ b/t

[PATCH bpf-next] tools/bpf: make libbpf _GNU_SOURCE friendly

2018-11-29 Thread Yonghong Song
value than non-gnu version, so strerror_r return value is handled differently if _GNU_SOURCE is defined. Signed-off-by: Yonghong Song --- tools/lib/bpf/libbpf.c | 2 ++ tools/lib/bpf/libbpf_errno.c | 10 ++ 2 files changed, 12 insertions(+) diff --git a/tools/lib/bpf/libbpf.c b

Re: [PATCH] bpf: Fix various lib and testsuite build failures on 32-bit.

2018-11-28 Thread Song Liu
On Wed, Nov 28, 2018 at 12:59 PM David Miller wrote: > > > Cannot cast a u64 to a pointer on 32-bit without an intervening (long) > cast otherwise GCC warns. > > Signed-off-by: David S. Miller Acked-by: Song Liu > -- > > diff --git a/tools/lib/bpf/btf.c b/tools/li

Re: [PATCH bpf] tools: bpftool: fix a bitfield pretty print issue

2018-11-28 Thread Song Liu
On Wed, Nov 28, 2018 at 10:09 AM Yonghong Song wrote: > > Commit b12d6ec09730 ("bpf: btf: add btf print functionality") > added btf pretty print functionality to bpftool. > There is a problem though in printing a bitfield whose type > has modifiers. > > For examp

[PATCH bpf] tools: bpftool: fix a bitfield pretty print issue

2018-11-28 Thread Yonghong Song
l m d id 76 [{ "key": 0, "value": { "a": 0x1, "b": 0x2 } } ] The kernel pretty print is implemented correctly and does not have this issue. Fixes: b12d6ec09730 ("bpf: btf: add btf pri

[PATCH bpf v2 1/4] bpf: btf: implement btf_name_valid_identifier()

2018-11-27 Thread Yonghong Song
Function btf_name_valid_identifier() have been implemented in bpf-next commit 2667a2626f4d ("bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO"). Backport this function so later patch can use it. Fixes: 69b693f0aefa ("bpf: btf: Introduce BPF Type Format (BTF)") Signed-o

[PATCH bpf v2 3/4] tools/bpf: fix two test_btf unit test cases

2018-11-27 Thread Yonghong Song
Signed-off-by: Yonghong Song --- tools/testing/selftests/bpf/test_btf.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c index f42b3396d622..b361bb851829 100644 --- a/tools/testing/sel

[PATCH bpf v2 0/4] bpf: btf: check name validity for various types

2018-11-27 Thread Yonghong Song
.." line. Patches #2, #3 and #4 can be applied to bpf-next without conflict. [1]: http://vger.kernel.org/lpc-bpf2018.html#session-2 Yonghong Song (4): bpf: btf: implement btf_name_valid_identifier() bpf: btf: check name validity for various types tools/bpf: fix two test_btf unit test c

[PATCH bpf v2 4/4] tools/bpf: add addition type tests to test_btf

2018-11-27 Thread Yonghong Song
uot;bpf: btf: Add BTF tests") Acked-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- tools/testing/selftests/bpf/test_btf.c | 361 + 1 file changed, 361 insertions(+) diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c

[PATCH bpf v2 2/4] bpf: btf: check name validity for various types

2018-11-27 Thread Yonghong Song
. This can be relaxed later if we found use cases for a different (non-C) frontend. Fixes: 69b693f0aefa ("bpf: btf: Introduce BPF Type Format (BTF)") Acked-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- kernel/bpf/btf.c | 57 1 file c

Re: [PATCH bpf-next 1/3] bpf: btf: check name validity for various types

2018-11-27 Thread Yonghong Song
On 11/27/18 11:02 AM, Alexei Starovoitov wrote: > On Mon, Nov 26, 2018 at 09:17:13PM -0800, Yonghong Song wrote: >> Commit 2667a2626f4d ("bpf: btf: Add BTF_KIND_FUNC >> and BTF_KIND_FUNC_PROTO") checked the name validity >> for BTF_KIND

Re: [PATCH] selftests/bpf: add config fragment CONFIG_FTRACE_SYSCALLS

2018-11-27 Thread Yonghong Song
On 11/27/18 7:24 AM, Naresh Kamboju wrote: > CONFIG_FTRACE_SYSCALLS=y is required for get_cgroup_id_user test case > this test reads a file from debug trace path > /sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/id > > Signed-off-by: Naresh Kamboju Acked-by

[PATCH bpf-next 1/3] bpf: btf: check name validity for various types

2018-11-26 Thread Yonghong Song
valid name is required, the name must be a valid C identifier. This can be relaxed later if we found use cases for a different (non-C) frontend. Acked-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- kernel/bpf/btf.c | 57 1 file changed, 57

[PATCH bpf-next 2/3] tools/bpf: fix two test_btf unit test cases

2018-11-26 Thread Yonghong Song
Signed-off-by: Yonghong Song --- tools/testing/selftests/bpf/test_btf.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c index bae7308b7ec5..99a92923e3f9 100644 --- a/tools/testing/sel

[PATCH bpf-next 3/3] tools/bpf: add addition type tests to test_btf

2018-11-26 Thread Yonghong Song
OK Acked-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- tools/testing/selftests/bpf/test_btf.c | 362 + 1 file changed, 362 insertions(+) diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c index 99a92923e3f9..a72678153

[PATCH bpf-next 0/3] bpf: btf: check name validity for various types

2018-11-26 Thread Yonghong Song
makes BTF more sound in the kernel and future BTF-to-header-file converesion ([1]) less fragile. [1]: http://vger.kernel.org/lpc-bpf2018.html#session-2 Yonghong Song (3): bpf: btf: check name validity for various types tools/bpf: fix two test_btf unit test cases tools/bpf: add addition

[PATCH bpf-next 0/2] bpf: support proper non-jit func info

2018-11-24 Thread Yonghong Song
ed id 1490 no instructions returned Yonghong Song (2): bpf: btf: support proper non-jit func info tools/bpf: change selftest test_btf for both jit and non-jit include/linux/bpf.h| 6 ++- include/linux/bpf_verifier.h | 1 - kernel/bpf/core.c

[PATCH bpf-next 1/2] bpf: btf: support proper non-jit func info

2018-11-24 Thread Yonghong Song
iscrepancy. Fixes: 838e96904ff3 ("bpf: Introduce bpf_func_info") Signed-off-by: Yonghong Song --- include/linux/bpf.h | 6 ++-- include/linux/bpf_verifier.h | 1 - kernel/bpf/core.c| 3 +- kernel/bpf/syscall.c | 33 ++ kernel/bpf/ve

[PATCH bpf-next 2/2] tools/bpf: change selftest test_btf for both jit and non-jit

2018-11-24 Thread Yonghong Song
The selftest test_btf is changed to test both jit and non-jit. The test result should be the same regardless of whether jit is enabled or not. Signed-off-by: Yonghong Song --- tools/testing/selftests/bpf/test_btf.c | 33 +++--- 1 file changed, 3 insertions(+), 30 deletions

Re: [PATCH bpf-next 1/2] libbpf: Add version script for DSO

2018-11-21 Thread Yonghong Song
On 11/21/18 9:40 AM, Andrey Ignatov wrote: > More and more projects use libbpf and one day it'll likely be packaged > and distributed as DSO and that requires ABI versioning so that both > compatible and incompatible changes to ABI can be introduced in a safe > way in the future without breaking

[PATCH bpf-next] bpf: fix a libbpf loader issue

2018-11-21 Thread Yonghong Song
-by: Emre Cantimur Tested-by: Andrey Ignatov Signed-off-by: Yonghong Song --- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index cb6565d79603..f022ac82e882 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/l

Re: selftests/bpf :get_cgroup_id_user: File not found: /sys/kernel/debug/tracing/events/syscalls/sys_enter_nanosleep/id

2018-11-21 Thread Y Song
On Wed, Nov 21, 2018 at 3:44 AM Naresh Kamboju wrote: > > Kselftest bpf get_cgroup_id_user is failed on all devices. > > selftests: bpf: get_cgroup_id_user > main:PASS:setup_cgroup_environment > main:PASS:create_and_get_cgroup > main:PASS:join_cgroup > main:PASS:bpf_prog_load >

Re: [PATCH bpf-next v2] libbpf: make sure bpf headers are c++ include-able

2018-11-20 Thread Y Song
On Tue, Nov 20, 2018 at 1:37 PM Stanislav Fomichev wrote: > > Wrap headers in extern "C", to turn off C++ mangling. > This simplifies including libbpf in c++ and linking against it. > > v2 changes: > * do the same for btf.h > > Signed-off-by: Stanislav

[PATCH bpf-next v2] bpf: fix a compilation error when CONFIG_BPF_SYSCALL is not defined

2018-11-20 Thread Yonghong Song
ompilation failure can be avoided. Fixes: 838e96904ff3 ("bpf: Introduce bpf_func_info") Reported-by: kbuild test robot Cc: Martin KaFai Lau Signed-off-by: Yonghong Song --- include/linux/btf.h | 14 ++ 1 file changed, 14 insertions(+) Changelog: v1 -> v2: . Two fun

[PATCH bpf-next] bpf: fix a compilation error when CONFIG_BPF_SYSCALL is not defined

2018-11-20 Thread Yonghong Song
ompilation failure can be avoided. Fixes: 838e96904ff3 ("bpf: Introduce bpf_func_info") Reported-by: kbuild test robot Cc: Martin KaFai Lau Signed-off-by: Yonghong Song --- include/linux/btf.h | 12 1 file changed, 12 insertions(+) diff --git a/include/linux/btf.h b/inclu

Re: [PATCH bpf-next] libbpf: make sure bpf headers are c++ include-able

2018-11-20 Thread Y Song
On Tue, Nov 20, 2018 at 10:19 AM Stanislav Fomichev wrote: > > Wrap headers in extern "C", to turn off C++ mangling. > This simplifies including libbpf in c++ and linking against it. > > Signed-off-by: Stanislav Fomichev > --- > tools/lib/bpf/bpf.h| 9 + > tools/lib/bpf/libbpf.h | 9

Re: [PATCH v2 0/4] Fix unsafe BPF_PROG_TEST_RUN interface

2018-11-20 Thread Y Song
ing another field in the uapi as described in https://www.spinics.net/lists/netdev/msg534277.html, then Acked-by: Yonghong Song

Re: [PATCH 3/3] selftests: add a test for bpf_prog_test_run output size

2018-11-20 Thread Y Song
On Tue, Nov 20, 2018 at 3:35 AM Lorenz Bauer wrote: > > On Sun, 18 Nov 2018 at 05:59, Y Song wrote: > > > > On Fri, Nov 16, 2018 at 12:55 PM Lorenz Bauer wrote: > > > > > > Make sure that bpf_prog_test_run returns the correct length > > > in the s

Re: [PATCH v2 bpf-next 0/2] bpf: adding support for mapinmap in libbpf

2018-11-19 Thread Y Song
support for map in map in libbpf > bpf: adding tests for mapinmap helpber in libbpf For the whole series. Acked-by: Yonghong Song > > tools/lib/bpf/libbpf.c | 7 +++ > tools/lib/bpf/libbpf.h | 2 + > tools/testing/selftests/bpf/Makefil

Re: [PATCH iproute2] bpf: initialise map symbol before retrieving and comparing its type

2018-11-19 Thread Y Song
by assigning the type to the temporary variable only after the > call to gelf_getsym(). > > Fixes: 7a04dd84a7f9 ("bpf: check map symbol type properly with newer llvm > compiler") > Reported-by: Ron Philip > Signed-off-by: Quentin Monnet > Reviewed-by: Jiong Wang Th

Re: [PATCH bpf-next] bpf: libbpf: retry program creation without the name

2018-11-19 Thread Y Song
I support > to specify BPF obj name"), libbpf unconditionally sets bpf_attr->name > for programs. Pre v4.14 kernels don't know about programs names and > return an error about unexpected non-zero data. Retry sys_bpf without > a program name to cover older kernels. > > Signed-off-by: Stanislav Fomichev Acked-by: Yonghong Song

Re: [PATCH bpf-next 2/2] bpf: adding tests for mapinmap helpber in libbpf

2018-11-19 Thread Y Song
On Mon, Nov 19, 2018 at 4:13 PM Nikita V. Shirokov wrote: > > adding test/example of bpf_map__add_inner_map_fd usage > > Signed-off-by: Nikita V. Shirokov > --- > tools/testing/selftests/bpf/Makefile| 3 +- > tools/testing/selftests/bpf/test_mapinmap.c | 53 >

Re: [PATCH bpf-next 1/2] bpf: adding support for map in map in libbpf

2018-11-19 Thread Y Song
On Mon, Nov 19, 2018 at 4:13 PM Nikita V. Shirokov wrote: > > idea is pretty simple. for specified map (pointed by struct bpf_map) > we would provide descriptor of already loaded map, which is going to be > used as a prototype for inner map. proposed workflow: > 1) open bpf's object

Re: [PATCH 0/3] Fix unsafe BPF_PROG_TEST_RUN interface

2018-11-17 Thread Y Song
On Fri, Nov 16, 2018 at 12:54 PM Lorenz Bauer wrote: > > Right now, there is no safe way to use BPF_PROG_TEST_RUN with data_out. > This is because bpf_test_finish copies the output buffer to user space > without checking its size. This can lead to the kernel overwriting > data in user space after

Re: [PATCH 3/3] selftests: add a test for bpf_prog_test_run output size

2018-11-17 Thread Y Song
On Fri, Nov 16, 2018 at 12:55 PM Lorenz Bauer wrote: > > Make sure that bpf_prog_test_run returns the correct length > in the size_out argument and that the kernel respects the > output size hint. > > Signed-off-by: Lorenz Bauer > --- > tools/testing/selftests/bpf/test_progs.c | 34

Re: [PATCH 2/3] libbpf: require size hint in bpf_prog_test_run

2018-11-17 Thread Y Song
On Fri, Nov 16, 2018 at 12:54 PM Lorenz Bauer wrote: > > Require size_out to be non-NULL if data_out is given. This prevents > accidental overwriting of process memory after the output buffer. > > Adjust callers of bpf_prog_test_run to this behaviour. > > Signed-off-by: Lorenz Bauer > --- >

Re: [PATCH 1/3] bpf: respect size hint to BPF_PROG_TEST_RUN if present

2018-11-17 Thread Y Song
On Fri, Nov 16, 2018 at 12:54 PM Lorenz Bauer wrote: > > Use data_size_out as a size hint when copying test output to user space. > A program using BPF_PERF_OUTPUT can compare its own buffer length with > data_size_out after the syscall to detect whether truncation has taken > place. Callers

Re: [PATCH v3 0/4] bpf: allow zero-initialising hash map seed

2018-11-16 Thread Song Liu
> On Nov 16, 2018, at 3:41 AM, Lorenz Bauer wrote: > > Allow forcing the seed of a hash table to zero, for deterministic > execution during benchmarking and testing. > > Changes from v2: > * Change ordering of BPF_F_ZERO_SEED in linux/bpf.h > > Comments adressed from v1: > * Add comment to

Re: [PATCH v3 0/4] bpf: allow zero-initialising hash map seed

2018-11-16 Thread Song Liu
t for BPF_F_ZERO_SEED > > include/uapi/linux/bpf.h| 9 ++-- > kernel/bpf/hashtab.c| 13 - > tools/include/uapi/linux/bpf.h | 13 +++-- > tools/testing/selftests/bpf/test_maps.c | 68 + > 4 files changed, 84 insertions(+),

Re: [PATCH bpf-next v2 02/13] bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO

2018-11-08 Thread Yonghong Song
On 11/8/18 2:56 PM, Edward Cree wrote: > On 08/11/18 19:42, Alexei Starovoitov wrote: >> same link let's continue at 1pm PST. > So, one thing we didn't really get onto was maps, and you mentioned that it >  wasn't really clear what I was proposing there. > What I have in mind comes in two

Re: [PATCH bpf-next v4 02/13] bpf: btf: Add BTF_KIND_FUNC

2018-11-08 Thread Yonghong Song
On 11/8/18 12:52 PM, Edward Cree wrote: > On 08/11/18 20:36, Yonghong Song wrote: >> This patch adds BTF_KIND_FUNC support to the type section. >> BTF_KIND_FUNC is used to specify the signature of a >> defined subprogram or the pointee of a function pointer. >> &

[PATCH bpf-next v4 12/13] tools/bpf: enhance test_btf file testing to test func info

2018-11-08 Thread Yonghong Song
Change the bpf programs test_btf_haskv.c and test_btf_nokv.c to have two sections, and enhance test_btf.c test_file feature to test btf func_info returned by the kernel. Signed-off-by: Yonghong Song --- tools/testing/selftests/bpf/test_btf.c | 117 +-- tools/testing

[PATCH bpf-next v4 10/13] tools/bpf: do not use pahole if clang/llvm can generate BTF sections

2018-11-08 Thread Yonghong Song
Add additional checks in tools/testing/selftests/bpf and samples/bpf such that if clang/llvm compiler can generate BTF sections, do not use pahole. Signed-off-by: Yonghong Song --- samples/bpf/Makefile | 8 tools/testing/selftests/bpf/Makefile | 8 2 files

[PATCH bpf-next v4 13/13] tools/bpf: bpftool: add support for func types

2018-11-08 Thread Yonghong Song
): bpf_prog_89d64e4abf0f0126_test_long_fname_2: 0: push %rbp 1: mov%rsp,%rbp .. 80: add$0x28,%rbp 84: leaveq 85: retq Signed-off-by: Yonghong Song --- tools/bpf/bpftool/btf_dumper.c| 98 +++ tools/bpf/bpftool/main.h | 2 + tools

[PATCH bpf-next v4 04/13] tools/bpf: add btf func unit tests in selftest test_btf

2018-11-08 Thread Yonghong Song
Add several BTF_KIND_FUNC unit tests in bpf selftest test_btf. Signed-off-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- tools/lib/bpf/btf.c| 3 + tools/testing/selftests/bpf/test_btf.c | 262 + 2 files changed, 265 insertions(+) diff --git

[PATCH bpf-next v4 11/13] tools/bpf: refactor to implement btf_get_from_id() in lib/bpf

2018-11-08 Thread Yonghong Song
The function get_btf() is implemented in tools/bpf/bpftool/map.c to get a btf structure given a map_info. This patch refactored this function to be function btf_get_from_id() in tools/lib/bpf so that it can be used later. Signed-off-by: Yonghong Song --- tools/bpf/bpftool/map.c | 68

[PATCH bpf-next v4 09/13] tools/bpf: add support to read .BTF.ext sections

2018-11-08 Thread Yonghong Song
section cannot. The loader may need to do some relocation and merging, similar to merging multiple code sections, before loading into the kernel. Acked-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- tools/lib/bpf/bpf.c| 46 ++- tools/lib/bpf/btf.c| 274

[PATCH bpf-next v4 08/13] tools/bpf: extends test_btf to test load/retrieve func_type info

2018-11-08 Thread Yonghong Song
loading/retriving of func_type info. Acked-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- tools/testing/selftests/bpf/test_btf.c | 315 - 1 file changed, 312 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing

[PATCH bpf-next v4 06/13] tools/bpf: sync kernel uapi bpf.h header to tools directory

2018-11-08 Thread Yonghong Song
The kernel uapi bpf.h is synced to tools directory. Acked-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- tools/include/uapi/linux/bpf.h | 13 + 1 file changed, 13 insertions(+) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 852dc17ab47a

[PATCH bpf-next v4 01/13] bpf: btf: Break up btf_type_is_void()

2018-11-08 Thread Yonghong Song
This patch breaks up btf_type_is_void() into btf_type_is_void() and btf_type_is_fwd(). It also adds btf_type_nosize() to better describe it is testing a type has nosize info. Signed-off-by: Martin KaFai Lau --- kernel/bpf/btf.c | 37 ++--- 1 file changed, 22

[PATCH bpf-next v4 07/13] tools/bpf: add new fields for program load in lib/bpf

2018-11-08 Thread Yonghong Song
The new fields are added for program load in lib/bpf so application uses api bpf_load_program_xattr() is able to load program with btf and func_info data. This functionality will be used in next patch by bpf selftest test_btf. Acked-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- tools

[PATCH bpf-next v4 02/13] bpf: btf: Add BTF_KIND_FUNC

2018-11-08 Thread Yonghong Song
program below, int foo(int (*bar)(int)) { return bar(5); } two func types will be generated: FuncType #1: subprogram "foo" with parameter "bar" FuncType #2: pointee of function pointer "int (*)(int)" Signed-off-by: Martin KaFai Lau Signed-off-by: Yonghong Song ---

[PATCH bpf-next v4 03/13] tools/bpf: sync kernel btf.h header

2018-11-08 Thread Yonghong Song
The kernel uapi btf.h is synced to the tools directory. Signed-off-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- tools/include/uapi/linux/btf.h | 17 ++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tools/include/uapi/linux/btf.h b/tools/include/uapi

[PATCH bpf-next v4 05/13] bpf: get better bpf_prog ksyms based on btf func type_id

2018-11-08 Thread Yonghong Song
also print out function prototypes for each jited function. Acked-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- include/linux/bpf.h | 5 +- include/linux/bpf_verifier.h | 1 + include/linux/btf.h | 2 + include/uapi/linux/bpf.h | 13 kernel/bpf/btf.c

[PATCH bpf-next v4 00/13] bpf: add btf func info support

2018-11-08 Thread Yonghong Song
h for validity test. . Removed/changed several verifier messages. . Modified several commit messages to remove line_off reference. Yonghong Song (13): bpf: btf: Break up btf_type_is_void() bpf: btf: Add BTF_KIND_FUNC tools/bpf: sync kernel btf.h header tools/bpf: add btf func unit tests i

Re: [RFC perf,bpf 1/5] perf, bpf: Introduce PERF_RECORD_BPF_EVENT

2018-11-08 Thread Song Liu
Hi Peter, > On Nov 8, 2018, at 7:00 AM, Peter Zijlstra wrote: > > On Wed, Nov 07, 2018 at 06:25:04PM +0000, Song Liu wrote: >> >> >>> On Nov 7, 2018, at 12:40 AM, Peter Zijlstra wrote: >>> >>> On Tue, Nov 06, 2018 at 12:52:42PM -0800, Song

[PATCH bpf v2] tools/bpftool: copy a few net uapi headers to tools directory

2018-11-07 Thread Yonghong Song
l test robot Cc: Li Zhijian Signed-off-by: Yonghong Song --- tools/include/uapi/linux/pkt_cls.h | 612 +++ tools/include/uapi/linux/tc_act/tc_bpf.h | 37 ++ 2 files changed, 649 insertions(+) create mode 100644 tools/include/uapi/linux/pkt_cls.h create mode 100644 tool

Re: [PATCH bpf] tools/bpftool: copy uapi/linux/tc_act/tc_bpf.h to tools directory

2018-11-07 Thread Yonghong Song
On 11/7/18 5:15 PM, Li Zhijian wrote: > On 11/8/2018 9:00 AM, Yonghong Song wrote: >> Commit f6f3bac08ff9 ("tools/bpf: bpftool: add net support") >> added certain networking support to bpftool. >> The implementation relies on a relatively recent uapi heade

[PATCH bpf] tools/bpftool: copy uapi/linux/tc_act/tc_bpf.h to tools directory

2018-11-07 Thread Yonghong Song
y to tools/include/uapi directory so building the bpftool does not depend on host system for this file. Fixes: f6f3bac08ff9 ("tools/bpf: bpftool: add net support") Reported-by: kernel test robot Signed-off-by: Yonghong Song --- tools/include/uapi/linux/tc_act/tc_bpf.h | 37

Re: [PATCH v2 1/3] bpf: allow zero-initializing hash map seed

2018-11-06 Thread Song Liu
On Thu, Oct 25, 2018 at 8:12 AM Lorenz Bauer wrote: > > On Tue, 9 Oct 2018 at 01:08, Song Liu wrote: > > > > > --- a/include/uapi/linux/bpf.h > > > +++ b/include/uapi/linux/bpf.h > > > @@ -253,6 +253,8 @@ enum bpf_attach_type { > > > #define BP

Re: [PATCH bpf-next] bpf_load: add map name to load_maps error message

2018-11-06 Thread Song Liu
rror(errno)); > > return 1; > > } > > maps[i].fd = map_fd[i]; > > > > LGTM > > Acked-by: John Fastabend Acked-by: Song Liu

Re: Help with the BPF verifier

2018-11-02 Thread Yonghong Song
On 11/2/18 8:42 AM, Edward Cree wrote: > On 02/11/18 15:02, Arnaldo Carvalho de Melo wrote: >> Yeah, didn't work as well: > >> And the -vv in 'perf trace' didn't seem to map to further details in the >> output of the verifier debug: > Yeah for log_level 2 you probably need to make source-level

[PATCH v2 bpf 3/3] bpf: show main program address and length in bpf_prog_info

2018-11-02 Thread Song Liu
Currently, when there is no subprog (prog->aux->func_cnt == 0), bpf_prog_info does not return any jited_ksyms or jited_func_lens. This patch adds main program address (prog->bpf_func) and main program length (prog->jited_len) to bpf_prog_info. Signed-off-by: Song Liu --- kernel/b

[PATCH v2 bpf 0/3] show more accurrate bpf program address

2018-11-02 Thread Song Liu
s set improves bpf program address showed in /proc/kallsyms and in bpf_prog_info. First, real program address is showed instead of page address. Second, when there is no subprogram, bpf_prog_info->jited_ksyms and bpf_prog_info->jited_fun_lens returns the main prog address and length. Song Liu

[PATCH v2 bpf 1/3] bpf: show real jited prog address in /proc/kallsyms

2018-11-02 Thread Song Liu
. This change is OK because these addresses are still protected by sysctl kptr_restrict (see kallsyms_show_value()), and only programs loaded by root are added to kallsyms (see bpf_prog_kallsyms_add()). Signed-off-by: Song Liu --- kernel/bpf/core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions

[PATCH v2 bpf 2/3] bpf: show real jited address in bpf_prog_info->jited_ksyms

2018-11-02 Thread Song Liu
address. This change is OK because bpf_prog_get_info_by_fd() is only available to root. Signed-off-by: Song Liu --- kernel/bpf/syscall.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index ccb93277aae2..34a9eef5992c 100644 --- a/kernel/bpf

Re: [PATCH bpf 2/3] bpf: show real jited address in bpf_prog_info->jited_ksyms

2018-11-02 Thread Song Liu
> On Nov 2, 2018, at 3:19 AM, Daniel Borkmann wrote: > > On 11/02/2018 11:09 AM, Daniel Borkmann wrote: >> On 11/01/2018 08:00 AM, Song Liu wrote: >>> Currently, jited_ksyms in bpf_prog_info shows page addresses of jited >>> bpf program. This is not ideal

Re: [PATCH bpf-next 2/3] bpf: emit RECORD_MMAP events for bpf prog load/unload

2018-11-01 Thread Song Liu
l process these event before the end of perf-record. Does this approach make sense? Thanks! Song

[PATCH bpf 1/3] bpf: show real jited prog address in /proc/kallsyms

2018-11-01 Thread Song Liu
Currently, /proc/kallsyms shows page address of jited bpf program. This is not ideal for detailed profiling (find hot instructions from stack traces). This patch replaces the page address with real prog start address. Signed-off-by: Song Liu --- kernel/bpf/core.c | 4 +--- 1 file changed, 1

[PATCH bpf 2/3] bpf: show real jited address in bpf_prog_info->jited_ksyms

2018-11-01 Thread Song Liu
Currently, jited_ksyms in bpf_prog_info shows page addresses of jited bpf program. This is not ideal for detailed profiling (find hot instructions from stack traces). This patch replaces the page address with real prog start address. Signed-off-by: Song Liu --- kernel/bpf/syscall.c | 1 - 1

[PATCH bpf 0/3] show more accurrate bpf program address

2018-11-01 Thread Song Liu
This set improves bpf program address showed in /proc/kallsyms and in bpf_prog_info. First, real program address is showed instead of page address. Second, when there is no subprogram, bpf_prog_info->jited_ksyms returns the main prog address. Song Liu (3): bpf: show real jited prog addr

[PATCH bpf 3/3] bpf: show main program address in bpf_prog_info->jited_ksyms

2018-11-01 Thread Song Liu
Currently, when there is not subprog (prog->aux->func_cnt == 0), bpf_prog_info does not return any jited_ksyms. This patch adds main program address (prog->bpf_func) to jited_ksyms. Signed-off-by: Song Liu --- kernel/bpf/syscall.c | 16 1 file changed, 12 inserti

[PATCH iproute2] bpf: check map symbol type properly with newer llvm compiler

2018-10-29 Thread Yonghong Song
: Yonghong Song Date: Wed Sep 19 16:04:13 2018 + [bpf] Symbol sizes and types in object file Clang-compiled object files currently don't include the symbol sizes and types. Some tools however need that information. For example, ctfconvert uses that information t

Re: [PATCH] bpf: tcp_bpf_recvmsg should return EAGAIN when nonblocking and no data

2018-10-29 Thread Song Liu
timeout expired > > before data was received. > > > > Signed-off-by: John Fastabend Acked-by: Song Liu > > --- > > Add fixes tag. > > Fixes: 604326b41a6f ("bpf, sockmap: convert to generic sk_msg interface") > > > >

Re: [PATCH bpf] tools/bpf: add unlimited rlimit for flow_dissector_load

2018-10-29 Thread Song Liu
On Mon, Oct 29, 2018 at 2:58 PM Yonghong Song wrote: > > On our test machine, bpf selftest test_flow_dissector.sh failed > with the following error: > # ./test_flow_dissector.sh > bpffs not mounted. Mounting... > libbpf: failed to create map (name: 'jmp_table'): Opera

[PATCH bpf] tools/bpf: add unlimited rlimit for flow_dissector_load

2018-10-29 Thread Yonghong Song
: bpf_prog_load bpf_flow.o selftests: test_flow_dissector [FAILED] Let us increase the rlimit to remove the above map creation failure. Signed-off-by: Yonghong Song --- tools/testing/selftests/bpf/flow_dissector_load.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests

Re: [PATCH bpf 7/7] bpf: make direct packet write unclone more robust

2018-10-24 Thread Song Liu
On Wed, Oct 24, 2018 at 3:08 PM Daniel Borkmann wrote: > > On 10/24/2018 11:42 PM, Song Liu wrote: > > On Wed, Oct 24, 2018 at 1:06 PM Daniel Borkmann > > wrote: > >> > >> Given this seems to be quite fragile and can easily slip through the > >> crac

Re: [PATCH bpf 0/7] Batch of direct packet access fixes for BPF

2018-10-24 Thread Song Liu
++ > kernel/bpf/verifier.c | 13 ++--- > net/core/filter.c | 17 + > tools/testing/selftests/bpf/test_verifier.c | 15 +-- > 5 files changed, 42 insertions(+), 7 deletions(-) > > -- > 2.9.5 > Other than the nitpick on 7/7, for the series: Acked-by: Song Liu

Re: [PATCH bpf 7/7] bpf: make direct packet write unclone more robust

2018-10-24 Thread Song Liu
On Wed, Oct 24, 2018 at 1:06 PM Daniel Borkmann wrote: > > Given this seems to be quite fragile and can easily slip through the > cracks, lets make direct packet write more robust by requiring that > future program types which allow for such write must provide a prologue > callback. In case of

Re: [PATCH v2 bpf] bpf: devmap: fix wrong interface selection in notifier_call

2018-10-24 Thread Song Liu
could occurred. > Hence netdev pointer comparison code is added. > > v2: compare netdev pointer instead of using net_eq() (Daniel Borkmann) > v1: Initial patch > > Fixes: 2ddf71e23cc2 ("net: add notifier hooks for devmap bpf map") > Signed-off-by: Taehee Yoo Acked-b

[PATCH v8 bpf-next 1/2] bpf: add cg_skb_is_valid_access for BPF_PROG_TYPE_CGROUP_SKB

2018-10-19 Thread Song Liu
proper data_end for the BPF program, and restore original data afterwards. Signed-off-by: Song Liu --- include/linux/filter.h | 21 + kernel/bpf/cgroup.c| 6 ++ net/core/filter.c | 36 +++- 3 files changed, 62 insertions(+), 1 deletion

[PATCH v8 bpf-next 0/2] bpf: add cg_skb_is_valid_access

2018-10-19 Thread Song Liu
ed helper function bpf_compute_and_save_data_pointers() and bpf_restore_data_pointers(). Changes v1 -> v2: 1. Updated the list of read-only fields, and read-write fields. 2. Added dummy sk to bpf_prog_test_run_skb(). This set enables BPF program of type BPF_PROG_TYPE_CGROUP_SKB to access some __skb_buff data directly. Son

[PATCH v8 bpf-next 2/2] bpf: add tests for direct packet access from CGROUP_SKB

2018-10-19 Thread Song Liu
Tests are added to make sure CGROUP_SKB cannot access: tc_classid, data_meta, flow_keys and can read and write: mark, prority, and cb[0-4] and can read other fields. To make selftest with skb->sk work, a dummy sk is added in bpf_prog_test_run_skb(). Signed-off-by: Song Liu --- net/

[PATCH v7 bpf-next 0/2] bpf: add cg_skb_is_valid_access

2018-10-19 Thread Song Liu
. Updated the list of read-only fields, and read-write fields. 2. Added dummy sk to bpf_prog_test_run_skb(). This set enables BPF program of type BPF_PROG_TYPE_CGROUP_SKB to access some __skb_buff data directly. Song Liu (2): bpf: add cg_skb_is_valid_access for BPF_PROG_TYPE_CGROUP_SKB bpf: ad

  1   2   3   4   5   6   7   8   9   10   >