Commit 8407994f authored by Jason Xing's avatar Jason Xing Committed by David S. Miller
Browse files

tcp: rstreason: introduce SK_RST_REASON_TCP_ABORT_ON_MEMORY for active reset



Introducing a new type TCP_ABORT_ON_MEMORY for tcp reset reason to handle
out of memory case.

Signed-off-by: default avatarJason Xing <kernelxing@tencent.com>
Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent edc92b48
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
	FN(INVALID_SYN)			\
	FN(TCP_ABORT_ON_CLOSE)		\
	FN(TCP_ABORT_ON_LINGER)		\
	FN(TCP_ABORT_ON_MEMORY)		\
	FN(MPTCP_RST_EUNSPEC)		\
	FN(MPTCP_RST_EMPTCP)		\
	FN(MPTCP_RST_ERESOURCE)		\
@@ -96,6 +97,11 @@ enum sk_rst_reason {
	 * corresponding to LINUX_MIB_TCPABORTONLINGER
	 */
	SK_RST_REASON_TCP_ABORT_ON_LINGER,
	/**
	 * @SK_RST_REASON_TCP_ABORT_ON_MEMORY: abort on memory
	 * corresponding to LINUX_MIB_TCPABORTONMEMORY
	 */
	SK_RST_REASON_TCP_ABORT_ON_MEMORY,

	/* Copy from include/uapi/linux/mptcp.h.
	 * These reset fields will not be changed since they adhere to
+1 −1
Original line number Diff line number Diff line
@@ -2927,7 +2927,7 @@ void __tcp_close(struct sock *sk, long timeout)
		if (tcp_check_oom(sk, 0)) {
			tcp_set_state(sk, TCP_CLOSE);
			tcp_send_active_reset(sk, GFP_ATOMIC,
					      SK_RST_REASON_NOT_SPECIFIED);
					      SK_RST_REASON_TCP_ABORT_ON_MEMORY);
			__NET_INC_STATS(sock_net(sk),
					LINUX_MIB_TCPABORTONMEMORY);
		} else if (!check_net(sock_net(sk))) {
+1 −1
Original line number Diff line number Diff line
@@ -125,7 +125,7 @@ static int tcp_out_of_resources(struct sock *sk, bool do_reset)
			do_reset = true;
		if (do_reset)
			tcp_send_active_reset(sk, GFP_ATOMIC,
					      SK_RST_REASON_NOT_SPECIFIED);
					      SK_RST_REASON_TCP_ABORT_ON_MEMORY);
		tcp_done(sk);
		__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY);
		return 1;