bpf, sockmap: Don't set up upcalls and progs for listening sockets
authorJakub Sitnicki <jakub@cloudflare.com>
Tue, 18 Feb 2020 17:10:17 +0000 (17:10 +0000)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 21 Feb 2020 21:29:45 +0000 (22:29 +0100)
commit6e830c2f6c9641217e22330cec1372acff78dcef
treee11fdef619c774d023e2294796acb479511e4c77
parent8ca30379a40103bf6734ae127ec940da798534dd
bpf, sockmap: Don't set up upcalls and progs for listening sockets

Now that sockmap/sockhash can hold listening sockets, when setting up the
psock we will (i) grab references to verdict/parser progs, and (2) override
socket upcalls sk_data_ready and sk_write_space.

However, since we cannot redirect to listening sockets so we don't need to
link the socket to the BPF progs. And more importantly we don't want the
listening socket to have overridden upcalls because they would get
inherited by child sockets cloned from it.

Introduce a separate initialization path for listening sockets that does
not change the upcalls and ignores the BPF progs.

Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20200218171023.844439-6-jakub@cloudflare.com
net/core/sock_map.c