]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commit
bonding: fix race that causes invalid statistics
authorAndy Gospodarek <andy@greyhouse.net>
Wed, 30 Jan 2008 02:07:46 +0000 (18:07 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 3 Feb 2008 12:28:13 +0000 (04:28 -0800)
commit2439f9ebd45349246b0fec7c47e6d0e05b1357c7
tree803000e31f25d0647d71bad8a7b9f2b7b3aea9c1
parent4fe4763cd8cacd81d892193efb48b99c99c15323
bonding: fix race that causes invalid statistics

I've seen reports of invalid stats in /proc/net/dev for bonding
interfaces, and found it's a pretty easy problem to reproduce.  Since
the current code zeros the bonding stats when a read is requested and a
pointer to that data is returned to the caller we cannot guarantee that
the caller has completely accessed the data before a successive call to
request the stats zeroes the stats again.

This patch creates a new stack variable to keep track of the updated
stats and copies the data from that variable into the bonding stats
structure.  This ensures that the value for any of the bonding stats
should not incorrectly return zero for any of the bonding statistics.
This does use more stack space and require an extra memcpy, but it seems
like a fair trade-off for consistently correct bonding statistics.

Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Chris Snook <csnook@redhat.com>
Acked-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_main.c