Re: [PATCH bpf-next v2 2/3] bpf, netns: Keep attached programs in bpf_prog_array

2020-06-23 Thread Martin KaFai Lau
On Tue, Jun 23, 2020 at 10:59:37PM +0200, Jakub Sitnicki wrote: > On Tue, Jun 23, 2020 at 09:33 PM CEST, Martin KaFai Lau wrote: > > On Tue, Jun 23, 2020 at 12:34:58PM +0200, Jakub Sitnicki wrote: > > > > [ ... ] > > > >> @@ -93,8 +108,16 @@ static int bpf_ne

Re: [PATCH bpf-next v2 2/3] bpf, netns: Keep attached programs in bpf_prog_array

2020-06-23 Thread Martin KaFai Lau
On Tue, Jun 23, 2020 at 12:34:58PM +0200, Jakub Sitnicki wrote: [ ... ] > @@ -93,8 +108,16 @@ static int bpf_netns_link_update_prog(struct bpf_link > *link, > goto out_unlock; > } > > + run_array = rcu_dereference_protected(net->bpf.run_array[type], > +

[PATCH bpf-next] bpf: sk_storage: Prefer to get a free cache_idx

2020-06-17 Thread Martin KaFai Lau
count for each cache_idx. There is 16 of them now (defined in BPF_SK_STORAGE_CACHE_SIZE). It will try to pick the free cache_idx. If none was found, it would pick one with the minimal usage count. Signed-off-by: Martin KaFai Lau --- net/core/bpf_sk_storage.c | 41

Re: [PATCH v2 bpf-next 1/3] bpf: Consolidate inner-map-compatible properties into bpf_types.h

2020-05-28 Thread Martin KaFai Lau
On Tue, May 26, 2020 at 10:54:26AM -0700, Andrii Nakryiko wrote: > On Fri, May 22, 2020 at 6:01 PM Martin KaFai Lau wrote: > > > > On Sat, May 23, 2020 at 12:22:48AM +0200, Daniel Borkmann wrote: > > > On 5/22/20 4:23 AM, Martin KaFai Lau wrote: > > > [...] > &

Re: [PATCH bpf-next] bpf: add SO_KEEPALIVE and related options to bpf_setsockopt

2020-05-27 Thread Martin KaFai Lau
ger value and do not need ns_capable()), do_tcp_setsockopt() and sock_setsockopt() can be directly called with some refactoring. The change looks good. For this patch, Acked-by: Martin KaFai Lau

Re: [PATCH v2 bpf-next 1/3] bpf: Consolidate inner-map-compatible properties into bpf_types.h

2020-05-22 Thread Martin KaFai Lau
On Sat, May 23, 2020 at 12:22:48AM +0200, Daniel Borkmann wrote: > On 5/22/20 4:23 AM, Martin KaFai Lau wrote: > [...] > > }; > > +/* Cannot be used as an inner map */ > > +#define BPF_MAP_NO_INNER_MAP (1 << 0) > > + > > struct bpf_map { > >

[PATCH v2 bpf-next 1/3] bpf: Consolidate inner-map-compatible properties into bpf_types.h

2020-05-21 Thread Martin KaFai Lau
one when a map's properties is decided at the same place as the new map type is added in bpf_types.h. That will help to avoid mistake like missing modification in other source files like the map_in_map.c here or other source files in the future. Cc: Andrey Ignatov Signed-off-by: Martin KaFai Lau

[PATCH v2 bpf-next 2/3] bpf: Relax the max_entries check for inner map

2020-05-21 Thread Martin KaFai Lau
with a smaller inner map first and then replaces it with a larger inner map later when it is needed. The max_entries of arraymap and xskmap are used statically in verification time to generate the inline code, so they are excluded in this patch. Cc: Andrey Ignatov Signed-off-by: Martin KaFai Lau

[PATCH v2 bpf-next 0/3] bpf: Allow inner map with different max_entries

2020-05-21 Thread Martin KaFai Lau
time during prog load). Please see individual patch for details. v2: - New BPF_MAP_TYPE_FL to minimize code churns (Alexei) - s/capabilities/properties/ (Andrii) - Describe WHY in commit log (Andrii) Martin KaFai Lau (3): bpf: Consolidate inner-map-compatible properties into bpf_types.h bpf

[PATCH v2 bpf-next 3/3] bpf: selftests: Add test for different inner map size

2020-05-21 Thread Martin KaFai Lau
This patch tests the inner map size can be different for reuseport_sockarray but has to be the same for arraymap. Cc: Andrey Ignatov Signed-off-by: Martin KaFai Lau --- .../selftests/bpf/prog_tests/btf_map_in_map.c | 12 +++ .../selftests/bpf/progs/test_btf_map_in_map.c | 31

Re: [PATCH bpf-next 0/3] bpf: Allow inner map with different max_entries

2020-05-21 Thread Martin KaFai Lau
On Thu, May 21, 2020 at 04:16:18PM -0700, Alexei Starovoitov wrote: > On Thu, May 21, 2020 at 04:10:36PM -0700, Andrii Nakryiko wrote: > > > > 4. Then for size check change, again, it's really much simpler and > > > > cleaner just to have a special case in check in bpf_map_meta_equal for > > > > ca

Re: [PATCH bpf-next 0/3] bpf: Allow inner map with different max_entries

