aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2008-11-20 00:40:23 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-20 00:40:23 -0500
commiteeda3fd64f75bcbfaa70ce946513abaf3f23b8e0 (patch)
tree082d1921a5783ef5b07b4cf666804d6509f25f1a /net/core/dev.c
parentd314774cf2cd5dfeb39a00d37deee65d4c627927 (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 'net/core/dev.c')
-rw-r--r--net/core/dev.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index ca14ab407b33..8843f4e3f5e1 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2620,7 +2620,7 @@ void dev_seq_stop(struct seq_file *seq, void *v)
2620 2620
2621static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev) 2621static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
2622{ 2622{
2623 struct net_device_stats *stats = dev->get_stats(dev); 2623 const struct net_device_stats *stats = dev_get_stats(dev);
2624 2624
2625 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu " 2625 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
2626 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n", 2626 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
@@ -4288,10 +4288,24 @@ void netdev_run_todo(void)
4288 } 4288 }
4289} 4289}
4290 4290
4291static struct net_device_stats *internal_stats(struct net_device *dev) 4291/**
4292{ 4292 * dev_get_stats - get network device statistics
4293 return &dev->stats; 4293 * @dev: device to get statistics from
4294 *
4295 * Get network statistics from device. The device driver may provide
4296 * its own method by setting dev->netdev_ops->get_stats; otherwise
4297 * the internal statistics structure is used.
4298 */
4299const struct net_device_stats *dev_get_stats(struct net_device *dev)
4300 {
4301 const struct net_device_ops *ops = dev->netdev_ops;
4302
4303 if (ops->ndo_get_stats)
4304 return ops->ndo_get_stats(dev);
4305 else
4306 return &dev->stats;
4294} 4307}
4308EXPORT_SYMBOL(dev_get_stats);
4295 4309
4296static void netdev_init_one_queue(struct net_device *dev, 4310static void netdev_init_one_queue(struct net_device *dev,
4297 struct netdev_queue *queue, 4311 struct netdev_queue *queue,
@@ -4370,7 +4384,6 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
4370 4384
4371 netdev_init_queues(dev); 4385 netdev_init_queues(dev);
4372 4386
4373 dev->get_stats = internal_stats;
4374 netpoll_netdev_init(dev); 4387 netpoll_netdev_init(dev);
4375 setup(dev); 4388 setup(dev);
4376 strcpy(dev->name, name); 4389 strcpy(dev->name, name);