mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-23 00:20:52 -05:00
tcp: rstreason: introduce SK_RST_REASON_TCP_STATE for active reset
Introducing a new type TCP_STATE to handle some reset conditions appearing in RFC 793 due to its socket state. Actually, we can look into RFC 9293 which has no discrepancy about this part. Signed-off-by: Jason Xing <kernelxing@tencent.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
8407994f0c
commit
edefba66d9
3 changed files with 13 additions and 5 deletions
|
@ -20,6 +20,7 @@
|
||||||
FN(TCP_ABORT_ON_CLOSE) \
|
FN(TCP_ABORT_ON_CLOSE) \
|
||||||
FN(TCP_ABORT_ON_LINGER) \
|
FN(TCP_ABORT_ON_LINGER) \
|
||||||
FN(TCP_ABORT_ON_MEMORY) \
|
FN(TCP_ABORT_ON_MEMORY) \
|
||||||
|
FN(TCP_STATE) \
|
||||||
FN(MPTCP_RST_EUNSPEC) \
|
FN(MPTCP_RST_EUNSPEC) \
|
||||||
FN(MPTCP_RST_EMPTCP) \
|
FN(MPTCP_RST_EMPTCP) \
|
||||||
FN(MPTCP_RST_ERESOURCE) \
|
FN(MPTCP_RST_ERESOURCE) \
|
||||||
|
@ -102,6 +103,11 @@ enum sk_rst_reason {
|
||||||
* corresponding to LINUX_MIB_TCPABORTONMEMORY
|
* corresponding to LINUX_MIB_TCPABORTONMEMORY
|
||||||
*/
|
*/
|
||||||
SK_RST_REASON_TCP_ABORT_ON_MEMORY,
|
SK_RST_REASON_TCP_ABORT_ON_MEMORY,
|
||||||
|
/**
|
||||||
|
* @SK_RST_REASON_TCP_STATE: abort on tcp state
|
||||||
|
* Please see RFC 9293 for all possible reset conditions
|
||||||
|
*/
|
||||||
|
SK_RST_REASON_TCP_STATE,
|
||||||
|
|
||||||
/* Copy from include/uapi/linux/mptcp.h.
|
/* Copy from include/uapi/linux/mptcp.h.
|
||||||
* These reset fields will not be changed since they adhere to
|
* These reset fields will not be changed since they adhere to
|
||||||
|
|
|
@ -3025,9 +3025,11 @@ int tcp_disconnect(struct sock *sk, int flags)
|
||||||
inet_csk_listen_stop(sk);
|
inet_csk_listen_stop(sk);
|
||||||
} else if (unlikely(tp->repair)) {
|
} else if (unlikely(tp->repair)) {
|
||||||
WRITE_ONCE(sk->sk_err, ECONNABORTED);
|
WRITE_ONCE(sk->sk_err, ECONNABORTED);
|
||||||
} else if (tcp_need_reset(old_state) ||
|
} else if (tcp_need_reset(old_state)) {
|
||||||
(tp->snd_nxt != tp->write_seq &&
|
tcp_send_active_reset(sk, gfp_any(), SK_RST_REASON_TCP_STATE);
|
||||||
(1 << old_state) & (TCPF_CLOSING | TCPF_LAST_ACK))) {
|
WRITE_ONCE(sk->sk_err, ECONNRESET);
|
||||||
|
} else if (tp->snd_nxt != tp->write_seq &&
|
||||||
|
(1 << old_state) & (TCPF_CLOSING | TCPF_LAST_ACK)) {
|
||||||
/* The last check adjusts for discrepancy of Linux wrt. RFC
|
/* The last check adjusts for discrepancy of Linux wrt. RFC
|
||||||
* states
|
* states
|
||||||
*/
|
*/
|
||||||
|
@ -4649,7 +4651,7 @@ int tcp_abort(struct sock *sk, int err)
|
||||||
if (!sock_flag(sk, SOCK_DEAD)) {
|
if (!sock_flag(sk, SOCK_DEAD)) {
|
||||||
if (tcp_need_reset(sk->sk_state))
|
if (tcp_need_reset(sk->sk_state))
|
||||||
tcp_send_active_reset(sk, GFP_ATOMIC,
|
tcp_send_active_reset(sk, GFP_ATOMIC,
|
||||||
SK_RST_REASON_NOT_SPECIFIED);
|
SK_RST_REASON_TCP_STATE);
|
||||||
tcp_done_with_error(sk, err);
|
tcp_done_with_error(sk, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -779,7 +779,7 @@ static void tcp_keepalive_timer (struct timer_list *t)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tcp_send_active_reset(sk, GFP_ATOMIC, SK_RST_REASON_NOT_SPECIFIED);
|
tcp_send_active_reset(sk, GFP_ATOMIC, SK_RST_REASON_TCP_STATE);
|
||||||
goto death;
|
goto death;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue