netdev: introduce dev_get_stats()
In order for the network device ops get_stats call to be immutable, the handling of the default internal network device stats block has to be changed. Add a new helper function which replaces the old use of internal_get_stats. Note: change return code to make it clear that the caller should not go changing the returned statistics. Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
d314774cf2
commit
eeda3fd64f
@@ -3899,7 +3899,7 @@ static int bond_close(struct net_device *bond_dev)
|
||||
static struct net_device_stats *bond_get_stats(struct net_device *bond_dev)
|
||||
{
|
||||
struct bonding *bond = netdev_priv(bond_dev);
|
||||
struct net_device_stats *stats = &(bond->stats), *sstats;
|
||||
struct net_device_stats *stats = &bond->stats;
|
||||
struct net_device_stats local_stats;
|
||||
struct slave *slave;
|
||||
int i;
|
||||
@@ -3909,7 +3909,8 @@ static struct net_device_stats *bond_get_stats(struct net_device *bond_dev)
|
||||
read_lock_bh(&bond->lock);
|
||||
|
||||
bond_for_each_slave(bond, slave, i) {
|
||||
sstats = slave->dev->get_stats(slave->dev);
|
||||
const struct net_device_stats *sstats = dev_get_stats(slave->dev);
|
||||
|
||||
local_stats.rx_packets += sstats->rx_packets;
|
||||
local_stats.rx_bytes += sstats->rx_bytes;
|
||||
local_stats.rx_errors += sstats->rx_errors;
|
||||
|
Reference in New Issue
Block a user