2020-05-21 Thread Martin KaFai Lau
On Thu, May 21, 2020 at 03:39:10PM -0700, Andrii Nakryiko wrote: > On Thu, May 21, 2020 at 12:18 PM Martin KaFai Lau wrote: > > > > This series allows the outer map to be updated with inner map in different > > size as long as it is safe (meaning the max_entri

[PATCH bpf-next 3/3] bpf: selftests: Add test for different inner map size

2020-05-21 Thread Martin KaFai Lau
This patch tests the inner map size can be different for reuseport_sockarray but has to be the same for arraymap. Cc: Andrey Ignatov Signed-off-by: Martin KaFai Lau --- .../selftests/bpf/prog_tests/btf_map_in_map.c | 12 +++ .../selftests/bpf/progs/test_btf_map_in_map.c | 31

[PATCH bpf-next 2/3] bpf: Relax the max_entries check for inner map

2020-05-21 Thread Martin KaFai Lau
xskmap are used statically in verification time to generate the inline code, so they are excluded in this patch. Cc: Andrey Ignatov Signed-off-by: Martin KaFai Lau --- include/linux/bpf.h | 12 include/linux/bpf_types.h | 6 -- kernel/bpf/map_in_map.c | 3 ++- 3 files

[PATCH bpf-next 0/3] bpf: Allow inner map with different max_entries

2020-05-21 Thread Martin KaFai Lau
This series allows the outer map to be updated with inner map in different size as long as it is safe (meaning the max_entries is not used in the verification time during prog load). Please see individual patch for details. Martin KaFai Lau (3): bpf: Clean up inner map type check bpf: Relax

[PATCH bpf-next 1/3] bpf: Clean up inner map type check

2020-05-21 Thread Martin KaFai Lau
l be less error prone to decide its capability at the same place as the new map type is added in bpf_types.h. That will help to avoid mistake like missing modification in other source files like the map_in_map.c here. Cc: Andrey Ignatov Signed-off-by: Martin KaFai Lau --- include/linux/b

[PATCH net] net: inet_csk: Fix so_reuseport bind-address cache in tb->fast*

2020-05-18 Thread Martin KaFai Lau
match_sk1_wildcard" and "bool match_sk2_wildcard". This change only affects the sk_reuseport_match() which is only used by inet_csk (e.g. TCP). The other use cases are calling inet_rcv_saddr_equal() and this patch makes it pass the same "match_wildcard" arg twice to the "ip

Re: [PATCH bpf-next v2 02/17] bpf: Introduce SK_LOOKUP program type with a dedicated attach point

2020-05-13 Thread Martin KaFai Lau
On Wed, May 13, 2020 at 04:34:13PM +0200, Jakub Sitnicki wrote: > On Wed, May 13, 2020 at 07:41 AM CEST, Martin KaFai Lau wrote: > > On Mon, May 11, 2020 at 08:52:03PM +0200, Jakub Sitnicki wrote: > > > > [ ... ] > > > >> +BPF_CALL_3(bpf_sk_lookup_assi

Re: [PATCH bpf-next v2 02/17] bpf: Introduce SK_LOOKUP program type with a dedicated attach point

2020-05-12 Thread Martin KaFai Lau
On Mon, May 11, 2020 at 08:52:03PM +0200, Jakub Sitnicki wrote: [ ... ] > +BPF_CALL_3(bpf_sk_lookup_assign, struct bpf_sk_lookup_kern *, ctx, > +struct sock *, sk, u64, flags) The SK_LOOKUP bpf_prog may have already selected the proper reuseport sk. It is possible by looking up sk from so

Re: [PATCH bpf-next v2 00/17] Run a BPF program on socket lookup

2020-05-12 Thread Martin KaFai Lau
On Tue, May 12, 2020 at 01:57:45PM +0200, Jakub Sitnicki wrote: > On Mon, May 11, 2020 at 09:45 PM CEST, Martin KaFai Lau wrote: > > On Mon, May 11, 2020 at 08:52:01PM +0200, Jakub Sitnicki wrote: > > > > [ ... ] > > > >> Performance considerations > >&g

Re: [PATCH bpf-next 02/17] bpf: Introduce SK_LOOKUP program type with a dedicated attach point

2020-05-11 Thread Martin KaFai Lau
On Mon, May 11, 2020 at 09:26:02PM +0200, Jakub Sitnicki wrote: > On Mon, May 11, 2020 at 08:59 PM CEST, Martin KaFai Lau wrote: > > On Mon, May 11, 2020 at 11:08:15AM +0200, Jakub Sitnicki wrote: > >> On Fri, May 08, 2020 at 08:39 PM CEST, Martin KaFai Lau wrote: > >> &

Re: [PATCH bpf-next v2 00/17] Run a BPF program on socket lookup

2020-05-11 Thread Martin KaFai Lau
On Mon, May 11, 2020 at 08:52:01PM +0200, Jakub Sitnicki wrote: [ ... ] > Performance considerations > == > > Patch set adds new code on receive hot path. This comes with a cost, > especially in a scenario of a SYN flood or small UDP packet flood. > > Measuring the perfo

Re: [PATCH bpf-next 02/17] bpf: Introduce SK_LOOKUP program type with a dedicated attach point

2020-05-11 Thread Martin KaFai Lau
On Mon, May 11, 2020 at 11:08:15AM +0200, Jakub Sitnicki wrote: > On Fri, May 08, 2020 at 08:39 PM CEST, Martin KaFai Lau wrote: > > On Fri, May 08, 2020 at 12:45:14PM +0200, Jakub Sitnicki wrote: > >> On Fri, May 08, 2020 at 09:06 AM CEST, Martin KaFai Lau wrote: > >> &

Re: [PATCH bpf-next 02/17] bpf: Introduce SK_LOOKUP program type with a dedicated attach point

2020-05-08 Thread Martin KaFai Lau
On Fri, May 08, 2020 at 12:45:14PM +0200, Jakub Sitnicki wrote: > On Fri, May 08, 2020 at 09:06 AM CEST, Martin KaFai Lau wrote: > > On Wed, May 06, 2020 at 02:54:58PM +0200, Jakub Sitnicki wrote: > >> Add a new program type BPF_PROG_TYPE_SK_LOOKUP and a dedicated attac

Re: [PATCH bpf-next v4 1/4] selftests/bpf: generalize helpers to control background listener

2020-05-08 Thread Martin KaFai Lau
tified by fd > > These will be used in the next commit. > > Also, extend these helpers to support AF_INET6 and accept the family > as an argument. > > v4: > * export extra helper to start server without a thread (Martin KaFai Lau) > * tcp_rtt is no longer starting backg

Re: [PATCH bpf-next v4 2/4] selftests/bpf: move existing common networking parts into network_helpers

2020-05-08 Thread Martin KaFai Lau
On Thu, May 07, 2020 at 12:12:13PM -0700, Stanislav Fomichev wrote: > 1. Move pkt_v4 and pkt_v6 into network_helpers and adjust the users. > 2. Copy-paste spin_lock_thread into two tests that use it. > > Cc: Martin KaFai Lau > Signed-off-by: Stanislav Fomichev Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next 02/17] bpf: Introduce SK_LOOKUP program type with a dedicated attach point

2020-05-08 Thread Martin KaFai Lau
On Wed, May 06, 2020 at 02:54:58PM +0200, Jakub Sitnicki wrote: > Add a new program type BPF_PROG_TYPE_SK_LOOKUP and a dedicated attach type > called BPF_SK_LOOKUP. The new program kind is to be invoked by the > transport layer when looking up a socket for a received packet. > > When called, SK_LO

Re: [PATCH bpf-next 02/17] bpf: Introduce SK_LOOKUP program type with a dedicated attach point

2020-05-07 Thread Martin KaFai Lau
On Wed, May 06, 2020 at 03:53:35PM +0200, Jakub Sitnicki wrote: > On Wed, May 06, 2020 at 03:16 PM CEST, Lorenz Bauer wrote: > > On Wed, 6 May 2020 at 13:55, Jakub Sitnicki wrote: > > [...] > > >> @@ -4012,4 +4051,18 @@ struct bpf_pidns_info { > >> __u32 pid; > >> __u32 tgid; > >

Re: [PATCH bpf-next v3 5/5] bpf: allow any port in bpf_bind helper

2020-05-06 Thread Martin KaFai Lau
nd flag > to indicate that the call site is BPF program. > > v3: > * More bpf_bind documentation refinements (Martin KaFai Lau) > * Add UDP tests as well (Martin KaFai Lau) > * Don't start the thread, just do socket+bind+listen (Martin KaFai Lau) > > v2: > * Update d

Re: [PATCH bpf-next v3 4/5] net: refactor arguments of inet{,6}_bind

2020-05-06 Thread Martin KaFai Lau
ges. > > Cc: Andrey Ignatov > Cc: Martin KaFai Lau > Signed-off-by: Stanislav Fomichev Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v3 3/5] selftests/bpf: move existing common networking parts into network_helpers

2020-05-06 Thread Martin KaFai Lau
On Wed, May 06, 2020 at 03:32:08PM -0700, Stanislav Fomichev wrote: > 1. Move pkt_v4 and pkt_v6 into network_helpers and adjust the users. > 2. Copy-paste spin_lock_thread into two tests that use it. Instead of copying it into two tests, can spin_lock_thread be moved to network-helpers.c?

Re: [PATCH bpf-next v3 1/5] selftests/bpf: generalize helpers to control background listener

2020-05-06 Thread Martin KaFai Lau
p the thread > * connect_to_fd - connect to the server identified by fd > > These will be used in the next commit. > > Also, extend these helpers to support AF_INET6 and accept the family > as an argument. > > v3: > * export extra helper to start server without a thr

Re: [PATCH v2] bpf, i386: remove unneeded conversion to bool

2020-05-06 Thread Martin KaFai Lau
On Wed, May 06, 2020 at 10:03:52PM +0800, Jason Yan wrote: > The '==' expression itself is bool, no need to convert it to bool again. > This fixes the following coccicheck warning: Make sense. It may belong to bpf-next instead. Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v2 4/5] bpf: allow any port in bpf_bind helper

