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

2018-06-07 Thread Martin KaFai Lau
On Thu, Jun 07, 2018 at 04:30:29PM -0300, Arnaldo Carvalho de Melo wrote: > Em Thu, Jun 07, 2018 at 12:05:10PM -0700, Martin KaFai Lau escreveu: > > On Thu, Jun 07, 2018 at 11:03:37AM -0300, Arnaldo Carvalho de Melo wrote: > > > Em Thu, Jun 07, 2018 at 10:54:01AM -0300, Arnald

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

2018-06-07 Thread Martin KaFai Lau
On Thu, Jun 07, 2018 at 11:03:37AM -0300, Arnaldo Carvalho de Melo wrote: > Em Thu, Jun 07, 2018 at 10:54:01AM -0300, Arnaldo Carvalho de Melo escreveu: > > Em Tue, Jun 05, 2018 at 02:25:48PM -0700, Martin KaFai Lau escreveu: > > > [ btw, the latest commit (1 commit) shou

Re: [PATCH RFC net-next] net: ipvs: Adjust gso_size for IPPROTO_TCP

2018-06-05 Thread Martin KaFai Lau
On Sat, May 05, 2018 at 03:58:25PM +0300, Julian Anastasov wrote: > So, except the RTF_LOCAL check in __ip6_rt_update_pmtu > we should have no other issues. Hi Julian, Do you have a chance to work on the IPv6 side? Thanks, Martin

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

2018-06-05 Thread Martin KaFai Lau
On Thu, Apr 19, 2018 at 04:40:34PM -0300, Arnaldo Carvalho de Melo wrote: > Em Wed, Apr 18, 2018 at 03:55:56PM -0700, Martin KaFai Lau escreveu: > > This patch introduces BPF Type Format (BTF). > > > > BTF (BPF Type Format) is the meta data format which describes > > th

[PATCH bpf-next 2/2] bpf: btf: Ensure t->type == 0 for BTF_KIND_FWD

2018-06-02 Thread Martin KaFai Lau
The t->type in BTF_KIND_FWD is not used. It must be 0. This patch ensures that and also adds a test case in test_btf.c Signed-off-by: Martin KaFai Lau --- kernel/bpf/btf.c | 21 - tools/testing/selftests/bpf/test_btf.c | 22 ++

[PATCH bpf-next 1/2] bpf: btf: Check array t->size

2018-06-02 Thread Martin KaFai Lau
This patch ensures array's t->size is 0. The array size is decided by its individual elem's size and the number of elements. Hence, t->size is not used and it must be 0. A test case is added to test_btf.c Signed-off-by: Martin KaFai Lau --- kernel/bpf/btf.c

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

2018-05-25 Thread Martin KaFai Lau
On Fri, May 25, 2018 at 10:23:13AM -0700, Andrey Ignatov wrote: > install_headers target should contain all headers that are part of > libbpf. Add missing btf.h > > Signed-off-by: Andrey Ignatov <r...@fb.com> Acked-by: Martin KaFai Lau <ka...@fb.com>

Re: [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 Martin KaFai Lau
ion to query kernel. > > Signed-off-by: Yonghong Song <y...@fb.com> Acked-by: Martin KaFai Lau <ka...@fb.com>

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

2018-05-23 Thread Martin KaFai Lau
ce to assume that ubuf can be directly used with strlen()/printf()... as long as the syscall does not return -1/ENOSPC. I think the comment change could be done in a follow up patch. or always null terminate ubuf as long as input_len > 0 and the output_buf_len should be strlen(buf) instead of st

[PATCH v2 bpf-next] bpf: btf: Avoid variable length array

2018-05-23 Thread Martin KaFai Lau
Sparse warning: kernel/bpf/btf.c:1985:34: warning: Variable length array is used. This patch directly uses ARRAY_SIZE(). Fixes: f80442a4cd18 ("bpf: btf: Change how section is supported in btf_header") Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- kernel/bpf/btf.c | 11 +++

[PATCH bpf-next] bpf: btf: Avoid variable length array

2018-05-23 Thread Martin KaFai Lau
Sparse warning: kernel/bpf/btf.c:1985:34: warning: Variable length array is used. This patch moves the nr_secs from btf_check_sec_info() to a macro. Fixes: f80442a4cd18 ("bpf: btf: Change how section is supported in btf_header") Signed-off-by: Martin KaFai Lau <ka...@fb.com>

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

2018-05-23 Thread Martin KaFai Lau
ress is used to initiate a kprobe perf event. > > Signed-off-by: Yonghong Song <y...@fb.com> Acked-by: Martin KaFai Lau <ka...@fb.com>

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

2018-05-23 Thread Martin KaFai Lau
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 program > is attached to which

Re: [PATCH v2 bpf-next 1/5] bpf: Hooks for sys_sendmsg

2018-05-23 Thread Martin KaFai Lau
gt; * `msg_src_ip6` to set source IPv6 for UDPv6. > > Signed-off-by: Andrey Ignatov <r...@fb.com> > Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Martin KaFai Lau <ka...@fb.com>

Re: [PATCH 1/1] tools/lib/libbpf.c: fix string format to allow build on arm32

2018-05-23 Thread Martin KaFai Lau
On Wed, May 23, 2018 at 12:41:14PM +0200, Daniel Borkmann wrote: > [ +Martin ] > > On 05/21/2018 08:59 AM, Sirio Balmelli wrote: > > On arm32, 'cd tools/testing/selftests/bpf && make' fails with: > > > > libbpf.c:80:10: error: format ‘%ld’ expects argument of type ‘long int’, > > but argument 4

Re: [PATCH bpf-next 5/5] selftests/bpf: Selftest for sys_sendmsg hooks

2018-05-22 Thread Martin KaFai Lau
gt; Summary: 26 PASSED, 0 FAILED > > Signed-off-by: Andrey Ignatov <r...@fb.com> > Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Martin KaFai Lau <ka...@fb.com>

Re: [PATCH bpf-next 4/5] selftests/bpf: Prepare test_sock_addr for extension

2018-05-22 Thread Martin KaFai Lau
port .. [PASS] > Summary: 16 PASSED, 0 FAILED > > (stderr contains errors from libbpf when testing load/attach with > invalid arguments) > > Signed-off-by: Andrey Ignatov <r...@fb.com> > Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Martin KaFai Lau <ka...@fb.com>

Re: [PATCH bpf-next 3/5] libbpf: Support guessing sendmsg{4,6} progs

2018-05-22 Thread Martin KaFai Lau
fb.com> > Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Martin KaFai Lau <ka...@fb.com>

Re: [PATCH bpf-next 2/5] bpf: Sync bpf.h to tools/

2018-05-22 Thread Martin KaFai Lau
On Fri, May 18, 2018 at 07:21:10PM -0700, Andrey Ignatov wrote: > Sync new `BPF_CGROUP_UDP4_SENDMSG` and `BPF_CGROUP_UDP6_SENDMSG` > attach types to tools/. > > Signed-off-by: Andrey Ignatov <r...@fb.com> > Acked-by: Alexei Starovoitov <a...@kernel.org> Acked-by: Martin KaFai Lau <ka...@fb.com>

[PATCH bpf-next v2 7/7] bpf: btf: Add tests for the btf uapi changes

2018-05-22 Thread Martin KaFai Lau
ot;n" Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- tools/lib/bpf/bpf.c| 4 +- tools/lib/bpf/bpf.h| 4 +- tools/lib/bpf/btf.c| 5 +- tools/lib/bpf/libbpf.c | 34 +-- tools/lib/bpf/libbpf.h

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

2018-05-22 Thread Martin KaFai Lau
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> --- include/linux/bpf.h | 2 ++ kernel/bpf/sy

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

2018-05-22 Thread Martin KaFai Lau
Instead of ingoring the array->index_type field. Enforce that it must be a BTF_KIND_INT in size 1/2/4/8 bytes. Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- kernel/bpf/btf.c | 80 +++- 1 file changed, 56 insertions(+), 24

[PATCH bpf-next v2 6/7] bpf: btf: Sync bpf.h and btf.h to tools

2018-05-22 Thread Martin KaFai Lau
This patch sync the uapi bpf.h and btf.h to tools. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Yonghong Song <y...@fb.com> --- tools/include/uapi/linux/bpf.h | 8 tools/include/uapi/linux/btf.h | 37 +++-- 2 files changed, 1

[PATCH bpf-next v2 0/7] BTF uapi cleanup

2018-05-22 Thread Martin KaFai Lau
further limit BTF_INT_ENCODING from 8 bits to 4 bits in patch 4 - Adjustments in test_btf.c to reflect changes in v2 Martin KaFai Lau (7): bpf: Expose check_uarg_tail_zero() bpf: btf: Change how section is supported in btf_header bpf: btf: Check array->index_type bpf: btf: Remove unuse

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

2018-05-22 Thread Martin KaFai Lau
. This patch also removes an unnecessary !err check at the end of btf_parse(). Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- include/uapi/linux/btf.h | 8 +- kernel/bpf/btf.c | 209 +++ 2 files changed, 160 insertions(+), 57 deletions(-) diff

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

2018-05-22 Thread Martin KaFai Lau
uot; 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.c

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

2018-05-22 Thread Martin KaFai Lau
. The BTF_INT_ENCODING is limited to 4 bits instead of 8 bits. The above can 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> --- include/uapi/linux/btf.h | 29 +--

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

2018-05-22 Thread Martin KaFai Lau
On Mon, May 21, 2018 at 02:04:51PM -0700, Yonghong Song wrote: > > > 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-of

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

2018-05-22 Thread Martin KaFai Lau
On Mon, May 21, 2018 at 09:41:11PM -0700, Yonghong Song wrote: > > > 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-of

Re: [PATCH bpf-next 1/5] bpf: Hooks for sys_sendmsg

2018-05-21 Thread Martin KaFai Lau
On Fri, May 18, 2018 at 07:21:09PM -0700, Andrey Ignatov wrote: > In addition to already existing BPF hooks for sys_bind and sys_connect, > the patch provides new hooks for sys_sendmsg. > > It leverages existing BPF program type `BPF_PROG_TYPE_CGROUP_SOCK_ADDR` > that provides access to socket

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

2018-05-21 Thread Martin KaFai Lau
On Mon, May 21, 2018 at 01:15:24PM -0700, Yonghong Song wrote: > > > 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 >

Re: [PATCH] bpf: fix mem leak in error path of lwt bpf setup

2018-05-21 Thread Martin KaFai Lau
On Sun, May 20, 2018 at 02:08:57PM +0100, Mathieu Xhonneux wrote: > In bpf_parse_prog, if bpf_prog_get_type fails, the function is > immediately terminated without freeing the previously allocated > prog->name. > This patch adds a kfree before the return. > > Signed-off-by: Mathieu Xhonneux

[PATCH bpf-next 6/7] bpf: btf: Sync bpf.h and btf.h to tools/include/uapi/linux/

2018-05-21 Thread Martin KaFai Lau
This patch sync the uapi's bpf.h and btf.h to tools/. Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- tools/include/uapi/linux/bpf.h | 8 tools/include/uapi/linux/btf.h | 28 +++- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/tools/i

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

2018-05-18 Thread Martin KaFai Lau
Instead of ingoring the array->index_type field. Enforce that it must be an unsigned BTF_KIND_INT. Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- kernel/bpf/btf.c | 83 1 file changed, 59 insertions(+), 24 deletions(-) d

[PATCH bpf-next 7/7] bpf: btf: Add tests for the btf uapi changes

2018-05-18 Thread Martin KaFai Lau
ot;n" Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- tools/lib/bpf/bpf.c| 4 +- tools/lib/bpf/bpf.h| 4 +- tools/lib/bpf/btf.c| 5 +- tools/lib/bpf/libbpf.c | 34 +-- tools/lib/bpf/libbpf.h

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

2018-05-18 Thread Martin KaFai Lau
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> --- include/linux/bpf.h | 2 ++ kernel/bpf/syscall.c | 14 +++--- 2 files changed, 9 insertions

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

2018-05-18 Thread Martin KaFai Lau
uot; 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> --- include/linux/bpf.h | 4 ++-- in

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

2018-05-18 Thread Martin KaFai Lau
bits are zeros. Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- include/uapi/linux/btf.h | 20 +--- kernel/bpf/btf.c | 34 +- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/include/uapi/linux/btf.h b/include/uapi

[PATCH bpf-next 0/7] BTF uapi cleanup

2018-05-18 Thread Martin KaFai Lau
This patch set makes some changes to cleanup the unused bits in BTF uapi. It also makes the btf_header extensible. Please see individual patches for details. Martin KaFai Lau (7): bpf: Expose check_uarg_tail_zero() bpf: btf: Change how section is supported in btf_header bpf: btf: Check

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

2018-05-18 Thread Martin KaFai Lau
. This patch also removes an unnecessary !err check at the end of btf_parse(). Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- include/uapi/linux/btf.h | 8 +- kernel/bpf/btf.c | 207 +++ 2 files changed, 158 insertions(+), 57 deletions(-) diff

Re: [PATCH bpf] bpf: fix truncated jump targets on heavy expansions

2018-05-17 Thread Martin KaFai Lau
e latter is split into an extra pass to probe problematic offsets > on the original program in order to fail early. With that in place > and carefully tested I no longer hit the panic and the rewrites are > rejected properly. The above example panic I've seen on bpf-next, > though the issue itself is generic in that a guard against this issue > in bpf seems more appropriate in this case. > > Signed-off-by: Daniel Borkmann <dan...@iogearbox.net> Acked-by: Martin KaFai Lau <ka...@fb.com>

Re: [bpf-next PATCH 2/2] bpf: add sk_msg prog sk access tests to test_verifier

2018-05-17 Thread Martin KaFai Lau
;invalid read offset in SK_MSG", > + .insns = { > + BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, > + offsetof(struct sk_msg_md, family) + 1), > + BPF_EXIT_INSN(), > + }, > + .errstr = "", same here. > + .result = REJECT, > + .prog_type = BPF_PROG_TYPE_SK_MSG, > + }, > + { > "direct packet read for SK_MSG", > .insns = { > BPF_LDX_MEM(BPF_DW, BPF_REG_2, BPF_REG_1, > Other than the above, Acked-by: Martin KaFai Lau <ka...@fb.com>

Re: [bpf-next PATCH 1/2] bpf: allow sk_msg programs to read sock fields

2018-05-17 Thread Martin KaFai Lau
|1 > net/core/filter.c| 114 > +- It is indeed a lot of dup lines with sock_ops_convert_ctx_access() as you mentioned in the cover. Other than that, LGTM. Acked-by: Martin KaFai Lau <kaf...@fb.com> > 4 files changed, 121 insertions(+), 3 deletions(-)

Re: [bpf PATCH 2/2] bpf: parse and verdict prog attach may race with bpf map update

2018-05-17 Thread Martin KaFai Lau
g_inc_not_zero could > dereference a NULL pointer. > > Fix this by using variable returned by READ_ONCE() that is checked > for NULL. > > Fixes: 2f857d04601a ("bpf: sockmap, remove STRPARSER map_flags and add > multi-map support") > Reported-by: Daniel Borkm

Re: [bpf PATCH 1/2] bpf: sockmap update rollback on error can incorrectly dec prog refcnt

2018-05-17 Thread Martin KaFai Lau
t; Fixes: 2f857d04601a ("bpf: sockmap, remove STRPARSER map_flags and add > multi-map support") > Reported-by: Daniel Borkmann <dan...@iogearbox.net> > Signed-off-by: John Fastabend <john.fastab...@gmail.com> Acked-by: Martin KaFai Lau <ka...@fb.com>

Re: [RFC bpf-next 07/11] bpf: Add helper to retrieve socket in BPF

2018-05-15 Thread Martin KaFai Lau
On Mon, May 14, 2018 at 08:16:59PM -0700, Alexei Starovoitov wrote: > On Fri, May 11, 2018 at 05:54:33PM -0700, Joe Stringer wrote: > > On 11 May 2018 at 14:41, Martin KaFai Lau <ka...@fb.com> wrote: > > > On Fri, May 11, 2018 at 02:08:01PM -0700, Joe Stringer wrote: > &

Re: [RFC bpf-next 07/11] bpf: Add helper to retrieve socket in BPF

2018-05-11 Thread Martin KaFai Lau
On Fri, May 11, 2018 at 02:08:01PM -0700, Joe Stringer wrote: > On 10 May 2018 at 22:00, Martin KaFai Lau <ka...@fb.com> wrote: > > On Wed, May 09, 2018 at 02:07:05PM -0700, Joe Stringer wrote: > >> This patch adds a new BPF helper function, sk_lookup() which allows BPF &

Re: [RFC bpf-next 07/11] bpf: Add helper to retrieve socket in BPF

2018-05-10 Thread Martin KaFai Lau
On Wed, May 09, 2018 at 02:07:05PM -0700, Joe Stringer wrote: > This patch adds a new BPF helper function, sk_lookup() which allows BPF > programs to find out if there is a socket listening on this host, and > returns a socket pointer which the BPF program can then access to > determine, for

Re: [PATCH RFC net-next] net: ipvs: Adjust gso_size for IPPROTO_TCP

2018-05-07 Thread Martin KaFai Lau
On Sat, May 05, 2018 at 03:58:25PM +0300, Julian Anastasov wrote: > > Hello, > > On Thu, 3 May 2018, Martin KaFai Lau wrote: > > > > - when exactly we start to use the new PMTU, eg. what happens > > > in case socket caches the route, whether route is kille

[PATCH bpf-next 2/6] bpf: btf: Introduce BTF ID

2018-05-04 Thread Martin KaFai Lau
en processing the BPF_BTF_GET_FD_BY_ID cmd, refcount_inc_not_zero() is needed because the BTF object could be already in the rcu dead row . btf_get() is removed since its usage is currently limited to btf.c alone. refcount_inc() is used directly instead. Signed-off-by: Martin KaFai Lau <ka...@fb.com&g

[PATCH bpf-next 1/6] bpf: btf: Avoid WARN_ON when CONFIG_REFCOUNT_FULL=y

2018-05-04 Thread Martin KaFai Lau
310 [ 34.872285] ? bad_area_access_error+0x310/0x310 [ 34.872894] do_syscall_64+0x95/0x3f0 This patch uses refcount_set() instead. Reported-by: Yonghong Song <y...@fb.com> Tested-by: Yonghong Song <y...@fb.com> Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- kernel/bpf

[PATCH bpf-next 0/6] Introduce BTF ID

2018-05-04 Thread Martin KaFai Lau
This series introduces BTF ID which is exposed through the new BPF_BTF_GET_FD_BY_ID cmd, new "struct bpf_btf_info" and new members in the "struct bpf_map_info". Please see individual patch for details. Martin KaFai Lau (6): bpf: btf: Avoid WARN_ON when CONFIG_REFCOU

[PATCH bpf-next 4/6] bpf: btf: Some test_btf clean up

2018-05-04 Thread Martin KaFai Lau
This patch adds a CHECK() macro for condition checking and error report purpose. Something similar to test_progs.c It also counts the number of tests passed/skipped/failed and print them at the end of the test run. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Staro

[PATCH bpf-next 5/6] bpf: btf: Update tools/include/uapi/linux/btf.h with BTF ID

2018-05-04 Thread Martin KaFai Lau
This patch sync the tools/include/uapi/linux/btf.h with the newly introduced BTF ID support. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> --- tools/include/uapi/linux/bpf.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/t

[PATCH bpf-next 6/6] bpf: btf: Tests for BPF_OBJ_GET_INFO_BY_FD and BPF_BTF_GET_FD_BY_ID

2018-05-04 Thread Martin KaFai Lau
This patch adds test for BPF_BTF_GET_FD_BY_ID and the new btf_id/btf_key_id/btf_value_id in the "struct bpf_map_info". It also modifies the existing BPF_OBJ_GET_INFO_BY_FD test to reflect the new "struct bpf_btf_info". Signed-off-by: Martin KaFai Lau <ka...@fb.com> Ac

[PATCH bpf-next 3/6] bpf: btf: Add struct bpf_btf_info

2018-05-04 Thread Martin KaFai Lau
ata itself is exposed through the "btf" and "btf_size" members. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> --- include/uapi/linux/bpf.h | 6 ++ kernel/bpf/btf.c | 26 +- kernel/bpf/sys

Re: [PATCH RFC net-next] net: ipvs: Adjust gso_size for IPPROTO_TCP

2018-05-03 Thread Martin KaFai Lau
On Wed, May 02, 2018 at 10:30:32PM +0300, Julian Anastasov wrote: > > Hello, > > On Wed, 2 May 2018, Martin KaFai Lau wrote: > > > On Wed, May 02, 2018 at 09:38:43AM +0300, Julian Anastasov wrote: > > > > > > - initial traffic for port 21 does no

Re: [PATCH RFC net-next] net: ipvs: Adjust gso_size for IPPROTO_TCP

2018-05-02 Thread Martin KaFai Lau
On Wed, May 02, 2018 at 09:38:43AM +0300, Julian Anastasov wrote: > > Hello, > > On Thu, 19 Apr 2018, Martin KaFai Lau wrote: > > > This patch is not a proper fix and mainly serves for discussion purpose. > > It is based on net-next which I have be

Re: [PATCH 2/2] bpf: btf: remove a couple conditions

2018-04-27 Thread Martin KaFai Lau
On Fri, Apr 27, 2018 at 02:26:50PM -0700, Martin KaFai Lau wrote: > On Fri, Apr 27, 2018 at 11:31:36PM +0300, Dan Carpenter wrote: > > On Fri, Apr 27, 2018 at 10:21:17PM +0200, Daniel Borkmann wrote: > > > On 04/27/2018 09:39 PM, Dan Carpenter wrote: > > > > On F

Re: [PATCH 2/2] bpf: btf: remove a couple conditions

2018-04-27 Thread Martin KaFai Lau
On Fri, Apr 27, 2018 at 11:31:36PM +0300, Dan Carpenter wrote: > On Fri, Apr 27, 2018 at 10:21:17PM +0200, Daniel Borkmann wrote: > > On 04/27/2018 09:39 PM, Dan Carpenter wrote: > > > On Fri, Apr 27, 2018 at 10:55:46AM -0700, Martin KaFai Lau wrote: > > >> On Fri, Ap

Re: [PATCH 2/2] bpf: btf: remove a couple conditions

2018-04-27 Thread Martin KaFai Lau
On Fri, Apr 27, 2018 at 10:20:25AM -0700, Martin KaFai Lau wrote: > On Fri, Apr 27, 2018 at 05:04:59PM +0300, Dan Carpenter wrote: > > We know "err" is zero so we can remove these and pull the code in one > > indent level. > > > > Signed-off-by: Dan Carpente

Re: [PATCH 2/2] bpf: btf: remove a couple conditions

2018-04-27 Thread Martin KaFai Lau
On Fri, Apr 27, 2018 at 05:04:59PM +0300, Dan Carpenter wrote: > We know "err" is zero so we can remove these and pull the code in one > indent level. > > Signed-off-by: Dan Carpenter <dan.carpen...@oracle.com> Thanks for the simplification! Acked-by: Ma

Re: [PATCH 1/2] bpf: btf: silence uninitialize variable warnings

2018-04-27 Thread Martin KaFai Lau
On Fri, Apr 27, 2018 at 05:04:09PM +0300, Dan Carpenter wrote: > Smatch complains that size can be uninitialized if btf_type_id_size() > returns NULL. It seems reasonable enough to check for that. > > Signed-off-by: Dan Carpenter > --- > This goes to the BPF tree

Re: [RFC bpf-next 8/9] bpf: Provide helper to do lookups in kernel FIB table

2018-04-27 Thread Martin KaFai Lau
On Wed, Apr 25, 2018 at 11:34:48AM -0700, David Ahern wrote: > Provide a helper for doing a FIB and neighbor lookup in the kernel > tables from an XDP program. The helper provides a fastpath for forwarding > packets. If the packet is a local delivery or for any reason is not a > simple lookup and

[PATCH bpf-next] bpf: btf: Clean up btf.h in uapi

2018-04-21 Thread Martin KaFai Lau
This patch cleans up btf.h in uapi: 1) Rename "name" to "name_off" to better reflect it is an offset to the string section instead of a char array. 2) Remove unused value BTF_FLAGS_COMPR and BTF_MAGIC_SWAP Suggested-by: Daniel Borkmann <dan...@iogearbox.net> Signed-of

