aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 86dc9f693f66..fec8cf27f75d 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -817,7 +817,6 @@ static int default_rebuild_header(struct sk_buff *skb)
817 return 1; 817 return 1;
818} 818}
819 819
820
821/** 820/**
822 * dev_open - prepare an interface for use. 821 * dev_open - prepare an interface for use.
823 * @dev: device to open 822 * @dev: device to open
@@ -2096,9 +2095,9 @@ void dev_seq_stop(struct seq_file *seq, void *v)
2096 2095
2097static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev) 2096static void dev_seq_printf_stats(struct seq_file *seq, struct net_device *dev)
2098{ 2097{
2099 if (dev->get_stats) { 2098 struct net_device_stats *stats = dev->get_stats(dev);
2100 struct net_device_stats *stats = dev->get_stats(dev);
2101 2099
2100 if (stats) {
2102 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu " 2101 seq_printf(seq, "%6s:%8lu %7lu %4lu %4lu %4lu %5lu %10lu %9lu "
2103 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n", 2102 "%8lu %7lu %4lu %4lu %4lu %5lu %7lu %10lu\n",
2104 dev->name, stats->rx_bytes, stats->rx_packets, 2103 dev->name, stats->rx_bytes, stats->rx_packets,
@@ -3282,6 +3281,13 @@ out:
3282 mutex_unlock(&net_todo_run_mutex); 3281 mutex_unlock(&net_todo_run_mutex);
3283} 3282}
3284 3283
3284static struct net_device_stats *maybe_internal_stats(struct net_device *dev)
3285{
3286 if (dev->features & NETIF_F_INTERNAL_STATS)
3287 return &dev->stats;
3288 return NULL;
3289}
3290
3285/** 3291/**
3286 * alloc_netdev - allocate network device 3292 * alloc_netdev - allocate network device
3287 * @sizeof_priv: size of private data to allocate space for 3293 * @sizeof_priv: size of private data to allocate space for
@@ -3317,6 +3323,7 @@ struct net_device *alloc_netdev(int sizeof_priv, const char *name,
3317 if (sizeof_priv) 3323 if (sizeof_priv)
3318 dev->priv = netdev_priv(dev); 3324 dev->priv = netdev_priv(dev);
3319 3325
3326 dev->get_stats = maybe_internal_stats;
3320 setup(dev); 3327 setup(dev);
3321 strcpy(dev->name, name); 3328 strcpy(dev->name, name);
3322 return dev; 3329 return dev;