• Eric Dumazet's avatar
    bonding: fix bond_get_stats() · 5b31abfd
    Eric Dumazet authored
    [ Upstream commit fe30937b ]
    
    bond_get_stats() can be called from rtnetlink (with RTNL held)
    or from /proc/net/dev seq handler (with RCU held)
    
    The logic added in commit 5f0c5f73 ("bonding: make global bonding
    stats more reliable") kind of assumed only one cpu could run there.
    
    If multiple threads are reading /proc/net/dev, stats can be really
    messed up after a while.
    
    A second problem is that some fields are 32bit, so we need to properly
    handle the wrap around problem.
    
    Given that RTNL is not always held, we need to use
    bond_for_each_slave_rcu().
    
    Fixes: 5f0c5f73 ("bonding: make global bonding stats more reliable")
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Cc: Andy Gospodarek <gospo@cumulusnetworks.com>
    Cc: Jay Vosburgh <j.vosburgh@gmail.com>
    Cc: Veaceslav Falico <vfalico@gmail.com>
    Reviewed-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
    5b31abfd
bond_main.c 132 KB