[PATCH bpf-next 1/7] bpf: Add bpf_line_info support

2018-12-07 Thread Martin KaFai Lau
info such that the user can get the xlated line_info back (i.e. the line_info with its insn_off reflecting the translated prog). The jited_line_info is available if the prog is jited. It is an array of __u64. If the prog is not jited, jited_line_info_cnt is 0. The verifier's verbose log with line_info

[PATCH bpf-next 6/7] bpf: libbpf: Add btf_line_info support to libbpf

2018-12-07 Thread Martin KaFai Lau
ail out. 3) BPF_PROG_LOAD a prog with line_info Signed-off-by: Martin KaFai Lau Acked-by: Yonghong Song --- tools/lib/bpf/bpf.c| 86 +++-- tools/lib/bpf/bpf.h| 3 + tools/lib/bpf/btf.c| 209 + tools/lib/bpf/btf.h| 10 +- too

[PATCH bpf-next 2/7] bpf: tools: Sync uapi bpf.h

2018-12-07 Thread Martin KaFai Lau
Sync uapi bpf.h to tools/include/uapi/linux for the new bpf_line_info. Signed-off-by: Martin KaFai Lau Acked-by: Yonghong Song --- tools/include/uapi/linux/bpf.h | 19 +++ 1 file changed, 19 insertions(+) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux

[PATCH bpf-next 3/7] bpf: Refactor and bug fix in test_func_type in test_btf.c

2018-12-07 Thread Martin KaFai Lau
n rec_size check should be < 8 instead of < 4. Fixes: 4798c4ba3ba9 ("tools/bpf: extends test_btf to test load/retrieve func_type info") Signed-off-by: Martin KaFai Lau Acked-by: Yonghong Song --- tools/testing/selftests/bpf/test_btf.c | 211 +++-- 1 file c

[PATCH bpf-next 0/7] Introduce bpf_line_info

2018-12-07 Thread Martin KaFai Lau
%rbx 74: mov0x8(%rbp),%r13 78: mov0x10(%rbp),%r14 7c: mov0x18(%rbp),%r15 80: add$0x28,%rbp 84: leaveq 85: retq [...] Martin KaFai Lau (7): bpf: Add bpf_line_info support bpf: tools: Sync uapi bpf.h bpf: Refactor and bug fix in test_func_type in test_bt

[PATCH bpf-next 7/7] bpf: libbpf: bpftool: Print bpf_line_info during prog dump

2018-12-07 Thread Martin KaFai Lau
selftests/bpf/test_btf_haskv.c line_num:54 line_col:2] 2a: xor%eax,%eax 2c: mov0x0(%rbp),%rbx 30: mov0x8(%rbp),%r13 34: mov0x10(%rbp),%r14 38: mov0x18(%rbp),%r15 3c: add$0x28,%rbp 40: leaveq 41: retq [...] Signed-off-by: Martin KaFai L

[PATCH bpf-next 4/7] bpf: Add unit tests for bpf_line_info

2018-12-07 Thread Martin KaFai Lau
raw test[12] (line_info (subprog. missing 2nd func line info)): OK BTF prog info raw test[13] (line_info (subprog. unordered insn offset)): OK Signed-off-by: Martin KaFai Lau Acked-by: Yonghong Song --- tools/testing/selftests/bpf/test_btf.c | 597 - 1 file changed, 58

[PATCH bpf-next 5/7] bpf: libbpf: Refactor and bug fix on the bpf_func_info loading logic

2018-12-07 Thread Martin KaFai Lau
func_info" from btf.h to btf.c. There is no external usage outside btf.c. Fixes: 2993e0515bb4 ("tools/bpf: add support to read .BTF.ext sections") Signed-off-by: Martin KaFai Lau Acked-by: Yonghong Song --- tools/lib/bpf/bpf.c| 7 +- tools/lib/bpf/btf.c| 191 +++

[PATCH bpf-next 1/4] bpf: Improve the info.func_info and info.func_info_rec_size behavior

