Re: [PATCH bpf v4] xdp: Handle device unregister for devmap_hash map type

2019-10-21 Thread Martin Lau
On Sat, Oct 19, 2019 at 01:19:31PM +0200, Toke Høiland-Jørgensen wrote: > It seems I forgot to add handling of devmap_hash type maps to the device > unregister hook for devmaps. This omission causes devices to not be > properly released, which causes hangs. > > Fix this by adding the missing handl

Re: [PATCH bpf v3] xdp: Handle device unregister for devmap_hash map type

2019-10-18 Thread Martin Lau
On Fri, Oct 18, 2019 at 09:44:18PM +0200, Toke Høiland-Jørgensen wrote: > It seems I forgot to add handling of devmap_hash type maps to the device > unregister hook for devmaps. This omission causes devices to not be > properly released, which causes hangs. > > Fix this by adding the missing handl

Re: [PATCH bpf v2] xdp: Handle device unregister for devmap_hash map type

2019-10-18 Thread Martin Lau
On Fri, Oct 18, 2019 at 12:26:55PM +0200, Toke Høiland-Jørgensen wrote: > Martin Lau writes: > > > On Thu, Oct 17, 2019 at 12:52:32PM +0200, Toke Høiland-Jørgensen wrote: > >> It seems I forgot to add handling of devmap_hash type maps to the device > >> unregister h

Re: [PATCH bpf v2] xdp: Handle device unregister for devmap_hash map type

2019-10-17 Thread Martin Lau
On Thu, Oct 17, 2019 at 12:52:32PM +0200, Toke Høiland-Jørgensen wrote: > It seems I forgot to add handling of devmap_hash type maps to the device > unregister hook for devmaps. This omission causes devices to not be > properly released, which causes hangs. > > Fix this by adding the missing handl

Re: [PATCH bpf-next] selftests/bpf: Restore the netns after flow dissector reattach test

2019-10-17 Thread Martin Lau
On Thu, Oct 17, 2019 at 10:37:52AM +0200, Jakub Sitnicki wrote: > flow_dissector_reattach test changes the netns we run in but does not > restore it to the one we started in when finished. This interferes with > tests that run after it. Fix it by restoring the netns when done. > > Fixes: f97eea175

Re: [PATCH v3 bpf-next 00/11] bpf: revolutionize bpf tracing

2019-10-16 Thread Martin Lau
On Tue, Oct 15, 2019 at 08:24:54PM -0700, Alexei Starovoitov wrote: > The end result is safer and faster bpf tracing. > Safer - because type safe direct load can be used most of the time > instead of bpf_probe_read(). > Faster - because direct loads are used to walk kernel data structures > instead

Re: [PATCH bpf] xdp: Handle device unregister for devmap_hash map type

2019-10-16 Thread Martin Lau
On Wed, Oct 16, 2019 at 03:28:02PM +0200, Toke Høiland-Jørgensen wrote: > It seems I forgot to add handling of devmap_hash type maps to the device > unregister hook for devmaps. This omission causes devices to not be > properly released, which causes hangs. > > Fix this by adding the missing handl

Re: Race condition in route lookup

2019-10-15 Thread Martin Lau
On Tue, Oct 15, 2019 at 09:44:11AM -0700, Wei Wang wrote: > On Tue, Oct 15, 2019 at 7:29 AM Jesse Hathaway wrote: > > > > On Fri, Oct 11, 2019 at 12:54 PM Wei Wang wrote: > > > Hmm... Yes... I would think a per-CPU input cache should work for the > > > case above. > > > Another idea is: instead o

Re: Race condition in route lookup

2019-10-15 Thread Martin Lau
On Tue, Oct 15, 2019 at 09:42:49AM -0700, Wei Wang wrote: > On Tue, Oct 15, 2019 at 7:45 AM David Ahern wrote: > > > > On 10/14/19 1:26 PM, Martin Lau wrote: > > > > > > AFAICT, even for the route that are affected by > > > fib6_update_sernum_upto_root(

Re: [PATCH bpf-next 2/2] selftests: bpf: add selftest for __sk_buff tstamp

2019-10-15 Thread Martin Lau
On Tue, Oct 15, 2019 at 11:31:25AM -0700, Stanislav Fomichev wrote: > Make sure BPF_PROG_TEST_RUN accepts tstamp and exports any > modifications that BPF program does. Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next 1/2] bpf: allow __sk_buff tstamp in BPF_PROG_TEST_RUN

2019-10-15 Thread Martin Lau
On Tue, Oct 15, 2019 at 11:31:24AM -0700, Stanislav Fomichev wrote: > It's useful for implementing EDT related tests (set tstamp, run the > test, see how the tstamp is changed or observe some other parameter). > > Note that bpf_ktime_get_ns() helper is using monotonic clock, so for > the BPF progr

Re: Race condition in route lookup

2019-10-14 Thread Martin Lau
On Sun, Oct 13, 2019 at 05:23:01PM -0700, Wei Wang wrote: > On Fri, Oct 11, 2019 at 11:56 PM Martin Lau wrote: > > > > On Fri, Oct 11, 2019 at 10:54:13AM -0700, Wei Wang wrote: > > > On Fri, Oct 11, 2019 at 8:42 AM Ido Schimmel wrote: > > > > > > &g

Re: [Potential Spoof] [PATCH v2 bpf-next 0/2] selftests/bpf Makefile cleanup and fixes

2019-10-12 Thread Martin Lau
On Fri, Oct 11, 2019 at 03:01:44PM -0700, Andrii Nakryiko wrote: > Patch #1 enforces libbpf build to have bpf_helper_defs.h ready before test BPF > programs are built. > Patch #2 drops obsolete BTF/pahole detection logic from Makefile. Acked-by: Martin KaFai Lau