Re: [PATCH RFC net-next] net: ipvs: Adjust gso_size for IPPROTO_TCP

2018-04-20 Thread Martin KaFai Lau
On Fri, Apr 20, 2018 at 11:43:59PM +0300, Julian Anastasov wrote: > > Hello, > > On Thu, 19 Apr 2018, Martin KaFai Lau wrote: > > > This patch is not a proper fix and mainly serves for discussion purpose. > > It is based on net-next which I have be

Re: [PATCH bpf-next] libbpf: fixed build error for samples/bpf/

2018-04-20 Thread Martin KaFai Lau
On Fri, Apr 20, 2018 at 10:05:16AM +0200, Björn Töpel wrote: > From: Björn Töpel > > Commit 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf") did not > include stdbool.h, so GCC complained when building samples/bpf/. > > In file included from

[PATCH RFC net-next] net: ipvs: Adjust gso_size for IPPROTO_TCP

2018-04-19 Thread Martin KaFai Lau
ike this: > ip -6 r show table local local 2401:db00:1011:1f01:face:b00c:0:85 dev lo src 2401:db00:1011:10af:face:0:27:0 metric 1024 mtu 1460 advmss 1440 pref medium Signed-off-by: Martin KaFai Lau <ka...@fb.com> --- net/netfilter/ipvs/ip_vs_xmit.c | 49 +++

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