2018-12-05 Thread Martin KaFai Lau
prog->aux->btf is not NULL only if prog->aux->func_info_cnt > 0. Breaking up info.btf_id from prog->aux->func_info_cnt is needed for the later line info patch anyway. A similar change is made to bpf_get_prog_name(). Fixes: 838e96904ff3 ("bpf: Introduce bp

[PATCH bpf-next 4/4] bpf: Expect !info.func_info and insn_off name changes in test_btf/libbpf/bpftool

2018-12-05 Thread Martin KaFai Lau
Similar to info.jited_*, info.func_info could be 0 if bpf_dump_raw_ok() == false. This patch makes changes to test_btf and bpftool to expect info.func_info could be 0. This patch also makes the needed changes for s/insn_offset/insn_off/. Signed-off-by: Martin KaFai Lau Acked-by: Yonghong Song

[PATCH bpf-next 2/4] bpf: Change insn_offset to insn_off in bpf_func_info

2018-12-05 Thread Martin KaFai Lau
means "offset" (e.g. name_off in "struct btf_type"). The to-be-added "struct bpf_line_info" also has another member, "insn_off" which is the same as the "insn_offset" in "struct bpf_func_info". Hence, this patch renames "insn_offset" to "i

[PATCH bpf-next 3/4] bpf: tools: Sync uapi bpf.h for the name changes in bpf_func_info

2018-12-05 Thread Martin KaFai Lau
This patch sync the name changes in bpf_func_info to the tools/. Signed-off-by: Martin KaFai Lau Acked-by: Yonghong Song --- tools/include/uapi/linux/bpf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index

[PATCH bpf-next 0/4] Misc improvements on bpf_func_info

2018-12-05 Thread Martin KaFai Lau
The patchset has a few improvements on bpf_func_info: 1. Improvements on the behaviors of info.func_info, info.func_info_cnt and info.func_info_rec_size. 2. Name change: s/insn_offset/insn_off/ Please see individual patch for details. Martin KaFai Lau (4): bpf: Improve the info.func_info

[PATCH bpf-next] bpf: Fix memleak in aux->func_info and aux->btf

2018-12-01 Thread Martin KaFai Lau
The aux->func_info and aux->btf are leaked in the error out cases during bpf_prog_load(). This patch fixes it. Fixes: ba64e7d85252 ("bpf: btf: support proper non-jit func info") Cc: Yonghong Song Signed-off-by: Martin KaFai Lau Acked-by: Yonghong Song --- kernel/bpf/syscall.

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

2018-11-19 Thread Martin KaFai Lau
From: 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 Signed-off-by: Martin KaFai Lau --- samples/bpf/Makefile | 8 tools

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

2018-11-19 Thread Martin KaFai Lau
): 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 Signed-off-by: Martin KaFai Lau --- tools/bpf/bpftool/btf_dumper.c| 136

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

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

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

2018-11-19 Thread Martin KaFai Lau
KaFai Lau --- tools/bpf/bpftool/map.c | 68 ++-- tools/lib/bpf/btf.c | 69 + tools/lib/bpf/btf.h | 1 + 3 files changed, 72 insertions(+), 66 deletions(-) diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool

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

2018-11-19 Thread Martin KaFai Lau
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 | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tools/include/uapi/linux/btf.h b/tools/include/uapi

[PATCH v5 bpf-next 00/13] bpf: Add btf func info support

2018-11-19 Thread Martin KaFai Lau
member_name length for validity test. . Removed/changed several verifier messages. . Modified several commit messages to remove line_off reference. Martin KaFai Lau (4): bpf: btf: Break up btf_type_is_void() bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO tools/bpf: Sync kernel btf.

[PATCH v5 bpf-next 04/13] tools/bpf: Add tests for BTF_KIND_FUNC_PROTO and BTF_KIND_FUNC

2018-11-19 Thread Martin KaFai Lau
This patch adds unit tests for BTF_KIND_FUNC_PROTO and BTF_KIND_FUNC to test_btf. Signed-off-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- tools/lib/bpf/btf.c| 4 + tools/testing/selftests/bpf/test_btf.c | 474 - 2 files changed, 476

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

2018-11-19 Thread Martin KaFai Lau
From: 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 Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf

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

2018-11-19 Thread Martin KaFai Lau
learn the function signature of a running bpf program. Signed-off-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- include/uapi/linux/btf.h | 18 +- kernel/bpf/btf.c | 389 ++- 2 files changed, 354 insertions(+), 53 deletions(-) diff --git a/include/uapi

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

2018-11-19 Thread Martin KaFai Lau
are also added to test loading/retriving of func_type info. Signed-off-by: Yonghong Song Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/test_btf.c | 332 - 1 file changed, 329 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf

[PATCH v5 bpf-next 05/13] bpf: Introduce bpf_func_info

2018-11-19 Thread Martin KaFai Lau
in bpf_prog_info, userspace can also print out function prototypes for each jited function. Signed-off-by: Yonghong Song Signed-off-by: Martin KaFai Lau --- include/linux/bpf.h | 5 +- include/linux/bpf_verifier.h | 1 + include/linux/btf.h | 2 + include/uapi/linux/bpf.h | 13

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

2018-11-19 Thread Martin KaFai Lau
From: Yonghong Song The kernel uapi bpf.h is synced to tools directory. Signed-off-by: Yonghong Song Signed-off-by: Martin KaFai Lau --- 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

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

2018-11-19 Thread Martin KaFai Lau
-by: Martin KaFai Lau --- tools/lib/bpf/bpf.c | 4 tools/lib/bpf/bpf.h | 4 2 files changed, 8 insertions(+) diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index 03f9bcc4ef50..06fc5e91ac51 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c @@ -196,6 +196,10 @@ int

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

2018-11-19 Thread Martin KaFai Lau
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] bpf: libbpf: Fix bpf_program__next() API

2018-11-12 Thread Martin KaFai Lau
ailure in bpf_object__pin") Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/libbpf.c | 25 +++-- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index e827542ffa3a..a01eb9584e52 100644 --- a/tools/lib/bpf/libbpf.

[PATCH bpf] bpf: btf: Fix end boundary calculation for type section

2018-09-12 Thread Martin KaFai Lau
new section would be added later. This patch fixes it. Fixes: f80442a4cd18 ("bpf: btf: Change how section is supported in btf_header") Reported-by: Dmitry Vyukov Signed-off-by: Martin KaFai Lau --- kernel/bpf/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ker

Re: bpf: btf: Change how section is supported in btf_header

2018-09-11 Thread Martin KaFai Lau
On Tue, Sep 11, 2018 at 06:40:05PM +0200, Dmitry Vyukov wrote: > Hi Martin, > > I am looking at the subj commit: > > static int btf_add_type(struct btf_verifier_env *env, struct btf_type *t) > @@ -1754,9 +1756,9 @@ static int btf_check_all_metas(struct > btf_verifier_env *env) > struct