Re: Race condition in route lookup

2019-10-11 Thread Martin Lau
On Fri, Oct 11, 2019 at 10:54:13AM -0700, Wei Wang wrote: > On Fri, Oct 11, 2019 at 8:42 AM Ido Schimmel wrote: > > > > On Fri, Oct 11, 2019 at 09:36:51AM -0500, Jesse Hathaway wrote: > > > On Thu, Oct 10, 2019 at 3:31 AM Ido Schimmel wrote: > > > > I think it's working as expected. Here is my th

Re: [PATCH bpf-next 1/2] selftests/bpf: enforce libbpf build before BPF programs are built

2019-10-11 Thread Martin Lau
On Thu, Oct 10, 2019 at 08:13:17PM -0700, Andrii Nakryiko wrote: > Given BPF programs rely on libbpf's bpf_helper_defs.h, which is > auto-generated during libbpf build, libbpf build has to happen before > we attempt progs/*.c build. Enforce it as order-only dependency. Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next 3/3] bpftool: print the comm of the process that loaded the program

2019-10-11 Thread Martin Lau
On Fri, Oct 11, 2019 at 09:21:24AM -0700, Stanislav Fomichev wrote: > Print recently added created_by_comm along the existing created_by_uid. > > Example with loop1.o (loaded via bpftool): > 4: raw_tracepoint name nested_loops tag b9472b3ff5753ef2 gpl > loaded_at 2019-10-10T13:38:18-070

Re: [Potential Spoof] [PATCH bpf-next 2/2] selftests/bpf: remove obsolete pahole/BTF support detection

2019-10-11 Thread Martin Lau
On Thu, Oct 10, 2019 at 08:13:18PM -0700, Andrii Nakryiko wrote: > Given lots of selftests won't work without recent enough Clang/LLVM that > fully supports BTF, there is no point in maintaining outdated BTF > support detection and fall-back to pahole logic. Just assume we have > everything we need

Re: [PATCH bpf-next] libbpf: handle invalid typedef emitted by old GCC

2019-10-11 Thread Martin Lau
On Thu, Oct 10, 2019 at 08:29:01PM -0700, Andrii Nakryiko wrote: > Old GCC versions are producing invalid typedef for __gnuc_va_list > pointing to void. Special-case this and emit valid: > > typedef __builtin_va_list __gnuc_va_list; Acked-by: Martin KaFai Lau

Re: [Potential Spoof] [PATCH bpf-next] bpf: fix cast to pointer from integer of different size warning

2019-10-10 Thread Martin Lau
On Thu, Oct 10, 2019 at 09:29:25PM -0700, Andrii Nakryiko wrote: > Fix "warning: cast to pointer from integer of different size" when > casting u64 addr to void *. > > Reported-by: kbuild test robot > Signed-off-by: Andrii Nakryiko Fixes: a23740ec43ba ("bpf: Track contents of read-only maps as s

Re: [PATCH bpf-next v2 2/2] selftests/bpf: Check that flow dissector can be re-attached

2019-10-10 Thread Martin Lau
On Thu, Oct 10, 2019 at 08:17:50PM +0200, Jakub Sitnicki wrote: > Make sure a new flow dissector program can be attached to replace the old > one with a single syscall. Also check that attaching the same program twice > is prohibited. > > Signed-off-by: Jakub Sitnicki Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v2 1/2] flow_dissector: Allow updating the flow dissector program atomically

2019-10-10 Thread Martin Lau
On Thu, Oct 10, 2019 at 08:17:49PM +0200, Jakub Sitnicki wrote: > It is currently not possible to detach the flow dissector program and > attach a new one in an atomic fashion, that is with a single syscall. > Attempts to do so will be met with EEXIST error. > > This makes updates to flow dissecto

Re: [PATCH bpf-next 03/10] bpf: process in-kernel BTF

2019-10-09 Thread Martin Lau
On Fri, Oct 04, 2019 at 10:03:07PM -0700, Alexei Starovoitov wrote: > If in-kernel BTF exists parse it and prepare 'struct btf *btf_vmlinux' > for further use by the verifier. > In-kernel BTF is trusted just like kallsyms and other build artifacts > embedded into vmlinux. > Yet run this BTF image t

Re: [PATCH bpf-next 1/2] bpf: track contents of read-only maps as scalars

2019-10-08 Thread Martin Lau
On Tue, Oct 08, 2019 at 04:49:30PM -0700, Andrii Nakryiko wrote: > On Tue, Oct 8, 2019 at 2:53 PM Martin Lau wrote: > > > > On Tue, Oct 08, 2019 at 12:45:47PM -0700, Andrii Nakryiko wrote: > > > Maps that are read-only both from BPF program side and user space side &

Re: [PATCH bpf-next 1/2] bpf: track contents of read-only maps as scalars

2019-10-08 Thread Martin Lau
On Tue, Oct 08, 2019 at 12:45:47PM -0700, Andrii Nakryiko wrote: > Maps that are read-only both from BPF program side and user space side > have their contents constant, so verifier can track referenced values > precisely and use that knowledge for dead code elimination, branch > pruning, etc. This

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

2019-09-27 Thread Martin Lau
On Fri, Sep 27, 2019 at 01:47:32PM -0700, Eric Dumazet wrote: > > > On 9/27/19 11:17 AM, Martin Lau wrote: > > On Fri, Sep 27, 2019 at 10:24:49AM -0700, Eric Dumazet wrote: > >> > >> > >> On 9/27/19 9:52 AM, Martin KaFai Lau wrote: > >>>

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