2020-05-06 Thread Martin KaFai Lau
On Wed, May 06, 2020 at 09:22:45AM -0700, s...@google.com wrote: > On 05/05, Martin KaFai Lau wrote: > > On Tue, May 05, 2020 at 01:27:29PM -0700, Stanislav Fomichev wrote: > > > We want to have a tighter control on what ports we bind to in > > > the BPF_CGROUP_INET{4,

Re: [PATCH bpf-next v2 1/5] selftests/bpf: generalize helpers to control background listener

2020-05-06 Thread Martin KaFai Lau
On Wed, May 06, 2020 at 09:28:02AM -0700, s...@google.com wrote: > On 05/06, Martin KaFai Lau wrote: > > On Tue, May 05, 2020 at 01:27:26PM -0700, Stanislav Fomichev wrote: > > > Move the following routines that let us start a background listener > > > thread and conne

Re: [PATCH bpf-next v2 1/5] selftests/bpf: generalize helpers to control background listener

2020-05-06 Thread Martin KaFai Lau
On Tue, May 05, 2020 at 01:27:26PM -0700, Stanislav Fomichev wrote: > Move the following routines that let us start a background listener > thread and connect to a server by fd to the test_prog: > * start_server_thread - start background INADDR_ANY thread > * stop_server_thread - stop the thread >

Re: [PATCH bpf-next v2 4/5] bpf: allow any port in bpf_bind helper

2020-05-05 Thread Martin KaFai Lau
On Tue, May 05, 2020 at 01:27:29PM -0700, Stanislav Fomichev wrote: > We want to have a tighter control on what ports we bind to in > the BPF_CGROUP_INET{4,6}_CONNECT hooks even if it means > connect() becomes slightly more expensive. The expensive part > comes from the fact that we now need to cal

Re: [PATCH 2/2] bpf: sockmap, bpf_tcp_ingress needs to subtract bytes from sg.size

2020-05-05 Thread Martin KaFai Lau
_elem+0xdd/0x120 > [ 173.700060] kasan_report+0x32/0x50 > [ 173.700070] sk_msg_free_elem+0xdd/0x120 > [ 173.700080] __sk_msg_free+0x87/0x150 > [ 173.700094] tcp_bpf_send_verdict+0x179/0x4f0 > [ 173.700109] tcp_bpf_sendpage+0x3ce/0x5d0 > > Fixes: 604326b41a6fb ("bpf, sockmap: convert to generic sk_msg interface") > Signed-off-by: John Fastabend Acked-by: Martin KaFai Lau

Re: [PATCH 1/2] bpf: sockmap, msg_pop_data can incorrecty set an sge length

2020-05-05 Thread Martin KaFai Lau
this. > > Fixes: 7246d8ed4dcce ("bpf: helper to pop data from messages") > Signed-off-by: John Fastabend Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next 3/4] net: refactor arguments of inet{,6}_bind