Re: [PATCH bpf-next] bpf: enable btf for use in all maps

2018-08-10 Thread Martin KaFai Lau
On Fri, Aug 10, 2018 at 09:55:35AM +0200, Daniel Borkmann wrote: > On 08/10/2018 04:13 AM, Alexei Starovoitov wrote: > > On Fri, Aug 10, 2018 at 12:43:20AM +0200, Daniel Borkmann wrote: > >> On 08/09/2018 11:44 PM, Alexei Starovoitov wrote: > >>> On Thu, Aug 09, 2018 at 11:30:52PM +0200, Daniel

[PATCH bpf-next 9/9] bpf: Test BPF_PROG_TYPE_SK_REUSEPORT

2018-08-08 Thread Martin KaFai Lau
ray The test depends on commit 3eee1f75f2b9 ("bpf: fix bpf_skb_load_bytes_relative pkt length check") Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- tools/lib/bpf/bpf.c | 1 + tools/lib/bpf/bpf.h | 1 + tools/test

[PATCH bpf-next 4/9] bpf: Introduce BPF_PROG_TYPE_SK_REUSEPORT

2018-08-08 Thread Martin KaFai Lau
lected (i.e. "reuse_kern->selected_sk != NULL"). If it does , it will use the selected sk. If not, the kernel will select one from "reuse->socks[]" (as before this patch). The SK_DROP and SK_PASS handling logic will be in the next patch. Signed-off-by: Martin KaFai Lau Ac

[PATCH bpf-next 2/9] net: Add ID (if needed) to sock_reuseport and expose reuseport_lock

2018-08-08 Thread Martin KaFai Lau
if any of the reuse->socks[] is added to the newly introduced "BPF_MAP_TYPE_REUSEPORT_ARRAY" map. If "BPF_MAP_TYPE_REUSEPORT_ARRAY" is not used, the changes in this patch is a no-op. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/net/so

[PATCH bpf-next 8/9] bpf: test BPF_MAP_TYPE_REUSEPORT_SOCKARRAY

2018-08-08 Thread Martin KaFai Lau
This patch adds tests for the new BPF_MAP_TYPE_REUSEPORT_SOCKARRAY. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- tools/lib/bpf/libbpf.c | 1 + tools/testing/selftests/bpf/test_maps.c | 262 +++- 2 files changed, 262 insertions(+), 1

[PATCH bpf-next 3/9] bpf: Introduce BPF_MAP_TYPE_REUSEPORT_SOCKARRAY

2018-08-08 Thread Martin KaFai Lau
future. Hence, reuseport_array supports both value_size 4 and 8, and assuming user will usually use value_size=4. The syscall's lookup will return ENOSPC on value_size=4. It will will only return 64bits value from sock_gen_cookie() when user consciously choose value_size=8 (as a signal

[PATCH bpf-next 6/9] bpf: Refactor ARRAY_SIZE macro to bpf_util.h

2018-08-08 Thread Martin KaFai Lau
This patch refactors the ARRAY_SIZE macro to bpf_util.h. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- tools/testing/selftests/bpf/bpf_util.h | 4 tools/testing/selftests/bpf/test_align.c | 5 + tools/testing/selftests/bpf/test_btf.c | 5 + tools

[PATCH bpf-next 5/9] bpf: Enable BPF_PROG_TYPE_SK_REUSEPORT bpf prog in reuseport selection

2018-08-08 Thread Martin KaFai Lau
he usual "bpf_prog_charge_memlock()" during load time instead of bounded by both bpf_prog_charge_memlock and sysctl_optmem_max. Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- include/linux/filter.h | 1 + include/net/sock_reuseport.h | 3 +- net/core/filter.c

[PATCH bpf-next 7/9] bpf: Sync bpf.h uapi to tools/

2018-08-08 Thread Martin KaFai Lau
This patch sync include/uapi/linux/bpf.h to tools/include/uapi/linux/ Signed-off-by: Martin KaFai Lau Acked-by: Alexei Starovoitov --- tools/include/uapi/linux/bpf.h | 37 +- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/tools/include/uapi/linux

[PATCH bpf-next 1/9] tcp: Avoid TCP syncookie rejected by SO_REUSEPORT socket

2018-08-08 Thread Martin KaFai Lau
euseport_cb are tested for SO_REUSEPORT usage. Update on "synq_overflow_ts" happens at roughly once every second. A synflood test was done with a 16 rx-queues and 16 reuseport sockets. No meaningful performance change is observed. Before and after the change is ~9Mpps in IPv4. Cc:

[PATCH bpf-next 0/9] Introduce BPF_MAP_TYPE_REUSEPORT_SOCKARRAY and BPF_PROG_TYPE_SK_REUSEPORT

2018-08-08 Thread Martin KaFai Lau
; Please see individual patch for details Martin KaFai Lau (9): tcp: Avoid TCP syncookie rejected by SO_REUSEPORT socket net: Add ID (if needed) to sock_reuseport and expose reuseport_lock bpf: Introduce BPF_MAP_TYPE_REUSEPORT_SOCKARRAY bpf: Introduce BPF_PROG_TYPE_SK_REUSEPORT bpf: Enabl