2019-09-27 Thread Martin Lau
On Fri, Sep 27, 2019 at 10:24:49AM -0700, Eric Dumazet wrote: > > > On 9/27/19 9:52 AM, Martin KaFai Lau wrote: > > In reuseport_array_free(), the rcu_read_lock() cannot ensure sk is still > > valid. It is because bpf_sk_reuseport_detach() can be called from > > __sk_destruct() which is invoked

Re: [PATCH bpf-next v3 2/4] bpf: support cloning sk storage on accept()

2019-08-14 Thread Martin Lau
On Tue, Aug 13, 2019 at 09:26:28AM -0700, Stanislav Fomichev wrote: > Add new helper bpf_sk_storage_clone which optionally clones sk storage > and call it from sk_clone_lock. Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v2 2/4] bpf: support cloning sk storage on accept()

2019-08-12 Thread Martin Lau
On Fri, Aug 09, 2019 at 09:10:36AM -0700, Stanislav Fomichev wrote: > Add new helper bpf_sk_storage_clone which optionally clones sk storage > and call it from sk_clone_lock. Thanks for v2. Sorry for the delay. I am traveling. > > Cc: Martin KaFai Lau > Cc: Yonghong Song > Signed-off-by: Stan

Re: [PATCH bpf-next 1/3] bpf: support cloning sk storage on accept()

2019-08-08 Thread Martin Lau
On Thu, Aug 08, 2019 at 08:28:30AM -0700, Stanislav Fomichev wrote: > On 08/08, Martin Lau wrote: > > On Wed, Aug 07, 2019 at 08:47:18AM -0700, Stanislav Fomichev wrote: > > > Add new helper bpf_sk_storage_clone which optionally clones sk storage > > > and call it from

Re: [PATCH bpf-next 1/3] bpf: support cloning sk storage on accept()

