diff options
author | Eric Dumazet <edumazet@google.com> | 2013-08-05 20:10:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-08-07 13:35:05 -0400 |
commit | 2ed0edf9090bf4afa2c6fc4f38575a85a80d4b20 (patch) | |
tree | ac245b0b7c36d13d62110e337dd33d14cf520ed4 | |
parent | 248ba8ec05a2c3b118c2224e57eb10c128176ab1 (diff) |
tcp: cubic: fix overflow error in bictcp_update()
commit 17a6e9f1aa9 ("tcp_cubic: fix clock dependency") added an
overflow error in bictcp_update() in following code :
/* change the unit from HZ to bictcp_HZ */
t = ((tcp_time_stamp + msecs_to_jiffies(ca->delay_min>>3) -
ca->epoch_start) << BICTCP_HZ) / HZ;
Because msecs_to_jiffies() being unsigned long, compiler does
implicit type promotion.
We really want to constrain (tcp_time_stamp - ca->epoch_start)
to a signed 32bit value, or else 't' has unexpected high values.
This bugs triggers an increase of retransmit rates ~24 days after
boot [1], as the high order bit of tcp_time_stamp flips.
[1] for hosts with HZ=1000
Big thanks to Van Jacobson for spotting this problem.
Diagnosed-by: Van Jacobson <vanj@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Neal Cardwell <ncardwell@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv4/tcp_cubic.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c index a9077f441cb2..b6b591f0a788 100644 --- a/net/ipv4/tcp_cubic.c +++ b/net/ipv4/tcp_cubic.c | |||
@@ -206,8 +206,8 @@ static u32 cubic_root(u64 a) | |||
206 | */ | 206 | */ |
207 | static inline void bictcp_update(struct bictcp *ca, u32 cwnd) | 207 | static inline void bictcp_update(struct bictcp *ca, u32 cwnd) |
208 | { | 208 | { |
209 | u64 offs; | 209 | u32 delta, bic_target, max_cnt; |
210 | u32 delta, t, bic_target, max_cnt; | 210 | u64 offs, t; |
211 | 211 | ||
212 | ca->ack_cnt++; /* count the number of ACKs */ | 212 | ca->ack_cnt++; /* count the number of ACKs */ |
213 | 213 | ||
@@ -250,9 +250,11 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd) | |||
250 | * if the cwnd < 1 million packets !!! | 250 | * if the cwnd < 1 million packets !!! |
251 | */ | 251 | */ |
252 | 252 | ||
253 | t = (s32)(tcp_time_stamp - ca->epoch_start); | ||
254 | t += msecs_to_jiffies(ca->delay_min >> 3); | ||
253 | /* change the unit from HZ to bictcp_HZ */ | 255 | /* change the unit from HZ to bictcp_HZ */ |
254 | t = ((tcp_time_stamp + msecs_to_jiffies(ca->delay_min>>3) | 256 | t <<= BICTCP_HZ; |
255 | - ca->epoch_start) << BICTCP_HZ) / HZ; | 257 | do_div(t, HZ); |
256 | 258 | ||
257 | if (t < ca->bic_K) /* t - K */ | 259 | if (t < ca->bic_K) /* t - K */ |
258 | offs = ca->bic_K - t; | 260 | offs = ca->bic_K - t; |