]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commit4a767b0cdf77cc26ef0d1982a9bb8a4ff50ffcc1
tree66854f14a43c09c2aea3c3c5e6e5ed93a65a1aea
parent9a9a2d910a72c7a46dadc66f39dbcdab7b2425fd
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