[PATCH v7 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 v7 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 v6 bpf-next 0/2] bpf: add cg_skb_is_valid_access

2018-10-18 Thread Song Liu
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: add tests for direct packet access from CGROUP_SKB include

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

2018-10-18 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 v6 bpf-next 1/2] bpf: add cg_skb_is_valid_access for BPF_PROG_TYPE_CGROUP_SKB

2018-10-18 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

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

2018-10-18 Thread Song Liu
> On Oct 18, 2018, at 10:22 PM, Eric Dumazet wrote: > > > > On 10/18/2018 10:01 PM, Song Liu wrote: >> Tests are added to make sure CGROUP_SKB cannot access: >> tc_classid, data_meta, flow_keys >> >> and can read and write: >> mark, prority,

Re: [PATCH bpf-next 2/2] samples: bpf: get ifindex from ifname

2018-10-18 Thread Y Song
On Thu, Oct 18, 2018 at 1:48 PM Matteo Croce wrote: > > Find the ifindex via ioctl(SIOCGIFINDEX) instead of requiring the > numeric ifindex. Maybe use if_nametoindex which is simpler? > > Signed-off-by: Matteo Croce > --- > samples/bpf/xdp1_user.c | 26 -- > 1 file

Re: [PATCH bpf-next 1/2] samples: bpf: improve xdp1 example

2018-10-18 Thread Y Song
On Thu, Oct 18, 2018 at 1:48 PM Matteo Croce wrote: > > Store only the total packet count for every protocol, instead of the > whole per-cpu array. > Use bpf_map_get_next_key() to iterate the map, instead of looking up > all the protocols. > > Signed-off-by: Matteo Croce Acked-by: Yonghong Song

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

2018-10-18 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 v5 bpf-next 0/2] bpf: add cg_skb_is_valid_access

2018-10-18 Thread Song Liu
KB to access some __skb_buff data directly. Song Liu (2): bpf: add cg_skb_is_valid_access for BPF_PROG_TYPE_CGROUP_SKB bpf: add tests for direct packet access from CGROUP_SKB include/linux/filter.h | 21 +++ kernel/bpf/cgroup.c | 6 + net/bp

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

2018-10-18 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

Re: [PATCH bpf-next v3 7/7] selftests/bpf: add test cases for queue and stack maps

2018-10-18 Thread Song Liu
On Thu, Oct 18, 2018 at 10:33 AM Mauricio Vasquez wrote: > > > On 10/18/18 11:36 AM, Song Liu wrote: > > On Thu, Oct 18, 2018 at 6:16 AM Mauricio Vasquez B > > wrote: > >> test_maps: > >> Tests that queue/stack maps are behaving correctly even in corner cas

Re: [PATCH bpf-next v3 7/7] selftests/bpf: add test cases for queue and stack maps

2018-10-18 Thread Song Liu
On Thu, Oct 18, 2018 at 6:16 AM Mauricio Vasquez B wrote: > > test_maps: > Tests that queue/stack maps are behaving correctly even in corner cases > > test_progs: > Tests new ebpf helpers > > Signed-off-by: Mauricio Vasquez B > --- > tools/lib/bpf/bpf.c| 12 ++

Re: [PATCH bpf-next v3 4/7] bpf: add queue and stack maps

2018-10-18 Thread Song Liu
> other use cases, like for exampling saving last N kernel events in a map > and then analysing from userspace. > > Signed-off-by: Mauricio Vasquez B Acked-by: Song Liu > --- > include/linux/bpf.h |6 + > include/linux/bpf_types.h |2 > include/uapi/linux/bpf

Re: [PATCH bpf-next v3 5/7] bpf: add MAP_LOOKUP_AND_DELETE_ELEM syscall

2018-10-18 Thread Song Liu
AND_DELETE_ELEM syscall is added, > this is mapped to the pop operation in the queue/stack maps > and it is still to implement in other kind of maps. > > Signed-off-by: Mauricio Vasquez B Acked-by: Song Liu > --- > include/uapi/linux/bpf.h |1 + &

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

