Re: [bpf-next V1 PATCH 0/8] bpf/xdp: add flags argument to ndo_xdp_xmit and flag flush operation

2018-05-30 Thread Song Liu
Overall, this set looks good to me. The only suggestion I have is to add more documentation on the expected behavior of XDP_XMIT_FLUSH in netdevice.h (as part of 01/08). Thanks, Song On Wed, May 30, 2018 at 11:00 AM, Jesper Dangaard Brouer wrote: > As I mentioned in merge commit 10f67868

Re: [bpf-next V1 PATCH 8/8] bpf/xdp: devmap can avoid calling ndo_xdp_flush

2018-05-30 Thread Song Liu
(struct bpf_dtab_netdev *obj, > -struct xdp_bulk_queue *bq) > + struct xdp_bulk_queue *bq, bool flush) How about we use "int flags" instead of "bool flush" for easier extension? Thanks, Song > { > struct net_devic

Re: [bpf-next V1 PATCH 2/8] i40e: implement flush flag for ndo_xdp_xmit

2018-05-30 Thread Song Liu
flags & XDP_XMIT_FLUSH)) > + i40e_xdp_ring_update_tail(vsi->xdp_rings[queue_index]); > + > return n - drops; Do we still flush when drops > 0? Thanks, Song > } > >

Re: [bpf-next V1 PATCH 1/8] xdp: add flags argument to ndo_xdp_xmit API

2018-05-30 Thread Song Liu
xdp_frame **xdp); > + struct xdp_frame **xdp, > + u32 flags); > void (*ndo_xdp_flush)(struct net_device *dev); > }; > > diff --git a/include/net/xdp.h b/include/net/xdp

Re: [PATCH bpf-next 08/11] bpf: fix cbpf parser bug for octal numbers

2018-05-30 Thread Song Liu
On Sun, May 27, 2018 at 5:43 PM, Daniel Borkmann wrote: > Range is 0-7, not 0-9, otherwise parser silently excludes it from the > strtol() rather than throwing an error. > > Reported-by: Marc Boschma > Signed-off-by: Daniel Borkmann > Acked-by: Alexei Starovoitov

Re: [PATCH bpf-next 07/11] bpf: make sure to clear unused fields in tunnel/xfrm state fetch

2018-05-30 Thread Song Liu
_u32 remote_ipv6[4]; /* 16 */ > }; /*1216 */ > > /* size: 28, cachelines: 1, members: 4 */ > /* sum members: 26, holes: 1, sum holes: 2 */ > /* last cacheline: 28 bytes */ > }; > > Signe

Re: [PATCH bpf-next 05/11] bpf: avoid retpoline for lookup/update/delete calls on maps

2018-05-30 Thread Song Liu
allback directly if we find that there's only a > single path with a map pointer leading to the helper call, meaning > when the map pointer has not been poisoned from verifier side. > Example code can be seen above for the delete case. > > Sig

Re: [PATCH bpf-next 09/11] bpf: fix context access in tracing progs on 32 bit archs

2018-05-30 Thread Song Liu
+ const u32 size_machine = sizeof(unsigned long); > + > + if (size > size_machine && size % size_machine == 0) > + size = size_machine; Not sure whether I understand this correctly. I guess we only need: if (size % size_machine =

Re: [PATCH bpf-next 04/11] bpf: show prog and map id in fdinfo

2018-05-30 Thread Song Liu
then use it along with bpftool in order to inspect an individual >>> application's used maps and progs. Right now we dump some basic >>> information in the fdinfo file but with the help of the map/prog >>> id full introspection becomes possible now. >>> >>&g

Re: [PATCH bpf-next 10/11] bpf: sync bpf uapi header with tools

2018-05-30 Thread Song Liu
On Sun, May 27, 2018 at 5:43 PM, Daniel Borkmann wrote: > Pull in recent changes from include/uapi/linux/bpf.h. > > Signed-off-by: Daniel Borkmann > Acked-by: Alexei Starovoitov Acked-by: Song Liu > --- > tools/include/uapi/linux/bpf.h | 20 ++-- >

Re: [PATCH bpf-next 11/11] bpf, doc: add missing patchwork url and libbpf to maintainers

2018-05-29 Thread Song Liu
On Sun, May 27, 2018 at 5:43 PM, Daniel Borkmann wrote: > Add missing bits under tools/lib/bpf/ and also Q: entry in order to > make it easier for people to retrieve current patch queue. > > Signed-off-by: Daniel Borkmann > Acked-by: Alexei Starovoitov Ack

Re: [PATCH bpf-next] bpftool: Support sendmsg{4,6} attach types

2018-05-29 Thread Song Liu
ion. >> >> Signed-off-by: Andrey Ignatov > > Reviewed-by: Jakub Kicinski > >> I'm not sure about "since 4.18" in Documentation part. I can follow-up when >> the next kernel version is known. > > IMHO it's fine, we can follow up if Linus decides to call it something > else :) > > Thanks! Acked-by: Song Liu

Re: [PATCH bpf-next] bpf: clean up eBPF helpers documentation

2018-05-29 Thread Song Liu
ingress). > * > * *ctx* is either **struct xdp_md** for XDP programs or > * **struct sk_buff** tc cls_act programs. > - * > * Return > * Egress device index on success, 0 if packet needs to continue > * up the stack for further processing or a negative error in > case > -- > 2.14.1 > Please also apply the same changes to tools/include/uapi/linux/bpf.h. Other than this, it looks to me. Acked-by: Song Liu Thanks, Song

