diff options
author | John Fastabend <john.fastabend@gmail.com> | 2018-02-05 13:17:49 -0500 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-02-06 05:39:32 -0500 |
commit | 1aa12bdf1bfb95db7e75bfecf0e39a65f4e8fbf8 (patch) | |
tree | ea5a01abe7ce73c70b2ca5433463b4cd45f4e8f7 /include/net/tcp.h | |
parent | b11a632c442eef34a0afeba61fab923241f317e9 (diff) |
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: 174a79ff9515 ("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>
Diffstat (limited to 'include/net/tcp.h')
-rw-r--r-- | include/net/tcp.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index a58292d31e12..e3fc667f9ac2 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -1985,6 +1985,7 @@ enum hrtimer_restart tcp_pace_kick(struct hrtimer *timer); | |||
1985 | 1985 | ||
1986 | enum { | 1986 | enum { |
1987 | TCP_ULP_TLS, | 1987 | TCP_ULP_TLS, |
1988 | TCP_ULP_BPF, | ||
1988 | }; | 1989 | }; |
1989 | 1990 | ||
1990 | struct tcp_ulp_ops { | 1991 | struct tcp_ulp_ops { |
@@ -2003,6 +2004,7 @@ struct tcp_ulp_ops { | |||
2003 | int tcp_register_ulp(struct tcp_ulp_ops *type); | 2004 | int tcp_register_ulp(struct tcp_ulp_ops *type); |
2004 | void tcp_unregister_ulp(struct tcp_ulp_ops *type); | 2005 | void tcp_unregister_ulp(struct tcp_ulp_ops *type); |
2005 | int tcp_set_ulp(struct sock *sk, const char *name); | 2006 | int tcp_set_ulp(struct sock *sk, const char *name); |
2007 | int tcp_set_ulp_id(struct sock *sk, const int ulp); | ||
2006 | void tcp_get_available_ulp(char *buf, size_t len); | 2008 | void tcp_get_available_ulp(char *buf, size_t len); |
2007 | void tcp_cleanup_ulp(struct sock *sk); | 2009 | void tcp_cleanup_ulp(struct sock *sk); |
2008 | 2010 | ||