diff options
author | Yuchung Cheng <ycheng@google.com> | 2019-04-29 18:46:20 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-05-01 11:47:54 -0400 |
commit | 98fa6271cfcb1de873b3fe0caf48d9daa1bcc0ac (patch) | |
tree | 0d8c0ce941e0e6441fb61631d1680b29b0c9eaf7 | |
parent | 6b94b1c88b660a786fdb1c22d8a0d3529fe40f8c (diff) |
tcp: refactor setting the initial congestion window
Relocate the congestion window initialization from tcp_init_metrics()
to tcp_init_transfer() to improve code readability.
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/tcp.c | 12 | ||||
-rw-r--r-- | net/ipv4/tcp_input.c | 26 | ||||
-rw-r--r-- | net/ipv4/tcp_metrics.c | 10 |
3 files changed, 26 insertions, 22 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index f7567a3698eb..1fa15beb8380 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -457,18 +457,6 @@ void tcp_init_sock(struct sock *sk) | |||
457 | } | 457 | } |
458 | EXPORT_SYMBOL(tcp_init_sock); | 458 | EXPORT_SYMBOL(tcp_init_sock); |
459 | 459 | ||
460 | void tcp_init_transfer(struct sock *sk, int bpf_op) | ||
461 | { | ||
462 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
463 | |||
464 | tcp_mtup_init(sk); | ||
465 | icsk->icsk_af_ops->rebuild_header(sk); | ||
466 | tcp_init_metrics(sk); | ||
467 | tcp_call_bpf(sk, bpf_op, 0, NULL); | ||
468 | tcp_init_congestion_control(sk); | ||
469 | tcp_init_buffer_space(sk); | ||
470 | } | ||
471 | |||
472 | static void tcp_tx_timestamp(struct sock *sk, u16 tsflags) | 460 | static void tcp_tx_timestamp(struct sock *sk, u16 tsflags) |
473 | { | 461 | { |
474 | struct sk_buff *skb = tcp_write_queue_tail(sk); | 462 | struct sk_buff *skb = tcp_write_queue_tail(sk); |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 706a99ec73f6..077d9abdfcf5 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -5647,6 +5647,32 @@ discard: | |||
5647 | } | 5647 | } |
5648 | EXPORT_SYMBOL(tcp_rcv_established); | 5648 | EXPORT_SYMBOL(tcp_rcv_established); |
5649 | 5649 | ||
5650 | void tcp_init_transfer(struct sock *sk, int bpf_op) | ||
5651 | { | ||
5652 | struct inet_connection_sock *icsk = inet_csk(sk); | ||
5653 | struct tcp_sock *tp = tcp_sk(sk); | ||
5654 | |||
5655 | tcp_mtup_init(sk); | ||
5656 | icsk->icsk_af_ops->rebuild_header(sk); | ||
5657 | tcp_init_metrics(sk); | ||
5658 | |||
5659 | /* Initialize the congestion window to start the transfer. | ||
5660 | * Cut cwnd down to 1 per RFC5681 if SYN or SYN-ACK has been | ||
5661 | * retransmitted. In light of RFC6298 more aggressive 1sec | ||
5662 | * initRTO, we only reset cwnd when more than 1 SYN/SYN-ACK | ||
5663 | * retransmission has occurred. | ||
5664 | */ | ||
5665 | if (tp->total_retrans > 1 && tp->undo_marker) | ||
5666 | tp->snd_cwnd = 1; | ||
5667 | else | ||
5668 | tp->snd_cwnd = tcp_init_cwnd(tp, __sk_dst_get(sk)); | ||
5669 | tp->snd_cwnd_stamp = tcp_jiffies32; | ||
5670 | |||
5671 | tcp_call_bpf(sk, bpf_op, 0, NULL); | ||
5672 | tcp_init_congestion_control(sk); | ||
5673 | tcp_init_buffer_space(sk); | ||
5674 | } | ||
5675 | |||
5650 | void tcp_finish_connect(struct sock *sk, struct sk_buff *skb) | 5676 | void tcp_finish_connect(struct sock *sk, struct sk_buff *skb) |
5651 | { | 5677 | { |
5652 | struct tcp_sock *tp = tcp_sk(sk); | 5678 | struct tcp_sock *tp = tcp_sk(sk); |
diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c index d4d687330e2b..c4848e7a0aad 100644 --- a/net/ipv4/tcp_metrics.c +++ b/net/ipv4/tcp_metrics.c | |||
@@ -512,16 +512,6 @@ reset: | |||
512 | 512 | ||
513 | inet_csk(sk)->icsk_rto = TCP_TIMEOUT_FALLBACK; | 513 | inet_csk(sk)->icsk_rto = TCP_TIMEOUT_FALLBACK; |
514 | } | 514 | } |
515 | /* Cut cwnd down to 1 per RFC5681 if SYN or SYN-ACK has been | ||
516 | * retransmitted. In light of RFC6298 more aggressive 1sec | ||
517 | * initRTO, we only reset cwnd when more than 1 SYN/SYN-ACK | ||
518 | * retransmission has occurred. | ||
519 | */ | ||
520 | if (tp->total_retrans > 1 && tp->undo_marker) | ||
521 | tp->snd_cwnd = 1; | ||
522 | else | ||
523 | tp->snd_cwnd = tcp_init_cwnd(tp, dst); | ||
524 | tp->snd_cwnd_stamp = tcp_jiffies32; | ||
525 | } | 515 | } |
526 | 516 | ||
527 | bool tcp_peer_is_proven(struct request_sock *req, struct dst_entry *dst) | 517 | bool tcp_peer_is_proven(struct request_sock *req, struct dst_entry *dst) |