2019-08-08 Thread Martin Lau
On Wed, Aug 07, 2019 at 05:05:33PM -0700, Stanislav Fomichev wrote: [ ... ] > > > +int bpf_sk_storage_clone(const struct sock *sk, struct sock *newsk) > > > +{ > > > + struct bpf_sk_storage *new_sk_storage = NULL; > > > + struct bpf_sk_storage *sk_storage; > > > + struct bpf_sk_storage_elem *selem;

Re: [PATCH bpf-next 1/3] bpf: support cloning sk storage on accept()

2019-08-07 Thread Martin Lau
On Wed, Aug 07, 2019 at 08:47:18AM -0700, Stanislav Fomichev wrote: > Add new helper bpf_sk_storage_clone which optionally clones sk storage > and call it from bpf_sk_storage_clone. Reuse the gap in > bpf_sk_storage_elem to store clone/non-clone flag. > > Cc: Martin KaFai Lau > Signed-off-by: Sta

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

2019-07-15 Thread Martin Lau
On Tue, Jul 09, 2019 at 09:33:21AM -0700, Stanislav Fomichev wrote: > On 06/11, Martin KaFai Lau wrote: > > The cloned sk should not carry its parent-listener's sk_bpf_storage. > > This patch fixes it by setting it back to NULL. > Have you thought about some kind of inheritance for listener sockets

Re: [PATCH v3 bpf 1/3] bpf: fix BTF verifier size resolution logic

2019-07-12 Thread Martin Lau
On Fri, Jul 12, 2019 at 10:25:55AM -0700, Andrii Nakryiko wrote: > BTF verifier has a size resolution bug which in some circumstances leads to > invalid size resolution for, e.g., TYPEDEF modifier. This happens if we have > [1] PTR -> [2] TYPEDEF -> [3] ARRAY, in which case due to being in pointer

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

2019-06-13 Thread Martin Lau
On Thu, Jun 13, 2019 at 01:14:46PM -0700, Andrii Nakryiko wrote: > On Wed, Jun 12, 2019 at 12:08 PM Martin KaFai Lau wrote: > > > > There is SO_ATTACH_REUSEPORT_[CE]BPF but there is no DETACH. > > This patch adds SO_DETACH_REUSEPORT_BPF sockopt. The same > > sockopt can be used to undo both SO_AT

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

2019-06-13 Thread Martin Lau
On Wed, Jun 12, 2019 at 12:59:17PM -0700, Stanislav Fomichev wrote: > On 06/12, Martin KaFai Lau wrote: > > 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. > > > >

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

2019-06-13 Thread Martin Lau
On Wed, Jun 12, 2019 at 12:59:17PM -0700, Stanislav Fomichev wrote: > On 06/12, Martin KaFai Lau wrote: > > 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. > > > >

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

2019-06-13 Thread Martin Lau
On Wed, Jun 12, 2019 at 02:53:35PM -0700, Alexei Starovoitov wrote: > On 6/12/19 2:47 PM, Stanislav Fomichev wrote: > CFLAGS += -Wall -O2 -I$(APIDIR) -I$(LIBDIR) -I$(BPFDIR) -I$(GENDIR) > $(GENFLAGS) -I../../../include \ > + -I../../../../usr/include/ \ > >>> Why not copy

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

2019-06-13 Thread Martin Lau
On Wed, Jun 12, 2019 at 03:25:47PM -0700, Alexei Starovoitov wrote: > On 6/12/19 3:15 PM, Martin Lau wrote: > > On Wed, Jun 12, 2019 at 02:53:35PM -0700, Alexei Starovoitov wrote: > >> On 6/12/19 2:47 PM, Stanislav Fomichev wrote: > >>>>>> CFLAGS += -Wall -O2

Re: [PATCH net v3 0/2] ipv6: Fix listing and flushing of cached route exceptions

2019-06-11 Thread Martin Lau
On Tue, Jun 11, 2019 at 12:47:58AM +0200, Stefano Brivio wrote: > On Mon, 10 Jun 2019 23:53:15 +0200 > Stefano Brivio wrote: > > > On Mon, 10 Jun 2019 15:38:06 -0600 > > David Ahern wrote: > > > > > in dot releases of stable trees, I think it would be better to converge > > > on consistent beha

Re: [PATCH net v3 0/2] ipv6: Fix listing and flushing of cached route exceptions

2019-06-10 Thread Martin Lau
On Mon, Jun 10, 2019 at 03:38:06PM -0600, David Ahern wrote: > The ability to list exceptions was deleted 2 years ago with 4.15. So far > no one has complained that exceptions do not show up in route dumps. > Rather than perturb the system again and worse with different behaviors, > in dot releases

Re: [PATCH bpf-next v5 0/8] bpf: getsockopt and setsockopt hooks

2019-06-10 Thread Martin Lau
On Mon, Jun 10, 2019 at 02:08:22PM -0700, Stanislav Fomichev wrote: > This series implements two new per-cgroup hooks: getsockopt and > setsockopt along with a new sockopt program type. The idea is pretty > similar to recently introduced cgroup sysctl hooks, but > implementation is simpler (no need

Re: [PATCH bpf-next] selftests/bpf: fix constness of source arg for bpf helpers

2019-06-10 Thread Martin Lau
On Mon, Jun 10, 2019 at 10:46:55AM -0700, Andrii Nakryiko wrote: > Fix signature of bpf_probe_read and bpf_probe_write_user to mark source > pointer as const. This causes warnings during compilation for > applications relying on those helpers. Acked-by: Martin KaFai Lau

Re: [PATCH v2 bpf] bpf: lpm_trie: check left child of last leftmost node for NULL

2019-06-10 Thread Martin Lau
On Sat, Jun 08, 2019 at 12:54:19PM -0700, Jonathan Lemon wrote: > If the leftmost parent node of the tree has does not have a child > on the left side, then trie_get_next_key (and bpftool map dump) will > not look at the child on the right. This leads to the traversal > missing elements. Good catc

Re: [PATCH bpf-next v4 1/8] bpf: implement getsockopt and setsockopt hooks

2019-06-10 Thread Martin Lau
On Mon, Jun 10, 2019 at 12:35:58PM -0700, Stanislav Fomichev wrote: > On 06/10, Martin Lau wrote: > > On Mon, Jun 10, 2019 at 09:34:14AM -0700, Stanislav Fomichev wrote: > > > Implement new BPF_PROG_TYPE_CGROUP_SOCKOPT program type and > > > BPF_CGROUP_

Re: [PATCH net 1/2] ipv6: Dump route exceptions too in rt6_dump_route()

2019-06-10 Thread Martin Lau
On Sat, Jun 08, 2019 at 05:47:07PM +0200, Stefano Brivio wrote: > On Sat, 8 Jun 2019 17:02:06 +0200 > Stefano Brivio wrote: > > > On Sat, 8 Jun 2019 07:19:23 +0000 > > Martin Lau wrote: > > > > > On Sat, Jun 08, 2019 at 07:59:11AM +0200, Stefano Brivio wr

Re: [PATCH bpf-next v4 1/8] bpf: implement getsockopt and setsockopt hooks

2019-06-10 Thread Martin Lau
BPF prog exits > * 2: success, do _not_ execute kernel {s,g}etsockopt path after BPF > prog exits > > v4: > * don't export bpf_sk_fullsock helper (Martin Lau) > * size != sizeof(__u64) for uapi pointers (Martin Lau) > * offsetof instead of bpf_ctx_range when checking ctx

Re: [PATCH net 1/2] ipv6: Dump route exceptions too in rt6_dump_route()

2019-06-08 Thread Martin Lau
On Sat, Jun 08, 2019 at 07:59:11AM +0200, Stefano Brivio wrote: > On Sat, 8 Jun 2019 05:40:06 + > Martin Lau wrote: > > > On Thu, Jun 06, 2019 at 04:47:00PM -0600, David Ahern wrote: > > > On 6/6/19 3:18 PM, Stefano Brivio wrote: > > > > On Thu, 6 J

Re: [PATCH bpf-next v3 1/8] bpf: implement getsockopt and setsockopt hooks

2019-06-08 Thread Martin Lau
BPF prog exits > * 2: success, do _not_ execute kernel {s,g}etsockopt path after BPF > prog exits > > v3: > * typos in BPF_PROG_CGROUP_SOCKOPT_RUN_ARRAY comments (Andrii Nakryiko) > * reverse christmas tree in BPF_PROG_CGROUP_SOCKOPT_RUN_ARRAY (Andrii > Nakryiko) >

Re: [PATCH net v2 1/2] ipv6: Dump route exceptions too in rt6_dump_route()

2019-06-07 Thread Martin Lau
r > listing, and wouldn't fix the issue with current and previous versions of > iproute2. > > v2: Add tracking of number of entries to be skipped in current node after > a partial dump. As we restart from the same node, if not all the > exceptions for a given nod

Re: [PATCH net 1/2] ipv6: Dump route exceptions too in rt6_dump_route()

2019-06-07 Thread Martin Lau
On Thu, Jun 06, 2019 at 04:47:00PM -0600, David Ahern wrote: > On 6/6/19 3:18 PM, Stefano Brivio wrote: > > On Thu, 6 Jun 2019 14:57:33 -0600 > > David Ahern wrote: > > > >>> This will cause a non-trivial conflict with commit cc5c073a693f > >>> ("ipv6: Move exception bucket to fib6_nh") on net-ne

Re: [PATCH v5 3/4] tools/bpf: Add bpf_map_lookup_elem selftest for xskmap

2019-06-06 Thread Martin Lau
On Thu, Jun 06, 2019 at 01:59:42PM -0700, Jonathan Lemon wrote: > Check that bpf_map_lookup_elem lookup and structure > access operats correctly. > > Signed-off-by: Jonathan Lemon Acked-by: Martin KaFai Lau

Re: [PATCH v5 bpf-next 2/4] bpf/tools: sync bpf.h

2019-06-06 Thread Martin Lau
On Thu, Jun 06, 2019 at 01:59:41PM -0700, Jonathan Lemon wrote: > Sync uapi/linux/bpf.h > > Signed-off-by: Jonathan Lemon Acked-by: Martin KaFai Lau

Re: [PATCH bpf-next v2 1/8] bpf: implement getsockopt and setsockopt hooks

2019-06-06 Thread Martin Lau
BPF prog exits > * 2: success, do _not_ execute kernel {s,g}etsockopt path after BPF > prog exits > > v2: > * moved bpf_sockopt_kern fields around to remove a hole (Martin Lau) > * aligned bpf_sockopt_kern->buf to 8 bytes (Martin Lau) > * bpf_prog_array_is_empty inst

Re: [PATCH net 1/2] ipv6: Dump route exceptions too in rt6_dump_route()

2019-06-06 Thread Martin Lau
On Fri, Jun 07, 2019 at 12:58:52AM +0200, Stefano Brivio wrote: > On Thu, 6 Jun 2019 22:37:11 + > Martin Lau wrote: > > > On Fri, Jun 07, 2019 at 12:17:47AM +0200, Stefano Brivio wrote: > > > On Thu, 6 Jun 2019 21:44:58 + > > > Martin Lau wrote: >

Re: [PATCH net 1/2] ipv6: Dump route exceptions too in rt6_dump_route()

2019-06-06 Thread Martin Lau
On Fri, Jun 07, 2019 at 12:17:47AM +0200, Stefano Brivio wrote: > On Thu, 6 Jun 2019 21:44:58 + > Martin Lau wrote: > > > > + if (!(filter->flags & RTM_F_CLONED)) { > > > + err = rt6_fill_node(net, arg->skb, rt, NULL, NULL, NULL, 0, > > &

Re: [PATCH net 1/2] ipv6: Dump route exceptions too in rt6_dump_route()

2019-06-06 Thread Martin Lau
On Thu, Jun 06, 2019 at 10:13:41PM +0200, Stefano Brivio wrote: > Since commit 2b760fcf5cfb ("ipv6: hook up exception table to store dst > cache"), route exceptions reside in a separate hash table, and won't be > found by walking the FIB, so they won't be dumped to userspace on a > RTM_GETROUTE mes

Re: [PATCH v2 bpf-next 2/2] bpf: use libbpf_num_possible_cpus in bpftool and selftests

2019-06-06 Thread Martin Lau
On Thu, Jun 06, 2019 at 09:58:37AM -0700, Hechao Li wrote: > Use the newly added bpf_num_possible_cpus() in bpftool and selftests > and remove duplicate implementations. > > Signed-off-by: Hechao Li > --- > tools/bpf/bpftool/common.c | 53 +++--- > tools/testing/s

Re: [PATCH v2 bpf-next 1/2] bpf: add a new API libbpf_num_possible_cpus()

2019-06-06 Thread Martin Lau
On Thu, Jun 06, 2019 at 09:58:36AM -0700, Hechao Li wrote: > Adding a new API libbpf_num_possible_cpus() that helps user with > per-CPU map operations. > > Signed-off-by: Hechao Li > --- > tools/lib/bpf/libbpf.c | 53 > tools/lib/bpf/libbpf.h | 16 +++

Re: [PATCH bpf v2 0/4] Fix unconnected bpf cgroup hooks

2019-06-06 Thread Martin Lau
On Thu, Jun 06, 2019 at 04:35:13PM +0200, Daniel Borkmann wrote: > Please refer to the patch 1/4 as the main patch with the details > on the current sendmsg hook API limitations and proposal to fix > it in order to work with basic applications like DNS. Remaining > patches are the usual uapi and to

Re: [PATCH bpf-next v2] samples: bpf: print a warning about headers_install

2019-06-05 Thread Martin Lau
On Wed, Jun 05, 2019 at 04:47:22PM -0700, Jakub Kicinski wrote: > It seems like periodically someone posts patches to "fix" > header includes. The issue is that samples expect the > include path to have the uAPI headers (from usr/) first, > and then tools/ headers, so that locally installed uAPI >

Re: [PATCH bpf 1/2] bpf: fix unconnected udp hooks

2019-06-05 Thread Martin Lau
On Wed, Jun 05, 2019 at 10:40:49PM +0200, Daniel Borkmann wrote: > Intention of cgroup bind/connect/sendmsg BPF hooks is to act transparently > to applications as also stated in original motivation in 7828f20e3779 ("Merge > branch 'bpf-cgroup-bind-connect'"). When recently integrating the latter >

Re: [PATCH 1/1] bpf: Allow bpf_map_lookup_elem() on an xskmap

2019-06-05 Thread Martin Lau
On Wed, Jun 05, 2019 at 08:57:56AM -0700, Jonathan Lemon wrote: > Currently, the AF_XDP code uses a separate map in order to > determine if an xsk is bound to a queue. Instead of doing this, > have bpf_map_lookup_elem() return a xdp_sock. > > Rearrange some xdp_sock members to eliminate structure

Re: [PATCH bpf-next 1/7] bpf: implement getsockopt and setsockopt hooks

2019-06-05 Thread Martin Lau
On Wed, Jun 05, 2019 at 02:16:30PM -0700, Stanislav Fomichev wrote: > On 06/05, Martin Lau wrote: > > On Wed, Jun 05, 2019 at 12:17:24PM -0700, Stanislav Fomichev wrote: > > > On 06/05, Martin Lau wrote: > > > > On Tue, Jun 04, 2019 at 02:35:18PM -

Re: [PATCH bpf-next 1/7] bpf: implement getsockopt and setsockopt hooks

2019-06-05 Thread Martin Lau
On Wed, Jun 05, 2019 at 12:17:24PM -0700, Stanislav Fomichev wrote: > On 06/05, Martin Lau wrote: > > On Tue, Jun 04, 2019 at 02:35:18PM -0700, Stanislav Fomichev wrote: > > > Implement new BPF_PROG_TYPE_CGROUP_SOCKOPT program type and > > > BPF_CGROUP_

Re: [PATCH bpf-next 1/7] bpf: implement getsockopt and setsockopt hooks

2019-06-05 Thread Martin Lau
On Tue, Jun 04, 2019 at 02:35:18PM -0700, Stanislav Fomichev wrote: > Implement new BPF_PROG_TYPE_CGROUP_SOCKOPT program type and > BPF_CGROUP_{G,S}ETSOCKOPT cgroup hooks. > > BPF_CGROUP_SETSOCKOPT get a read-only view of the setsockopt arguments. > BPF_CGROUP_GETSOCKOPT can modify the supplied bu

Re: [PATCH v2 net-next 4/7] ipv6: Plumb support for nexthop object in a fib6_info

2019-06-04 Thread Martin Lau
On Tue, Jun 04, 2019 at 08:05:58PM -0600, David Ahern wrote: > On 6/4/19 6:39 PM, Martin Lau wrote: > > IMO, ip6_create_rt_rcu(), which returns untracked rt, was a mistake > > and removing it has been overdue. Tracking down the unregister dev > > bug is not easy. > >

Re: [PATCH v2 net-next 4/7] ipv6: Plumb support for nexthop object in a fib6_info

2019-06-04 Thread Martin Lau
On Tue, Jun 04, 2019 at 02:36:27PM -0700, Wei Wang wrote: > On Tue, Jun 4, 2019 at 2:13 PM David Ahern wrote: > > > > On 6/4/19 3:06 PM, Martin Lau wrote: > > > On Tue, Jun 04, 2019 at 02:17:28PM -0600, David Ahern wrote: > > >> On 6/3/19 11:29 PM, Martin Lau

Re: [PATCH v2 net-next 4/7] ipv6: Plumb support for nexthop object in a fib6_info

2019-06-04 Thread Martin Lau
On Tue, Jun 04, 2019 at 03:13:38PM -0600, David Ahern wrote: > On 6/4/19 3:06 PM, Martin Lau wrote: > > On Tue, Jun 04, 2019 at 02:17:28PM -0600, David Ahern wrote: > >> On 6/3/19 11:29 PM, Martin Lau wrote: > >>> On Mon, Jun 03, 2019 at 07:36:06PM -0600, David Aher

Re: [PATCH v2 net-next 4/7] ipv6: Plumb support for nexthop object in a fib6_info

2019-06-04 Thread Martin Lau
On Tue, Jun 04, 2019 at 02:17:28PM -0600, David Ahern wrote: > On 6/3/19 11:29 PM, Martin Lau wrote: > > On Mon, Jun 03, 2019 at 07:36:06PM -0600, David Ahern wrote: > >> On 6/3/19 6:58 PM, Martin Lau wrote: > >>> I have concern on calling ip6_create_rt_rcu() in gene

Re: [PATCH v4 bpf-next 1/2] bpf: Allow bpf_map_lookup_elem() on an xskmap

2019-06-04 Thread Martin Lau
On Tue, Jun 04, 2019 at 10:25:23AM -0700, Jonathan Lemon wrote: > On 4 Jun 2019, at 9:43, Jesper Dangaard Brouer wrote: > > > On Mon, 3 Jun 2019 09:38:51 -0700 > > Jonathan Lemon wrote: > > > >> Currently, the AF_XDP code uses a separate map in order to > >> determine if an xsk is bound to a queu

Re: [PATCH v2 net-next 4/7] ipv6: Plumb support for nexthop object in a fib6_info

2019-06-03 Thread Martin Lau
On Mon, Jun 03, 2019 at 07:36:06PM -0600, David Ahern wrote: > On 6/3/19 6:58 PM, Martin Lau wrote: > > I have concern on calling ip6_create_rt_rcu() in general which seems > > to trace back to this commit > > dec9b0e295f6 ("net/ipv6: Add rt6_info create function for

Re: [PATCH v2 net-next 4/7] ipv6: Plumb support for nexthop object in a fib6_info

2019-06-03 Thread Martin Lau
On Mon, Jun 03, 2019 at 05:18:11PM -0600, David Ahern wrote: > On 6/3/19 5:05 PM, Wei Wang wrote: > > On Mon, Jun 3, 2019 at 3:35 PM David Ahern wrote: > >> > >> On 6/3/19 3:58 PM, Wei Wang wrote: > >>> Hmm... I am still a bit concerned with the ip6_create_rt_rcu() call. > >>> If we have a blackho

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

2019-06-01 Thread Martin Lau
On Sat, Jun 01, 2019 at 04:54:46PM -0700, Song Liu wrote: > > > > On May 31, 2019, at 3:29 PM, Martin KaFai Lau wrote: > > > > When the commit a6024562ffd7 ("udp: Add GRO functions to UDP socket") > > added udp[46]_lib_lookup_skb to the udp_gro code path, it broke > > the reuseport_select_sock(

Re: [PATCH v4 bpf-next 0/6] bpf: Propagate cn to TCP

2019-05-31 Thread Martin Lau
On Tue, May 28, 2019 at 04:59:34PM -0700, brakmo wrote: > This patchset adds support for propagating congestion notifications (cn) > to TCP from cgroup inet skb egress BPF programs. Acked-by: Martin KaFai Lau

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

2019-05-20 Thread Martin Lau
On Sat, May 18, 2019 at 07:07:29PM -0700, Martin Lau wrote: > On Sat, May 18, 2019 at 06:52:48PM -0700, Joe Stringer wrote: > > On Sat, May 18, 2019, 09:05 Martin Lau wrote: > > > > > > On Sat, May 18, 2019 at 08:38:46AM -1000, Joe Stringer wrote: > > > >

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

2019-05-18 Thread Martin Lau
On Sat, May 18, 2019 at 06:52:48PM -0700, Joe Stringer wrote: > On Sat, May 18, 2019, 09:05 Martin Lau wrote: > > > > On Sat, May 18, 2019 at 08:38:46AM -1000, Joe Stringer wrote: > > > On Fri, May 17, 2019, 12:02 Martin Lau wrote: > > > > > > > O

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

2019-05-18 Thread Martin Lau
On Sat, May 18, 2019 at 08:38:46AM -1000, Joe Stringer wrote: > On Fri, May 17, 2019, 12:02 Martin Lau wrote: > > > On Fri, May 17, 2019 at 02:51:48PM -0700, Eric Dumazet wrote: > > > > > > > > > On 5/17/19 2:21 PM, Martin KaFai Lau wrote: > >

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

2019-05-17 Thread Martin Lau
On Fri, May 17, 2019 at 02:51:48PM -0700, Eric Dumazet wrote: > > > On 5/17/19 2:21 PM, Martin KaFai Lau wrote: > > The BPF_FUNC_sk_lookup_xxx helpers return RET_PTR_TO_SOCKET_OR_NULL. > > Meaning a fullsock ptr and its fullsock's fields in bpf_sock can be > > accessed, e.g. type, protocol, mark

Re: [PATCH v3 net] ipv6: fix src addr routing with the exception table

2019-05-16 Thread Martin Lau
nfo is created for a gateway route with > src addr. However, the lookup code is not able to find this route cache. > > Fixes: 2b760fcf5cfb ("ipv6: hook up exception table to store dst cache") > Reported-by: Mikael Magnusson > Bisected-by: David Ahern > Signed-off-by

Re: [PATCH v2 net] ipv6: fix src addr routing with the exception table

2019-05-16 Thread Martin Lau
nfo is created for a gateway route with > src addr. However, the lookup code is not able to find this route cache. > > Fixes: 2b760fcf5cfb ("ipv6: hook up exception table to store dst cache") > Reported-by: Mikael Magnusson > Bisected-by: David Ahern > Signed-off-by

Re: [PATCH net] ipv6: prevent possible fib6 leaks

2019-05-15 Thread Martin Lau
On Wed, May 15, 2019 at 07:39:52PM -0700, Eric Dumazet wrote: > At ipv6 route dismantle, fib6_drop_pcpu_from() is responsible > for finding all percpu routes and set their ->from pointer > to NULL, so that fib6_ref can reach its expected value (1). > > The problem right now is that other cpus can

Re: [PATCH net] ipv6: fix src addr routing with the exception table

2019-05-15 Thread Martin Lau
On Wed, May 15, 2019 at 06:06:58PM -0600, David Ahern wrote: > On 5/15/19 6:03 PM, Wei Wang wrote: > > Thanks Martin. > > Changing __rt6_find_exception_xxx() might not be easy cause other > > callers of this function does not really need to back off and use > > another saddr. > > And the validation

Re: IPv6 PMTU discovery fails with source-specific routing

2019-05-15 Thread Martin Lau
On Wed, May 15, 2019 at 11:31:44AM -0700, Wei Wang wrote: > On Wed, May 15, 2019 at 11:06 AM Martin Lau wrote: > > > > On Tue, May 14, 2019 at 12:33:25PM -0700, Wei Wang wrote: > > > I think the bug is because when creating exceptions, src_addr is not > > > alway

Re: [PATCH net] ipv6: fix src addr routing with the exception table

2019-05-15 Thread Martin Lau
On Tue, May 14, 2019 at 05:46:10PM -0700, Wei Wang wrote: > From: Wei Wang > > When inserting route cache into the exception table, the key is > generated with both src_addr and dest_addr with src addr routing. > However, current logic always assumes the src_addr used to generate the > key is a /

Re: IPv6 PMTU discovery fails with source-specific routing

2019-05-15 Thread Martin Lau
On Tue, May 14, 2019 at 12:33:25PM -0700, Wei Wang wrote: > I think the bug is because when creating exceptions, src_addr is not > always set even though fib6_info is in the subtree. (because of > rt6_is_gw_or_nonexthop() check) > However, when looking up for exceptions, we always set src_addr to t

Re: [PATCH bpf v2] selftests: bpf: initialize bpf_object pointers where needed

2019-05-09 Thread Martin Lau
On Wed, May 08, 2019 at 05:49:32PM +0100, Lorenz Bauer wrote: > There are a few tests which call bpf_object__close on uninitialized > bpf_object*, which may segfault. Explicitly zero-initialise these pointers > to avoid this. Acked-by: Martin KaFai Lau

Re: [PATCH bpf] libbpf: always NULL out pobj in bpf_prog_load_xattr

2019-05-02 Thread Martin Lau
On Thu, May 02, 2019 at 11:49:32AM -0400, Lorenz Bauer wrote: > Currently, code like the following segfaults if bpf_prog_load_xattr > returns an error: > > struct bpf_object *obj; > > err = bpf_prog_load_xattr(&attr, &obj, &prog_fd); > bpf_object__close(obj); This is a bug. err shoul

Re: [PATCH net] ipv6: fix races in ip6_dst_destroy()

2019-04-29 Thread Martin Lau
On Sun, Apr 28, 2019 at 12:22:25PM -0700, Eric Dumazet wrote: > We had many syzbot reports that seem to be caused by use-after-free > of struct fib6_info. > > ip6_dst_destroy(), fib6_drop_pcpu_from() and rt6_remove_exception() > are writers vs rt->from, and use non consistent synchronization among

Re: [PATCH net-next] bpf: Use PTR_ERR_OR_ZERO in bpf_fd_sk_storage_update_elem()

2019-04-29 Thread Martin Lau
On Mon, Apr 29, 2019 at 08:40:17AM -0700, Martin KaFai Lau wrote: > On Mon, Apr 29, 2019 at 01:56:11PM +, YueHaibing wrote: > > Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR > Acked-by: Martin KaFai Lau btw, that should go to the bpf-next branch.

Re: [PATCH net-next] bpf: Use PTR_ERR_OR_ZERO in bpf_fd_sk_storage_update_elem()

2019-04-29 Thread Martin Lau
On Mon, Apr 29, 2019 at 01:56:11PM +, YueHaibing wrote: > Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR Acked-by: Martin KaFai Lau

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

2019-04-26 Thread Martin Lau
On Fri, Apr 26, 2019 at 11:32:01AM -0700, Yonghong Song wrote: > > > On 4/26/19 10:11 AM, Martin KaFai Lau wrote: > > 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/ d

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

2019-04-26 Thread Martin Lau
On Fri, Apr 26, 2019 at 10:55:02AM -0700, Stanislav Fomichev wrote: > On 04/26, Martin KaFai Lau wrote: > > 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 KaFa

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

2019-04-26 Thread Martin Lau
On Fri, Apr 26, 2019 at 10:54:00AM -0700, Stanislav Fomichev wrote: > On 04/26, Martin KaFai Lau wrote: > > 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

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

2019-04-26 Thread Martin Lau
On Fri, Apr 26, 2019 at 10:52:20AM -0700, Stanislav Fomichev wrote: > On 04/26, Martin KaFai Lau wrote: > > After allowing a bpf prog to > > - directly read the skb->sk ptr > > - get the fullsock bpf_sock by "bpf_sk_fullsock()" > > - get the bpf_tcp_sock by "bpf_tcp_sock()" > > - get the listener s

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

2019-04-26 Thread Martin Lau
On Fri, Apr 26, 2019 at 10:50:29AM -0700, Yonghong Song wrote: > > > On 4/26/19 10:11 AM, Martin KaFai Lau wrote: > > 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. > >

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

2019-04-26 Thread Martin Lau
On Fri, Apr 26, 2019 at 10:27:16AM -0700, Yonghong Song wrote: > > > On 4/25/19 5:10 PM, Martin KaFai Lau wrote: > > After allowing a bpf prog to > > - directly read the skb->sk ptr > > - get the fullsock bpf_sock by "bpf_sk_fullsock()" > > - get the bpf_tcp_sock by "bpf_tcp_sock()" > > - get the

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

2019-04-24 Thread Martin Lau
On Wed, Apr 24, 2019 at 03:39:58PM -0700, Martin KaFai Lau wrote: > 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

Re: [PATCH bpf] bpf: allow clearing all sock_ops callback flags

2019-04-15 Thread Martin Lau
On Mon, Apr 15, 2019 at 09:54:55AM +, Viet Hoang Tran wrote: > The helper function bpf_sock_ops_cb_flags_set() can be used to both > set and clear the sock_ops callback flags. However, its current > behavior is not consistent. BPF program may clear a flag if more than > one were set, or replace

Re: [PATCH net] route: Avoid crash from dereferencing NULL rt->from

2019-04-15 Thread Martin Lau
On Sun, Apr 14, 2019 at 03:29:30PM -0700, Eric Dumazet wrote: > > > On 04/14/2019 02:21 PM, Jonathan Lemon wrote: > > When __ip6_rt_update_pmtu() is called, rt->from is RCU dereferenced, but is > > never checked for null - rt6_flush_exceptions() may have removed the entry. > > > > [ 1913.989004]

Re: [PATCH net] route: Avoid crash from dereferencing NULL rt->from

2019-04-15 Thread Martin Lau
On Sun, Apr 14, 2019 at 02:21:29PM -0700, Jonathan Lemon wrote: > When __ip6_rt_update_pmtu() is called, rt->from is RCU dereferenced, but is > never checked for null - rt6_flush_exceptions() may have removed the entry. > > [ 1913.989004] RIP: 0010:ip6_rt_cache_alloc+0x13/0x170 > [ 1914.209410] Ca

  1   2   3   >