]> bbs.cooldavid.org Git - net-next-2.6.git/commit - drivers/net/bonding/bond_main.c
bonding: Fix jiffies overflow problems (again)
authorJiri Bohac <jbohac@suse.cz>
Thu, 2 Sep 2010 05:45:54 +0000 (05:45 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 7 Sep 2010 20:57:20 +0000 (13:57 -0700)
commitcb32f2a0d194212e4e750a8cdedcc610c9ca4876
tree2f3762514e3feddb612c9d74379df98ac54eb300
parentc4433be6e19e3680727f3f89c938a22e7b789b43
bonding: Fix jiffies overflow problems (again)

The time_before_eq()/time_after_eq() functions operate on unsigned
long and only work if the difference between the two compared values
is smaller than half the range of unsigned long (31 bits on i386).

Some of the variables (slave->jiffies, dev->trans_start, dev->last_rx)
used by bonding store a copy of jiffies and may not be updated for a
long time. With HZ=1000, time_before_eq()/time_after_eq() will start
giving bad results after ~25 days.

jiffies will never be before slave->jiffies, dev->trans_start,
dev->last_rx by more than possibly a couple ticks caused by preemption
of this code. This allows us to detect/prevent these overflows by
replacing time_before_eq()/time_after_eq() with time_in_range().

Signed-off-by: Jiri Bohac <jbohac@suse.cz>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_main.c