2018-04-19 Thread Martin KaFai Lau
On Thu, Apr 19, 2018 at 04:40:34PM -0300, Arnaldo Carvalho de Melo wrote: > Em Wed, Apr 18, 2018 at 03:55:56PM -0700, Martin KaFai Lau escreveu: > > This patch introduces BPF Type Format (BTF). > > > > BTF (BPF Type Format) is the meta data format which describes > > th

Re: [PATCH bpf-next v3 6/8] bpf: add documentation for eBPF helpers (42-50)

2018-04-18 Thread Martin KaFai Lau
0 on success, or a negative error in case of failure. > + * LGTM. Thanks! Acked-by: Martin KaFai Lau <ka...@fb.com>

[PATCH bpf-next v5 03/10] bpf: btf: Check members of struct/union

2018-04-18 Thread Martin KaFai Lau
done after the needs_resolve member's type is resolved. Hence, the above is done together in btf_struct_resolve(). Each possible member's type (e.g. int, enum, modifier...) implements the check_member() ops which will be called from btf_struct_resolve(). Signed-off-by: Martin KaFai Lau <ka...@

[PATCH bpf-next v5 01/10] bpf: btf: Introduce BPF Type Format (BTF)

2018-04-18 Thread Martin KaFai Lau
e done in the second pass. The second verification pass will be implemented in the next patch. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> --- include/uapi/linux/btf.h | 130 +++ kernel/bpf/Makefile | 1 +

