* [PATCH] tcp_cubic: fix the range of delayed_ack
@ 2014-04-30 9:34 Liu Yu
2014-04-30 14:18 ` Eric Dumazet
2014-04-30 20:16 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Liu Yu @ 2014-04-30 9:34 UTC (permalink / raw)
To: eric.dumazet, ncardwell, shemminger, David S. Miller; +Cc: netdev
From: Liu Yu <allanyuliu@tencent.com>
commit b9f47a3aaeab (tcp_cubic: limit delayed_ack ratio to prevent
divide error) try to prevent divide error, but there is still a little
chance that delayed_ack can reach zero. In case the param cnt get
negative value, then ratio+cnt would overflow and may happen to be zero.
As a result, min(ratio, ACK_RATIO_LIMIT) will calculate to be zero.
In some old kernels, such as 2.6.32, there is a bug that would
pass negative param, which then ultimately leads to this divide error.
commit 5b35e1e6e9c (tcp: fix tcp_trim_head() to adjust segment count
with skb MSS) fixed the negative param issue. However,
it's safe that we fix the range of delayed_ack as well,
to make sure we do not hit a divide by zero.
CC: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: Liu Yu <allanyuliu@tencent.com>
---
net/ipv4/tcp_cubic.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c
index 8bf2245..b4f1b29 100644
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -409,7 +409,7 @@ static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us)
ratio -= ca->delayed_ack >> ACK_RATIO_SHIFT;
ratio += cnt;
- ca->delayed_ack = min(ratio, ACK_RATIO_LIMIT);
+ ca->delayed_ack = clamp(ratio, 1U, ACK_RATIO_LIMIT);
}
/* Some calls are for duplicates without timetamps */
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] tcp_cubic: fix the range of delayed_ack
2014-04-30 9:34 [PATCH] tcp_cubic: fix the range of delayed_ack Liu Yu
@ 2014-04-30 14:18 ` Eric Dumazet
2014-04-30 14:53 ` Neal Cardwell
2014-04-30 20:16 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2014-04-30 14:18 UTC (permalink / raw)
To: Liu Yu; +Cc: ncardwell, shemminger, David S. Miller, netdev
On Wed, 2014-04-30 at 17:34 +0800, Liu Yu wrote:
> From: Liu Yu <allanyuliu@tencent.com>
>
> commit b9f47a3aaeab (tcp_cubic: limit delayed_ack ratio to prevent
> divide error) try to prevent divide error, but there is still a little
> chance that delayed_ack can reach zero. In case the param cnt get
> negative value, then ratio+cnt would overflow and may happen to be zero.
> As a result, min(ratio, ACK_RATIO_LIMIT) will calculate to be zero.
>
> In some old kernels, such as 2.6.32, there is a bug that would
> pass negative param, which then ultimately leads to this divide error.
>
> commit 5b35e1e6e9c (tcp: fix tcp_trim_head() to adjust segment count
> with skb MSS) fixed the negative param issue. However,
> it's safe that we fix the range of delayed_ack as well,
> to make sure we do not hit a divide by zero.
>
> CC: Stephen Hemminger <shemminger@vyatta.com>
> Signed-off-by: Liu Yu <allanyuliu@tencent.com>
> ---
> net/ipv4/tcp_cubic.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
Signed-off-by: Eric Dumazet <edumazet@google.com>
Thanks !
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tcp_cubic: fix the range of delayed_ack
2014-04-30 14:18 ` Eric Dumazet
@ 2014-04-30 14:53 ` Neal Cardwell
0 siblings, 0 replies; 4+ messages in thread
From: Neal Cardwell @ 2014-04-30 14:53 UTC (permalink / raw)
To: Eric Dumazet; +Cc: Liu Yu, Stephen Hemminger, David S. Miller, Netdev
On Wed, Apr 30, 2014 at 10:18 AM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Wed, 2014-04-30 at 17:34 +0800, Liu Yu wrote:
>> From: Liu Yu <allanyuliu@tencent.com>
>>
>> commit b9f47a3aaeab (tcp_cubic: limit delayed_ack ratio to prevent
>> divide error) try to prevent divide error, but there is still a little
>> chance that delayed_ack can reach zero. In case the param cnt get
>> negative value, then ratio+cnt would overflow and may happen to be zero.
>> As a result, min(ratio, ACK_RATIO_LIMIT) will calculate to be zero.
>>
>> In some old kernels, such as 2.6.32, there is a bug that would
>> pass negative param, which then ultimately leads to this divide error.
>>
>> commit 5b35e1e6e9c (tcp: fix tcp_trim_head() to adjust segment count
>> with skb MSS) fixed the negative param issue. However,
>> it's safe that we fix the range of delayed_ack as well,
>> to make sure we do not hit a divide by zero.
>>
>> CC: Stephen Hemminger <shemminger@vyatta.com>
>> Signed-off-by: Liu Yu <allanyuliu@tencent.com>
>> ---
>> net/ipv4/tcp_cubic.c | 2 +-
>> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Indeed, thanks!
neal
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tcp_cubic: fix the range of delayed_ack
2014-04-30 9:34 [PATCH] tcp_cubic: fix the range of delayed_ack Liu Yu
2014-04-30 14:18 ` Eric Dumazet
@ 2014-04-30 20:16 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2014-04-30 20:16 UTC (permalink / raw)
To: allanliuyu; +Cc: eric.dumazet, ncardwell, shemminger, netdev
From: Liu Yu <allanliuyu@gmail.com>
Date: Wed, 30 Apr 2014 17:34:09 +0800
>
> From: Liu Yu <allanyuliu@tencent.com>
>
> commit b9f47a3aaeab (tcp_cubic: limit delayed_ack ratio to prevent
> divide error) try to prevent divide error, but there is still a little
> chance that delayed_ack can reach zero. In case the param cnt get
> negative value, then ratio+cnt would overflow and may happen to be zero.
> As a result, min(ratio, ACK_RATIO_LIMIT) will calculate to be zero.
>
> In some old kernels, such as 2.6.32, there is a bug that would
> pass negative param, which then ultimately leads to this divide error.
>
> commit 5b35e1e6e9c (tcp: fix tcp_trim_head() to adjust segment count
> with skb MSS) fixed the negative param issue. However,
> it's safe that we fix the range of delayed_ack as well,
> to make sure we do not hit a divide by zero.
>
> CC: Stephen Hemminger <shemminger@vyatta.com>
> Signed-off-by: Liu Yu <allanyuliu@tencent.com>
Applied and queued up for -stable, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-04-30 20:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-30 9:34 [PATCH] tcp_cubic: fix the range of delayed_ack Liu Yu
2014-04-30 14:18 ` Eric Dumazet
2014-04-30 14:53 ` Neal Cardwell
2014-04-30 20:16 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).