2018-10-18 Thread Song Liu
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: add tests for direct packet access from CGROUP_SKB include/linux/filter.h

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

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

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

2018-10-18 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/

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

2018-10-18 Thread Song Liu
> On Oct 17, 2018, at 11:25 PM, Alexei Starovoitov > wrote: > > On Wed, Oct 17, 2018 at 10:39:49PM -0700, Song Liu wrote: >> Tests are added to make sure CGROUP_SKB cannot access: >> tc_classid, data_meta, flow_keys >> >> and can read and

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

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

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

2018-10-17 Thread Song Liu
f 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: add tests for direct packet access from CGROUP_SKB include/linux/filter.h | 24 +++ kernel/bpf/cgroup.c | 6

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

2018-10-17 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/

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

2018-10-17 Thread Song Liu
> On Oct 17, 2018, at 9:44 PM, Alexei Starovoitov > wrote: > > On Wed, Oct 17, 2018 at 04:36:15PM -0700, Song Liu wrote: >> BPF programs of BPF_PROG_TYPE_CGROUP_SKB need to access headers in the >> skb. This patch enables direct access o

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

2018-10-17 Thread Song Liu
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. Song Liu (2): bpf: add cg_skb_is_valid_acc

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

2018-10-17 Thread Song Liu
BPF programs of BPF_PROG_TYPE_CGROUP_SKB need to access headers in the skb. This patch enables direct access of skb for these programs. In __cgroup_bpf_run_filter_skb(), bpf_compute_data_pointers() is called to compute proper data_end for the BPF program. Signed-off-by: Song Liu --- kernel/bpf

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

2018-10-17 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 bpf-next v3 13/13] tools/bpf: bpftool: add support for jited func types

2018-10-17 Thread Yonghong Song
%rbp 1: mov%rsp,%rbp .. 80: add$0x28,%rbp 84: leaveq 85: retq Signed-off-by: Yonghong Song --- tools/bpf/bpftool/btf_dumper.c | 90 ++ tools/bpf/bpftool/main.h | 2 + tools/bpf/bpftool/prog.c | 54

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

2018-10-17 Thread Yonghong Song
The kernel uapi bpf.h is synced to tools directory. Signed-off-by: Yonghong Song --- tools/include/uapi/linux/bpf.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index f9187b41dff6..7ebbf4f06a65 100644

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

2018-10-17 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 v3 12/13] tools/bpf: enhance test_btf file testing to test func info

2018-10-17 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 | 87 ++-- tools/testing

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

2018-10-17 Thread Yonghong Song
to return btf_id and jited_func_types, so user spaces can print out the function prototype for each jited function. Signed-off-by: Yonghong Song --- include/linux/bpf.h | 2 + include/linux/bpf_verifier.h | 1 + include/linux/btf.h | 2 + include/uapi/linux/bpf.h | 11

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

2018-10-17 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. Signed-off-by: Yonghong Song --- tools/lib/bpf/btf.c| 232 + tools/lib/bpf/btf.h| 48 + tools

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

2018-10-17 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 Signed-off-by: Yonghong Song --- kernel/bpf/btf.c | 37

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

2018-10-17 Thread Yonghong Song
loading/retriving of func_type info. Signed-off-by: Yonghong Song --- tools/testing/selftests/bpf/test_btf.c | 278 - 1 file changed, 275 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c index

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

2018-10-17 Thread Yonghong Song
Add several BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO unit tests in bpf selftest 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 | 216 + 2 files changed, 220

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

2018-10-17 Thread Yonghong Song
function signature is available to both kernel and user space. Here, the insn offset is not available during the dump time as relocation is resolved pretty late in the compilation process. Signed-off-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- include/u

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

