aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_timer.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-01-29 10:14:59 -0500
committerDavid S. Miller <davem@davemloft.net>2018-01-29 10:15:51 -0500
commit3e3ab9ccca5b50b11bd4d16c2048b667343354bd (patch)
tree7279f7401e7cc2b93fb7cb2bff894b5385429a68 /net/ipv4/tcp_timer.c
parent868c36dcc949c26bc74fa4661b670d9acc6489e4 (diff)
parentba804bb4b72e57374b5f567b783aa0298fba0ce6 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_timer.c')
-rw-r--r--net/ipv4/tcp_timer.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 257abdde23b0..71fc60f1b326 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -48,11 +48,19 @@ static void tcp_write_err(struct sock *sk)
48 * to prevent DoS attacks. It is called when a retransmission timeout 48 * to prevent DoS attacks. It is called when a retransmission timeout
49 * or zero probe timeout occurs on orphaned socket. 49 * or zero probe timeout occurs on orphaned socket.
50 * 50 *
51 * Also close if our net namespace is exiting; in that case there is no
52 * hope of ever communicating again since all netns interfaces are already
53 * down (or about to be down), and we need to release our dst references,
54 * which have been moved to the netns loopback interface, so the namespace
55 * can finish exiting. This condition is only possible if we are a kernel
56 * socket, as those do not hold references to the namespace.
57 *
51 * Criteria is still not confirmed experimentally and may change. 58 * Criteria is still not confirmed experimentally and may change.
52 * We kill the socket, if: 59 * We kill the socket, if:
53 * 1. If number of orphaned sockets exceeds an administratively configured 60 * 1. If number of orphaned sockets exceeds an administratively configured
54 * limit. 61 * limit.
55 * 2. If we have strong memory pressure. 62 * 2. If we have strong memory pressure.
63 * 3. If our net namespace is exiting.
56 */ 64 */
57static int tcp_out_of_resources(struct sock *sk, bool do_reset) 65static int tcp_out_of_resources(struct sock *sk, bool do_reset)
58{ 66{
@@ -81,6 +89,13 @@ static int tcp_out_of_resources(struct sock *sk, bool do_reset)
81 __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY); 89 __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY);
82 return 1; 90 return 1;
83 } 91 }
92
93 if (!check_net(sock_net(sk))) {
94 /* Not possible to send reset; just close */
95 tcp_done(sk);
96 return 1;
97 }
98
84 return 0; 99 return 0;
85} 100}
86 101