Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eeda3fd6 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller
Browse files

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: default avatarStephen Hemminger <shemminger@vyatta.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d314774c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -67,7 +67,6 @@ static void appldata_get_net_sum_data(void *data)
	int i;
	struct appldata_net_sum_data *net_data;
	struct net_device *dev;
	struct net_device_stats *stats;
	unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes, rx_errors,
			tx_errors, rx_dropped, tx_dropped, collisions;

@@ -86,7 +85,8 @@ static void appldata_get_net_sum_data(void *data)
	collisions = 0;
	read_lock(&dev_base_lock);
	for_each_netdev(&init_net, dev) {
		stats = dev->get_stats(dev);
		const struct net_device_stats *stats = dev_get_stats(dev);

		rx_packets += stats->rx_packets;
		tx_packets += stats->tx_packets;
		rx_bytes   += stats->rx_bytes;
+3 −2
Original line number Diff line number Diff line
@@ -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;
+1 −1
Original line number Diff line number Diff line
@@ -426,7 +426,7 @@ static void efx_ethtool_get_stats(struct net_device *net_dev,
	EFX_BUG_ON_PARANOID(stats->n_stats != EFX_ETHTOOL_NUM_STATS);

	/* Update MAC and NIC statistics */
	net_dev->get_stats(net_dev);
	dev_get_stats(net_dev);

	/* Fill detailed statistics buffer */
	for (i = 0; i < EFX_ETHTOOL_NUM_STATS; i++) {
+2 −2
Original line number Diff line number Diff line
@@ -360,13 +360,13 @@ static __inline__ int led_get_net_activity(void)
	read_lock(&dev_base_lock);
	rcu_read_lock();
	for_each_netdev(&init_net, dev) {
	    struct net_device_stats *stats;
	    const struct net_device_stats *stats;
	    struct in_device *in_dev = __in_dev_get_rcu(dev);
	    if (!in_dev || !in_dev->ifa_list)
		continue;
	    if (ipv4_is_loopback(in_dev->ifa_list->ifa_local))
		continue;
	    stats = dev->get_stats(dev);
	    stats = dev_get_stats(dev);
	    rx_total += stats->rx_packets;
	    tx_total += stats->tx_packets;
	}
+3 −1
Original line number Diff line number Diff line
@@ -864,9 +864,9 @@ struct net_device
							    unsigned short vid);
#ifdef CONFIG_NET_POLL_CONTROLLER
		void                    (*poll_controller)(struct net_device *dev);
#endif
#endif
	};
#endif
};
#define to_net_dev(d) container_of(d, struct net_device, dev)

@@ -1780,6 +1780,8 @@ extern void netdev_features_change(struct net_device *dev);
/* Load a device via the kmod */
extern void		dev_load(struct net *net, const char *name);
extern void		dev_mcast_init(void);
extern const struct net_device_stats *dev_get_stats(struct net_device *dev);

extern int		netdev_max_backlog;
extern int		weight_p;
extern int		netdev_set_master(struct net_device *dev, struct net_device *master);
Loading