• Andy Gospodarek's avatar
    bonding: fix race that causes invalid statistics · 2439f9eb
    Andy Gospodarek authored
    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: default avatarAndy Gospodarek <andy@greyhouse.net>
    Signed-off-by: default avatarChris Snook <csnook@redhat.com>
    Acked-by: default avatarJay Vosburgh <fubar@us.ibm.com>
    Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    2439f9eb
bond_main.c 132 KB