2020-05-05 Thread Martin KaFai Lau
On Mon, May 04, 2020 at 10:34:29AM -0700, Stanislav Fomichev wrote: > The intent is to add an additional bind parameter in the next commit. > Instead of adding another argument, let's convert all existing > flag arguments into an extendable bit field. > > No functional changes. > > Cc: Andrey Ign

Re: [PATCH] sysctl: fix unused function warning

2020-05-05 Thread Martin KaFai Lau
27;bpf_stats_handler' > [-Werror,-Wunused-function] > static int bpf_stats_handler(struct ctl_table *table, int write, > > Fix the check to match the reference. > > Fixes: d46edd671a14 ("bpf: Sharing bpf runtime stats with BPF_ENABLE_STATS") > Signed-off-by: Arnd Bergmann Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next] selftests/bpf: use reno instead of dctcp

2020-05-01 Thread Martin KaFai Lau
On Fri, May 01, 2020 at 03:43:20PM -0700, Stanislav Fomichev wrote: > Andrey pointed out that we can use reno instead of dctcp for CC > tests and drop CONFIG_TCP_CONG_DCTCP=y requirement. Acked-by: Martin KaFai Lau

Re: [PATCH v2 bpf-next] bpf: fix use-after-free of bpf_link when priming half-fails

2020-05-01 Thread Martin KaFai Lau
file. Adding ID to > link_idr is ok, because link at that point still doesn't have its ID set, so > no user-space process can create a new FD for it. Acked-by: Martin KaFai Lau

Re: [Potential Spoof] [PATCH bpf-next] bpf: fix use-after-free of bpf_link when priming half-fails

2020-05-01 Thread Martin KaFai Lau
On Thu, Apr 30, 2020 at 11:32:59PM -0700, Andrii Nakryiko wrote: > On Thu, Apr 30, 2020 at 11:25 PM Martin KaFai Lau wrote: > > > > On Thu, Apr 30, 2020 at 12:46:08PM -0700, Andrii Nakryiko wrote: > > > If bpf_link_prime() succeeds to allocate new anon file, but then fa

Re: [Potential Spoof] [PATCH bpf-next] bpf: fix use-after-free of bpf_link when priming half-fails

2020-04-30 Thread Martin KaFai Lau
On Thu, Apr 30, 2020 at 12:46:08PM -0700, Andrii Nakryiko wrote: > If bpf_link_prime() succeeds to allocate new anon file, but then fails to > allocate ID for it, link priming is considered to be failed and user is > supposed ot be able to directly kfree() bpf_link, because it was never exposed > t

Re: [PATCH bpf-next v3] bpf: bpf_{g,s}etsockopt for struct bpf_sock_addr

2020-04-30 Thread Martin KaFai Lau
> v3: > * Expose custom helpers for bpf_sock_addr context instead of doing > generic bpf_sock argument (as suggested by Daniel). Even with > try_socket_lock that doesn't sleep we have a problem where context sk > is already locked and socket lock is non-nestable. Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v1 07/19] bpf: create anonymous bpf iterator

2020-04-29 Thread Martin KaFai Lau
On Wed, Apr 29, 2020 at 12:20:05PM -0700, Yonghong Song wrote: > > > On 4/29/20 11:46 AM, Martin KaFai Lau wrote: > > On Wed, Apr 29, 2020 at 11:16:35AM -0700, Andrii Nakryiko wrote: > > > On Wed, Apr 29, 2020 at 12:07 AM Yonghong Song wrote: > > > > > &

Re: [PATCH bpf-next v1 07/19] bpf: create anonymous bpf iterator

2020-04-29 Thread Martin KaFai Lau
On Wed, Apr 29, 2020 at 11:16:35AM -0700, Andrii Nakryiko wrote: > On Wed, Apr 29, 2020 at 12:07 AM Yonghong Song wrote: > > > > > > > > On 4/28/20 11:56 PM, Andrii Nakryiko wrote: > > > On Mon, Apr 27, 2020 at 1:19 PM Yonghong Song wrote: > > >> > > >> A new bpf command BPF_ITER_CREATE is added.

Re: [PATCH bpf-next] bpf: bpf_{g,s}etsockopt for struct bpf_sock

2020-04-29 Thread Martin KaFai Lau
On Tue, Apr 28, 2020 at 11:57:19AM -0700, Stanislav Fomichev wrote: > Currently, bpf_getsocktop and bpf_setsockopt helpers operate on the > 'struct bpf_sock_ops' context in BPF_PROG_TYPE_CGROUP_SOCKOPT program. > Let's generalize them and make the first argument be 'struct bpf_sock'. > That way, in

