Commit 0b6a05c1dbebe8c616e2e5b0f52b7a01fd792911
Committed by
David S. Miller
1 parent
036d6a673f
Exists in
master
and in
7 other branches
tcp: fix ssthresh u16 leftover
It was once upon time so that snd_sthresh was a 16-bit quantity. ...That has not been true for long period of time. I run across some ancient compares which still seem to trust such legacy. Put all that magic into a single place, I hopefully found all of them. Compile tested, though linking of allyesconfig is ridiculous nowadays it seems. Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 6 changed files with 15 additions and 7 deletions Side-by-side Diff
include/net/tcp.h
... | ... | @@ -793,6 +793,13 @@ |
793 | 793 | return tp->packets_out - tcp_left_out(tp) + tp->retrans_out; |
794 | 794 | } |
795 | 795 | |
796 | +#define TCP_INFINITE_SSTHRESH 0x7fffffff | |
797 | + | |
798 | +static inline bool tcp_in_initial_slowstart(const struct tcp_sock *tp) | |
799 | +{ | |
800 | + return tp->snd_ssthresh >= TCP_INFINITE_SSTHRESH; | |
801 | +} | |
802 | + | |
796 | 803 | /* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd. |
797 | 804 | * The exception is rate halving phase, when cwnd is decreasing towards |
798 | 805 | * ssthresh. |
net/ipv4/tcp.c
... | ... | @@ -2012,7 +2012,7 @@ |
2012 | 2012 | tp->snd_cwnd = 2; |
2013 | 2013 | icsk->icsk_probes_out = 0; |
2014 | 2014 | tp->packets_out = 0; |
2015 | - tp->snd_ssthresh = 0x7fffffff; | |
2015 | + tp->snd_ssthresh = TCP_INFINITE_SSTHRESH; | |
2016 | 2016 | tp->snd_cwnd_cnt = 0; |
2017 | 2017 | tp->bytes_acked = 0; |
2018 | 2018 | tcp_set_ca_state(sk, TCP_CA_Open); |
net/ipv4/tcp_input.c
... | ... | @@ -761,7 +761,7 @@ |
761 | 761 | set_dst_metric_rtt(dst, RTAX_RTTVAR, var); |
762 | 762 | } |
763 | 763 | |
764 | - if (tp->snd_ssthresh >= 0xFFFF) { | |
764 | + if (tcp_in_initial_slowstart(tp)) { | |
765 | 765 | /* Slow start still did not finish. */ |
766 | 766 | if (dst_metric(dst, RTAX_SSTHRESH) && |
767 | 767 | !dst_metric_locked(dst, RTAX_SSTHRESH) && |
net/ipv4/tcp_ipv4.c
... | ... | @@ -1808,7 +1808,7 @@ |
1808 | 1808 | /* See draft-stevens-tcpca-spec-01 for discussion of the |
1809 | 1809 | * initialization of these values. |
1810 | 1810 | */ |
1811 | - tp->snd_ssthresh = 0x7fffffff; /* Infinity */ | |
1811 | + tp->snd_ssthresh = TCP_INFINITE_SSTHRESH; | |
1812 | 1812 | tp->snd_cwnd_clamp = ~0; |
1813 | 1813 | tp->mss_cache = 536; |
1814 | 1814 | |
... | ... | @@ -2284,7 +2284,7 @@ |
2284 | 2284 | jiffies_to_clock_t(icsk->icsk_ack.ato), |
2285 | 2285 | (icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong, |
2286 | 2286 | tp->snd_cwnd, |
2287 | - tp->snd_ssthresh >= 0xFFFF ? -1 : tp->snd_ssthresh, | |
2287 | + tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh, | |
2288 | 2288 | len); |
2289 | 2289 | } |
2290 | 2290 |
net/ipv4/tcp_minisocks.c
... | ... | @@ -410,7 +410,7 @@ |
410 | 410 | newtp->retrans_out = 0; |
411 | 411 | newtp->sacked_out = 0; |
412 | 412 | newtp->fackets_out = 0; |
413 | - newtp->snd_ssthresh = 0x7fffffff; | |
413 | + newtp->snd_ssthresh = TCP_INFINITE_SSTHRESH; | |
414 | 414 | |
415 | 415 | /* So many TCP implementations out there (incorrectly) count the |
416 | 416 | * initial SYN frame in their delayed-ACK and congestion control |
net/ipv6/tcp_ipv6.c
... | ... | @@ -1846,7 +1846,7 @@ |
1846 | 1846 | /* See draft-stevens-tcpca-spec-01 for discussion of the |
1847 | 1847 | * initialization of these values. |
1848 | 1848 | */ |
1849 | - tp->snd_ssthresh = 0x7fffffff; | |
1849 | + tp->snd_ssthresh = TCP_INFINITE_SSTHRESH; | |
1850 | 1850 | tp->snd_cwnd_clamp = ~0; |
1851 | 1851 | tp->mss_cache = 536; |
1852 | 1852 | |
... | ... | @@ -1969,7 +1969,8 @@ |
1969 | 1969 | jiffies_to_clock_t(icsk->icsk_rto), |
1970 | 1970 | jiffies_to_clock_t(icsk->icsk_ack.ato), |
1971 | 1971 | (icsk->icsk_ack.quick << 1 ) | icsk->icsk_ack.pingpong, |
1972 | - tp->snd_cwnd, tp->snd_ssthresh>=0xFFFF?-1:tp->snd_ssthresh | |
1972 | + tp->snd_cwnd, | |
1973 | + tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh | |
1973 | 1974 | ); |
1974 | 1975 | } |
1975 | 1976 |