]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: sockmap, add sock close() hook to remove socks
authorJohn Fastabend <john.fastabend@gmail.com>
Mon, 5 Feb 2018 18:17:49 +0000 (10:17 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 6 Feb 2018 10:39:32 +0000 (11:39 +0100)
commitef42e83a88b1109eb78651aeb1231e5594b5b22a
treeea5a01abe7ce73c70b2ca5433463b4cd45f4e8f7
parent0ae7f6ef6012e9fc2eae3fd3ed9359dc4edfbeb0
bpf: sockmap, add sock close() hook to remove socks

The selftests test_maps program was leaving dangling BPF sockmap
programs around because not all psock elements were removed from
the map. The elements in turn hold a reference on the BPF program
they are attached to causing BPF programs to stay open even after
test_maps has completed.

The original intent was that sk_state_change() would be called
when TCP socks went through TCP_CLOSE state. However, because
socks may be in SOCK_DEAD state or the sock may be a listening
socket the event is not always triggered.

To resolve this use the ULP infrastructure and register our own
proto close() handler. This fixes the above case.

Fixes: c1f8f893521d ("bpf: sockmap with sk redirect support")
Reported-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
include/net/tcp.h
kernel/bpf/sockmap.c