2018-10-17 Thread Yonghong Song
d/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 and BTF_KIND_FUNC_PROTO tools/bpf: sync kernel btf.h header tools/bpf: add btf func/func_proto unit

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

2018-10-17 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 v3 03/13] tools/bpf: sync kernel btf.h header

2018-10-17 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 | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/include/uapi/linux/btf.h b/tools/include/uapi/linux/btf.h

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

2018-10-17 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. Signed-off-by: Yonghong Song --- tools/lib/bpf/bpf.c | 3 +++ tools

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

2018-10-17 Thread Song Liu
> On Oct 17, 2018, at 12:02 PM, Alexei Starovoitov wrote: > > On 10/17/18 10:26 AM, Alexei Starovoitov wrote: >> On Tue, Oct 16, 2018 at 10:56:05PM -0700, Song Liu wrote: >>> BPF programs of BPF_PROG_TYPE_CGROUP_SKB need to access headers in the >>> skb.

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

2018-10-17 Thread Yonghong Song
On 10/17/18 4:11 AM, Edward Cree wrote: > On 17/10/18 08:24, Yonghong Song wrote: >> This patch added support to print function signature >> if btf func_info is available. Note that ksym >> now uses function name instead of prog_name as >> prog_name has a limit of 1

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

2018-10-17 Thread Yonghong Song
On 10/17/18 9:13 AM, Edward Cree wrote: > On 17/10/18 08:23, Yonghong Song wrote: >> This patch adds BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO >> support to the type section. BTF_KIND_FUNC_PROTO is used >> to specify the type of a function pointer. With this, >> BTF ha

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

2018-10-17 Thread Song Liu
Hi David, On Wed, Oct 17, 2018 at 8:09 AM David Ahern wrote: > > On 10/16/18 11:43 PM, Song Liu wrote: > > I agree that processing events while recording has significant overhead. > > In this case, perf user space need to know details about the the jited BPF > > program.

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

2018-10-17 Thread Yonghong Song
On 10/17/18 4:02 AM, Edward Cree wrote: > I think the BTF work needs to be better documented; at the moment the only way >  to determine how BTF sections are structured is to read through the headers, >  and cross-reference with the DWARF spec to guess at the semantics of various >  fields. 

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

2018-10-17 Thread Song Liu
t 16, 2018 at 11:43:11PM -0700, Song Liu escreveu: > > > On Tue, Oct 16, 2018 at 4:43 PM David Ahern wrote: > > > > On 10/15/18 4:33 PM, Song Liu wrote: > > > > > I am working with Alexei on the idea of fetching BPF program > > > > > in

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

2018-10-17 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 v2 10/13] tools/bpf: do not use pahole if clang/llvm can generate BTF sections

2018-10-17 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 v2 13/13] tools/bpf: bpftool: add support for jited func types

2018-10-17 Thread Yonghong Song
%rbp 1: mov%rsp,%rbp .. 80: add$0x28,%rbp 84: leaveq 85: retq Signed-off-by: Yonghong Song --- tools/bpf/bpftool/btf_dumper.c | 96 ++ tools/bpf/bpftool/main.h | 2 + tools/bpf/bpftool/prog.c | 54

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

2018-10-17 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 | 72 +++- tools/testing

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

2018-10-17 Thread Yonghong Song
The kernel uapi bpf.h is synced to tools directory. Signed-off-by: Yonghong Song --- tools/include/uapi/linux/bpf.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index f9187b41dff6..7ebbf4f06a65 100644

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

2018-10-17 Thread Yonghong Song
. In this patch, only func type info is processed. The functionality is implemented in libbpf. Signed-off-by: Yonghong Song --- tools/lib/bpf/btf.c| 232 + tools/lib/bpf/btf.h| 31 ++ tools/lib/bpf/libbpf.c | 53 +- 3 files changed, 312

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

2018-10-17 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. Signed-off-by: Yonghong Song --- tools/lib/bpf/bpf.c | 3 +++ tools

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