[PATCH bpf-next v5 02/10] bpf: btf: Validate type reference

2018-04-18 Thread Martin KaFai Lau
of an array). This info will be useful in checking the struct's members in a later patch. They will also be useful in doing pretty print later. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> --- include/linux/btf.h | 37 +++ kernel/bpf/bt

[PATCH bpf-next v5 10/10] bpf: btf: Add BTF tests

2018-04-18 Thread Martin KaFai Lau
of the llvm repo for now. BTF_PAHOLE: The modified pahole with BTF support: https://github.com/iamkafai/pahole/tree/btf To add a BTF section: "pahole -J bpf_prog.o" LLVM_OBJCOPY: Any llvm-objcopy should do Signed-off-by: Martin KaFai Lau <ka...@fb.com>

[PATCH bpf-next v5 07/10] bpf: btf: Add pretty print support to the basic arraymap

2018-04-18 Thread Martin KaFai Lau
cat /sys/fs/bpf/pinned_array_map: 0: {1,2} 1: {3,4} 2: {5,6} ... Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> --- include/linux/bpf.h | 20 +- include/uapi/linux/bpf.h | 3 + kernel/bpf/arraymap.c| 50 +

[PATCH bpf-next v5 06/10] bpf: btf: Add BPF_OBJ_GET_INFO_BY_FD support to BTF fd

