ben*_*ell 8 networking linux tcp sysctl
将 tcp_orphan_retries 设置为 0 是否意味着重试没有限制,还是意味着它根本不会重试?
小智 8
将 tcp_orphan_retries 设置为 0 是一种特殊情况,请参阅 tcp_timer.c
98 /* Calculate maximal number or retries on an orphaned socket. */
99 static int tcp_orphan_retries(struct sock *sk, int alive)
100 {
101 int retries = sysctl_tcp_orphan_retries; /* May be zero. */
102
103 /* We know from an ICMP that something is wrong. */
104 if (sk->sk_err_soft && !alive)
105 retries = 0;
106
107 /* However, if socket sent something recently, select some safe
108 * number of retries. 8 corresponds to >100 seconds with minimal
109 * RTO of 200msec. */
110 if (retries == 0 && alive)
111 retries = 8;
112 return retries;
113 }
Run Code Online (Sandbox Code Playgroud)
它并不意味着“永远尝试”,而是意味着“根本不要尝试”。这是服务器试图礼貌地告诉客户端服务器正准备关闭他的套接字,如果它愿意有序地断开连接,或者发送更多数据,那就太好了。它会尝试 X 次让客户端响应,X 次后,它会回收系统端的套接字。
对我来说,将该数字设置为 0 表明该服务器已被大量使用,并且对孤立服务器采取零容忍政策。这也可能是对 DDOS 的响应:许多 DDOS 的工作方式是打开套接字连接,然后挂在该连接上,什么都不做。