All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child()
@ 2019-01-17 19:23 Eric Dumazet
  2019-01-17 19:23 ` [PATCH net-next 01/11] tcp: do not set snd_ssthresh in tcp_create_openreq_child() Eric Dumazet
                   ` (12 more replies)
  0 siblings, 13 replies; 15+ messages in thread
From: Eric Dumazet @ 2019-01-17 19:23 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, Soheil Hassas Yeganeh, Neal Cardwell, Yuchung Cheng,
	Eric Dumazet, Eric Dumazet

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.

Eric Dumazet (11):
  tcp: do not set snd_ssthresh in tcp_create_openreq_child()
  tcp: move icsk_rto init to tcp_disconnect()
  tcp: do not clear packets_out in tcp_create_openreq_child()
  tcp: do not clear srtt_us in tcp_create_openreq_child
  tcp: move mdev_us init to tcp_disconnect()
  tcp: move snd_cwnd & snd_cwnd_cnt init to tcp_disconnect()
  tcp: do not clear urg_data in tcp_create_openreq_child
  tcp: move retrans_out,sacked_out,tlp_high_seq,last_oow_ack_time init
    to tcp_disconnect()
  tcp: move app_limited init to tcp_disconnect()
  tcp: move tp->rack init to tcp_disconnect()
  tcp: move rx_opt & syn_data_acked init to tcp_disconnect()

 net/ipv4/tcp.c           | 21 ++++++++++++++++++++-
 net/ipv4/tcp_minisocks.c | 34 ----------------------------------
 2 files changed, 20 insertions(+), 35 deletions(-)