2018-04-18 Thread Martin KaFai Lau
. If it is, the userspace should realloc with the kernel-returned info.info_len and call the BPF_OBJ_GET_INFO_BY_FD again. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> --- include/linux/btf.h | 5 + kernel/bpf/btf.c | 17 - kernel/bpf/sy

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

2018-04-18 Thread Martin KaFai Lau
eep the rev xmas tree in btf.c Martin KaFai Lau (10): bpf: btf: Introduce BPF Type Format (BTF) bpf: btf: Validate type reference bpf: btf: Check members of struct/union bpf: btf: Add pretty print capability for data with BTF type info bpf: btf: Add BPF_BTF_LOAD command bpf: btf:

[PATCH bpf-next v5 04/10] bpf: btf: Add pretty print capability for data with BTF type info

2018-04-18 Thread Martin KaFai Lau
This patch adds pretty print capability for data with BTF type info. The current usage is to allow pretty print for a BPF map. The next few patches will allow a read() on a pinned map with BTF type info for its key and value. This patch uses the seq_printf() infra. Signed-off-by: Martin KaFai

[PATCH bpf-next v5 05/10] bpf: btf: Add BPF_BTF_LOAD command

2018-04-18 Thread Martin KaFai Lau
This patch adds a BPF_BTF_LOAD command which 1) loads and verifies the BTF (implemented in earlier patches) 2) returns a BTF fd to userspace. In the next patch, the BTF fd can be specified during BPF_MAP_CREATE. It currently limits to CAP_SYS_ADMIN. Signed-off-by: Martin KaFai Lau <