[PATCH bpf] bpf: btf: Change tools/lib/bpf/btf to LGPL

2018-08-05 Thread Martin KaFai Lau
This patch changes the tools/lib/bpf/btf.[ch] to LGPL which is inline with libbpf also. Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/btf.c | 2 +- tools/lib/bpf/btf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c index

[PATCH bpf] bpf: btf: Use exact btf value_size match in map_check_btf()

2018-07-26 Thread Martin KaFai Lau
aymap") Suggested-by: Yonghong Song Acked-by: Yonghong Song Signed-off-by: Martin KaFai Lau --- kernel/bpf/arraymap.c | 2 +- tools/testing/selftests/bpf/test_btf.c | 86 +- 2 files changed, 85 insertions(+), 3 deletions(-) diff --git a/kernel/b

Re: [PATCH bpf-next v2] bpf: add End.DT6 action to bpf_lwt_seg6_action helper

2018-07-25 Thread Martin KaFai Lau
On Wed, Jul 25, 2018 at 12:36:45PM +, Mathieu Xhonneux wrote: > The seg6local LWT provides the End.DT6 action, which allows to > decapsulate an outer IPv6 header containing a Segment Routing Header > (SRH), full specification is available here: > >

Re: [PATCH V2 bpf] xdp: add NULL pointer check in __xdp_return()

2018-07-25 Thread Martin KaFai Lau
On Thu, Jul 26, 2018 at 12:09:50AM +0900, Taehee Yoo wrote: > rhashtable_lookup() can return NULL. so that NULL pointer > check routine should be added. > > Fixes: 02b55e5657c3 ("xdp: add MEM_TYPE_ZERO_COPY") > Signed-off-by: Taehee Yoo Acked-by: Martin KaFai Lau >

Re: [PATCH] samples/bpf: Add BTF build flags to Makefile

2018-07-25 Thread Martin KaFai Lau
On Wed, Jul 25, 2018 at 01:38:44PM -0700, Martin KaFai Lau wrote: > On Thu, Jul 26, 2018 at 01:30:39AM +0900, Taeung Song wrote: > > To smoothly test BTF supported binary on samples/bpf, > > let samples/bpf/Makefile probe llc, pahole and > > llvm-objcopy for BPF support and us

Re: [PATCH] samples/bpf: Add BTF build flags to Makefile

2018-07-25 Thread Martin KaFai Lau
a1b6c3efc ("bpf: btf: > Add BTF tests") > > Cc: Martin KaFai Lau > Signed-off-by: Taeung Song Thanks for the patch. LGTM. Acked-by: Martin KaFai Lau > --- > samples/bpf/Makefile | 21 - > 1 file changed, 20 insertions(+), 1 deletion(-) &g

Re: pahole + BTF was: Re: [Question] bpf: about a new 'tools/bpf/bpf_dwarf2btf'

2018-07-25 Thread Martin KaFai Lau
he future. > > > > Currently for bpf binary that have .BTF section, > > > > we need to use pahole from https://github.com/iamkafai/pahole/tree/btf > > > > with the command line such as "pahole -J bpf_prog.o". > > > > I think it is great

Re: selftests: bpf: test_progs: deadlock at trace_call_bpf

2018-07-25 Thread Martin KaFai Lau
On Tue, Jul 24, 2018 at 02:51:42PM +0530, Naresh Kamboju wrote: > Deadlock warning on x86 machine while testing selftests: bpf: > test_progs and running linux next 4.18.0-rc3-next-20180705 and still > happening on 4.18.0-rc5-next-20180720. > > Any one noticed this kernel warning about deadlock ?

Re: [PATCH bpf-next] bpf: add End.DT6 action to bpf_lwt_seg6_action helper

2018-07-24 Thread Martin KaFai Lau
On Tue, Jul 24, 2018 at 04:59:54PM +, Mathieu Xhonneux wrote: > The seg6local LWT provides the End.DT6 action, which allows to > decapsulate an outer IPv6 header containing a Segment Routing Header > (SRH), full specification is available here: > >

[PATCH v3 bpf 1/3] bpf: btf: Sync uapi btf.h to tools

2018-07-24 Thread Martin KaFai Lau
This patch sync the uapi btf.h to tools/ Fixes: 36fc3c8c282c bpf: btf: Clean up BTF_INT_BITS() in uapi btf.h Signed-off-by: Martin KaFai Lau Acked-by: Yonghong Song --- tools/include/uapi/linux/btf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/uapi/linux

[PATCH v3 bpf 2/3] bpf: Replace [u]int32_t and [u]int64_t in libbpf

2018-07-24 Thread Martin KaFai Lau
This patch replaces [u]int32_t and [u]int64_t usage with __[su]32 and __[su]64. The same change goes for [u]int16_t and [u]int8_t. Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf") Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/btf

[PATCH v3 bpf 0/3] Introduce BPF_ANNOTATE_KV_PAIR

2018-07-24 Thread Martin KaFai Lau
;' check on container_type in bpf_map_find_btf_info(). - Expose the existing static btf_type_by_id() instead of creating a new one. Martin KaFai Lau (3): bpf: btf: Sync uapi btf.h to tools bpf: Replace [u]int32_t and [u]int64_t in libbpf bpf: Introduce BPF_ANNOTATE_KV_PAIR tools/include/ua