Re: [PATCH bpf-next 03/11] bpf: fixup error message from gpl helpers on license mismatch

2018-05-29 Thread Song Liu
ust >> not compatible. >> >> Reference: https://twitter.com/majek04/status/998531268039102465 >> Signed-off-by: Daniel Borkmann >> Acked-by: Alexei Starovoitov > > Acked-by: Jesper Dangaard Brouer > > Thank you for cleaning up this confusion :-) > Acked-by: Son

Re: [PATCH bpf-next 02/11] bpf: add also cbpf long jump test cases with heavy expansion

2018-05-29 Thread Song Liu
tarovoitov Acked-by: Song Liu > --- > lib/test_bpf.c | 63 > ++ > 1 file changed, 63 insertions(+) > > diff --git a/lib/test_bpf.c b/lib/test_bpf.c > index 317f231..60aedc8 100644 > --- a/lib/test_bpf.c > +++ b/lib

Re: [PATCH bpf-next 01/11] bpf: test case for map pointer poison with calls/branches

2018-05-29 Thread Song Liu
; Acked-by: Alexei Starovoitov Acked-by: Song Liu > --- > include/linux/filter.h | 10 ++ > tools/include/linux/filter.h| 10 ++ > tools/testing/selftests/bpf/test_verifier.c | 185 > > 3 files changed, 178 insertion

[PATCH v2 net-next] net: remove bypassed check in sch_direct_xmit()

2018-05-29 Thread Song Liu
zen_or_stopped(txq)) return false; This patch cleans up the code by removing the whole condition. For more discussion about this, please refer to https://marc.info/?t=15272719578 Signed-off-by: Song Liu Cc: John Fastabend Cc: Alexei Starovoitov Cc: David S. Miller --- net/sched

Re: [PATCH net-next] net: remove bypassed check in sch_direct_xmit()

2018-05-29 Thread Song Liu
> On May 29, 2018, at 1:58 AM, Sergei Shtylyov > wrote: > > Hello! > > On 5/29/2018 12:36 AM, Song Liu wrote: > >> Check sch_direct_xmit() at the end of sch_direct_xmit() will be bypassed. > > "Checking netif_xmit_frozen_or_stopped()",

Re: [PATCH net] net: sched: check netif_xmit_frozen_or_stopped() in sch_direct_xmit()

2018-05-29 Thread Song Liu
> On May 29, 2018, at 7:02 AM, David Miller wrote: > > From: Song Liu > Date: Fri, 25 May 2018 11:11:44 -0700 > >> Summary: >> >> At the end of sch_direct_xmit(), we are in the else path of >> !dev_xmit_complete(ret), which means ret == NETDEV_TX_OK.

[PATCH net-next] net: remove bypassed check in sch_direct_xmit()

2018-05-28 Thread Song Liu
return false; This patch cleans up the code by removing the whole condition. For more discussion about this, please refer to https://marc.info/?t=15272719578 Signed-off-by: Song Liu Cc: John Fastabend Cc: Alexei Starovoitov Cc: David S. Miller --- net/sched/sch_generic.c | 3 -

Re: [PATCH net] net: sched: check netif_xmit_frozen_or_stopped() in sch_direct_xmit()

2018-05-28 Thread Song Liu
> On May 26, 2018, at 12:43 PM, John Fastabend wrote: > > On 05/25/2018 12:46 PM, Song Liu wrote: >> On Fri, May 25, 2018 at 11:11 AM, Song Liu wrote: >>> Summary: >>> >>> At the end of sch_direct_xmit(), we are in the else path of &g

Re: [bpf-next PATCH] bpf: sockhash fix race with bpf_tcp_close and map delete

2018-05-26 Thread Song Liu
the psock from sk_user_data. > > Both removal paths omitted taking the hash bucket lock resulting > in the case where we have two references that are in the process > of being free'd. > > Reported-by: syzbot+a761b81c211794fa1...@syzkaller.appspotmail.com > Signed-off-by: Jo

Re: [PATCH v2 net-next] tcp: use data length instead of skb->len in tcp_probe

2018-05-25 Thread Song Liu
> On May 25, 2018, at 3:14 AM, Yafang Shao <laoar.s...@gmail.com> wrote: > > skb->len is meaningless to user. > data length could be more helpful, with which we can easily filter out > the packet without payload. > > Signed-off-by: Yafang Shao <laoar.s.

Re: [PATCH bpf-next] libbpf: Install btf.h with libbpf

2018-05-25 Thread Song Liu
rey Ignatov <r...@fb.com> > Acked-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Song Liu <songliubrav...@fb.com>

Re: [PATCH, net-next 2/2] bpf: avoid -Wmaybe-uninitialized warning