Re: [PATCH bpf-next v1 06/19] bpf: support bpf tracing/iter programs for BPF_LINK_UPDATE

2020-04-28 Thread Martin KaFai Lau
On Tue, Apr 28, 2020 at 11:32:15PM -0700, Andrii Nakryiko wrote: > On Tue, Apr 28, 2020 at 10:59 PM Martin KaFai Lau wrote: > > > > On Tue, Apr 28, 2020 at 10:04:54PM -0700, Yonghong Song wrote: > > > > > > > > > On 4/28/20 6:32 PM, Martin KaFai Lau wr

Re: [PATCH bpf-next v1 03/19] bpf: add bpf_map iterator

2020-04-28 Thread Martin KaFai Lau
te: > > > > On 4/28/20 6:15 PM, Yonghong Song wrote: > > > > > > > > > > > > > > > On 4/28/20 5:48 PM, Alexei Starovoitov wrote: > > > > > > On 4/28/20 5:37 PM, Martin KaFai Lau wrote: > > > > > >

Re: [PATCH bpf-next v1 06/19] bpf: support bpf tracing/iter programs for BPF_LINK_UPDATE

2020-04-28 Thread Martin KaFai Lau
On Tue, Apr 28, 2020 at 10:04:54PM -0700, Yonghong Song wrote: > > > On 4/28/20 6:32 PM, Martin KaFai Lau wrote: > > On Mon, Apr 27, 2020 at 01:12:41PM -0700, Yonghong Song wrote: > > > Added BPF_LINK_UPDATE support for tracing/iter programs. > > > This way,

Re: [PATCH bpf-next v1 07/19] bpf: create anonymous bpf iterator

2020-04-28 Thread Martin KaFai Lau
On Mon, Apr 27, 2020 at 01:12:42PM -0700, Yonghong Song wrote: > A new bpf command BPF_ITER_CREATE is added. > > The anonymous bpf iterator is seq_file based. > The seq_file private data are referenced by targets. > The bpf_iter infrastructure allocated additional space > at seq_file->private afte

Re: [PATCH bpf-next v1 06/19] bpf: support bpf tracing/iter programs for BPF_LINK_UPDATE

2020-04-28 Thread Martin KaFai Lau
On Mon, Apr 27, 2020 at 01:12:41PM -0700, Yonghong Song wrote: > Added BPF_LINK_UPDATE support for tracing/iter programs. > This way, a file based bpf iterator, which holds a reference > to the link, can have its bpf program updated without > creating new files. > > Signed-off-by: Yonghong Song >

Re: [Potential Spoof] [PATCH bpf-next v1 05/19] bpf: support bpf tracing/iter programs for BPF_LINK_CREATE

2020-04-28 Thread Martin KaFai Lau
On Mon, Apr 27, 2020 at 01:12:40PM -0700, Yonghong Song wrote: > Given a bpf program, the step to create an anonymous bpf iterator is: > - create a bpf_iter_link, which combines bpf program and the target. > In the future, there could be more information recorded in the link. > A link_fd

Re: [PATCH bpf-next v1 04/19] bpf: allow loading of a bpf_iter program

2020-04-28 Thread Martin KaFai Lau
On Mon, Apr 27, 2020 at 01:12:39PM -0700, Yonghong Song wrote: > A bpf_iter program is a tracing program with attach type > BPF_TRACE_ITER. The load attribute > attach_btf_id > is used by the verifier against a particular kernel function, > e.g., __bpf_iter__bpf_map in our previous bpf_map iterat

Re: [PATCH bpf-next v1 03/19] bpf: add bpf_map iterator

2020-04-28 Thread Martin KaFai Lau
On Mon, Apr 27, 2020 at 01:12:37PM -0700, Yonghong Song wrote: > The bpf_map iterator is implemented. > The bpf program is called at seq_ops show() and stop() functions. > bpf_iter_get_prog() will retrieve bpf program and other > parameters during seq_file object traversal. In show() function, > bp

Re: [PATCH bpf-next v1 02/19] bpf: implement an interface to register bpf_iter targets

2020-04-28 Thread Martin KaFai Lau
On Mon, Apr 27, 2020 at 01:12:36PM -0700, Yonghong Song wrote: > The target can call bpf_iter_reg_target() to register itself. > The needed information: > target: target name, reprsented as a directory hierarchy > target_func_name: the kernel func name used by verifier to >

[PATCH net] net: Unpublish sk from sk_reuseport_cb before call_rcu

2019-09-27 Thread Martin KaFai Lau
and this fix is depending on it. Fixes: a4298e4522d6 ("net: add SOCK_RCU_FREE socket flag") Cc: Eric Dumazet Suggested-by: Eric Dumazet Signed-off-by: Martin KaFai Lau --- net/core/sock.c | 11 --- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/net/core/sock.c

[PATCH bpf] bpf: Fix a race in reuseport_array_free()

2019-09-27 Thread Martin KaFai Lau
path. The lock is taken inside the loop in case that the bpf map is big. Signed-off-by: Martin KaFai Lau --- kernel/bpf/reuseport_array.c | 27 +-- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/kernel/bpf/reuseport_array.c b/kernel/bpf/reuseport_array.c

[PATCH v3 bpf-next 3/3] bpf: Add test for SO_REUSEPORT_DETACH_BPF

2019-06-13 Thread Martin KaFai Lau
This patch adds a test for the new sockopt SO_REUSEPORT_DETACH_BPF. Signed-off-by: Martin KaFai Lau --- .../selftests/bpf/test_select_reuseport.c | 54 +++ 1 file changed, 54 insertions(+) diff --git a/tools/testing/selftests/bpf/test_select_reuseport.c b/tools/testing

[PATCH v3 bpf-next 1/3] bpf: net: Add SO_DETACH_REUSEPORT_BPF

