diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2008-11-20 00:40:23 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-20 00:40:23 -0500 |
commit | eeda3fd64f75bcbfaa70ce946513abaf3f23b8e0 (patch) | |
tree | 082d1921a5783ef5b07b4cf666804d6509f25f1a /drivers | |
parent | d314774cf2cd5dfeb39a00d37deee65d4c627927 (diff) |
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/bonding/bond_main.c | 5 | ||||
-rw-r--r-- | drivers/net/sfc/ethtool.c | 2 | ||||
-rw-r--r-- | drivers/parisc/led.c | 4 |
3 files changed, 6 insertions, 5 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index a08ea4808056..db5f5c24a250 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -3899,7 +3899,7 @@ static int bond_close(struct net_device *bond_dev) | |||
3899 | static struct net_device_stats *bond_get_stats(struct net_device *bond_dev) | 3899 | static struct net_device_stats *bond_get_stats(struct net_device *bond_dev) |
3900 | { | 3900 | { |
3901 | struct bonding *bond = netdev_priv(bond_dev); | 3901 | struct bonding *bond = netdev_priv(bond_dev); |
3902 | struct net_device_stats *stats = &(bond->stats), *sstats; | 3902 | struct net_device_stats *stats = &bond->stats; |
3903 | struct net_device_stats local_stats; | 3903 | struct net_device_stats local_stats; |
3904 | struct slave *slave; | 3904 | struct slave *slave; |
3905 | int i; | 3905 | int i; |
@@ -3909,7 +3909,8 @@ static struct net_device_stats *bond_get_stats(struct net_device *bond_dev) | |||
3909 | read_lock_bh(&bond->lock); | 3909 | read_lock_bh(&bond->lock); |
3910 | 3910 | ||
3911 | bond_for_each_slave(bond, slave, i) { | 3911 | bond_for_each_slave(bond, slave, i) { |
3912 | sstats = slave->dev->get_stats(slave->dev); | 3912 | const struct net_device_stats *sstats = dev_get_stats(slave->dev); |
3913 | |||
3913 | local_stats.rx_packets += sstats->rx_packets; | 3914 | local_stats.rx_packets += sstats->rx_packets; |
3914 | local_stats.rx_bytes += sstats->rx_bytes; | 3915 | local_stats.rx_bytes += sstats->rx_bytes; |
3915 | local_stats.rx_errors += sstats->rx_errors; | 3916 | local_stats.rx_errors += sstats->rx_errors; |
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c index abd8fcd6e62d..cd92c4d8dbc5 100644 --- a/drivers/net/sfc/ethtool.c +++ b/drivers/net/sfc/ethtool.c | |||
@@ -426,7 +426,7 @@ static void efx_ethtool_get_stats(struct net_device *net_dev, | |||
426 | EFX_BUG_ON_PARANOID(stats->n_stats != EFX_ETHTOOL_NUM_STATS); | 426 | EFX_BUG_ON_PARANOID(stats->n_stats != EFX_ETHTOOL_NUM_STATS); |
427 | 427 | ||
428 | /* Update MAC and NIC statistics */ | 428 | /* Update MAC and NIC statistics */ |
429 | net_dev->get_stats(net_dev); | 429 | dev_get_stats(net_dev); |
430 | 430 | ||
431 | /* Fill detailed statistics buffer */ | 431 | /* Fill detailed statistics buffer */ |
432 | for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) { | 432 | for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) { |
diff --git a/drivers/parisc/led.c b/drivers/parisc/led.c index f9b12664f9fb..454b6532e409 100644 --- a/drivers/parisc/led.c +++ b/drivers/parisc/led.c | |||
@@ -360,13 +360,13 @@ static __inline__ int led_get_net_activity(void) | |||
360 | read_lock(&dev_base_lock); | 360 | read_lock(&dev_base_lock); |
361 | rcu_read_lock(); | 361 | rcu_read_lock(); |
362 | for_each_netdev(&init_net, dev) { | 362 | for_each_netdev(&init_net, dev) { |
363 | struct net_device_stats *stats; | 363 | const struct net_device_stats *stats; |
364 | struct in_device *in_dev = __in_dev_get_rcu(dev); | 364 | struct in_device *in_dev = __in_dev_get_rcu(dev); |
365 | if (!in_dev || !in_dev->ifa_list) | 365 | if (!in_dev || !in_dev->ifa_list) |
366 | continue; | 366 | continue; |
367 | if (ipv4_is_loopback(in_dev->ifa_list->ifa_local)) | 367 | if (ipv4_is_loopback(in_dev->ifa_list->ifa_local)) |
368 | continue; | 368 | continue; |
369 | stats = dev->get_stats(dev); | 369 | stats = dev_get_stats(dev); |
370 | rx_total += stats->rx_packets; | 370 | rx_total += stats->rx_packets; |
371 | tx_total += stats->tx_packets; | 371 | tx_total += stats->tx_packets; |
372 | } | 372 | } |