History

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.

John Fastabend committed 8 years ago

Commit 1aa12bd1 parent b11a6322 files · +103 −67Browse files

Showing the changes to include/net (1 of 2 files). Show all

Unified · Split

include/net/tcp.h+2−0
@@ -1985,6 +1985,7 @@ enum hrtimer_restart tcp_pace_kick(struct hrtimer *timer); · 1984 unmodified lines
19851985
19861986 enum {
19871987 TCP_ULP_TLS,
1988+ TCP_ULP_BPF,
19881989 };
19891990
19901991 struct tcp_ulp_ops {
@@ -2003,6 +2004,7 @@ struct tcp_ulp_ops { · 12 unmodified lines
20032004 int tcp_register_ulp(struct tcp_ulp_ops *type);
20042005 void tcp_unregister_ulp(struct tcp_ulp_ops *type);
20052006 int tcp_set_ulp(struct sock *sk, const char *name);
2007+int tcp_set_ulp_id(struct sock *sk, const int ulp);
20062008 void tcp_get_available_ulp(char *buf, size_t len);
20072009 void tcp_cleanup_ulp(struct sock *sk);
20082010

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t