[PATCH v3 bpf 3/3] bpf: Introduce BPF_ANNOTATE_KV_PAIR

2018-07-24 Thread Martin KaFai Lau
and btf_value_type_id from a map's name. Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf") Suggested-by: Daniel Borkmann Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/btf.c | 7 +- tools/lib/bpf/btf.h | 2 + tools/lib/bp

Re: [PATCH v2 bpf 2/3] bpf: Replace [u]int32_t and [u]int64_t in libbpf

2018-07-23 Thread Martin KaFai Lau
On Mon, Jul 23, 2018 at 11:04:34AM -0700, Yonghong Song wrote: > > > On 7/21/18 11:20 AM, Martin KaFai Lau wrote: > > This patch replaces [u]int32_t and [u]int64_t usage with > > __[su]32 and __[su]64. The same change goes for [u]int16_t > > and [u]int8_t. > &g

Re: [PATCH v2 bpf 3/3] bpf: Introduce BPF_ANNOTATE_KV_PAIR

2018-07-23 Thread Martin KaFai Lau
On Mon, Jul 23, 2018 at 11:31:43AM -0700, Yonghong Song wrote: > > > On 7/21/18 11:20 AM, Martin KaFai Lau wrote: > > This patch introduces BPF_ANNOTATE_KV_PAIR to signal the > > bpf loader about the btf key_type and value_type of a bpf map. > > Please refer to the

Re: [PATCH net] ipv6: use fib6_info_hold_safe() when necessary

2018-07-23 Thread Martin KaFai Lau
ut still exists > in the rcu grace period. Holding reference to it could cause double > free and crash the kernel. > > This patch adds a new function fib6_info_hold_safe() and replace > fib6_info_hold() in all necessary places. Acked-by: Martin KaFai Lau

[PATCH v2 bpf 0/3] Introduce BPF_ANNOTATE_KV_PAIR

2018-07-21 Thread Martin KaFai Lau
g static btf_type_by_id() instead of creating a new one. Martin KaFai Lau (3): bpf: btf: Sync uapi btf.h to tools bpf: Replace [u]int32_t and [u]int64_t in libbpf bpf: Introduce BPF_ANNOTATE_KV_PAIR tools/include/uapi/linux/btf.h | 2 +- tools/lib/bpf/btf.c

[PATCH v2 bpf 2/3] bpf: Replace [u]int32_t and [u]int64_t in libbpf

2018-07-21 Thread Martin KaFai Lau
This patch replaces [u]int32_t and [u]int64_t usage with __[su]32 and __[su]64. The same change goes for [u]int16_t and [u]int8_t. Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf") Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/btf.c| 28 +---

[PATCH v2 bpf 3/3] bpf: Introduce BPF_ANNOTATE_KV_PAIR

2018-07-21 Thread Martin KaFai Lau
and btf_value_type_id from a map's name. Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf") Suggested-by: Daniel Borkmann Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/btf.c | 7 +- tools/lib/bpf/btf.h | 2 + tools/lib/bp

[PATCH v2 bpf 1/3] bpf: btf: Sync uapi btf.h to tools

2018-07-21 Thread Martin KaFai Lau
This patch sync the uapi btf.h to tools/ Fixes: 36fc3c8c282c bpf: btf: Clean up BTF_INT_BITS() in uapi btf.h Signed-off-by: Martin KaFai Lau --- tools/include/uapi/linux/btf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/uapi/linux/btf.h b/tools/include/uapi

Re: [PATCH bpf 3/3] bpf: Introduce BPF_ANNOTATE_KV_PAIR

2018-07-21 Thread Martin KaFai Lau
On Fri, Jul 20, 2018 at 06:39:33PM -0700, Martin KaFai Lau wrote: > This patch introduces BPF_ANNOTATE_KV_PAIR to signal the > bpf loader about the btf key_type and value_type of a bpf map. > Please refer to the changes in test_btf_haskv.c for its usage. > Both iproute2 and l

[PATCH bpf 3/3] bpf: Introduce BPF_ANNOTATE_KV_PAIR

2018-07-20 Thread Martin KaFai Lau
and btf_value_type_id from a map's name. Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf") Suggested-by: Daniel Borkmann Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/btf.c | 8 +++ tools/lib/bpf/btf.h | 1 + tools/lib/bp

[PATCH bpf 2/3] bpf: Replace [u]int32_t and [u]int64_t in libbpf

2018-07-20 Thread Martin KaFai Lau
This patch replaces [u]int32_t and [u]int64_t usage with __[su]32 and __[su]64. The same change goes for [u]int16_t and [u]int8_t. Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf") Signed-off-by: Martin KaFai Lau --- tools/lib/bpf/btf.c| 28 +---

[PATCH bpf 1/3] bpf: btf: Sync uapi btf.h to tools

2018-07-20 Thread Martin KaFai Lau
This patch sync the uapi btf.h to tools/ Fixes: 36fc3c8c282c bpf: btf: Clean up BTF_INT_BITS() in uapi btf.h Signed-off-by: Martin KaFai Lau --- tools/include/uapi/linux/btf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/uapi/linux/btf.h b/tools/include/uapi

[PATCH bpf 0/3] Introduce BPF_ANNOTATE_KV_PAIR

