History

bpf: Add BPF_SOCK_OPS_TCP_LISTEN_CB

Add new TCP-BPF callback that is called on listen(2) right after socket transition to TCP_LISTEN state. It fills the gap for listening sockets in TCP-BPF. For example BPF program can set BPF_SOCK_OPS_STATE_CB_FLAG when socket becomes listening and track later transition from TCP_LISTEN to TCP_CLOSE with BPF_SOCK_OPS_STATE_CB callback. Before there was no way to do it with TCP-BPF and other options were much harder to work with. E.g. socket state tracking can be done with tracepoints (either raw or regular) but they can't be attached to cgroup and their lifetime has to be managed separately.

Andrey Ignatov committed 8 years ago

Commit f333ee01 parent 2d3feca2 files · +4 −0Browse files

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

Unified · Split

include/uapi/linux/bpf.h+3−0
@@ -2555,6 +2555,9 @@ enum { · 2554 unmodified lines
2555 * Arg1: old_state2555 * Arg1: old_state
2556 * Arg2: new_state2556 * Arg2: new_state
2557 */2557 */
2558 BPF_SOCK_OPS_TCP_LISTEN_CB, /* Called on listen(2), right after
2559 * socket transition to LISTEN state.
2560 */
2558};2561};
2559 2562
2560/* List of TCP states. There is a build check in net/ipv4/tcp.c to detect2563/* List of TCP states. There is a build check in net/ipv4/tcp.c to detect