[PATCH bpf-next v5 09/10] bpf: btf: Add BTF support to libbpf

2018-04-18 Thread Martin KaFai Lau
btf_key_id and btf_value_id of a map by finding the BTF type with name "_key" and "_value". If they cannot be found, it will continue without using the BTF. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> --- tools/lib/bpf/Build

[PATCH bpf-next v5 08/10] bpf: btf: Sync bpf.h and btf.h to tools/

2018-04-18 Thread Martin KaFai Lau
This patch sync up the bpf.h and btf.h to tools/ Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> --- tools/include/uapi/linux/bpf.h | 12 tools/include/uapi/linux/btf.h | 130 + 2 files

Re: [PATCH bpf-next v4 03/10] bpf: btf: Check members of struct/union

2018-04-18 Thread Martin KaFai Lau
On Wed, Apr 18, 2018 at 10:22:10AM -0700, Jakub Kicinski wrote: > On Tue, 17 Apr 2018 13:42:36 -0700, Martin KaFai Lau wrote: > > This patch checks a few things of struct's members: > > > > 1) It has a valid size (e.g. a "const void" is invalid) > > 2) A membe

Re: [PATCH bpf-next v4 07/10] bpf: btf: Add pretty print support to the basic arraymap

2018-04-18 Thread Martin KaFai Lau
On Wed, Apr 18, 2018 at 05:20:11PM +0200, Daniel Borkmann wrote: > Hi Martin, > > first of all great work on the set! One issue that puzzled me > while digesting it further below. > > On 04/17/2018 10:42 PM, Martin KaFai Lau wrote: > > This patch adds pretty print suppo