2018-07-20 Thread Martin KaFai Lau
consistent way to figure out the btf_key_type_id and btf_value_type_id for a map. The first two patches are some prep/cleanup works. The last patch introduces BPF_ANNOTATE_KV_PAIR. Martin KaFai Lau (3): bpf: btf: Sync uapi btf.h to tools bpf: Replace [u]int32_t and [u]int64_t in libbpf bpf

[PATCH bpf] bpf: btf: Ensure the member->offset is in the right order

2018-07-20 Thread Martin KaFai Lau
69b693f0aefa ("bpf: btf: Introduce BPF Type Format (BTF)") Signed-off-by: Martin KaFai Lau --- kernel/bpf/btf.c | 14 - tools/testing/selftests/bpf/test_btf.c | 28 ++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --g

Re: [PATCH bpf] xdp: add NULL pointer check in __xdp_return()

2018-07-20 Thread Martin KaFai Lau
On Sat, Jul 21, 2018 at 01:04:45AM +0900, Taehee Yoo wrote: > rhashtable_lookup() can return NULL. so that NULL pointer > check routine should be added. > > Fixes: 02b55e5657c3 ("xdp: add MEM_TYPE_ZERO_COPY") > Signed-off-by: Taehee Yoo > --- > net/core/xdp.c | 3 ++- > 1 file changed, 2

[PATCH bpf] bpf: Use option "help" in the llvm-objcopy test

2018-07-19 Thread Martin KaFai Lau
n the future. Fixes: c0fa1b6c3efc ("bpf: btf: Add BTF tests") Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 7a6

[PATCH bpf] bpf: btf: Clean up BTF_INT_BITS() in uapi btf.h

2018-07-19 Thread Martin KaFai Lau
()) path stays as is to deal with invalid BTF situation. Fixes: 69b693f0aefa ("bpf: btf: Introduce BPF Type Format (BTF)") Signed-off-by: Martin KaFai Lau --- include/uapi/linux/btf.h | 2 +- kernel/bpf/btf.c | 16 ++-- 2 files changed, 11 insertions(+), 7 deletions(-)

Re: [PATCH iproute2 5/5] bpf: implement btf handling and map annotation

2018-07-19 Thread Martin KaFai Lau
On Thu, Jul 19, 2018 at 05:43:11PM +0200, Daniel Borkmann wrote: > On 07/19/2018 02:11 AM, Martin KaFai Lau wrote: > > On Wed, Jul 18, 2018 at 11:13:37AM -0700, Jakub Kicinski wrote: > >> On Wed, 18 Jul 2018 11:33:22 +0200, Daniel Borkmann wrote: > >>> On 07/18/2018 1

Re: [PATCH iproute2 5/5] bpf: implement btf handling and map annotation

2018-07-18 Thread Martin KaFai Lau
On Wed, Jul 18, 2018 at 11:13:37AM -0700, Jakub Kicinski wrote: > On Wed, 18 Jul 2018 11:33:22 +0200, Daniel Borkmann wrote: > > On 07/18/2018 10:42 AM, Daniel Borkmann wrote: > > > On 07/18/2018 02:27 AM, Jakub Kicinski wrote: > > >> On Wed, 18 Jul 2018 01:31:22 +0200, Daniel Borkmann wrote:

Re: [PATCH iproute2 5/5] bpf: implement btf handling and map annotation

2018-07-18 Thread Martin KaFai Lau
On Tue, Jul 17, 2018 at 05:27:43PM -0700, Jakub Kicinski wrote: > On Wed, 18 Jul 2018 01:31:22 +0200, Daniel Borkmann wrote: > > # bpftool map dump id 386 > >[{ > > "key": 0, > > "value": { > > "": { > > "value": 0, > > "ifindex":

Re: [PATCH bpf-next] bpf: show in bpftool map overview whether btf is available

2018-07-18 Thread Martin KaFai Lau
t;: 4, > "bytes_value": 20, > "max_entries": 40, > "bytes_memlock": 4096 > } > ] > > Signed-off-by: Daniel Borkmann Acked-by: Martin KaFai Lau

Re: [bpf PATCH v4 3/4] bpf: sockhash fix omitted bucket lock in sock_close

2018-06-25 Thread Martin KaFai Lau
l map/hash references to a > sock when the sock is closed) > > Reported-by: syzbot+0ce137753c78f7b6a...@syzkaller.appspotmail.com > Fixes: 81110384441a ("bpf: sockmap, add hash map support") > Signed-off-by: John Fastabend Acked-by: Martin KaFai Lau

Re: [bpf PATCH v3 3/4] bpf: sockhash fix omitted bucket lock in sock_close

2018-06-23 Thread Martin KaFai Lau
On Fri, Jun 22, 2018 at 08:21:44AM -0700, John Fastabend wrote: > First in tcp_close, reduce scope of sk_callback_lock() the lock is > only needed for protecting maps list the ingress and cork > lists are protected by sock lock. Having the lock in wider scope is > harmless but may confuse the

Re: [bpf PATCH v3 2/4] bpf: sockmap, fix smap_list_map_remove when psock is in many maps

2018-06-23 Thread Martin KaFai Lau
t; > To fix this create two list handlers one for sockmap and one for > sockhash. > > Reported-by: syzbot+0ce137753c78f7b6a...@syzkaller.appspotmail.com > Fixes: 81110384441a ("bpf: sockmap, add hash map support") > Signed-off-by: John Fastabend One nit. Other tha

Re: [bpf PATCH v3 1/4] bpf: sockmap, fix crash when ipv6 sock is added

