Skip to content

Commit 435f3f2

Browse files
committed
Merge branch 'tcp_openreq_child'
Eric Dumazet says: ==================== tcp: remove code from tcp_create_openreq_child() tcp_create_openreq_child() is essentially cloning a listener, then must initialize some fields that can not be inherited. Listeners are either fresh sockets, or sockets that came through tcp_disconnect() after a session that dirtied many fields. By moving code to tcp_disconnect(), we can shorten time taken to create a clone, since tcp_disconnect() operation is very unlikely. ==================== Acked-by: Yuchung Cheng <ycheng@google.com> Acked-by: Soheil Hassas Yeganeh <soheil@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents bec03de + 6bcdc40 commit 435f3f2

File tree

2 files changed

+20
-35
lines changed

2 files changed

+20
-35
lines changed

net/ipv4/tcp.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2572,14 +2572,16 @@ int tcp_disconnect(struct sock *sk, int flags)
25722572
sk->sk_shutdown = 0;
25732573
sock_reset_flag(sk, SOCK_DONE);
25742574
tp->srtt_us = 0;
2575+
tp->mdev_us = jiffies_to_usecs(TCP_TIMEOUT_INIT);
25752576
tp->rcv_rtt_last_tsecr = 0;
25762577
tp->write_seq += tp->max_window + 2;
25772578
if (tp->write_seq == 0)
25782579
tp->write_seq = 1;
25792580
icsk->icsk_backoff = 0;
2580-
tp->snd_cwnd = 2;
25812581
icsk->icsk_probes_out = 0;
2582+
icsk->icsk_rto = TCP_TIMEOUT_INIT;
25822583
tp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
2584+
tp->snd_cwnd = TCP_INIT_CWND;
25832585
tp->snd_cwnd_cnt = 0;
25842586
tp->window_clamp = 0;
25852587
tp->delivered_ce = 0;
@@ -2603,6 +2605,23 @@ int tcp_disconnect(struct sock *sk, int flags)
26032605
tp->duplicate_sack[0].end_seq = 0;
26042606
tp->dsack_dups = 0;
26052607
tp->reord_seen = 0;
2608+
tp->retrans_out = 0;
2609+
tp->sacked_out = 0;
2610+
tp->tlp_high_seq = 0;
2611+
tp->last_oow_ack_time = 0;
2612+
/* There's a bubble in the pipe until at least the first ACK. */
2613+
tp->app_limited = ~0U;
2614+
tp->rack.mstamp = 0;
2615+
tp->rack.advanced = 0;
2616+
tp->rack.reo_wnd_steps = 1;
2617+
tp->rack.last_delivered = 0;
2618+
tp->rack.reo_wnd_persist = 0;
2619+
tp->rack.dsack_seen = 0;
2620+
tp->syn_data_acked = 0;
2621+
tp->rx_opt.saw_tstamp = 0;
2622+
tp->rx_opt.dsack = 0;
2623+
tp->rx_opt.num_sacks = 0;
2624+
26062625

26072626
/* Clean up fastopen related fields */
26082627
tcp_free_fastopen_req(tp);

net/ipv4/tcp_minisocks.c

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -479,43 +479,16 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
479479

480480
tcp_init_wl(newtp, treq->rcv_isn);
481481

482-
newtp->srtt_us = 0;
483-
newtp->mdev_us = jiffies_to_usecs(TCP_TIMEOUT_INIT);
484482
minmax_reset(&newtp->rtt_min, tcp_jiffies32, ~0U);
485-
newicsk->icsk_rto = TCP_TIMEOUT_INIT;
486483
newicsk->icsk_ack.lrcvtime = tcp_jiffies32;
487484

488-
newtp->packets_out = 0;
489-
newtp->retrans_out = 0;
490-
newtp->sacked_out = 0;
491-
newtp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
492-
newtp->tlp_high_seq = 0;
493485
newtp->lsndtime = tcp_jiffies32;
494486
newsk->sk_txhash = treq->txhash;
495-
newtp->last_oow_ack_time = 0;
496487
newtp->total_retrans = req->num_retrans;
497488

498-
/* So many TCP implementations out there (incorrectly) count the
499-
* initial SYN frame in their delayed-ACK and congestion control
500-
* algorithms that we must have the following bandaid to talk
501-
* efficiently to them. -DaveM
502-
*/
503-
newtp->snd_cwnd = TCP_INIT_CWND;
504-
newtp->snd_cwnd_cnt = 0;
505-
506-
/* There's a bubble in the pipe until at least the first ACK. */
507-
newtp->app_limited = ~0U;
508-
509489
tcp_init_xmit_timers(newsk);
510490
newtp->write_seq = newtp->pushed_seq = treq->snt_isn + 1;
511491

512-
newtp->rx_opt.saw_tstamp = 0;
513-
514-
newtp->rx_opt.dsack = 0;
515-
newtp->rx_opt.num_sacks = 0;
516-
517-
newtp->urg_data = 0;
518-
519492
if (sock_flag(newsk, SOCK_KEEPOPEN))
520493
inet_csk_reset_keepalive_timer(newsk,
521494
keepalive_time_when(newtp));
@@ -556,13 +529,6 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
556529
tcp_ecn_openreq_child(newtp, req);
557530
newtp->fastopen_req = NULL;
558531
newtp->fastopen_rsk = NULL;
559-
newtp->syn_data_acked = 0;
560-
newtp->rack.mstamp = 0;
561-
newtp->rack.advanced = 0;
562-
newtp->rack.reo_wnd_steps = 1;
563-
newtp->rack.last_delivered = 0;
564-
newtp->rack.reo_wnd_persist = 0;
565-
newtp->rack.dsack_seen = 0;
566532

567533
__TCP_INC_STATS(sock_net(sk), TCP_MIB_PASSIVEOPENS);
568534

0 commit comments

Comments
 (0)