Skip to content

Commit 8407994

Browse files
JasonXingdavem330
authored andcommitted
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: Jason Xing <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent edc92b4 commit 8407994

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

include/net/rstreason.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
FN(INVALID_SYN) \
2020
FN(TCP_ABORT_ON_CLOSE) \
2121
FN(TCP_ABORT_ON_LINGER) \
22+
FN(TCP_ABORT_ON_MEMORY) \
2223
FN(MPTCP_RST_EUNSPEC) \
2324
FN(MPTCP_RST_EMPTCP) \
2425
FN(MPTCP_RST_ERESOURCE) \
@@ -96,6 +97,11 @@ enum sk_rst_reason {
9697
* corresponding to LINUX_MIB_TCPABORTONLINGER
9798
*/
9899
SK_RST_REASON_TCP_ABORT_ON_LINGER,
100+
/**
101+
* @SK_RST_REASON_TCP_ABORT_ON_MEMORY: abort on memory
102+
* corresponding to LINUX_MIB_TCPABORTONMEMORY
103+
*/
104+
SK_RST_REASON_TCP_ABORT_ON_MEMORY,
99105

100106
/* Copy from include/uapi/linux/mptcp.h.
101107
* These reset fields will not be changed since they adhere to

net/ipv4/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2927,7 +2927,7 @@ void __tcp_close(struct sock *sk, long timeout)
29272927
if (tcp_check_oom(sk, 0)) {
29282928
tcp_set_state(sk, TCP_CLOSE);
29292929
tcp_send_active_reset(sk, GFP_ATOMIC,
2930-
SK_RST_REASON_NOT_SPECIFIED);
2930+
SK_RST_REASON_TCP_ABORT_ON_MEMORY);
29312931
__NET_INC_STATS(sock_net(sk),
29322932
LINUX_MIB_TCPABORTONMEMORY);
29332933
} else if (!check_net(sock_net(sk))) {

net/ipv4/tcp_timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static int tcp_out_of_resources(struct sock *sk, bool do_reset)
125125
do_reset = true;
126126
if (do_reset)
127127
tcp_send_active_reset(sk, GFP_ATOMIC,
128-
SK_RST_REASON_NOT_SPECIFIED);
128+
SK_RST_REASON_TCP_ABORT_ON_MEMORY);
129129
tcp_done(sk);
130130
__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY);
131131
return 1;

0 commit comments

Comments
 (0)