2018-10-17 Thread Yonghong Song
sections. Patch #11 refactors to have btf_get_from_id() in libbpf for reuse. Patch #12 enhance test_btf file testing to test func info. Patch #13 adds bpftool support for func signature dump. Yonghong Song (13): bpf: btf: Break up btf_type_is_void() bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FU

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

2018-10-17 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 Signed-off-by: Yonghong Song --- kernel/bpf/btf.c | 37

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

2018-10-17 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 | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/include/uapi/linux/btf.h b/tools/include/uapi/linux/btf.h

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

2018-10-17 Thread Yonghong Song
loading/retriving of func_type info. Signed-off-by: Yonghong Song --- tools/testing/selftests/bpf/test_btf.c | 278 - 1 file changed, 275 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c index

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

2018-10-17 Thread Yonghong Song
to return btf_id and jited_func_types, so user spaces can print out the function prototype for each jited function. Signed-off-by: Yonghong Song --- include/linux/bpf.h | 2 + include/linux/bpf_verifier.h | 1 + include/linux/btf.h | 2 + include/uapi/linux/bpf.h | 11

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

2018-10-17 Thread Yonghong Song
function signature is available to both kernel and user space. Here, the insn offset is not available during the dump time as relocation is resolved pretty late in the compilation process. Signed-off-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- include/u

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

2018-10-17 Thread Yonghong Song
Add several BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO unit tests in bpf selftest 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 | 216 + 2 files changed, 220

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

2018-10-17 Thread Song Liu
Hi David, On Tue, Oct 16, 2018 at 4:43 PM David Ahern wrote: > > On 10/15/18 4:33 PM, Song Liu wrote: > > I am working with Alexei on the idea of fetching BPF program information via > > BPF_OBJ_GET_INFO_BY_FD cmd. I added PERF_RECORD_BPF_EVENT > > to perf_event_type,

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

2018-10-16 Thread Song Liu
BPF programs of BPF_PROG_TYPE_CGROUP_SKB need to access headers in the skb. This patch enables direct access of skb for these programs. In __cgroup_bpf_run_filter_skb(), bpf_compute_data_pointers() is called to compute proper data_end for the BPF program. Signed-off-by: Song Liu --- kernel/bpf

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

2018-10-16 Thread Song Liu
Tests are added to make sure CGROUP_SKB can directly access len, data, and data_end in __sk_buff, but not other fields. Signed-off-by: Song Liu --- tools/testing/selftests/bpf/test_verifier.c | 30 + 1 file changed, 30 insertions(+) diff --git a/tools/testing/selftests/bpf

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

2018-10-16 Thread Song Liu
This set enables BPF program of type BPF_PROG_TYPE_CGROUP_SKB to access __skb_buff->len/data/data_end directly. Song Liu (2): bpf: add cg_skb_is_valid_access for BPF_PROG_TYPE_CGROUP_SKB bpf: add tests for direct packet access from CGROUP_SKB kernel/bpf/cgroup.c |

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

2018-10-16 Thread Yonghong Song
On 10/16/18 11:27 AM, Alexei Starovoitov wrote: > On Fri, Oct 12, 2018 at 11:54:20AM -0700, Yonghong Song wrote: >> The BTF support was added to kernel by Commit 69b693f0aefa >> ("bpf: btf: Introduce BPF Type Format (BTF)"), which introduced >> .BTF section into EL

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

2018-10-16 Thread Yonghong Song
On 10/16/18 10:59 AM, Alexei Starovoitov wrote: > On Fri, Oct 12, 2018 at 11:54:42AM -0700, Yonghong Song wrote: >> This patch added interface to load a program with the following >> additional information: >> . prog_btf_fd >> . func_info and func_

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

