bpf: Allow selecting reuseport socket from a SOCKMAP/SOCKHASH
authorJakub Sitnicki <jakub@cloudflare.com>
Tue, 18 Feb 2020 17:10:20 +0000 (17:10 +0000)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 21 Feb 2020 21:29:45 +0000 (22:29 +0100)
commit9fed9000c5c6cacfcaaa48aff74818072ae294cc
tree66854f14a43c09c2aea3c3c5e6e5ed93a65a1aea
parent1d59f3bcee356caa933646dc45ff0836455535e8
bpf: Allow selecting reuseport socket from a SOCKMAP/SOCKHASH

SOCKMAP & SOCKHASH now support storing references to listening
sockets. Nothing keeps us from using these map types a collection of
sockets to select from in BPF reuseport programs. Whitelist the map types
with the bpf_sk_select_reuseport helper.

The restriction that the socket has to be a member of a reuseport group
still applies. Sockets in SOCKMAP/SOCKHASH that don't have sk_reuseport_cb
set are not a valid target and we signal it with -EINVAL.

The main benefit from this change is that, in contrast to
REUSEPORT_SOCKARRAY, SOCK{MAP,HASH} don't impose a restriction that a
listening socket can be just one BPF map at the same time.

Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20200218171023.844439-9-jakub@cloudflare.com
kernel/bpf/verifier.c
net/core/filter.c