2019-06-13 Thread Martin KaFai Lau
are, it does not call reuseport_alloc() and returns -ENOENT when there is no old prog. Cc: Craig Gallek Signed-off-by: Martin KaFai Lau --- arch/alpha/include/uapi/asm/socket.h | 2 ++ arch/mips/include/uapi/asm/socket.h | 2 ++ arch/parisc/include/uapi/asm/socket.h | 2 ++ arch/sparc

[PATCH v3 bpf-next 0/3] bpf: net: Detach BPF prog from reuseport sk

2019-06-13 Thread Martin KaFai Lau
v3: - Use rcu_swap_protected (Stanislav Fomichev) - Use 0x0047 for SO_DETACH_REUSEPORT_BPF for sparc (kbuild test robot ) v2: - Copy asm-generic/socket.h to tools/ in the new patch 2 (Stanislav Fomichev) This patch adds SO_DETACH_REUSEPORT_BPF to detach BPF prog from reuseport sk. Martin KaFai

[PATCH v3 bpf-next 2/3] bpf: Sync asm-generic/socket.h to tools/

2019-06-13 Thread Martin KaFai Lau
SO_DETACH_REUSEPORT_BPF is needed for the test in the next patch. It is defined in the socket.h. Signed-off-by: Martin KaFai Lau --- tools/include/uapi/asm-generic/socket.h | 147 1 file changed, 147 insertions(+) create mode 100644 tools/include/uapi/asm-generic

[PATCH v2 bpf-next 1/3] bpf: net: Add SO_DETACH_REUSEPORT_BPF

2019-06-13 Thread Martin KaFai Lau
are, it does not call reuseport_alloc() and returns -ENOENT when there is no old prog. Cc: Craig Gallek Signed-off-by: Martin KaFai Lau --- arch/alpha/include/uapi/asm/socket.h | 2 ++ arch/mips/include/uapi/asm/socket.h | 2 ++ arch/parisc/include/uapi/asm/socket.h | 2 ++ arch/sparc

[PATCH v2 bpf-next 3/3] bpf: Add test for SO_REUSEPORT_DETACH_BPF

2019-06-13 Thread Martin KaFai Lau
This patch adds a test for the new sockopt SO_REUSEPORT_DETACH_BPF. Signed-off-by: Martin KaFai Lau --- .../selftests/bpf/test_select_reuseport.c | 54 +++ 1 file changed, 54 insertions(+) diff --git a/tools/testing/selftests/bpf/test_select_reuseport.c b/tools/testing

[PATCH v2 bpf-next 0/3] bpf: net: Detach BPF prog from reuseport sk

2019-06-13 Thread Martin KaFai Lau
v2: Copy asm-generic/socket.h to tools/ in the new patch 2 (Stanislav Fomichev) This patch adds SO_DETACH_REUSEPORT_BPF to detach BPF prog from reuseport sk. Martin KaFai Lau (3): bpf: net: Add SO_DETACH_REUSEPORT_BPF bpf: Sync asm-generic/socket.h to tools/ bpf: Add test for

[PATCH v2 bpf-next 2/3] bpf: Sync asm-generic/socket.h to tools/

2019-06-13 Thread Martin KaFai Lau
SO_DETACH_REUSEPORT_BPF is needed for the test in the next patch. It is defined in the socket.h. Signed-off-by: Martin KaFai Lau --- tools/include/uapi/asm-generic/socket.h | 147 1 file changed, 147 insertions(+) create mode 100644 tools/include/uapi/asm-generic

[PATCH bpf-next 1/2] bpf: net: Add SO_DETACH_REUSEPORT_BPF

2019-06-12 Thread Martin KaFai Lau
are, it does not call reuseport_alloc() and returns -ENOENT when there is no old prog. Cc: Craig Gallek Signed-off-by: Martin KaFai Lau --- arch/alpha/include/uapi/asm/socket.h | 2 ++ arch/mips/include/uapi/asm/socket.h | 2 ++ arch/parisc/include/uapi/asm/socket.h | 2 ++ arch/sparc

[PATCH bpf-next 2/2] bpf: Add test for SO_REUSEPORT_DETACH_BPF

2019-06-12 Thread Martin KaFai Lau
This patch adds a test for the new sockopt SO_REUSEPORT_DETACH_BPF. '-I../../../../usr/include/' is added to the Makefile to get the newly added SO_REUSEPORT_DETACH_BPF. Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/Makefile | 1 + .../sel

[PATCH bpf-next 0/2] bpf: net: Detach BPF prog from reuseport sk

2019-06-12 Thread Martin KaFai Lau
This patch adds SO_DETACH_REUSEPORT_BPF to detach BPF prog from reuseport sk. Martin KaFai Lau (2): bpf: net: Add SO_DETACH_REUSEPORT_BPF bpf: Add test for SO_REUSEPORT_DETACH_BPF arch/alpha/include/uapi/asm/socket.h | 2 + arch/mips/include/uapi/asm/socket.h | 2

[PATCH bpf] bpf: net: Set sk_bpf_storage back to NULL for cloned sk

2019-06-11 Thread Martin KaFai Lau
The cloned sk should not carry its parent-listener's sk_bpf_storage. This patch fixes it by setting it back to NULL. Fixes: 6ac99e8f23d4 ("bpf: Introduce bpf sk local storage") Signed-off-by: Martin KaFai Lau --- net/core/sock.c | 3 +++ 1 file changed, 3 insertions(+) diff -

[PATCH bpf 0/2] bpf: udp: A few reuseport's bpf_prog for udp lookup

2019-05-31 Thread Martin KaFai Lau
ic to running bpf_prog, so bpf tag is used for this series. Please refer to the individual commit message for details. Martin KaFai Lau (2): bpf: udp: ipv6: Avoid running reuseport's bpf_prog from __udp6_lib_err bpf: udp: Avoid calling reuseport's bpf_prog from udp_gro net/ipv4/udp