2018-10-16 Thread Yonghong Song
On 10/15/18 3:36 PM, Daniel Borkmann wrote: > On 10/12/2018 08:54 PM, Yonghong Song wrote: > [...] >> +static bool btf_name_valid_identifier(const struct btf *btf, u32 offset) >> +{ >> +/* offset must be valid */ >> +const char *src = >strings[offset

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

2018-10-16 Thread Yonghong Song
On 10/15/18 3:30 PM, Daniel Borkmann wrote: > On 10/12/2018 08:54 PM, Yonghong Song wrote: >> This patch adds BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO >> support to the type section. BTF_KIND_FUNC_PROTO is used >> to specify the type of a function pointer. With this, >>

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

2018-10-16 Thread Yonghong Song
On 10/15/18 4:12 PM, Martin Lau wrote: > On Fri, Oct 12, 2018 at 11:54:42AM -0700, Yonghong Song wrote: >> This patch added interface to load a program with the following >> additional information: >> . prog_btf_fd >> . func_info and func_info_len >&

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

2018-10-15 Thread Song Liu
[ perf record: Captured and wrote 9.337 MB perf.data (93178 samples) ] In this example, the bpf program was loaded and then unloaded in another terminal. When machine__process_bpf_event() processes the load event, the bpf program is already unloaded. Therefore, machine__process_bpf_event() will not be able to get information about the program via BPF_OBJ_GET_INFO_BY_FD cmd. To solve this problem, we will need to run BPF_OBJ_GET_INFO_BY_FD as soon as perf get the event from kernel. I looked around the perf code for a while. But I haven't found a good example where some events are processed before the end of perf-record. Could you please help me with this? Thanks, Song

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

2018-10-12 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 12/13] tools/bpf: enhance test_btf file testing to test func info

2018-10-12 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 | 72 +++- tools/testing

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

2018-10-12 Thread Yonghong Song
%rbp 1: mov%rsp,%rbp .. 80: add$0x28,%rbp 84: leaveq 85: retq Signed-off-by: Yonghong Song --- tools/bpf/bpftool/btf_dumper.c | 96 ++ tools/bpf/bpftool/main.h | 2 + tools/bpf/bpftool/prog.c | 54

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

2018-10-12 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 05/13] bpf: get better bpf_prog ksyms based on btf func type_id

2018-10-12 Thread Yonghong Song
to return btf_id and jited_func_types, so user spaces can print out the function prototype for each jited function. Signed-off-by: Yonghong Song --- include/linux/bpf.h | 2 + include/linux/bpf_verifier.h | 1 + include/linux/btf.h | 2 + include/uapi/linux/bpf.h | 11

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

2018-10-12 Thread Yonghong Song
The kernel uapi bpf.h is synced to tools directory. Signed-off-by: Yonghong Song --- tools/include/uapi/linux/bpf.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index f9187b41dff6..7ebbf4f06a65 100644

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

2018-10-12 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. Signed-off-by: Yonghong Song --- tools/lib/bpf/bpf.c | 3 +++ tools

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

2018-10-12 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 | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/include/uapi/linux/btf.h b/tools/include/uapi/linux/btf.h

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

2018-10-12 Thread Yonghong Song
loading/retriving of func_type info. Signed-off-by: Yonghong Song --- tools/testing/selftests/bpf/test_btf.c | 278 - 1 file changed, 275 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c index

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

2018-10-12 Thread Yonghong Song
gnature is available to both kernel and user space. Here, the insn offset is not available during the dump time as relocation is resolved pretty late in the compilation process. Signed-off-by: Martin KaFai Lau Signed-off-by: Yonghong Song --- include/uapi/linux/btf.h | 9 +- kernel/bpf/btf.c

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

2018-10-12 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 04/13] tools/bpf: add btf func/func_proto unit tests in selftest test_btf

2018-10-12 Thread Yonghong Song
Add several BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO unit tests in bpf selftest 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 | 216 + 2 files changed, 220

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

