Skip to content

Commit 4396e46

Browse files
soheilhydavem330
authored andcommitted
tcp: remove tcp_tw_recycle
The tcp_tw_recycle was already broken for connections behind NAT, since the per-destination timestamp is not monotonically increasing for multiple machines behind a single destination address. After the randomization of TCP timestamp offsets in commit 8a5bd45f6616 (tcp: randomize tcp timestamp offsets for each connection), the tcp_tw_recycle is broken for all types of connections for the same reason: the timestamps received from a single machine is not monotonically increasing, anymore. Remove tcp_tw_recycle, since it is not functional. Also, remove the PAWSPassive SNMP counter since it is only used for tcp_tw_recycle, and simplify tcp_v4_route_req and tcp_v6_route_req since the strict argument is only set when tcp_tw_recycle is enabled. Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: Yuchung Cheng <ycheng@google.com> Cc: Lutz Vieweg <lvml@5t9.de> Cc: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d82bae1 commit 4396e46

File tree

9 files changed

+9
-59
lines changed

9 files changed

+9
-59
lines changed

Documentation/networking/ip-sysctl.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -640,11 +640,6 @@ tcp_tso_win_divisor - INTEGER
640640
building larger TSO frames.
641641
Default: 3
642642

643-
tcp_tw_recycle - BOOLEAN
644-
Enable fast recycling TIME-WAIT sockets. Default value is 0.
645-
It should not be changed without advice/request of technical
646-
experts.
647-
648643
tcp_tw_reuse - BOOLEAN
649644
Allow to reuse TIME-WAIT sockets for new connections when it is
650645
safe from protocol viewpoint. Default value is 0.

include/net/netns/ipv4.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ struct inet_timewait_death_row {
3333
atomic_t tw_count;
3434

3535
struct inet_hashinfo *hashinfo ____cacheline_aligned_in_smp;
36-
int sysctl_tw_recycle;
3736
int sysctl_max_tw_buckets;
3837
};
3938