[PATCH bpf 1/2] bpf: udp: ipv6: Avoid running reuseport's bpf_prog from __udp6_lib_err

2019-05-31 Thread Martin KaFai Lau
PF") Cc: Craig Gallek Signed-off-by: Martin KaFai Lau --- net/ipv6/udp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 07fa579dfb96..133e6370f89c 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -515,7 +515,7 @@ int __udp6_l

[PATCH bpf 2/2] bpf: udp: Avoid calling reuseport's bpf_prog from udp_gro

2019-05-31 Thread Martin KaFai Lau
ng a NULL skb to avoid calling the reuseport's bpf_prog. Fixes: a6024562ffd7 ("udp: Add GRO functions to UDP socket") Cc: Tom Herbert Signed-off-by: Martin KaFai Lau --- net/ipv4/udp.c | 6 +- net/ipv6/udp.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git

[PATCH bpf] bpf: Check sk_fullsock() before returning from bpf_sk_lookup()

2019-05-17 Thread Martin KaFai Lau
alled if needed and then returns NULL. Fixes: 6acc9b432e67 ("bpf: Add helper to retrieve socket in BPF") Cc: Joe Stringer Signed-off-by: Martin KaFai Lau --- net/core/filter.c | 16 ++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/net/core/filter.c b/ne

[PATCH net] ipv6: A few fixes on dereferencing rt->from

2019-04-30 Thread Martin KaFai Lau
uot;net/ipv6: Make from in rt6_info rcu protected") Signed-off-by: Martin KaFai Lau --- net/ipv6/route.c | 38 ++ 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index b4899f0de0d0..73ef72c208af 100644 ---

[PATCH v4 bpf-next 7/7] bpf: Add ene-to-end test for bpf_sk_storage_* helpers

2019-04-26 Thread Martin KaFai Lau
This patch rides on an existing BPF_PROG_TYPE_CGROUP_SKB test (test_sock_fields.c) to do a TCP end-to-end test on the new bpf_sk_storage_* helpers. Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/bpf_helpers.h | 5 + .../bpf/progs/test_sock_fields_kern.c | 53

[PATCH v4 bpf-next 5/7] bpf: Add verifier tests for the bpf_sk_storage

2019-04-26 Thread Martin KaFai Lau
: Yonghong Song Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/test_verifier.c | 55 ++ tools/testing/selftests/bpf/verifier/sock.c | 116 2 files changed, 152 insertions(+), 19 deletions(-) diff --git a/tools/testing/selftests/bpf/test_verifier.

[PATCH v4 bpf-next 4/7] bpf: Refactor BTF encoding macro to test_btf.h

2019-04-26 Thread Martin KaFai Lau
Refactor common BTF encoding macros for other tests to use. The libbpf may reuse some of them in the future which requires some more thoughts before publishing as a libbpf API. Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/test_btf.c | 63 +-- tools

[PATCH v4 bpf-next 0/7] BPF sk local storage

2019-04-26 Thread Martin KaFai Lau
in patch 1 (kbuild test robot ) v2: - Add the "test_maps.h" file in patch 5 This series introduces the BPF sk local storage. The details is in the patch 1 commit message. Martin KaFai Lau (7): bpf: Introduce bpf sk local storage bpf: Sync bpf.h to tools bp

[PATCH v4 bpf-next 6/7] bpf: Add BPF_MAP_TYPE_SK_STORAGE test to test_maps

2019-04-26 Thread Martin KaFai Lau
This patch adds BPF_MAP_TYPE_SK_STORAGE test to test_maps. The src file is rather long, so it is put into another dir map_tests/ and compile like the current prog_tests/ does. Other existing tests in test_maps can also be re-factored into map_tests/ in the future. Signed-off-by: Martin KaFai Lau

[PATCH v4 bpf-next 1/7] bpf: Introduce bpf sk local storage

2019-04-26 Thread Martin KaFai Lau
│ list ├───▶│map_node│ │ │ │└┘ │ │ ││ │ │ elem │ └─┘┌┐ │ ┌─▶│ snode │ │ │ ├┤ │ │ │ data │ │ │ ├┤ │ │ │map_node│◀─┘ │ └────┘

[PATCH v4 bpf-next 3/7] bpf: Support BPF_MAP_TYPE_SK_STORAGE in bpf map probing

2019-04-26 Thread Martin KaFai Lau
This patch supports probing for the new BPF_MAP_TYPE_SK_STORAGE. BPF_MAP_TYPE_SK_STORAGE enforces BTF usage, so the new probe requires to create and load a BTF also. Signed-off-by: Martin KaFai Lau --- tools/bpf/bpftool/map.c | 1 + tools/lib/bpf/libbpf_probes.c | 74

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

2019-04-26 Thread Martin KaFai Lau
This patch sync the bpf.h to tools/. Signed-off-by: Martin KaFai Lau --- tools/include/uapi/linux/bpf.h | 44 +- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 704bb69514a2

[PATCH v3 bpf-next 3/6] bpf: Support BPF_MAP_TYPE_SK_STORAGE in bpf map probing

2019-04-26 Thread Martin KaFai Lau
This patch supports probing for the new BPF_MAP_TYPE_SK_STORAGE. BPF_MAP_TYPE_SK_STORAGE enforces BTF usage, so the new probe requires to create and load a BTF also. Signed-off-by: Martin KaFai Lau --- tools/bpf/bpftool/map.c | 1 + tools/lib/bpf/libbpf_probes.c | 74

[PATCH v3 bpf-next 1/6] bpf: Introduce bpf sk local storage