2018-10-12 Thread Yonghong Song
FContext.h). Signed-off-by: Yonghong Song --- tools/lib/bpf/btf.c| 232 + tools/lib/bpf/btf.h| 31 ++ tools/lib/bpf/libbpf.c | 53 +- 3 files changed, 312 insertions(+), 4 deletions(-) diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/b

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

2018-10-12 Thread Yonghong Song
11 refactors to have btf_get_from_id() in libbpf for reuse. Patch #12 enhance test_btf file testing to test func info. Patch #13 adds bpftool support for func signature dump. Yonghong Song (13): bpf: btf: Break up btf_type_is_void() bpf: btf: Add BTF_KIND_FUNC and BTF_KIND_FUNC_PROTO tools/bpf: sync

Re: [PATCH bpf-next v2 3/7] bpf: add MAP_LOOKUP_AND_DELETE_ELEM syscall

2018-10-10 Thread Song Liu
On Wed, Oct 10, 2018 at 10:48 AM Mauricio Vasquez wrote: > > > > On 10/10/2018 11:48 AM, Song Liu wrote: > > On Wed, Oct 10, 2018 at 7:06 AM Mauricio Vasquez B > > wrote: > >> The following patch implements a bpf queue/stack maps that > >

Re: [PATCH bpf-next v2 3/7] bpf: add MAP_LOOKUP_AND_DELETE_ELEM syscall

2018-10-10 Thread Song Liu
ptr = map->ops->map_lookup_and_delete_elem(map, key); > + if (ptr) > + memcpy(value, ptr, value_size); I think we are exposed to race condition with push and pop in parallel. map_lookup_and_delete_elem() only updates the head/tail, so it giv

Re: [PATCH bpf-next v2 1/7] bpf: rename stack trace map operations

2018-10-10 Thread Song Liu
d-off-by: Mauricio Vasquez B Acked-by: Song Liu > --- > include/linux/bpf_types.h |2 +- > kernel/bpf/stackmap.c |2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/include/linux/bpf_types.h b/include/linux/bpf_types.h > index 5432f4c9f50e..65

Re: [PATCH bpf-next v2 6/7] Sync uapi/bpf.h to tools/include

2018-10-10 Thread Song Liu
On Wed, Oct 10, 2018 at 7:06 AM Mauricio Vasquez B wrote: > > Sync both files. > > Signed-off-by: Mauricio Vasquez B Acked-by: Song Liu > --- > tools/include/uapi/linux/bpf.h | 30 +- > 1 file changed, 29 insertions(+), 1 deletion(-) &

Re: [PATCH bpf-next v2 4/7] bpf/verifier: add ARG_PTR_TO_UNINIT_MAP_VALUE

2018-10-10 Thread Song Liu
gt; This will be used in the following patch that implements some new > helpers that receive a pointer to be filled with a map value. > > Signed-off-by: Mauricio Vasquez B Acked-by: Song Liu > --- > include/linux/bpf.h |1 + > kernel/bpf/verifier.c |9 ++--- > 2 f

Re: [PATCH bpf-next v2 2/7] bpf/syscall: allow key to be null in map functions

2018-10-10 Thread Song Liu
rces that key must be > null. > > Signed-off-by: Mauricio Vasquez B Acked-by: Song Liu > --- > kernel/bpf/syscall.c | 19 +++ > 1 file changed, 15 insertions(+), 4 deletions(-) > > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c > index 4f41623

Re: [PATCH bpf-next] tools/bpf: use proper type and uapi perf_event.h header for libbpf

2018-10-09 Thread Song Liu
> On Oct 9, 2018, at 4:14 PM, Yonghong Song wrote: > > Use __u32 instead u32 in libbpf.c and also use > uapi perf_event.h instead of tools/perf/perf-sys.h. > > Signed-off-by: Yonghong Song Acked-by: Song Liu > --- > tools/lib/bpf/Makefile | 2 +- > tools/lib/bp

[PATCH bpf-next] tools/bpf: use proper type and uapi perf_event.h header for libbpf

