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 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 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 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 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-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 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: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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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-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
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 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] 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 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 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 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] 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 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-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-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 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 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 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 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 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 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 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 v1] bpf, lpm: fix lookup bug in map_delete_elem

2019-02-21 Thread Martin Lau
On Thu, Feb 21, 2019 at 05:39:26PM +0100, Alban Crequy wrote: > From: Alban Crequy > > trie_delete_elem() was deleting an entry even though it was not matching > if the prefixlen was correct. This patch adds a check on matchlen. > > Reproducer: > > $ sudo bpftool map create /sys/fs/bpf/mylpm ty

Re: [PATCH] samples/bpf: Fix dummy program unloading for xdp_redirect samples

2019-02-21 Thread Martin Lau
On Thu, Feb 21, 2019 at 05:30:54PM +0100, Maciej Fijalkowski wrote: > On Thu, 21 Feb 2019 17:05:39 +0100 > Toke Høiland-Jørgensen wrote: > > > The xdp_redirect and xdp_redirect_map sample programs both load a dummy > > program onto the egress interfaces. However, the unload code checks these > >

Re: [PATCH 1/3] bpf: add helper to check for a valid SYN cookie

2019-02-22 Thread Martin Lau
On Fri, Feb 22, 2019 at 09:50:55AM +, Lorenz Bauer wrote: > Using bpf_sk_lookup_tcp it's possible to ascertain whether a packet belongs > to a known connection. However, there is one corner case: no sockets are > created if SYN cookies are active. This means that the final ACK in the > 3WHS is

Re: [PATCH v2 bpf-next 4/9] bpf: add bpf helper bpf_skb_ecn_set_ce

2019-02-22 Thread Martin Lau
On Sat, Feb 23, 2019 at 02:14:26AM +0100, Daniel Borkmann wrote: > On 02/23/2019 02:06 AM, brakmo wrote: > > This patch adds a new bpf helper BPF_FUNC_skb_ecn_set_ce > > "int bpf_skb_ecn_set_ce(struct sk_buff *skb)". It is added to > > BPF_PROG_TYPE_CGROUP_SKB typed bpf_prog which currently can > >

Re: [PATCH v2 bpf-next 2/9] bpf: Add bpf helper bpf_tcp_enter_cwr

2019-02-23 Thread Martin Lau
On Sat, Feb 23, 2019 at 05:32:14PM -0800, Eric Dumazet wrote: > > > On 02/22/2019 05:06 PM, brakmo wrote: > > From: Martin KaFai Lau > > > > This patch adds a new bpf helper BPF_FUNC_tcp_enter_cwr > > "int bpf_tcp_enter_cwr(struct bpf_tcp_sock *tp)". > > It is added to BPF_PROG_TYPE_CGROUP_SKB

Re: [PATCH v2 bpf-next 2/9] bpf: Add bpf helper bpf_tcp_enter_cwr

2019-02-25 Thread Martin Lau
On Mon, Feb 25, 2019 at 03:14:38PM -0800, Stanislav Fomichev wrote: [ ... ] > > > > To ensure it is only called from BPF_CGROUP_INET_EGRESS, the > > attr->expected_attach_type must be specified as BPF_CGROUP_INET_EGRESS > > during load time if the prog uses this new helper. > > The newly added pr

Re: [PATCH 1/3] bpf: add helper to check for a valid SYN cookie

2019-02-25 Thread Martin Lau
On Mon, Feb 25, 2019 at 06:26:42PM +, Lorenz Bauer wrote: > On Sat, 23 Feb 2019 at 00:44, Martin Lau wrote: > > > > On Fri, Feb 22, 2019 at 09:50:55AM +, Lorenz Bauer wrote: > > > Using bpf_sk_lookup_tcp it's possible to ascertain whether a packet &

Re: [PATCH] bpf: decrease usercnt if bpf_map_new_fd() fails in bpf_map_get_fd_by_id()

2019-02-26 Thread Martin Lau
On Tue, Feb 26, 2019 at 10:15:37PM +0800, zerons wrote: > [ Upstream commit c91951f15978f1a0c6b65f063d30f7ea7bc6fb42 ] > > In bpf/syscall.c, bpf_map_get_fd_by_id() use bpf_map_inc_not_zero() to > increase > the refcount, both map->refcnt and map->usercnt. Then, if bpf_map_new_fd() > fails, > sho