include/net/tcp.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,8 +1810,7 @@ struct tcp_request_sock_ops {
18101810
__u16 *mss);
18111811
#endif
18121812
struct dst_entry *(*route_req)(const struct sock *sk, struct flowi *fl,
1813-
const struct request_sock *req,
1814-
bool *strict);
1813+
const struct request_sock *req);
18151814
__u32 (*init_seq_tsoff)(const struct sk_buff *skb, u32 *tsoff);
18161815
int (*send_synack)(const struct sock *sk, struct dst_entry *dst,
18171816
struct flowi *fl, struct request_sock *req,

include/uapi/linux/snmp.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ enum
177177
LINUX_MIB_TIMEWAITED, /* TimeWaited */
178178
LINUX_MIB_TIMEWAITRECYCLED, /* TimeWaitRecycled */
179179
LINUX_MIB_TIMEWAITKILLED, /* TimeWaitKilled */
180-
LINUX_MIB_PAWSPASSIVEREJECTED, /* PAWSPassiveRejected */
181180
LINUX_MIB_PAWSACTIVEREJECTED, /* PAWSActiveRejected */
182181
LINUX_MIB_PAWSESTABREJECTED, /* PAWSEstabRejected */
183182
LINUX_MIB_DELAYEDACKS, /* DelayedACKs */

net/ipv4/proc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ static const struct snmp_mib snmp4_net_list[] = {
199199
SNMP_MIB_ITEM("TW", LINUX_MIB_TIMEWAITED),
200200
SNMP_MIB_ITEM("TWRecycled", LINUX_MIB_TIMEWAITRECYCLED),
201201
SNMP_MIB_ITEM("TWKilled", LINUX_MIB_TIMEWAITKILLED),
202-
SNMP_MIB_ITEM("PAWSPassive", LINUX_MIB_PAWSPASSIVEREJECTED),
203202
SNMP_MIB_ITEM("PAWSActive", LINUX_MIB_PAWSACTIVEREJECTED),
204203
SNMP_MIB_ITEM("PAWSEstab", LINUX_MIB_PAWSESTABREJECTED),
205204
SNMP_MIB_ITEM("DelayedACKs", LINUX_MIB_DELAYEDACKS),

net/ipv4/sysctl_net_ipv4.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -980,13 +980,6 @@ static struct ctl_table ipv4_net_table[] = {
980980
.mode = 0644,
981981
.proc_handler = proc_dointvec
982982
},
983-
{
984-
.procname = "tcp_tw_recycle",
985-
.data = &init_net.ipv4.tcp_death_row.sysctl_tw_recycle,
986-
.maxlen = sizeof(int),
987-
.mode = 0644,
988-
.proc_handler = proc_dointvec
989-
},
990983
{
991984
.procname = "tcp_max_syn_backlog",
992985
.data = &init_net.ipv4.sysctl_max_syn_backlog,

net/ipv4/tcp_input.c

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6327,31 +6327,11 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
63276327
af_ops->init_seq_tsoff(skb, &tcp_rsk(req)->ts_off);
63286328

63296329
if (!want_cookie && !isn) {
6330-
/* VJ's idea. We save last timestamp seen
6331-
* from the destination in peer table, when entering
6332-
* state TIME-WAIT, and check against it before
6333-
* accepting new connection request.
6334-
*
6335-
* If "isn" is not zero, this request hit alive
6336-
* timewait bucket, so that all the necessary checks
6337-
* are made in the function processing timewait state.
6338-
*/
6339-
if (net->ipv4.tcp_death_row.sysctl_tw_recycle) {
6340-
bool strict;
6341-
6342-
dst = af_ops->route_req(sk, &fl, req, &strict);
6343-
6344-
if (dst && strict &&
6345-
!tcp_peer_is_proven(req, dst)) {
6346-
NET_INC_STATS(sock_net(sk), LINUX_MIB_PAWSPASSIVEREJECTED);
6347-
goto drop_and_release;
6348-
}
6349-
}
63506330
/* Kill the following clause, if you dislike this way. */
6351-
else if (!net->ipv4.sysctl_tcp_syncookies &&
6352-
(net->ipv4.sysctl_max_syn_backlog - inet_csk_reqsk_queue_len(sk) <
6353-
(net->ipv4.sysctl_max_syn_backlog >> 2)) &&
6354-
!tcp_peer_is_proven(req, dst)) {
6331+
if (!net->ipv4.sysctl_tcp_syncookies &&
6332+
(net->ipv4.sysctl_max_syn_backlog - inet_csk_reqsk_queue_len(sk) <
6333+
(net->ipv4.sysctl_max_syn_backlog >> 2)) &&
6334+
!tcp_peer_is_proven(req, dst)) {
63556335
/* Without syncookies last quarter of
63566336
* backlog is filled with destinations,
63576337
* proven to be alive.
@@ -6367,7 +6347,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
63676347
isn = af_ops->init_seq_tsoff(skb, &tcp_rsk(req)->ts_off);
63686348
}
63696349
if (!dst) {
6370-
dst = af_ops->route_req(sk, &fl, req, NULL);
6350+
dst = af_ops->route_req(sk, &fl, req);
63716351
if (!dst)
63726352
goto drop_and_free;
63736353
}

net/ipv4/tcp_ipv4.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,19 +1213,9 @@ static void tcp_v4_init_req(struct request_sock *req,
12131213

12141214
static struct dst_entry *tcp_v4_route_req(const struct sock *sk,
12151215
struct flowi *fl,
1216-
const struct request_sock *req,
1217-
bool *strict)
1216+
const struct request_sock *req)
12181217
{
1219-
struct dst_entry *dst = inet_csk_route_req(sk, &fl->u.ip4, req);
1220-
1221-
if (strict) {
1222-
if (fl->u.ip4.daddr == inet_rsk(req)->ir_rmt_addr)
1223-
*strict = true;
1224-
else
1225-
*strict = false;
1226-
}
1227-
1228-
return dst;
1218+
return inet_csk_route_req(sk, &fl->u.ip4, req);
12291219
}
12301220

12311221
struct request_sock_ops tcp_request_sock_ops __read_mostly = {
@@ -2462,7 +2452,6 @@ static int __net_init tcp_sk_init(struct net *net)
24622452
net->ipv4.sysctl_tcp_tw_reuse = 0;
24632453

24642454
cnt = tcp_hashinfo.ehash_mask + 1;
2465-
net->ipv4.tcp_death_row.sysctl_tw_recycle = 0;
24662455
net->ipv4.tcp_death_row.sysctl_max_tw_buckets = (cnt + 1) / 2;
24672456
net->ipv4.tcp_death_row.hashinfo = &tcp_hashinfo;
24682457

net/ipv6/tcp_ipv6.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,8 @@ static void tcp_v6_init_req(struct request_sock *req,
722722

723723
static struct dst_entry *tcp_v6_route_req(const struct sock *sk,
724724
struct flowi *fl,
725-
const struct request_sock *req,
726-
bool *strict)
725+
const struct request_sock *req)
727726
{
728-
if (strict)
729-
*strict = true;
730727
return inet6_csk_route_req(sk, &fl->u.ip6, req, IPPROTO_TCP);
731728
}
732729

0 commit comments

Comments
 (0)