diff mbox

[3/6] tcp_cubic: fix comparison of jiffies

Message ID 20110310165328.999266946@vyatta.com
State Superseded, archived
Delegated to: David Miller
Headers show

Commit Message

stephen hemminger March 10, 2011, 4:51 p.m. UTC
Jiffies wraps around therefore the correct way to compare is
to use cast to signed value.

Note: cubic is not using full jiffies value on 64 bit arch
because using full unsigned long makes struct bictcp grow too
large for the available ca_priv area.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Lucas Nussbaum March 11, 2011, 9:40 a.m. UTC | #1
On 10/03/11 at 08:51 -0800, Stephen Hemminger wrote:
> --- a/net/ipv4/tcp_cubic.c	2011-03-10 08:08:32.867492953 -0800
> +++ b/net/ipv4/tcp_cubic.c	2011-03-10 08:24:39.658201745 -0800
> @@ -342,9 +342,11 @@ static void hystart_update(struct sock *
>  		u32 curr_jiffies = jiffies;
>  
>  		/* first detection parameter - ack-train detection */
> -		if (curr_jiffies - ca->last_jiffies <= msecs_to_jiffies(2)) {
> +		if ((s32)(curr_jiffies - ca->last_jiffies) <=
> +		    msecs_to_jiffies(2)) {
>  			ca->last_jiffies = curr_jiffies;
> -			if (curr_jiffies - ca->round_start >= ca->delay_min>>4)
> +			if ((s32) (curr_jiffies - ca->round_start) <=
> +			    ca->delay_min >> 4)

>=, not <=
diff mbox

Patch

--- a/net/ipv4/tcp_cubic.c	2011-03-10 08:08:32.867492953 -0800
+++ b/net/ipv4/tcp_cubic.c	2011-03-10 08:24:39.658201745 -0800
@@ -342,9 +342,11 @@  static void hystart_update(struct sock *
 		u32 curr_jiffies = jiffies;
 
 		/* first detection parameter - ack-train detection */
-		if (curr_jiffies - ca->last_jiffies <= msecs_to_jiffies(2)) {
+		if ((s32)(curr_jiffies - ca->last_jiffies) <=
+		    msecs_to_jiffies(2)) {
 			ca->last_jiffies = curr_jiffies;
-			if (curr_jiffies - ca->round_start >= ca->delay_min>>4)
+			if ((s32) (curr_jiffies - ca->round_start) <=
+			    ca->delay_min >> 4)
 				ca->found |= HYSTART_ACK_TRAIN;
 		}