2018-05-25 Thread Song Liu
ILD_ID_VALID; > } > > - if (!in_nmi_ctx) { > + if (!work) { > up_read(>mm->mmap_sem); > } else { > work->sem = >mm->mmap_sem; > -- > 2.9.0 > Acked-by: Song Liu <songliubrav...@fb.com>

Re: [PATCH, net-next 1/2] bpf: btf: avoid -Wreturn-type warning

2018-05-25 Thread Song Liu
olve_sink(const struct > btf_verifier_env *env, > !btf_type_is_array(next_type) && > !btf_type_is_struct(next_type); > default: > - BUG_ON(1); > + BUG(); > } > } > > -- > 2.9.0 > Acked-by: Song Liu <songliubrav...@fb.com>

Re: [PATCH net] net: sched: check netif_xmit_frozen_or_stopped() in sch_direct_xmit()

2018-05-25 Thread Song Liu
On Fri, May 25, 2018 at 11:11 AM, Song Liu <songliubrav...@fb.com> wrote: > Summary: > > At the end of sch_direct_xmit(), we are in the else path of > !dev_xmit_complete(ret), which means ret == NETDEV_TX_OK. The following > condition will always fail and netif_x

[PATCH net] net: sched: check netif_xmit_frozen_or_stopped() in sch_direct_xmit()

2018-05-25 Thread Song Liu
th") Cc: John Fastabend <john.fastab...@gmail.com> Cc: David S. Miller <da...@davemloft.net> Signed-off-by: Song Liu <songliubrav...@fb.com> --- net/sched/sch_generic.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/net/sched/sch_generic.c b/net/sched/

Re: [PATCH] [RFC] bpf: tracing: new helper bpf_get_current_cgroup_ino

2018-05-25 Thread Y Song
On Fri, May 25, 2018 at 8:21 AM, Alban Crequy <al...@kinvolk.io> wrote: > On Wed, May 23, 2018 at 4:34 AM Y Song <ys114...@gmail.com> wrote: > >> I did a quick prototyping and the above interface seems working fine. > > Thanks! I gave your kernel patch & us

Re: [PATCH bpf-next] selftests/bpf: missing headers test_lwt_seg6local

2018-05-25 Thread Y Song
On Fri, May 25, 2018 at 9:16 AM, Y Song <ys114...@gmail.com> wrote: > On Fri, May 25, 2018 at 4:20 AM, Mathieu Xhonneux <m.xhonn...@gmail.com> > wrote: >> Previous patch "selftests/bpf: test for seg6local End.BPF action" lacks >> some UAPI headers in too

Re: [PATCH bpf-next] selftests/bpf: missing headers test_lwt_seg6local

2018-05-25 Thread Song Liu
gt; [...]/net-next/tools/testing/selftests/bpf/test_lwt_seg6local.o > test_lwt_seg6local.c:4:10: fatal error: 'linux/seg6_local.h' file not found > ^~~~ > 1 error generated. > make: Leaving directory > `/data/users/yhs/work/net-next/tools/testing/selftests/bpf' > >

Re: [PATCH bpf-next] selftests/bpf: missing headers test_lwt_seg6local

2018-05-25 Thread Y Song
gt; [...]/net-next/tools/testing/selftests/bpf/test_lwt_seg6local.o > test_lwt_seg6local.c:4:10: fatal error: 'linux/seg6_local.h' file not found > ^~~~ > 1 error generated. > make: Leaving directory > `/data/users/yhs/work/net-next/tools/testing/selftests/bpf' > >

Re: [PATCH bpf-next v7 6/6] selftests/bpf: test for seg6local End.BPF action

2018-05-24 Thread Y Song
When compiling latest bpf-next, I hit the following compilation error: clang -I. -I./include/uapi -I../../../include/uapi -idirafter /usr/local/include -idirafter /data/users/yhs/work/llvm/build/install/lib/clang/7.0.0/include -idirafter /usr/include -Wno-compare-distinct-pointer-types \

[PATCH bpf-next v5 6/7] tools/bpf: add two BPF_TASK_FD_QUERY tests in test_progs

2018-05-24 Thread Yonghong Song
The new tests are added to query perf_event information for raw_tracepoint and tracepoint attachment. For tracepoint, both syscalls and non-syscalls tracepoints are queries as they are treated slightly differently inside the kernel. Signed-off-by: Yonghong Song <y...@fb.com> --- tools/t

[PATCH bpf-next v5 5/7] samples/bpf: add a samples/bpf test for BPF_TASK_FD_QUERY

2018-05-24 Thread Yonghong Song
This is mostly to test kprobe/uprobe which needs kernel headers. Signed-off-by: Yonghong Song <y...@fb.com> --- samples/bpf/Makefile | 4 + samples/bpf/task_fd_query_kern.c | 19 ++ samples/bpf/task_fd_query_user.c | 382 +++ 3 files c

[PATCH bpf-next v5 7/7] tools/bpftool: add perf subcommand

2018-05-24 Thread Yonghong Song
write 21765 pts/0S+ 0:00 python ./trace.py r::__x64_sys_nanosleep 21767 pts/2S+ 0:00 python ./trace.py t:syscalls:sys_enter_nanosleep 21800 pts/3S+ 0:00 python ./trace.py p:/home/yhs/a.out:main 22374 pts/1S+ 0:00 grep --color=auto py

[PATCH bpf-next v5 3/7] tools/bpf: sync kernel header bpf.h and add bpf_task_fd_query in libbpf

2018-05-24 Thread Yonghong Song
ed-off-by: Yonghong Song <y...@fb.com> --- tools/include/uapi/linux/bpf.h | 26 ++ tools/lib/bpf/bpf.c| 23 +++ tools/lib/bpf/bpf.h| 3 +++ 3 files changed, 52 insertions(+) diff --git a/tools/include/uapi/linux/bpf.h b/tools/includ

[PATCH bpf-next v5 4/7] tools/bpf: add ksym_get_addr() in trace_helpers

2018-05-24 Thread Yonghong Song
com> Signed-off-by: Yonghong Song <y...@fb.com> --- tools/testing/selftests/bpf/trace_helpers.c | 12 tools/testing/selftests/bpf/trace_helpers.h | 1 + 2 files changed, 13 insertions(+) diff --git a/tools/testing/selftests/bpf/trace_helpers.c b/tools/testing/selftests/bpf/tra

[PATCH bpf-next v5 0/7] bpf: implement BPF_TASK_FD_QUERY

2018-05-24 Thread Yonghong Song
rf" issues and added documentation and auto-completion. Yonghong Song (7): perf/core: add perf_get_event() to return perf_event given a struct file bpf: introduce bpf subcommand BPF_TASK_FD_QUERY tools/bpf: sync kernel header bpf.h and add bpf_task_fd_query in libbpf tools/bpf:

[PATCH bpf-next v5 1/7] perf/core: add perf_get_event() to return perf_event given a struct file

2018-05-24 Thread Yonghong Song
A new extern function, perf_get_event(), is added to return a perf event given a struct file. This function will be used in later patches. Signed-off-by: Yonghong Song <y...@fb.com> --- include/linux/perf_event.h | 5 + kernel/events/core.c | 8 2 files changed, 13 inse

[PATCH bpf-next v5 2/7] bpf: introduce bpf subcommand BPF_TASK_FD_QUERY

2018-05-24 Thread Yonghong Song
Acked-by: Martin KaFai Lau <ka...@fb.com> Signed-off-by: Yonghong Song <y...@fb.com> --- include/linux/trace_events.h | 17 ++ include/uapi/linux/bpf.h | 26 + kernel/bpf/syscall.c | 131 +++ kernel

Re: [PATCH net-next] tcp: use data length instead of skb->len in tcp_probe

2018-05-24 Thread Song Liu
o rename __entry->length to __entry->data_len, so that whoever using this field will notice the change. Thanks, Song > __entry->snd_nxt = tp->snd_nxt; > __entry->snd_una = tp->snd_una; > __entry->snd_cwnd = tp->snd_cwnd; > @@

Re: [PATCH bpf-next v4 2/7] bpf: introduce bpf subcommand BPF_TASK_FD_QUERY

2018-05-24 Thread Yonghong Song
On 5/23/18 10:07 PM, Martin KaFai Lau wrote: On Wed, May 23, 2018 at 05:18:42PM -0700, Yonghong Song wrote: Currently, suppose a userspace application has loaded a bpf program and attached it to a tracepoint/kprobe/uprobe, and a bpf introspection tool, e.g., bpftool, wants to show which bpf

[PATCH bpf-next v4 5/7] samples/bpf: add a samples/bpf test for BPF_TASK_FD_QUERY

2018-05-23 Thread Yonghong Song
This is mostly to test kprobe/uprobe which needs kernel headers. Signed-off-by: Yonghong Song <y...@fb.com> --- samples/bpf/Makefile | 4 + samples/bpf/task_fd_query_kern.c | 19 ++ samples/bpf/task_fd_query_user.c | 382 +++ 3 files c

[PATCH bpf-next v4 6/7] tools/bpf: add two BPF_TASK_FD_QUERY tests in test_progs

2018-05-23 Thread Yonghong Song
The new tests are added to query perf_event information for raw_tracepoint and tracepoint attachment. For tracepoint, both syscalls and non-syscalls tracepoints are queries as they are treated slightly differently inside the kernel. Signed-off-by: Yonghong Song <y...@fb.com> --- tools/t

[PATCH bpf-next v4 7/7] tools/bpftool: add perf subcommand

2018-05-23 Thread Yonghong Song
write 21765 pts/0S+ 0:00 python ./trace.py r::__x64_sys_nanosleep 21767 pts/2S+ 0:00 python ./trace.py t:syscalls:sys_enter_nanosleep 21800 pts/3S+ 0:00 python ./trace.py p:/home/yhs/a.out:main 22374 pts/1S+ 0:00 grep --color=auto py

[PATCH bpf-next v4 2/7] bpf: introduce bpf subcommand BPF_TASK_FD_QUERY

2018-05-23 Thread Yonghong Song
_id. Signed-off-by: Yonghong Song <y...@fb.com> --- include/linux/trace_events.h | 17 +++ include/uapi/linux/bpf.h | 26 ++ kernel/bpf/syscall.c | 115 +++ kernel/trace/bpf_trace.c | 48 ++ kernel/trace

[PATCH bpf-next v4 1/7] perf/core: add perf_get_event() to return perf_event given a struct file

2018-05-23 Thread Yonghong Song
A new extern function, perf_get_event(), is added to return a perf event given a struct file. This function will be used in later patches. Signed-off-by: Yonghong Song <y...@fb.com> --- include/linux/perf_event.h | 5 + kernel/events/core.c | 8 2 files changed, 13 inse

[PATCH bpf-next v4 3/7] tools/bpf: sync kernel header bpf.h and add bpf_task_fd_query in libbpf

2018-05-23 Thread Yonghong Song
Sync kernel header bpf.h to tools/include/uapi/linux/bpf.h and implement bpf_task_fd_query() in libbpf. The test programs in samples/bpf and tools/testing/selftests/bpf, and later bpftool will use this libbpf function to query kernel. Signed-off-by: Yonghong Song <y...@fb.com> --- tools/i

[PATCH bpf-next v4 4/7] tools/bpf: add ksym_get_addr() in trace_helpers

2018-05-23 Thread Yonghong Song
com> Signed-off-by: Yonghong Song <y...@fb.com> --- tools/testing/selftests/bpf/trace_helpers.c | 12 tools/testing/selftests/bpf/trace_helpers.h | 1 + 2 files changed, 13 insertions(+) diff --git a/tools/testing/selftests/bpf/trace_helpers.c b/tools/testing/selftests/bpf/tra

[PATCH bpf-next v4 0/7] bpf: implement BPF_TASK_FD_QUERY

2018-05-23 Thread Yonghong Song
quot; issues and added documentation and auto-completion. Yonghong Song (7): perf/core: add perf_get_event() to return perf_event given a struct file bpf: introduce bpf subcommand BPF_TASK_FD_QUERY tools/bpf: sync kernel header bpf.h and add bpf_task_fd_query in libbpf tools/bpf: add

Re: [PATCH bpf-next v3 2/7] bpf: introduce bpf subcommand BPF_TASK_FD_QUERY

2018-05-23 Thread Yonghong Song
On 5/23/18 2:04 PM, Alexei Starovoitov wrote: On Wed, May 23, 2018 at 10:13:22AM -0700, Martin KaFai Lau wrote: + __u32 prog_id;/* output: prod_id */ + __u32 attach_info;/* output: BPF_ATTACH_* */ + __u64

Re: [PATCH bpf-next v3 2/7] bpf: introduce bpf subcommand BPF_TASK_FD_QUERY

2018-05-23 Thread Yonghong Song
On 5/23/18 10:13 AM, Martin KaFai Lau wrote: On Tue, May 22, 2018 at 09:30:46AM -0700, Yonghong Song wrote: Currently, suppose a userspace application has loaded a bpf program and attached it to a tracepoint/kprobe/uprobe, and a bpf introspection tool, e.g., bpftool, wants to show which bpf

Re: [PATCH] [RFC] bpf: tracing: new helper bpf_get_current_cgroup_ino

2018-05-22 Thread Y Song
On Tue, May 22, 2018 at 8:35 PM, Alexei Starovoitov <alexei.starovoi...@gmail.com> wrote: > On Tue, May 22, 2018 at 08:33:24PM -0700, Y Song wrote: >> + struct cgroup *cgrp = task_dfl_cgroup(current); >> + if (!cgrp) >> + return -EINVAL; &

Re: [PATCH] [RFC] bpf: tracing: new helper bpf_get_current_cgroup_ino

2018-05-22 Thread Y Song
d user space cgid matches. Will provide a formal patch later. On Mon, May 21, 2018 at 5:24 PM, Y Song <ys114...@gmail.com> wrote: > On Mon, May 21, 2018 at 9:26 AM, Alexei Starovoitov > <alexei.starovoi...@gmail.com> wrote: >> On Sun, May 13, 2018 at 07:33:18PM +0200, Alban

[PATCH bpf-next v3 7/7] tools/bpftool: add perf subcommand

2018-05-22 Thread Yonghong Song
./trace.py __x64_sys_write 21765 pts/0S+ 0:00 python ./trace.py r::__x64_sys_nanosleep 21767 pts/2S+ 0:00 python ./trace.py t:syscalls:sys_enter_nanosleep 21800 pts/3S+ 0:00 python ./trace.py p:/home/yhs/a.out:main 22374 pts/1S+ 0:00 grep --color=auto py

[PATCH bpf-next v3 6/7] tools/bpf: add two BPF_TASK_FD_QUERY tests in test_progs

2018-05-22 Thread Yonghong Song
The new tests are added to query perf_event information for raw_tracepoint and tracepoint attachment. For tracepoint, both syscalls and non-syscalls tracepoints are queries as they are treated slightly differently inside the kernel. Signed-off-by: Yonghong Song <y...@fb.com> --- tools/t

[PATCH bpf-next v3 5/7] samples/bpf: add a samples/bpf test for BPF_TASK_FD_QUERY

2018-05-22 Thread Yonghong Song
This is mostly to test kprobe/uprobe which needs kernel headers. Signed-off-by: Yonghong Song <y...@fb.com> --- samples/bpf/Makefile | 4 + samples/bpf/task_fd_query_kern.c | 19 ++ samples/bpf/task_fd_query_user.c | 379 +++ 3 files c

[PATCH bpf-next v3 0/7] bpf: implement BPF_TASK_FD_QUERY

2018-05-22 Thread Yonghong Song
. changed bpf subcommand name from BPF_PERF_EVENT_QUERY to BPF_TASK_FD_QUERY. . fixed various "bpftool perf" issues and added documentation and auto-completion. Yonghong Song (7): perf/core: add perf_get_event() to return perf_event given a struct file bpf: intr

[PATCH bpf-next v3 2/7] bpf: introduce bpf subcommand BPF_TASK_FD_QUERY

2018-05-22 Thread Yonghong Song
_id. Signed-off-by: Yonghong Song <y...@fb.com> --- include/linux/trace_events.h | 16 ++ include/uapi/linux/bpf.h | 27 ++ kernel/bpf/syscall.c | 124 +++ kernel/trace/bpf_trace.c | 48 + kernel/trace

[PATCH bpf-next v3 1/7] perf/core: add perf_get_event() to return perf_event given a struct file

2018-05-22 Thread Yonghong Song
A new extern function, perf_get_event(), is added to return a perf event given a struct file. This function will be used in later patches. Signed-off-by: Yonghong Song <y...@fb.com> --- include/linux/perf_event.h | 5 + kernel/events/core.c | 8 2 files changed, 13 inse

[PATCH bpf-next v3 3/7] tools/bpf: sync kernel header bpf.h and add bpf_trace_event_query in libbpf

2018-05-22 Thread Yonghong Song
Sync kernel header bpf.h to tools/include/uapi/linux/bpf.h and implement bpf_trace_event_query() in libbpf. The test programs in samples/bpf and tools/testing/selftests/bpf, and later bpftool will use this libbpf function to query kernel. Signed-off-by: Yonghong Song <y...@fb.com> ---

[PATCH bpf-next v3 4/7] tools/bpf: add ksym_get_addr() in trace_helpers

2018-05-22 Thread Yonghong Song
Given a kernel function name, ksym_get_addr() will return the kernel address for this function, or 0 if it cannot find this function name in /proc/kallsyms. This function will be used later when a kernel address is used to initiate a kprobe perf event. Signed-off-by: Yonghong Song <y...@fb.

Re: [PATCH bpf-next 3/7] bpf: btf: Check array->index_type

2018-05-21 Thread Yonghong Song
On 5/18/18 5:16 PM, Martin KaFai Lau wrote: Instead of ingoring the array->index_type field. Enforce that it must be an unsigned BTF_KIND_INT. Signed-off-by: Martin KaFai Lau --- kernel/bpf/btf.c | 83 1 file changed,

Re: [PATCH] [RFC] bpf: tracing: new helper bpf_get_current_cgroup_ino

2018-05-21 Thread Y Song
On Mon, May 21, 2018 at 9:26 AM, Alexei Starovoitov wrote: > On Sun, May 13, 2018 at 07:33:18PM +0200, Alban Crequy wrote: >> >> +BPF_CALL_2(bpf_get_current_cgroup_ino, u32, hierarchy, u64, flags) >> +{ >> + // TODO: pick the correct hierarchy instead of the mem

Re: [PATCH bpf-next 4/7] bpf: btf: Remove unused bits from uapi/linux/btf.h

2018-05-21 Thread Yonghong Song
be added back later because the verifier ensures the unused bits are zeros. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Yonghong Song <y...@fb.com>

Re: [PATCH bpf-next 5/7] bpf: btf: Rename btf_key_id and btf_value_id in bpf_map_info

2018-05-21 Thread Yonghong Song
_key_id" and "btf_value_id" means the BTF type id within that BTF object. To make it clear, btf_key_id and btf_value_id are renamed to btf_key_type_id and btf_value_type_id. Suggested-by: Daniel Borkmann <dan...@iogearbox.net> Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Yonghong Song <y...@fb.com>

Re: [PATCH bpf-next 3/7] bpf: btf: Check array->index_type

2018-05-21 Thread Yonghong Song
On 5/18/18 5:16 PM, Martin KaFai Lau wrote: Instead of ingoring the array->index_type field. Enforce that it must be an unsigned BTF_KIND_INT. Signed-off-by: Martin KaFai Lau --- kernel/bpf/btf.c | 83 1 file changed,

Re: [PATCH bpf-next 2/7] bpf: btf: Change how section is supported in btf_header

2018-05-21 Thread Yonghong Song
On 5/18/18 5:16 PM, Martin KaFai Lau wrote: There are currently unused section descriptions in the btf_header. Those sections are here to support future BTF use cases. For example, the func section (func_off) is to support function signature (e.g. the BPF prog function signature). Instead

Re: [PATCH bpf-next 1/7] bpf: Expose check_uarg_tail_zero()

2018-05-21 Thread Yonghong Song
On 5/18/18 5:16 PM, Martin KaFai Lau wrote: This patch exposes check_uarg_tail_zero() which will be reused by a later BTF patch. Its name is changed to bpf_check_uarg_tail_zero(). Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Yonghong Song <y...@fb.com>

Re: [PATCH bpf-next v2 7/7] tools/bpftool: add perf subcommand

2018-05-18 Thread Y Song
On Fri, May 18, 2018 at 1:51 PM, Jakub Kicinski <jakub.kicin...@netronome.com> wrote: > On Thu, 17 May 2018 22:03:10 -0700, Yonghong Song wrote: >> The new command "bpftool perf [show | list]" will traverse >> all processes under /proc, and if any fd is

Re: [PATCH v4 3/3] bpf: add selftest for lirc_mode2 type program

2018-05-18 Thread Y Song
On Fri, May 18, 2018 at 1:17 PM, Y Song <ys114...@gmail.com> wrote: > On Fri, May 18, 2018 at 7:07 AM, Sean Young <s...@mess.org> wrote: >> This is simple test over rc-loopback. >> >> Signed-off-by: Sean Young <s...@mess.org> > > Acked-by: Yonghong

Re: [PATCH v4 3/3] bpf: add selftest for lirc_mode2 type program

2018-05-18 Thread Y Song
On Fri, May 18, 2018 at 7:07 AM, Sean Young <s...@mess.org> wrote: > This is simple test over rc-loopback. > > Signed-off-by: Sean Young <s...@mess.org> Acked-by: Yonghong Song <y...@fb.com> > --- > tools/bpf/bpftool/prog.c | 1 +

Re: [PATCH v4 2/3] media: rc: introduce BPF_PROG_LIRC_MODE2

2018-05-18 Thread Y Song
be attached to using the bpf(BPF_PROG_ATTACH) syscall; > the target_fd must be the /dev/lircN device. > > Signed-off-by: Sean Young <s...@mess.org> Acked-by: Yonghong Song <y...@fb.com> > --- > drivers/media/rc/Kconfig| 13 ++ > drivers/media/rc/Ma

Re: [PATCH v4 1/3] bpf: bpf_prog_array_copy() should return -ENOENT if exclude_prog not found

2018-05-18 Thread Y Song
On Fri, May 18, 2018 at 7:07 AM, Sean Young <s...@mess.org> wrote: > This makes is it possible for bpf prog detach to return -ENOENT. > > Signed-off-by: Sean Young <s...@mess.org> Acked-by: Yonghong Song <y...@fb.com>

Re: [PATCH bpf-next v2 1/7] perf/core: add perf_get_event() to return perf_event given a struct file

2018-05-18 Thread Yonghong Song
On 5/18/18 12:18 AM, Peter Zijlstra wrote: On Thu, May 17, 2018 at 10:32:53PM -0700, Yonghong Song wrote: A new extern function, perf_get_event(), is added to return a perf event given a struct file. This function will be used in later patches. Can't you do a narrower interface? Like return

[PATCH bpf-next v2 1/7] perf/core: add perf_get_event() to return perf_event given a struct file

2018-05-17 Thread Yonghong Song
A new extern function, perf_get_event(), is added to return a perf event given a struct file. This function will be used in later patches. Signed-off-by: Yonghong Song <y...@fb.com> --- include/linux/perf_event.h | 5 + kernel/events/core.c | 8 2 files changed, 13 inse

Re: [PATCH v3 1/2] media: rc: introduce BPF_PROG_RAWIR_EVENT

2018-05-17 Thread Y Song
On Thu, May 17, 2018 at 2:45 PM, Sean Young <s...@mess.org> wrote: > Hi, > > Again thanks for a thoughtful review. This will definitely will improve > the code. > > On Thu, May 17, 2018 at 10:02:52AM -0700, Y Song wrote: >> On Wed, May 16, 2018 at 2:04 PM, Se

[PATCH bpf-next v2 2/7] bpf: introduce bpf subcommand BPF_TASK_FD_QUERY

2018-05-17 Thread Yonghong Song
_id. Signed-off-by: Yonghong Song <y...@fb.com> --- include/linux/trace_events.h | 15 ++ include/uapi/linux/bpf.h | 27 ++ kernel/bpf/syscall.c | 124 +++ kernel/trace/bpf_trace.c | 48 + kernel/trace

[PATCH bpf-next v2 4/7] tools/bpf: add ksym_get_addr() in trace_helpers

2018-05-17 Thread Yonghong Song
Given a kernel function name, ksym_get_addr() will return the kernel address for this function, or 0 if it cannot find this function name in /proc/kallsyms. This function will be used later when a kernel address is used to initiate a kprobe perf event. Signed-off-by: Yonghong Song <y...@fb.

[PATCH bpf-next v2 0/7] bpf: implement BPF_TASK_FD_QUERY

2018-05-17 Thread Yonghong Song
l. Changelogs: v1 -> v2: . changed bpf subcommand name from BPF_PERF_EVENT_QUERY to BPF_TASK_FD_QUERY. . fixed various "bpftool perf" issues and added documentation and auto-completion. Yonghong Song (7): perf/core: add perf_get_event() to return perf_ev

[PATCH bpf-next v2 7/7] tools/bpftool: add perf subcommand

2018-05-17 Thread Yonghong Song
not jited memlock 4096B map_ids 8 9: kprobe name probe_main_1 tag 0a87bdc2e2953b6d gpl loaded_at 2018-05-15T04:49:52-0700 uid 0 xlated 200B not jited memlock 4096B map_ids 9 $ ps ax | grep "python ./trace.py" 21711 pts/0T 0:03 python ./trace.p

[PATCH bpf-next v2 3/7] tools/bpf: sync kernel header bpf.h and add bpf_trace_event_query in libbpf

2018-05-17 Thread Yonghong Song
Sync kernel header bpf.h to tools/include/uapi/linux/bpf.h and implement bpf_trace_event_query() in libbpf. The test programs in samples/bpf and tools/testing/selftests/bpf, and later bpftool will use this libbpf function to query kernel. Signed-off-by: Yonghong Song <y...@fb.com> ---

[PATCH bpf-next v2 5/7] samples/bpf: add a samples/bpf test for BPF_TASK_FD_QUERY

2018-05-17 Thread Yonghong Song
This is mostly to test kprobe/uprobe which needs kernel headers. Signed-off-by: Yonghong Song <y...@fb.com> --- samples/bpf/Makefile | 4 + samples/bpf/task_fd_query_kern.c | 19 ++ samples/bpf/task_fd_query_user.c | 379 +++ 3 files c

[PATCH bpf-next v2 6/7] tools/bpf: add two BPF_TASK_FD_QUERY tests in test_progs

2018-05-17 Thread Yonghong Song
The new tests are added to query perf_event information for raw_tracepoint and tracepoint attachment. For tracepoint, both syscalls and non-syscalls tracepoints are queries as they are treated slightly differently inside the kernel. Signed-off-by: Yonghong Song <y...@fb.com> --- tools/t

Re: [PATCH bpf-next 2/7] bpf: introduce bpf subcommand BPF_PERF_EVENT_QUERY

2018-05-17 Thread Yonghong Song
On 5/17/18 8:32 AM, Daniel Borkmann wrote: On 05/16/2018 11:59 PM, Yonghong Song wrote: On 5/16/18 4:27 AM, Peter Zijlstra wrote: On Tue, May 15, 2018 at 04:45:16PM -0700, Yonghong Song wrote: Currently, suppose a userspace application has loaded a bpf program and attached

Re: [PATCH v3 2/2] bpf: add selftest for rawir_event type program

2018-05-17 Thread Y Song
On Wed, May 16, 2018 at 2:04 PM, Sean Young wrote: > This is simple test over rc-loopback. > > Signed-off-by: Sean Young > --- > tools/bpf/bpftool/prog.c | 1 + > tools/include/uapi/linux/bpf.h| 57 +++- >

Re: [PATCH v3 1/2] media: rc: introduce BPF_PROG_RAWIR_EVENT

2018-05-17 Thread Y Song
On Wed, May 16, 2018 at 2:04 PM, Sean Young wrote: > Add support for BPF_PROG_RAWIR_EVENT. This type of BPF program can call > rc_keydown() to reported decoded IR scancodes, or rc_repeat() to report > that the last key should be repeated. > > The bpf program can be attached to

Re: [PATCH bpf-next 2/7] bpf: introduce bpf subcommand BPF_PERF_EVENT_QUERY

2018-05-16 Thread Yonghong Song
On 5/16/18 4:27 AM, Peter Zijlstra wrote: On Tue, May 15, 2018 at 04:45:16PM -0700, Yonghong Song wrote: Currently, suppose a userspace application has loaded a bpf program and attached it to a tracepoint/kprobe/uprobe, and a bpf introspection tool, e.g., bpftool, wants to show which bpf

[PATCH bpf-next] bpf: fix sock hashmap kmalloc warning

2018-05-16 Thread Yonghong Song
he key unsuccessfully, it will issue the above warning. Similar to hashtab, ensure the key size is at most MAX_BPF_STACK for a successful map creation. Fixes: 81110384441a ("bpf: sockmap, add hash map support") Reported-by: syzbot+e4566d29080e7f346...@syzkaller.appspotmail.com Signed-off-by:

Re: [PATCH bpf-next] samples/bpf: Decrement ttl in fib forwarding example

2018-05-16 Thread Y Song
is patch, but it looks good to me with visual inspection. Acked-by: Yonghong Song <y...@fb.com>

Re: [PATCH bpf-next 7/7] tools/bpftool: add perf subcommand

2018-05-15 Thread Yonghong Song
On 5/15/18 9:41 PM, Jakub Kicinski wrote: On Tue, 15 May 2018 16:45:21 -0700, Yonghong Song wrote: The new command "bpftool perf [show]" will traverse all processes under /proc, and if any fd is associated with a perf event, it will print out related perf event informati

[PATCH bpf-next 5/7] samples/bpf: add a samples/bpf test for BPF_PERF_EVENT_QUERY

2018-05-15 Thread Yonghong Song
This is mostly to test kprobe/uprobe which needs kernel headers. Signed-off-by: Yonghong Song <y...@fb.com> --- samples/bpf/Makefile| 4 + samples/bpf/perf_event_query_kern.c | 19 ++ samples/bpf/perf_event_query_user.c | 376 3

[PATCH bpf-next 0/7] bpf: implement BPF_PERF_EVENT_QUERY for perf event query

2018-05-15 Thread Yonghong Song
utility function. Patch #5 add a test in samples/bpf for querying k[ret]probes and u[ret]probes. Patch #6 add a test in tools/testing/selftests/bpf for querying raw_tracepoint and tracepoint. Patch #7 add a new subcommand "perf" to bpftool. Yonghong Song (7): perf/core: add perf_get_event()

[PATCH bpf-next 3/7] tools/bpf: sync kernel header bpf.h and add bpf_trace_event_query in libbpf

2018-05-15 Thread Yonghong Song
Sync kernel header bpf.h to tools/include/uapi/linux/bpf.h and implement bpf_trace_event_query() in libbpf. The test programs in samples/bpf and tools/testing/selftests/bpf, and later bpftool will use this libbpf function to query kernel. Signed-off-by: Yonghong Song <y...@fb.com> ---

[PATCH bpf-next 2/7] bpf: introduce bpf subcommand BPF_PERF_EVENT_QUERY

2018-05-15 Thread Yonghong Song
prog_id. Signed-off-by: Yonghong Song <y...@fb.com> --- include/linux/trace_events.h | 15 ++ include/uapi/linux/bpf.h | 25 ++ kernel/bpf/syscall.c | 113 +++ kernel/trace/bpf_trace.c | 53 kernel/trace

[PATCH bpf-next 6/7] tools/bpf: add two BPF_PERF_EVENT_QUERY tests in test_progs

2018-05-15 Thread Yonghong Song
The new tests are added to query perf_event information for raw_tracepoint and tracepoint attachment. For tracepoint, both syscalls and non-syscalls tracepoints are queries as they are treated slightly differently inside the kernel. Signed-off-by: Yonghong Song <y...@fb.com> --- tools/t

[PATCH bpf-next 7/7] tools/bpftool: add perf subcommand

2018-05-15 Thread Yonghong Song
d 0 xlated 200B not jited memlock 4096B map_ids 9 $ ps ax | grep "python ./trace.py" 21711 pts/0T 0:03 python ./trace.py __x64_sys_write 21765 pts/0S+ 0:00 python ./trace.py r::__x64_sys_nanosleep 21767 pts/2S+ 0:00 python ./trace.py t:syscalls:sys_enter_nan

[PATCH bpf-next 1/7] perf/core: add perf_get_event() to return perf_event given a struct file

2018-05-15 Thread Yonghong Song
A new extern function, perf_get_event(), is added to return a perf event given a struct file. This function will be used in later patches. Signed-off-by: Yonghong Song <y...@fb.com> --- include/linux/perf_event.h | 5 + kernel/events/core.c | 8 2 files changed, 13 inse

[PATCH bpf-next 4/7] tools/bpf: add ksym_get_addr() in trace_helpers

2018-05-15 Thread Yonghong Song
Given a kernel function name, ksym_get_addr() will return the kernel address for this function, or 0 if it cannot find this function name in /proc/kallsyms. This function will be used later when a kernel address is used to initiate a kprobe perf event. Signed-off-by: Yonghong Song <y...@fb.

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