[PATCH bpf-next v4 07/10] bpf: btf: Add pretty print support to the basic arraymap

2018-04-17 Thread Martin KaFai Lau
is a sample output when reading a pinned arraymap with the following map's value: struct map_value { int count_a; int count_b; }; cat /sys/fs/bpf/pinned_array_map: 0: {1,2} 1: {3,4} 2: {5,6} ... Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a.

[PATCH bpf-next v4 10/10] bpf: btf: Add BTF tests

2018-04-17 Thread Martin KaFai Lau
of the llvm repo for now. BTF_PAHOLE: The modified pahole with BTF support: https://github.com/iamkafai/pahole/tree/btf To add a BTF section: "pahole -J bpf_prog.o" LLVM_OBJCOPY: Any llvm-objcopy should do Signed-off-by: Martin KaFai Lau <ka...@fb.com>

[PATCH bpf-next v4 05/10] bpf: btf: Add BPF_BTF_LOAD command

2018-04-17 Thread Martin KaFai Lau
This patch adds a BPF_BTF_LOAD command which 1) loads and verifies the BTF (implemented in earlier patches) 2) returns a BTF fd to userspace. In the next patch, the BTF fd can be specified during BPF_MAP_CREATE. It currently limits to CAP_SYS_ADMIN. Signed-off-by: Martin KaFai Lau <

[PATCH bpf-next v4 06/10] bpf: btf: Add BPF_OBJ_GET_INFO_BY_FD support to BTF fd

2018-04-17 Thread Martin KaFai Lau
. If it is, the userspace should realloc with the kernel-returned info.info_len and call the BPF_OBJ_GET_INFO_BY_FD again. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> --- include/linux/btf.h | 5 + kernel/bpf/btf.c | 17 - kernel/bpf/sy

[PATCH bpf-next v4 02/10] bpf: btf: Validate type reference