Re: [PATCH bpf-next 1/3] bpf: add bpf_progenyof helper

2019-02-26 Thread Martin Lau
On Tue, Feb 26, 2019 at 02:36:49PM -0800, Javier Honduvilla Coto wrote: > This patch adds the bpf_progenyof helper which receives a PID and returns What is progenof? > 1 if the process currently being executed is in the process hierarchy > including itself or 0 if not. > > This is very useful in

Re: [PATCH] samples: bpf: fix: broken sample regarding removed function

2019-02-26 Thread Martin Lau
On Tue, Feb 26, 2019 at 10:05:59PM -0500, Daniel T. Lee wrote: > Currently, running sample "task_fd_query" and "tracex3" occurs the > following error. On kernel v5.0-rc* this sample will be unavailable > due to the removal of function 'blk_start_request' at commit "a1ce35f". > (function removed, as

Re: [PATCH internal pre-review] bpf: add missing entries to bpf_helpers.h

2019-02-26 Thread Martin Lau
On Tue, Feb 26, 2019 at 05:55:53PM -0500, Willem de Bruijn wrote: > From: Willem de Bruijn > > Signed-off-by: Willem de Bruijn > --- > tools/testing/selftests/bpf/bpf_helpers.h | 29 +++ > 1 file changed, 29 insertions(+) > > diff --git a/tools/testing/selftests/bpf/bpf_hel

Re: [PATCH] bpf: drop refcount if bpf_map_new_fd() fails in map_create()

2019-02-27 Thread Martin Lau
On Wed, Feb 27, 2019 at 10:36:25PM +0800, zerons wrote: > In bpf/syscall.c, map_create() first set map->usercnt to 1, a file descriptor > is > supposed to return to userspace. When bpf_map_new_fd() fails, drop the > refcount. Thanks for the patch. Please add a Fixes tag for bug fix in the future

Re: [PATCH 1/3] bpf: add helper to check for a valid SYN cookie

2019-02-28 Thread Martin Lau
On Thu, Feb 28, 2019 at 03:11:09PM +, Lorenz Bauer wrote: > I've started working on this, and I've hit a snag with the reference > tracking behaviour > of bpf_tcp_sock. From what I can tell, the assumption is that a > PTR_TO_TCP_SOCK > doesn't need reference tracking, because its either skb->

Re: [PATCH bpf-next 1/2] bpf: Fix bpf_tcp_sock and bpf_sk_fullsock issue related to bpf_sk_release

2019-03-01 Thread Martin Lau
On Fri, Mar 01, 2019 at 03:58:52PM +, Lorenz Bauer wrote: > On Fri, 1 Mar 2019 at 07:03, Martin KaFai Lau wrote: > > > > Lorenz Bauer [thanks!] reported that a ptr returned by bpf_tcp_sock(sk) > > can still be accessed after bpf_sk_release(sk). > > Both bpf_tcp_sock() and bpf_sk_fullsock() hav

Re: [PATCH bpf-next 1/3] bpf: add bpf_progenyof helper

2019-03-01 Thread Martin Lau
On Fri, Mar 01, 2019 at 09:28:39AM -0800, Javier Honduvilla Coto wrote: > On Wed, Feb 27, 2019 at 06:26:41AM +0000, Martin Lau wrote: > > On Tue, Feb 26, 2019 at 02:36:49PM -0800, Javier Honduvilla Coto wrote: > > > This patch adds the bpf_progenyof helper which receives a PID an

Re: [PATCH v2 bpf-next 1/3] bpf: add bpf_progenyof helper

2019-03-01 Thread Martin Lau
On Fri, Mar 01, 2019 at 10:06:12AM -0800, Javier Honduvilla Coto wrote: > From: Javier Honduvilla Coto > > This patch adds the bpf_progenyof helper which receives a PID and returns > 1 if the process currently being executed is in the process hierarchy > including itself or 0 if not. > > This is

Re: [PATCH bpf-next 1/2] bpf: Fix bpf_tcp_sock and bpf_sk_fullsock issue related to bpf_sk_release

2019-03-02 Thread Martin Lau
On Fri, Mar 01, 2019 at 09:07:48AM -0800, Martin Lau wrote: > > How about resetting reg->refcount_id in mark_ptr_or_null_reg as well? > I don't think so. release_reg_references() would not work then. After a second thought, 'reg->refcount_id = 0' should be done

Re: [PATCH v3 bpf-next 1/2] bpf: Fix bpf_tcp_sock and bpf_sk_fullsock issue related to bpf_sk_release

2019-03-02 Thread Martin Lau
On Sat, Mar 02, 2019 at 10:03:03AM -0800, Alexei Starovoitov wrote: > On Sat, Mar 02, 2019 at 08:10:10AM -0800, Martin KaFai Lau wrote: > > Lorenz Bauer [thanks!] reported that a ptr returned by bpf_tcp_sock(sk) > > can still be accessed after bpf_sk_release(sk). > > Both bpf_tcp_sock() and bpf_sk_

Re: [PATCH v3 bpf-next 1/2] bpf: Fix bpf_tcp_sock and bpf_sk_fullsock issue related to bpf_sk_release

2019-03-04 Thread Martin Lau
On Mon, Mar 04, 2019 at 10:33:46AM +0100, Daniel Borkmann wrote: > On 03/02/2019 09:21 PM, Martin Lau wrote: > > On Sat, Mar 02, 2019 at 10:03:03AM -0800, Alexei Starovoitov wrote: > >> On Sat, Mar 02, 2019 at 08:10:10AM -0800, Martin KaFai Lau wrote: > >>> Lorenz B

Re: [PATCH v3 bpf]: libbpf: fixing leak when kernel does not support btf

2019-03-08 Thread Martin Lau
On Fri, Mar 08, 2019 at 05:18:14AM +, Nikita V. Shirokov wrote: > we could end up in situation when we have object file w/ all btf > info but kernel does not support btf yet. in this situation currently > libbpf just set obj->btf to NULL w/o freeing it first. > this patch if fixing it by making

Re: [PATCH v3 bpf-next 1/2] bpf: Fix bpf_tcp_sock and bpf_sk_fullsock issue related to bpf_sk_release

2019-03-08 Thread Martin Lau
On Wed, Mar 06, 2019 at 03:59:40PM +, Lorenz Bauer wrote: > On Mon, 4 Mar 2019 at 17:43, Martin Lau wrote: > > > > On Mon, Mar 04, 2019 at 10:33:46AM +0100, Daniel Borkmann wrote: > > > On 03/02/2019 09:21 PM, Martin Lau wrote: > > > > On Sat, Mar

Re: [PATCH bpf] libbpf: handle BTF parsing and loading properly

2019-03-08 Thread Martin Lau
On Fri, Mar 08, 2019 at 03:58:20PM -0800, Andrii Nakryiko wrote: > This patch splits and cleans up error handling logic for loading BTF data. > Previously, if BTF data was parsed successfully, but failed to load into > kernel, we'd report nonsensical error code, instead of error returned from > btf

Re: [PATCH v4 bpf 0/5] Fix bpf_tcp_sock and bpf_sk_fullsock issue related to bpf_sk_release

2019-03-13 Thread Martin Lau
On Wed, Mar 13, 2019 at 12:20:27PM -0700, Alexei Starovoitov wrote: > On Tue, Mar 12, 2019 at 10:23:01AM -0700, Martin KaFai Lau wrote: > > This set addresses issue about accessing invalid > > ptr returned from bpf_tcp_sock() and bpf_sk_fullsock() > > after bpf_sk_release(). > > > > v4: > > - Trie

Re: [PATCH bpf] bpf: make bpf_skb_ecn_set_ce callable from BPF_PROG_TYPE_SCHED_ACT

2019-03-15 Thread Martin Lau
On Thu, Mar 14, 2019 at 05:28:58PM -0700, Peter Oskolkov wrote: > This helper is useful if a bpf tc filter sets skb->tstamp. > For the patch, Acked-by: Martin KaFai Lau Not sure if it should belong to bpf-next material though.

Re: selftests: bpf: test_align Failed to find match 1: R1=ctx(id=0,off=0,imm=0) func#0 @0

2019-03-18 Thread Martin Lau
On Mon, Mar 18, 2019 at 06:31:53PM +0530, Naresh Kamboju wrote: > selftests: bpf: test_align > Test 0: mov ... Failed to find match 1: R1=ctx(id=0,off=0,imm=0) Thanks for the report. I will post a fix.

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 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 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 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 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 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 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 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 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] 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 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 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: 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 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 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 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: [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 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 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 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 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-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-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-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-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 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 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

  1   2   3   >