]> git.baikalelectronics.ru Git - kernel.git/commit
sock_map: Lift socket state restriction for datagram sockets
authorCong Wang <cong.wang@bytedance.com>
Sun, 4 Jul 2021 19:02:43 +0000 (12:02 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 16 Jul 2021 01:17:49 +0000 (18:17 -0700)
commit8c958a52bedfe6119802378063638a661c84faa2
treea91ec2c9f219c4f23f842f44aa3d9826881885fe
parent244734c4a4b1d7d651f8a235cd955f79bf56da54
sock_map: Lift socket state restriction for datagram sockets

TCP and other connection oriented sockets have accept()
for each incoming connection on the server side, hence
they can just insert those fd's from accept() to sockmap,
which are of course established.

Now with datagram sockets begin to support sockmap and
redirection, the restriction is no longer applicable to
them, as they have no accept(). So we have to lift this
restriction for them. This is fine, because inside
bpf_sk_redirect_map() we still have another socket status
check, sock_map_redirect_allowed(), as a guard.

This also means they do not have to be removed from
sockmap when disconnecting.

Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210704190252.11866-3-xiyou.wangcong@gmail.com
net/core/sock_map.c
net/ipv4/udp_bpf.c
tools/testing/selftests/bpf/prog_tests/sockmap_listen.c