2018-04-17 Thread Martin KaFai Lau
of an array). This info will be useful in checking the struct's members in a later patch. They will also be useful in doing pretty print later. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> --- include/linux/btf.h | 37 +++ kernel/bpf/bt

[PATCH bpf-next v4 03/10] bpf: btf: Check members of struct/union

2018-04-17 Thread Martin KaFai Lau
done after the needs_resolve member's type is resolved. Hence, the above is done together in btf_struct_resolve(). Each possible member's type (e.g. int, enum, modifier...) implements the check_member() ops which will be called from btf_struct_resolve(). Signed-off-by: Martin KaFai Lau <ka...@

[PATCH bpf-next v4 08/10] bpf: btf: Sync bpf.h and btf.h to tools/

2018-04-17 Thread Martin KaFai Lau
This patch sync up the bpf.h and btf.h to tools/ Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> --- tools/include/uapi/linux/bpf.h | 13 tools/include/uapi/linux/btf.h | 132 + 2 files

[PATCH bpf-next v4 09/10] bpf: btf: Add BTF support to libbpf

2018-04-17 Thread Martin KaFai Lau
btf_key_id and btf_value_id of a map by finding the BTF type with name "_key" and "_value". If they cannot be found, it will continue without using the BTF. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> --- tools/lib/bpf/Build

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

2018-04-17 Thread Martin KaFai Lau
rev xmas tree in btf.c Martin KaFai Lau (10): bpf: btf: Introduce BPF Type Format (BTF) bpf: btf: Validate type reference bpf: btf: Check members of struct/union bpf: btf: Add pretty print capability for data with BTF type info bpf: btf: Add BPF_BTF_LOAD command bpf: btf:

[PATCH bpf-next v4 01/10] bpf: btf: Introduce BPF Type Format (BTF)

2018-04-17 Thread Martin KaFai Lau
e done in the second pass. The second verification pass will be implemented in the next patch. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> --- include/uapi/linux/btf.h | 132 +++ kernel/bpf/Makefile | 1 +

[PATCH bpf-next v4 04/10] bpf: btf: Add pretty print capability for data with BTF type info

2018-04-17 Thread Martin KaFai Lau
This patch adds pretty print capability for data with BTF type info. The current usage is to allow pretty print for a BPF map. The next few patches will allow a read() on a pinned map with BTF type info for its key and value. This patch uses the seq_printf() infra. Signed-off-by: Martin KaFai

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

2018-04-17 Thread Martin KaFai Lau
On Mon, Apr 16, 2018 at 05:22:00PM -0300, Arnaldo Carvalho de Melo wrote: > Em Mon, Apr 16, 2018 at 12:33:17PM -0700, Martin KaFai Lau escreveu: > > This patch introduces BPF Type Format (BTF). > > > > BTF (BPF Type Format) is the meta data format which describes > > th

[PATCH bpf-next v3 03/10] bpf: btf: Check members of struct/union

2018-04-16 Thread Martin KaFai Lau
done after the needs_resolve member's type is resolved. Hence, the above is done together in btf_struct_resolve(). Each possible member's type (e.g. int, enum, modifier...) implements the check_member() ops which will be called from btf_struct_resolve(). Signed-off-by: Martin KaFai Lau <ka...@

[PATCH bpf-next v3 01/10] bpf: btf: Introduce BPF Type Format (BTF)

2018-04-16 Thread Martin KaFai Lau
e done in the second pass. The second verification pass will be implemented in the next patch. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> --- include/uapi/linux/btf.h | 132 +++ kernel/bpf/Makefile | 1 +

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

2018-04-16 Thread Martin KaFai Lau
eta() in patch 1 - Fix an incorrect goto target in map_create() during the btf-error-path in patch 7 - re-org some local vars to keep the rev xmas tree in btf.c Martin KaFai Lau (10): bpf: btf: Introduce BPF Type Format (BTF) bpf: btf: Validate type reference bpf: btf: Check members of str

[PATCH bpf-next v3 02/10] bpf: btf: Validate type reference

2018-04-16 Thread Martin KaFai Lau
of an array). This info will be useful in checking the struct's members in a later patch. They will also be useful in doing pretty print later. Signed-off-by: Martin KaFai Lau <ka...@fb.com> Acked-by: Alexei Starovoitov <a...@fb.com> --- include/linux/btf.h | 37 +++ kernel/bpf/bt

[PATCH bpf-next v3 05/10] bpf: btf: Add BPF_BTF_LOAD command

2018-04-16 Thread Martin KaFai Lau
This patch adds a BPF_BTF_LOAD command which 1) loads and verifies the BTF (implemented in earlier patches) 2) returns a BTF fd to userspace. In the next patch, the BTF fd can be specified during BPF_MAP_CREATE. It currently limits to CAP_SYS_ADMIN. Signed-off-by: Martin KaFai Lau <

<    1   2   3   4   5   6   7   8   >