2019-04-26 Thread Martin KaFai Lau
lem │ └─┘┌┐ │ ┌─▶│ snode │ │ │ ├┤ │ │ │ data │ │ │ ├┤ │ │ │map_node│◀─┘ │ └┘ │ │ │ ┌───

[PATCH v3 bpf-next 5/6] bpf: Add BPF_MAP_TYPE_SK_STORAGE test to test_maps

2019-04-26 Thread Martin KaFai Lau
This patch adds BPF_MAP_TYPE_SK_STORAGE test to test_maps. The src file is rather long, so it is put into another dir map_tests/ and compile like the current prog_tests/ does. Other existing tests in test_maps can also be re-factored into map_tests/ in the future. Signed-off-by: Martin KaFai Lau

[PATCH v3 bpf-next 0/6] BPF sk local storage

2019-04-26 Thread Martin KaFai Lau
v3: - Replace spinlock_types.h with spinlock.h in patch 1 (kbuild test robot ) v2: - Add the "test_maps.h" file in patch 5 This series introduces the BPF sk local storage. The details is in the patch 1 commit message. Martin KaFai Lau (6): bpf: Introduce bpf sk local storage

[PATCH v3 bpf-next 2/6] bpf: Sync bpf.h to tools

2019-04-26 Thread Martin KaFai Lau
This patch sync the bpf.h to tools/. Signed-off-by: Martin KaFai Lau --- tools/include/uapi/linux/bpf.h | 44 +- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 704bb69514a2

[PATCH v3 bpf-next 4/6] bpf: Add verifier tests for the bpf_sk_storage

2019-04-26 Thread Martin KaFai Lau
This patch adds verifier tests for the bpf_sk_storage: 1. ARG_PTR_TO_MAP_VALUE_OR_NULL 2. Map and helper compatibility (e.g. disallow bpf_map_loookup_elem) It also takes this chance to remove the unused struct btf_raw_data. Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf

[PATCH v3 bpf-next 6/6] bpf: Add ene-to-end test for bpf_sk_storage_* helpers

2019-04-26 Thread Martin KaFai Lau
This patch rides on an existing BPF_PROG_TYPE_CGROUP_SKB test (test_sock_fields.c) to do a TCP end-to-end test on the new bpf_sk_storage_* helpers. Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/bpf_helpers.h | 5 + .../bpf/progs/test_sock_fields_kern.c | 49

[PATCH v2 bpf-next 3/6] bpf: Support BPF_MAP_TYPE_SK_STORAGE in bpf map probing

2019-04-25 Thread Martin KaFai Lau
This patch supports probing for the new BPF_MAP_TYPE_SK_STORAGE. BPF_MAP_TYPE_SK_STORAGE enforces BTF usage, so the new probe requires to create and load a BTF also. Signed-off-by: Martin KaFai Lau --- tools/bpf/bpftool/map.c | 1 + tools/lib/bpf/libbpf_probes.c | 74

[PATCH v2 bpf-next 2/6] bpf: Sync bpf.h to tools

2019-04-25 Thread Martin KaFai Lau
This patch sync the bpf.h to tools/. Signed-off-by: Martin KaFai Lau --- tools/include/uapi/linux/bpf.h | 44 +- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 704bb69514a2

[PATCH v2 bpf-next 1/6] bpf: Introduce bpf sk local storage

2019-04-25 Thread Martin KaFai Lau
| elem | +-+++ | +->| snode | | | ++ | | | data | | | ++ | | |map_node|<-+ | +----+ | |

[PATCH v2 bpf-next 4/6] bpf: Add verifier tests for the bpf_sk_storage

2019-04-25 Thread Martin KaFai Lau
This patch adds verifier tests for the bpf_sk_storage: 1. ARG_PTR_TO_MAP_VALUE_OR_NULL 2. Map and helper compatibility (e.g. disallow bpf_map_loookup_elem) It also takes this chance to remove the unused struct btf_raw_data. Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf

[PATCH v2 bpf-next 6/6] bpf: Add ene-to-end test for bpf_sk_storage_* helpers

2019-04-25 Thread Martin KaFai Lau
This patch rides on an existing BPF_PROG_TYPE_CGROUP_SKB test (test_sock_fields.c) to do a TCP end-to-end test on the new bpf_sk_storage_* helpers. Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/bpf_helpers.h | 5 + .../bpf/progs/test_sock_fields_kern.c | 49

[PATCH v2 bpf-next 5/6] bpf: Add BPF_MAP_TYPE_SK_STORAGE test to test_maps

2019-04-25 Thread Martin KaFai Lau
This patch adds BPF_MAP_TYPE_SK_STORAGE test to test_maps. The src file is rather long, so it is put into another dir map_tests/ and compile like the current prog_tests/ does. Other existing tests in test_maps can also be re-factored into map_tests/ in the future. Signed-off-by: Martin KaFai Lau

[PATCH v2 bpf-next 0/6] BPF sk local storage

2019-04-25 Thread Martin KaFai Lau
v2: - Add the "test_maps.h" file in patch 5 This series introduces the BPF sk local storage. The details is in the patch 1 commit message. Martin KaFai Lau (6): bpf: Introduce bpf sk local storage bpf: Sync bpf.h to tools bpf: Support BPF_MAP_TYPE_SK_STORAGE in bpf map probing

[PATCH bpf-next 6/6] bpf: Add ene-to-end test for bpf_sk_storage_* helpers

2019-04-24 Thread Martin KaFai Lau
This patch rides on an existing BPF_PROG_TYPE_CGROUP_SKB test (test_sock_fields.c) to do a TCP end-to-end test on the new bpf_sk_storage_* helpers. Signed-off-by: Martin KaFai Lau --- tools/testing/selftests/bpf/bpf_helpers.h | 5 + .../bpf/progs/test_sock_fields_kern.c | 49

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