diff options
Diffstat (limited to 'net/ipv4/tcp.c')
-rw-r--r-- | net/ipv4/tcp.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 88b62441e7e9..f013ddc191e0 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -2042,6 +2042,30 @@ void tcp_set_state(struct sock *sk, int state) | |||
2042 | { | 2042 | { |
2043 | int oldstate = sk->sk_state; | 2043 | int oldstate = sk->sk_state; |
2044 | 2044 | ||
2045 | /* We defined a new enum for TCP states that are exported in BPF | ||
2046 | * so as not force the internal TCP states to be frozen. The | ||
2047 | * following checks will detect if an internal state value ever | ||
2048 | * differs from the BPF value. If this ever happens, then we will | ||
2049 | * need to remap the internal value to the BPF value before calling | ||
2050 | * tcp_call_bpf_2arg. | ||
2051 | */ | ||
2052 | BUILD_BUG_ON((int)BPF_TCP_ESTABLISHED != (int)TCP_ESTABLISHED); | ||
2053 | BUILD_BUG_ON((int)BPF_TCP_SYN_SENT != (int)TCP_SYN_SENT); | ||
2054 | BUILD_BUG_ON((int)BPF_TCP_SYN_RECV != (int)TCP_SYN_RECV); | ||
2055 | BUILD_BUG_ON((int)BPF_TCP_FIN_WAIT1 != (int)TCP_FIN_WAIT1); | ||
2056 | BUILD_BUG_ON((int)BPF_TCP_FIN_WAIT2 != (int)TCP_FIN_WAIT2); | ||
2057 | BUILD_BUG_ON((int)BPF_TCP_TIME_WAIT != (int)TCP_TIME_WAIT); | ||
2058 | BUILD_BUG_ON((int)BPF_TCP_CLOSE != (int)TCP_CLOSE); | ||
2059 | BUILD_BUG_ON((int)BPF_TCP_CLOSE_WAIT != (int)TCP_CLOSE_WAIT); | ||
2060 | BUILD_BUG_ON((int)BPF_TCP_LAST_ACK != (int)TCP_LAST_ACK); | ||
2061 | BUILD_BUG_ON((int)BPF_TCP_LISTEN != (int)TCP_LISTEN); | ||
2062 | BUILD_BUG_ON((int)BPF_TCP_CLOSING != (int)TCP_CLOSING); | ||
2063 | BUILD_BUG_ON((int)BPF_TCP_NEW_SYN_RECV != (int)TCP_NEW_SYN_RECV); | ||
2064 | BUILD_BUG_ON((int)BPF_TCP_MAX_STATES != (int)TCP_MAX_STATES); | ||
2065 | |||
2066 | if (BPF_SOCK_OPS_TEST_FLAG(tcp_sk(sk), BPF_SOCK_OPS_STATE_CB_FLAG)) | ||
2067 | tcp_call_bpf_2arg(sk, BPF_SOCK_OPS_STATE_CB, oldstate, state); | ||
2068 | |||
2045 | switch (state) { | 2069 | switch (state) { |
2046 | case TCP_ESTABLISHED: | 2070 | case TCP_ESTABLISHED: |
2047 | if (oldstate != TCP_ESTABLISHED) | 2071 | if (oldstate != TCP_ESTABLISHED) |