2018-06-23 Thread Martin KaFai Lau
rt") > Reported-by: syzbot+5c063698bdbfac19f...@syzkaller.appspotmail.com > Signed-off-by: John Fastabend > Signed-off-by: Wei Wang Acked-by: Martin KaFai Lau > --- > kernel/bpf/sockmap.c | 58 > +- > 1 file changed, 48 insertions(+), 10 dele

Re: [PATCH v2 bpf-net] bpf: Change bpf_fib_lookup to return lookup status

2018-06-21 Thread Martin KaFai Lau
e fib result for unicast routes must have an egress device, so remove > the check that it is non-NULL. Acked-by: Martin KaFai Lau > > Signed-off-by: David Ahern > --- > v2 > - drop BPF_FIB_LKUP_RET_NO_NHDEV; check in dev in fib result not needed > - enhance documentation

Re: [PATCH bpf-net] bpf: Change bpf_fib_lookup to return lookup status

2018-06-19 Thread Martin KaFai Lau
On Tue, Jun 19, 2018 at 02:16:53PM -0600, David Ahern wrote: > On 6/19/18 10:36 AM, Martin KaFai Lau wrote: > > On Tue, Jun 19, 2018 at 09:34:28AM -0600, David Ahern wrote: > >> On 6/19/18 9:25 AM, Martin KaFai Lau wrote: > >>> On Mon, Jun 18, 2018 at 03:35

Re: [PATCH bpf-net] bpf: Change bpf_fib_lookup to return lookup status

