]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, sockmap: Allow inserting listening TCP sockets into sockmap
authorJakub Sitnicki <jakub@cloudflare.com>
Tue, 18 Feb 2020 17:10:16 +0000 (17:10 +0000)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 21 Feb 2020 21:29:45 +0000 (22:29 +0100)
commit12757f2dc802a5ddf28140df2108a53cbb348767
treeadf458c5d38536d0e12590567aee965a862546f9
parentce5a6e8eb3f18daca5fcf61c8ab0912d32356a88
bpf, sockmap: Allow inserting listening TCP sockets into sockmap

In order for sockmap/sockhash types to become generic collections for
storing TCP sockets we need to loosen the checks during map update, while
tightening the checks in redirect helpers.

Currently sock{map,hash} require the TCP socket to be in established state,
which prevents inserting listening sockets.

Change the update pre-checks so the socket can also be in listening state.

Since it doesn't make sense to redirect with sock{map,hash} to listening
sockets, add appropriate socket state checks to BPF redirect helpers too.

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-5-jakub@cloudflare.com
net/core/sock_map.c
tools/testing/selftests/bpf/test_maps.c