-- 
2.20.1.321.g9e740568ce-goog


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH net-next 01/11] tcp: do not set snd_ssthresh in tcp_create_openreq_child()
  2019-01-17 19:23 [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Eric Dumazet
@ 2019-01-17 19:23 ` Eric Dumazet
  2019-01-17 19:23 ` [PATCH net-next 02/11] tcp: move icsk_rto init to tcp_disconnect() Eric Dumazet
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Eric Dumazet @ 2019-01-17 19:23 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, Soheil Hassas Yeganeh, Neal Cardwell, Yuchung Cheng,
	Eric Dumazet, Eric Dumazet

New sockets get the field set to TCP_INFINITE_SSTHRESH in tcp_init_sock()
In case a socket had this field changed and transitions to TCP_LISTEN
state, tcp_disconnect() also makes sure snd_ssthresh is set to
TCP_INFINITE_SSTHRESH.

So a listener has this field set to TCP_INFINITE_SSTHRESH already.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp_minisocks.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 12affb7864d981a6494059232c4965aaee756803..0cffa5937b1261984c3986b107220af495264437 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -488,7 +488,6 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
 	newtp->packets_out = 0;
 	newtp->retrans_out = 0;
 	newtp->sacked_out = 0;
-	newtp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
 	newtp->tlp_high_seq = 0;
 	newtp->lsndtime = tcp_jiffies32;
 	newsk->sk_txhash = treq->txhash;
-- 
2.20.1.321.g9e740568ce-goog


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 02/11] tcp: move icsk_rto init to tcp_disconnect()
  2019-01-17 19:23 [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Eric Dumazet
  2019-01-17 19:23 ` [PATCH net-next 01/11] tcp: do not set snd_ssthresh in tcp_create_openreq_child() Eric Dumazet
@ 2019-01-17 19:23 ` Eric Dumazet
  2019-01-17 19:23 ` [PATCH net-next 03/11] tcp: do not clear packets_out in tcp_create_openreq_child() Eric Dumazet
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Eric Dumazet @ 2019-01-17 19:23 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, Soheil Hassas Yeganeh, Neal Cardwell, Yuchung Cheng,
	Eric Dumazet, Eric Dumazet

If we make sure a listener always has its icsk_rto
field set to TCP_TIMEOUT_INIT, we do not need to rewrite
this field after a new clone is created.

tcp_disconnect() is very seldom used in real applications.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp.c           | 1 +
 net/ipv4/tcp_minisocks.c | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 27e2f6837062374baaea267a8788b9fd91db25ff..9d8131f95a9732fb873c8a8b2c918657e1dade30 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2579,6 +2579,7 @@ int tcp_disconnect(struct sock *sk, int flags)
 	icsk->icsk_backoff = 0;
 	tp->snd_cwnd = 2;
 	icsk->icsk_probes_out = 0;
+	icsk->icsk_rto = TCP_TIMEOUT_INIT;
 	tp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
 	tp->snd_cwnd_cnt = 0;
 	tp->window_clamp = 0;
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 0cffa5937b1261984c3986b107220af495264437..9799f1d32e44f4c733b41c4d8fc7739970ccca28 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -482,7 +482,6 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
 	newtp->srtt_us = 0;
 	newtp->mdev_us = jiffies_to_usecs(TCP_TIMEOUT_INIT);
 	minmax_reset(&newtp->rtt_min, tcp_jiffies32, ~0U);
-	newicsk->icsk_rto = TCP_TIMEOUT_INIT;
 	newicsk->icsk_ack.lrcvtime = tcp_jiffies32;
 
 	newtp->packets_out = 0;
-- 
2.20.1.321.g9e740568ce-goog


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 03/11] tcp: do not clear packets_out in tcp_create_openreq_child()
  2019-01-17 19:23 [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Eric Dumazet
  2019-01-17 19:23 ` [PATCH net-next 01/11] tcp: do not set snd_ssthresh in tcp_create_openreq_child() Eric Dumazet
  2019-01-17 19:23 ` [PATCH net-next 02/11] tcp: move icsk_rto init to tcp_disconnect() Eric Dumazet
@ 2019-01-17 19:23 ` Eric Dumazet
  2019-01-17 19:23 ` [PATCH net-next 04/11] tcp: do not clear srtt_us in tcp_create_openreq_child Eric Dumazet
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Eric Dumazet @ 2019-01-17 19:23 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, Soheil Hassas Yeganeh, Neal Cardwell, Yuchung Cheng,
	Eric Dumazet, Eric Dumazet

New sockets have this field cleared, and tcp_disconnect()
calls tcp_write_queue_purge() which among other things
also clear tp->packets_out

So a listener is guaranteed to have this field cleared.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp_minisocks.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 9799f1d32e44f4c733b41c4d8fc7739970ccca28..830e4eb558f8861fb3813c35b215425a53cacf62 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -484,7 +484,6 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
 	minmax_reset(&newtp->rtt_min, tcp_jiffies32, ~0U);
 	newicsk->icsk_ack.lrcvtime = tcp_jiffies32;
 
-	newtp->packets_out = 0;
 	newtp->retrans_out = 0;
 	newtp->sacked_out = 0;
 	newtp->tlp_high_seq = 0;
-- 
2.20.1.321.g9e740568ce-goog


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 04/11] tcp: do not clear srtt_us in tcp_create_openreq_child
  2019-01-17 19:23 [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Eric Dumazet
                   ` (2 preceding siblings ...)
  2019-01-17 19:23 ` [PATCH net-next 03/11] tcp: do not clear packets_out in tcp_create_openreq_child() Eric Dumazet
@ 2019-01-17 19:23 ` Eric Dumazet
  2019-01-17 19:23 ` [PATCH net-next 05/11] tcp: move mdev_us init to tcp_disconnect() Eric Dumazet
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Eric Dumazet @ 2019-01-17 19:23 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, Soheil Hassas Yeganeh, Neal Cardwell, Yuchung Cheng,
	Eric Dumazet, Eric Dumazet

All listeners have this field cleared already, since tcp_disconnect()
clears it and newly created sockets have also a zero value here.

So a clone will inherit a zero value here.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp_minisocks.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 830e4eb558f8861fb3813c35b215425a53cacf62..977ad1c0cccad564fa111556ad0a0f3af4534381 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -479,7 +479,6 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
 
 	tcp_init_wl(newtp, treq->rcv_isn);
 
-	newtp->srtt_us = 0;
 	newtp->mdev_us = jiffies_to_usecs(TCP_TIMEOUT_INIT);
 	minmax_reset(&newtp->rtt_min, tcp_jiffies32, ~0U);
 	newicsk->icsk_ack.lrcvtime = tcp_jiffies32;
-- 
2.20.1.321.g9e740568ce-goog


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 05/11] tcp: move mdev_us init to tcp_disconnect()
  2019-01-17 19:23 [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Eric Dumazet
                   ` (3 preceding siblings ...)
  2019-01-17 19:23 ` [PATCH net-next 04/11] tcp: do not clear srtt_us in tcp_create_openreq_child Eric Dumazet
@ 2019-01-17 19:23 ` Eric Dumazet
  2019-01-17 19:23 ` [PATCH net-next 06/11] tcp: move snd_cwnd & snd_cwnd_cnt " Eric Dumazet
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Eric Dumazet @ 2019-01-17 19:23 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, Soheil Hassas Yeganeh, Neal Cardwell, Yuchung Cheng,
	Eric Dumazet, Eric Dumazet

If we make sure a listener always has its mdev_us
field set to TCP_TIMEOUT_INIT, we do not need to rewrite
this field after a new clone is created.

tcp_disconnect() is very seldom used in real applications.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp.c           | 1 +
 net/ipv4/tcp_minisocks.c | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 9d8131f95a9732fb873c8a8b2c918657e1dade30..731b1c6e88a992e51b9e303803444dc255d888fa 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2572,6 +2572,7 @@ int tcp_disconnect(struct sock *sk, int flags)
 	sk->sk_shutdown = 0;
 	sock_reset_flag(sk, SOCK_DONE);
 	tp->srtt_us = 0;
+	tp->mdev_us = jiffies_to_usecs(TCP_TIMEOUT_INIT);
 	tp->rcv_rtt_last_tsecr = 0;
 	tp->write_seq += tp->max_window + 2;
 	if (tp->write_seq == 0)
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 977ad1c0cccad564fa111556ad0a0f3af4534381..35906b44e2cfa767f760773d0321a992114fee5b 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -479,7 +479,6 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
 
 	tcp_init_wl(newtp, treq->rcv_isn);
 
-	newtp->mdev_us = jiffies_to_usecs(TCP_TIMEOUT_INIT);
 	minmax_reset(&newtp->rtt_min, tcp_jiffies32, ~0U);
 	newicsk->icsk_ack.lrcvtime = tcp_jiffies32;
 
-- 
2.20.1.321.g9e740568ce-goog


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 06/11] tcp: move snd_cwnd & snd_cwnd_cnt init to tcp_disconnect()
  2019-01-17 19:23 [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Eric Dumazet
                   ` (4 preceding siblings ...)
  2019-01-17 19:23 ` [PATCH net-next 05/11] tcp: move mdev_us init to tcp_disconnect() Eric Dumazet
@ 2019-01-17 19:23 ` Eric Dumazet
  2019-01-17 19:23 ` [PATCH net-next 07/11] tcp: do not clear urg_data in tcp_create_openreq_child Eric Dumazet
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Eric Dumazet @ 2019-01-17 19:23 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, Soheil Hassas Yeganeh, Neal Cardwell, Yuchung Cheng,
	Eric Dumazet, Eric Dumazet

Passive connections can inherit proper value by cloning,
if we make sure all listeners have the proper values there.

tcp_disconnect() was setting snd_cwnd to 2, which seems
quite obsolete since IW10 adoption.

Also remove an obsolete comment.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp.c           | 2 +-
 net/ipv4/tcp_minisocks.c | 8 --------
 2 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 731b1c6e88a992e51b9e303803444dc255d888fa..3f99ad92eaedb2364e339842365f553fca8922e1 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2578,10 +2578,10 @@ int tcp_disconnect(struct sock *sk, int flags)
 	if (tp->write_seq == 0)
 		tp->write_seq = 1;
 	icsk->icsk_backoff = 0;
-	tp->snd_cwnd = 2;
 	icsk->icsk_probes_out = 0;
 	icsk->icsk_rto = TCP_TIMEOUT_INIT;
 	tp->snd_ssthresh = TCP_INFINITE_SSTHRESH;
+	tp->snd_cwnd = TCP_INIT_CWND;
 	tp->snd_cwnd_cnt = 0;
 	tp->window_clamp = 0;
 	tp->delivered_ce = 0;
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 35906b44e2cfa767f760773d0321a992114fee5b..ca96e7da99b6e450a5e881e280ad84137a57409d 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -490,14 +490,6 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
 	newtp->last_oow_ack_time = 0;
 	newtp->total_retrans = req->num_retrans;
 
-	/* So many TCP implementations out there (incorrectly) count the
-	 * initial SYN frame in their delayed-ACK and congestion control
-	 * algorithms that we must have the following bandaid to talk
-	 * efficiently to them.  -DaveM
-	 */
-	newtp->snd_cwnd = TCP_INIT_CWND;
-	newtp->snd_cwnd_cnt = 0;
-
 	/* There's a bubble in the pipe until at least the first ACK. */
 	newtp->app_limited = ~0U;
 
-- 
2.20.1.321.g9e740568ce-goog


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 07/11] tcp: do not clear urg_data in tcp_create_openreq_child
  2019-01-17 19:23 [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Eric Dumazet
                   ` (5 preceding siblings ...)
  2019-01-17 19:23 ` [PATCH net-next 06/11] tcp: move snd_cwnd & snd_cwnd_cnt " Eric Dumazet
@ 2019-01-17 19:23 ` Eric Dumazet
  2019-01-17 19:23 ` [PATCH net-next 08/11] tcp: move retrans_out,sacked_out,tlp_high_seq,last_oow_ack_time init to tcp_disconnect() Eric Dumazet
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Eric Dumazet @ 2019-01-17 19:23 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, Soheil Hassas Yeganeh, Neal Cardwell, Yuchung Cheng,
	Eric Dumazet, Eric Dumazet

All listeners have this field cleared already, since tcp_disconnect()
clears it and newly created sockets have also a zero value here.

So a clone will inherit a zero value here.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp_minisocks.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index ca96e7da99b6e450a5e881e280ad84137a57409d..2747aa72b8e2b5c190c2c3e68a7dea04ee97dcac 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -501,8 +501,6 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
 	newtp->rx_opt.dsack = 0;
 	newtp->rx_opt.num_sacks = 0;
 
-	newtp->urg_data = 0;
-
 	if (sock_flag(newsk, SOCK_KEEPOPEN))
 		inet_csk_reset_keepalive_timer(newsk,
 					       keepalive_time_when(newtp));
-- 
2.20.1.321.g9e740568ce-goog


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 08/11] tcp: move retrans_out,sacked_out,tlp_high_seq,last_oow_ack_time init to tcp_disconnect()
  2019-01-17 19:23 [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Eric Dumazet
                   ` (6 preceding siblings ...)
  2019-01-17 19:23 ` [PATCH net-next 07/11] tcp: do not clear urg_data in tcp_create_openreq_child Eric Dumazet
@ 2019-01-17 19:23 ` Eric Dumazet
  2019-01-17 19:23 ` [PATCH net-next 09/11] tcp: move app_limited " Eric Dumazet
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Eric Dumazet @ 2019-01-17 19:23 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, Soheil Hassas Yeganeh, Neal Cardwell, Yuchung Cheng,
	Eric Dumazet, Eric Dumazet

If we make sure all listeners have these fields cleared, then a clone
will also inherit zero values.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp.c           | 4 ++++
 net/ipv4/tcp_minisocks.c | 4 ----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 3f99ad92eaedb2364e339842365f553fca8922e1..551ad8604bea0cb459805165bb216a99fd3bd8e2 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2605,6 +2605,10 @@ int tcp_disconnect(struct sock *sk, int flags)
 	tp->duplicate_sack[0].end_seq = 0;
 	tp->dsack_dups = 0;
 	tp->reord_seen = 0;
+	tp->retrans_out = 0;
+	tp->sacked_out = 0;
+	tp->tlp_high_seq = 0;
+	tp->last_oow_ack_time = 0;
 
 	/* Clean up fastopen related fields */
 	tcp_free_fastopen_req(tp);
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 2747aa72b8e2b5c190c2c3e68a7dea04ee97dcac..29fba13849a79695b3f62a989b27157b57caedfb 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -482,12 +482,8 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
 	minmax_reset(&newtp->rtt_min, tcp_jiffies32, ~0U);
 	newicsk->icsk_ack.lrcvtime = tcp_jiffies32;
 
-	newtp->retrans_out = 0;
-	newtp->sacked_out = 0;
-	newtp->tlp_high_seq = 0;
 	newtp->lsndtime = tcp_jiffies32;
 	newsk->sk_txhash = treq->txhash;
-	newtp->last_oow_ack_time = 0;
 	newtp->total_retrans = req->num_retrans;
 
 	/* There's a bubble in the pipe until at least the first ACK. */
-- 
2.20.1.321.g9e740568ce-goog


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 09/11] tcp: move app_limited init to tcp_disconnect()
  2019-01-17 19:23 [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Eric Dumazet
                   ` (7 preceding siblings ...)
  2019-01-17 19:23 ` [PATCH net-next 08/11] tcp: move retrans_out,sacked_out,tlp_high_seq,last_oow_ack_time init to tcp_disconnect() Eric Dumazet
@ 2019-01-17 19:23 ` Eric Dumazet
  2019-01-17 19:23 ` [PATCH net-next 10/11] tcp: move tp->rack " Eric Dumazet
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Eric Dumazet @ 2019-01-17 19:23 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, Soheil Hassas Yeganeh, Neal Cardwell, Yuchung Cheng,
	Eric Dumazet, Eric Dumazet

If we make sure all listeners have app_limited set to ~0U,
then a clone will also inherit proper initial value.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp.c           | 3 +++
 net/ipv4/tcp_minisocks.c | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 551ad8604bea0cb459805165bb216a99fd3bd8e2..5f15fcc9612ae6b6964ca15660dbb7eb8cd71d83 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2609,6 +2609,9 @@ int tcp_disconnect(struct sock *sk, int flags)
 	tp->sacked_out = 0;
 	tp->tlp_high_seq = 0;
 	tp->last_oow_ack_time = 0;
+	/* There's a bubble in the pipe until at least the first ACK. */
+	tp->app_limited = ~0U;
+
 
 	/* Clean up fastopen related fields */
 	tcp_free_fastopen_req(tp);
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 29fba13849a79695b3f62a989b27157b57caedfb..13f3c6444efa63b63fe38bf4606c91fa962ec584 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -486,9 +486,6 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
 	newsk->sk_txhash = treq->txhash;
 	newtp->total_retrans = req->num_retrans;
 
-	/* There's a bubble in the pipe until at least the first ACK. */
-	newtp->app_limited = ~0U;
-
 	tcp_init_xmit_timers(newsk);
 	newtp->write_seq = newtp->pushed_seq = treq->snt_isn + 1;
 
-- 
2.20.1.321.g9e740568ce-goog


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 10/11] tcp: move tp->rack init to tcp_disconnect()
  2019-01-17 19:23 [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Eric Dumazet
                   ` (8 preceding siblings ...)
  2019-01-17 19:23 ` [PATCH net-next 09/11] tcp: move app_limited " Eric Dumazet
@ 2019-01-17 19:23 ` Eric Dumazet
  2019-01-17 19:23 ` [PATCH net-next 11/11] tcp: move rx_opt & syn_data_acked " Eric Dumazet
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Eric Dumazet @ 2019-01-17 19:23 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, Soheil Hassas Yeganeh, Neal Cardwell, Yuchung Cheng,
	Eric Dumazet, Eric Dumazet

If we make sure all listeners have proper tp->rack value,
then a clone will also inherit proper initial value.

Note that fresh sockets init tp->rack from tcp_init_sock()

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp.c           | 6 ++++++
 net/ipv4/tcp_minisocks.c | 6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 5f15fcc9612ae6b6964ca15660dbb7eb8cd71d83..2348199e6cee9b644177b1d5158680359fa2b57d 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2611,6 +2611,12 @@ int tcp_disconnect(struct sock *sk, int flags)
 	tp->last_oow_ack_time = 0;
 	/* There's a bubble in the pipe until at least the first ACK. */
 	tp->app_limited = ~0U;
+	tp->rack.mstamp = 0;
+	tp->rack.advanced = 0;
+	tp->rack.reo_wnd_steps = 1;
+	tp->rack.last_delivered = 0;
+	tp->rack.reo_wnd_persist = 0;
+	tp->rack.dsack_seen = 0;
 
 
 	/* Clean up fastopen related fields */
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 13f3c6444efa63b63fe38bf4606c91fa962ec584..27e11eb4164ca18da0e939eb928b5b2442f300dd 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -535,12 +535,6 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
 	newtp->fastopen_req = NULL;
 	newtp->fastopen_rsk = NULL;
 	newtp->syn_data_acked = 0;
-	newtp->rack.mstamp = 0;
-	newtp->rack.advanced = 0;
-	newtp->rack.reo_wnd_steps = 1;
-	newtp->rack.last_delivered = 0;
-	newtp->rack.reo_wnd_persist = 0;
-	newtp->rack.dsack_seen = 0;
 
 	__TCP_INC_STATS(sock_net(sk), TCP_MIB_PASSIVEOPENS);
 
-- 
2.20.1.321.g9e740568ce-goog


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH net-next 11/11] tcp: move rx_opt & syn_data_acked init to tcp_disconnect()
  2019-01-17 19:23 [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Eric Dumazet
                   ` (9 preceding siblings ...)
  2019-01-17 19:23 ` [PATCH net-next 10/11] tcp: move tp->rack " Eric Dumazet
@ 2019-01-17 19:23 ` Eric Dumazet
  2019-01-17 22:19 ` [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Yuchung Cheng
  2019-01-18  6:19 ` David Miller
  12 siblings, 0 replies; 15+ messages in thread
From: Eric Dumazet @ 2019-01-17 19:23 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, Soheil Hassas Yeganeh, Neal Cardwell, Yuchung Cheng,
	Eric Dumazet, Eric Dumazet

If we make sure all listeners have these fields cleared, then a clone
will also inherit zero values.

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 net/ipv4/tcp.c           | 4 ++++
 net/ipv4/tcp_minisocks.c | 6 ------
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 2348199e6cee9b644177b1d5158680359fa2b57d..541bdb9f81d791ca84c7f03d9caf15d84066c32e 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2617,6 +2617,10 @@ int tcp_disconnect(struct sock *sk, int flags)
 	tp->rack.last_delivered = 0;
 	tp->rack.reo_wnd_persist = 0;
 	tp->rack.dsack_seen = 0;
+	tp->syn_data_acked = 0;
+	tp->rx_opt.saw_tstamp = 0;
+	tp->rx_opt.dsack = 0;
+	tp->rx_opt.num_sacks = 0;
 
 
 	/* Clean up fastopen related fields */
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 27e11eb4164ca18da0e939eb928b5b2442f300dd..182595e2d40ff5b48cd6d095d4bd97b4cb26d3c0 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -489,11 +489,6 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
 	tcp_init_xmit_timers(newsk);
 	newtp->write_seq = newtp->pushed_seq = treq->snt_isn + 1;
 
-	newtp->rx_opt.saw_tstamp = 0;
-
-	newtp->rx_opt.dsack = 0;
-	newtp->rx_opt.num_sacks = 0;
-
 	if (sock_flag(newsk, SOCK_KEEPOPEN))
 		inet_csk_reset_keepalive_timer(newsk,
 					       keepalive_time_when(newtp));
@@ -534,7 +529,6 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
 	tcp_ecn_openreq_child(newtp, req);
 	newtp->fastopen_req = NULL;
 	newtp->fastopen_rsk = NULL;
-	newtp->syn_data_acked = 0;
 
 	__TCP_INC_STATS(sock_net(sk), TCP_MIB_PASSIVEOPENS);
 
-- 
2.20.1.321.g9e740568ce-goog


^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child()
  2019-01-17 19:23 [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Eric Dumazet
                   ` (10 preceding siblings ...)
  2019-01-17 19:23 ` [PATCH net-next 11/11] tcp: move rx_opt & syn_data_acked " Eric Dumazet
@ 2019-01-17 22:19 ` Yuchung Cheng
  2019-01-17 22:42   ` Soheil Hassas Yeganeh
  2019-01-18  6:19 ` David Miller
  12 siblings, 1 reply; 15+ messages in thread
From: Yuchung Cheng @ 2019-01-17 22:19 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S . Miller, netdev, Soheil Hassas Yeganeh, Neal Cardwell,
	Eric Dumazet

On Thu, Jan 17, 2019 at 11:23 AM Eric Dumazet <edumazet@google.com> wrote:
>
> 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.
>
> Eric Dumazet (11):
>   tcp: do not set snd_ssthresh in tcp_create_openreq_child()
>   tcp: move icsk_rto init to tcp_disconnect()
>   tcp: do not clear packets_out in tcp_create_openreq_child()
>   tcp: do not clear srtt_us in tcp_create_openreq_child
>   tcp: move mdev_us init to tcp_disconnect()
>   tcp: move snd_cwnd & snd_cwnd_cnt init to tcp_disconnect()
>   tcp: do not clear urg_data in tcp_create_openreq_child
>   tcp: move retrans_out,sacked_out,tlp_high_seq,last_oow_ack_time init
>     to tcp_disconnect()
>   tcp: move app_limited init to tcp_disconnect()
>   tcp: move tp->rack init to tcp_disconnect()
>   tcp: move rx_opt & syn_data_acked init to tcp_disconnect()
>
>  net/ipv4/tcp.c           | 21 ++++++++++++++++++++-
>  net/ipv4/tcp_minisocks.c | 34 ----------------------------------
>  2 files changed, 20 insertions(+), 35 deletions(-)
>
> --
Entire patch set looks great to me!

Acked-by: Yuchung Cheng <ycheng@google.com>

> 2.20.1.321.g9e740568ce-goog
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child()
  2019-01-17 22:19 ` [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Yuchung Cheng
@ 2019-01-17 22:42   ` Soheil Hassas Yeganeh
  0 siblings, 0 replies; 15+ messages in thread
From: Soheil Hassas Yeganeh @ 2019-01-17 22:42 UTC (permalink / raw)
  To: Yuchung Cheng
  Cc: Eric Dumazet, David S . Miller, netdev, Neal Cardwell, Eric Dumazet

On Thu, Jan 17, 2019 at 5:20 PM Yuchung Cheng <ycheng@google.com> wrote:
>
> On Thu, Jan 17, 2019 at 11:23 AM Eric Dumazet <edumazet@google.com> wrote:
> >
> > 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.
> >
> > Eric Dumazet (11):
> >   tcp: do not set snd_ssthresh in tcp_create_openreq_child()
> >   tcp: move icsk_rto init to tcp_disconnect()
> >   tcp: do not clear packets_out in tcp_create_openreq_child()
> >   tcp: do not clear srtt_us in tcp_create_openreq_child
> >   tcp: move mdev_us init to tcp_disconnect()
> >   tcp: move snd_cwnd & snd_cwnd_cnt init to tcp_disconnect()
> >   tcp: do not clear urg_data in tcp_create_openreq_child
> >   tcp: move retrans_out,sacked_out,tlp_high_seq,last_oow_ack_time init
> >     to tcp_disconnect()
> >   tcp: move app_limited init to tcp_disconnect()
> >   tcp: move tp->rack init to tcp_disconnect()
> >   tcp: move rx_opt & syn_data_acked init to tcp_disconnect()
> >
> >  net/ipv4/tcp.c           | 21 ++++++++++++++++++++-
> >  net/ipv4/tcp_minisocks.c | 34 ----------------------------------
> >  2 files changed, 20 insertions(+), 35 deletions(-)
> >
> > --
> Entire patch set looks great to me!
>
> Acked-by: Yuchung Cheng <ycheng@google.com>

Acked-by: Soheil Hassas Yeganeh <soheil@google.com>

Thank you very much, Eric, for the nice code removal!

> > 2.20.1.321.g9e740568ce-goog
> >

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child()
  2019-01-17 19:23 [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Eric Dumazet
                   ` (11 preceding siblings ...)
  2019-01-17 22:19 ` [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Yuchung Cheng
@ 2019-01-18  6:19 ` David Miller
  12 siblings, 0 replies; 15+ messages in thread
From: David Miller @ 2019-01-18  6:19 UTC (permalink / raw)
  To: edumazet; +Cc: netdev, soheil, ncardwell, ycheng, eric.dumazet

From: Eric Dumazet <edumazet@google.com>
Date: Thu, 17 Jan 2019 11:23:31 -0800

> 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.

Series applied, thanks Eric.

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2019-01-18  6:19 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-17 19:23 [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Eric Dumazet
2019-01-17 19:23 ` [PATCH net-next 01/11] tcp: do not set snd_ssthresh in tcp_create_openreq_child() Eric Dumazet
2019-01-17 19:23 ` [PATCH net-next 02/11] tcp: move icsk_rto init to tcp_disconnect() Eric Dumazet
2019-01-17 19:23 ` [PATCH net-next 03/11] tcp: do not clear packets_out in tcp_create_openreq_child() Eric Dumazet
2019-01-17 19:23 ` [PATCH net-next 04/11] tcp: do not clear srtt_us in tcp_create_openreq_child Eric Dumazet
2019-01-17 19:23 ` [PATCH net-next 05/11] tcp: move mdev_us init to tcp_disconnect() Eric Dumazet
2019-01-17 19:23 ` [PATCH net-next 06/11] tcp: move snd_cwnd & snd_cwnd_cnt " Eric Dumazet
2019-01-17 19:23 ` [PATCH net-next 07/11] tcp: do not clear urg_data in tcp_create_openreq_child Eric Dumazet
2019-01-17 19:23 ` [PATCH net-next 08/11] tcp: move retrans_out,sacked_out,tlp_high_seq,last_oow_ack_time init to tcp_disconnect() Eric Dumazet
2019-01-17 19:23 ` [PATCH net-next 09/11] tcp: move app_limited " Eric Dumazet
2019-01-17 19:23 ` [PATCH net-next 10/11] tcp: move tp->rack " Eric Dumazet
2019-01-17 19:23 ` [PATCH net-next 11/11] tcp: move rx_opt & syn_data_acked " Eric Dumazet
2019-01-17 22:19 ` [PATCH net-next 00/11] tcp: remove code from tcp_create_openreq_child() Yuchung Cheng
2019-01-17 22:42   ` Soheil Hassas Yeganeh
2019-01-18  6:19 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.