2018-06-19 Thread Martin KaFai Lau
On Tue, Jun 19, 2018 at 09:34:28AM -0600, David Ahern wrote: > On 6/19/18 9:25 AM, Martin KaFai Lau wrote: > > On Mon, Jun 18, 2018 at 03:35:25PM -0600, David Ahern wrote: > >> On 6/18/18 2:55 PM, Martin KaFai Lau wrote: > >>>> /* rc > 0 case

Re: [PATCH bpf-net] bpf: Change bpf_fib_lookup to return lookup status

2018-06-19 Thread Martin KaFai Lau
On Mon, Jun 18, 2018 at 03:35:25PM -0600, David Ahern wrote: > On 6/18/18 2:55 PM, Martin KaFai Lau wrote: > >>/* rc > 0 case */ > >>switch(rc) { > >>case BPF_FIB_LKUP_RET_BLACKHOLE: > >>case BPF_FIB_LKUP_RET_UNREACHAB

Re: [bpf PATCH v2 2/6] bpf: sockmap only allow ESTABLISHED sock state

2018-06-18 Thread Martin KaFai Lau
On Mon, Jun 18, 2018 at 07:50:19AM -0700, John Fastabend wrote: > On 06/14/2018 05:18 PM, Martin KaFai Lau wrote: > > On Thu, Jun 14, 2018 at 09:44:52AM -0700, John Fastabend wrote: > >> Per the note in the TLS ULP (which is actually a generic statement > >> regarding

Re: [PATCH bpf-net] bpf: Change bpf_fib_lookup to return lookup status

2018-06-18 Thread Martin KaFai Lau
On Mon, Jun 18, 2018 at 12:27:07PM -0600, David Ahern wrote: > On 6/18/18 12:11 PM, Martin KaFai Lau wrote: > > On Sun, Jun 17, 2018 at 08:18:19AM -0700, dsah...@kernel.org wrote: > >> From: David Ahern > >> > >> For ACLs implemented using either FIB rules

Re: [PATCH bpf-net] bpf: Change bpf_fib_lookup to return lookup status

2018-06-18 Thread Martin KaFai Lau
On Sun, Jun 17, 2018 at 08:18:19AM -0700, dsah...@kernel.org wrote: > From: David Ahern > > For ACLs implemented using either FIB rules or FIB entries, the BPF > program needs the FIB lookup status to be able to drop the packet. Except BPF_FIB_LKUP_RET_SUCCESS and BPF_FIB_LKUP_RET_NO_NEIGH, can

Re: [PATCH bpf 2/2] bpf: reject any prog that failed read-only lock

2018-06-15 Thread Martin KaFai Lau
in the > destructor we call bpf_prog_free_deferred() on the main prog where we > try to bpf_prog_unlock_free() the program, and since we go via > bpf_prog_select_runtime() do that as well. > > Reported-by: syzbot+3b889862e65a98317...@syzkaller.appspotmail.com > Reported-by: syzbot+

Re: [PATCH bpf 1/2] bpf: fix panic in prog load calls cleanup

2018-06-15 Thread Martin KaFai Lau
; done under jit_subprogs(). Add proper API to make BPF kallsyms deletion > more clear and fix that. > > Fixes: 1c2a088a6626 ("bpf: x64: add JIT support for multi-function programs") > Signed-off-by: Daniel Borkmann Acked-by: Martin KaFai Lau > --- > include/linu

Re: [bpf PATCH v2 3/6] bpf: sockhash fix omitted bucket lock in sock_close

2018-06-15 Thread Martin KaFai Lau
On Fri, Jun 15, 2018 at 08:23:14AM -0700, John Fastabend wrote: > On 06/14/2018 10:41 PM, Martin KaFai Lau wrote: > > On Thu, Jun 14, 2018 at 09:44:57AM -0700, John Fastabend wrote: > >> First in tcp_close, reduce scope of sk_callback_lock() the lock is > >>

Re: [bpf PATCH v2 6/6] bpf: selftest remove attempts to add LISTEN sockets to sockmap

2018-06-15 Thread Martin KaFai Lau
ror now. Fix the test to avoid adding sockets in listening state. > > Signed-off-by: John Fastabend Acked-by: Martin KaFai Lau > --- > 0 files changed > > diff --git a/tools/testing/selftests/bpf/test_maps.c > b/tools/testing/selftests/bpf/test_maps.c > index 6c25334..

Re: [bpf PATCH v2 5/6] bpf: sockhash, add release routine

2018-06-15 Thread Martin KaFai Lau
t;) > Signed-off-by: John Fastabend Acked-by: Martin KaFai Lau > --- > 0 files changed > > diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c > index ffc5152..77fe204 100644 > --- a/kernel/bpf/sockmap.c > +++ b/kernel/bpf/sockmap.c > @@ -2518,6 +2518,7 @@ struct s

Re: [bpf PATCH v2 4/6] bpf: sockmap, tcp_disconnect to listen transition

2018-06-15 Thread Martin KaFai Lau
ing the sock. > > To do this add unhash hook and remove sock from map there. > > Reported-by: Eric Dumazet > Fixes: 81110384441a ("bpf: sockmap, add hash map support") > Signed-off-by: John Fastabend LGTM. One nit. Acked-by: Martin KaFai Lau > --- > 0 files ch

Re: [bpf PATCH v2 3/6] bpf: sockhash fix omitted bucket lock in sock_close

2018-06-14 Thread Martin KaFai Lau
On Thu, Jun 14, 2018 at 09:44:57AM -0700, John Fastabend wrote: > First in tcp_close, reduce scope of sk_callback_lock() the lock is > only needed for protecting smap_release_sock() the ingress and cork > lists are protected by sock lock. Having the lock in wider scope is > harmless but may

Re: [bpf PATCH v2 2/6] bpf: sockmap only allow ESTABLISHED sock state

2018-06-14 Thread Martin KaFai Lau
On Thu, Jun 14, 2018 at 09:44:52AM -0700, John Fastabend wrote: > Per the note in the TLS ULP (which is actually a generic statement > regarding ULPs) > > /* The TLS ulp is currently supported only for TCP sockets > * in ESTABLISHED state. > * Supporting sockets in LISTEN state will require

Re: [bpf PATCH v2 1/6] bpf: sockmap, fix crash when ipv6 sock is added

2018-06-14 Thread Martin KaFai Lau
On Thu, Jun 14, 2018 at 09:44:46AM -0700, John Fastabend wrote: > This fixes a crash where we assign tcp_prot to IPv6 sockets instead > of tcpv6_prot. > > Previously we overwrote the sk->prot field with tcp_prot even in the > AF_INET6 case. This patch ensures the correct tcp_prot and tcpv6_prot >

Re: [PATCH bpf-net] selftests/bpf: delete xfrm tunnel when test exits.

2018-06-14 Thread Martin KaFai Lau
On Thu, Jun 14, 2018 at 05:01:06AM -0700, William Tu wrote: > Make the printting of bpf xfrm tunnel better and > cleanup xfrm state and policy when xfrm test finishes. LGTM. The subject tag actually meant s/bpf-net/bpf-next/? It makes sense to be in bpf-next but I think bpf-next is still closed.

Re: [PATCH bpf-next v5 00/10] BTF: BPF Type Format

2018-06-14 Thread Martin KaFai Lau
On Thu, Jun 14, 2018 at 12:03:34PM -0300, Arnaldo Carvalho de Melo wrote: > > > > > 1. The tools/testing/selftests/bpf/Makefile has the CLANG_FLAGS and > > > > >LLC_FLAGS needed to compile the bpf prog. It requires a new > > > > >"-mattr=dwarf" llc option which was added to the future >

Re: [bpf PATCH 4/6] bpf: sockmap, tcp_disconnect to listen transition

2018-06-13 Thread Martin KaFai Lau
On Wed, Jun 13, 2018 at 10:50:14AM -0700, John Fastabend wrote: > After adding checks to ensure TCP is in ESTABLISHED state when a > sock is added we need to also ensure that user does not transition > through tcp_disconnect() and back into ESTABLISHED state without > sockmap removing the sock. >

Re: [PATCH bpf-next v5 00/10] BTF: BPF Type Format

2018-06-13 Thread Martin KaFai Lau
On Tue, Jun 12, 2018 at 05:41:26PM -0300, Arnaldo Carvalho de Melo wrote: > Em Tue, Jun 12, 2018 at 05:31:24PM -0300, Arnaldo Carvalho de Melo escreveu: > > Em Thu, Jun 07, 2018 at 01:07:01PM -0700, Martin KaFai Lau escreveu: > > > On Thu, Jun 07, 2018 at 04:30:29PM -0300, Arnald

Re: [PATCH net] ipv6: allow PMTU exceptions to local routes

2018-06-11 Thread Martin KaFai Lau
On Mon, Jun 11, 2018 at 02:02:54AM +0300, Julian Anastasov wrote: > IPVS setups with local client and remote tunnel server need > to create exception for the local virtual IP. What we do is to > change PMTU from 64KB (on "lo") to 1460 in the common case. > > Sugge

  1   2   3   4   5   6   7   8   >