2018-10-09 Thread Yonghong Song
Use __u32 instead u32 in libbpf.c and also use uapi perf_event.h instead of tools/perf/perf-sys.h. Signed-off-by: Yonghong Song --- tools/lib/bpf/Makefile | 2 +- tools/lib/bpf/libbpf.c | 8 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/lib/bpf/Makefile b/tools

Re: [bpf-next V2 PATCH 0/3] bpf/xdp: fix generic-XDP and demonstrate VLAN manipulation

2018-10-09 Thread Song Liu
For the series: Acked-by: Song Liu On Tue, Oct 9, 2018 at 3:04 AM Jesper Dangaard Brouer wrote: > > While implementing PoC building blocks for eBPF code XDP+TC that can > manipulate VLANs headers, I discovered a bug in generic-XDP. > > The fix should be backported to stable

Re: [PATCH bpf-next 4/6] bpf: add queue and stack maps

2018-10-09 Thread Song Liu
On Tue, Oct 9, 2018 at 6:05 AM Mauricio Vasquez wrote: > > > > On 10/08/2018 08:36 PM, Song Liu wrote: > > On Mon, Oct 8, 2018 at 12:12 PM Mauricio Vasquez B > > wrote: > >> Queue/stack maps implement a FIFO/LIFO data storage for ebpf programs. > >

Re: [PATCH bpf-next 6/6] selftests/bpf: test_verifier, check bpf_map_lookup_elem access in bpf prog

2018-10-09 Thread Song Liu
heck whether verifier prevents > bpf_map_lookup_elem call on above programs from bpf program. > > Signed-off-by: Prashant Bhole > Acked-by: Alexei Starovoitov Acked-by: Song Liu > --- > tools/testing/selftests/bpf/test_verifier.c | 121 +++- > 1 file changed,

Re: [PATCH bpf-next 5/6] selftests/bpf: test_verifier, change names of fixup maps

2018-10-09 Thread Song Liu
and replace change: > fixup_map1 -> fixup_map_hash_8b > fixup_map2 -> fixup_map_hash_48b > fixup_map3 -> fixup_map_hash_16b > fixup_map4 -> fixup_map_array_48b > > Suggested-by: Alexei Starovoitov > Signed-off-by: Prashant Bhole > Acked-by: Alexei Sta

Re: [PATCH bpf-next 4/6] tools/bpf: bpftool, print strerror when map lookup error occurs

2018-10-09 Thread Song Liu
;,"0x00","0x00" > ], > "value": { > "error": "Operation not supported" > }, > "key": ["0x0b","0x00","0x00","0x00" > ], > "value": { > "

Re: [PATCH bpf-next 3/6] tools/bpf: bpftool, split the function do_dump()

2018-10-09 Thread Song Liu
ed-by: Jakub Kicinski > Acked-by: Alexei Starovoitov Acked-by: Song Liu > --- > tools/bpf/bpftool/map.c | 83 - > 1 file changed, 49 insertions(+), 34 deletions(-) > > diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c &g

Re: [PATCH bpf-next 2/6] bpf: return EOPNOTSUPP when map lookup isn't supported

2018-10-09 Thread Song Liu
gt; Signed-off-by: Prashant Bhole > Acked-by: Alexei Starovoitov Acked-by: Song Liu > --- > kernel/bpf/arraymap.c | 2 +- > kernel/bpf/sockmap.c | 2 +- > kernel/bpf/stackmap.c | 2 +- > kernel/bpf/xskmap.c | 2 +- > 4 files changed, 4 insertions(+), 4 deletions(-) >

Re: [PATCH bpf-next 1/6] bpf: error handling when map_lookup_elem isn't supported

2018-10-09 Thread Song Liu
> Acked-by: Alexei Starovoitov Acked-by: Song Liu > --- > kernel/bpf/syscall.c | 9 +++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c > index 5742df21598c..4f416234251f 100644 > --- a/kernel/bpf/syscal

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