net: Enable 64-bit net device statistics on 32-bit architectures
Use struct rtnl_link_stats64 as the statistics structure. On 32-bit architectures, insert 32 bits of padding after/before each field of struct net_device_stats to make its layout compatible with struct rtnl_link_stats64. Add an anonymous union in net_device; move stats into the union and add struct rtnl_link_stats64 stats64. Add net_device_ops::ndo_get_stats64, implementations of which will return a pointer to struct rtnl_link_stats64. Drivers that implement this operation must not update the structure asynchronously. Change dev_get_stats() to call ndo_get_stats64 if available, and to return a pointer to struct rtnl_link_stats64. Change callers of dev_get_stats() accordingly. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
d19b514999
commit
be1f3c2c02
@@ -3804,20 +3804,21 @@ static int bond_close(struct net_device *bond_dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct net_device_stats *bond_get_stats(struct net_device *bond_dev)
|
||||
static struct rtnl_link_stats64 *bond_get_stats(struct net_device *bond_dev)
|
||||
{
|
||||
struct bonding *bond = netdev_priv(bond_dev);
|
||||
struct net_device_stats *stats = &bond_dev->stats;
|
||||
struct net_device_stats local_stats;
|
||||
struct rtnl_link_stats64 *stats = &bond_dev->stats64;
|
||||
struct rtnl_link_stats64 local_stats;
|
||||
struct slave *slave;
|
||||
int i;
|
||||
|
||||
memset(&local_stats, 0, sizeof(struct net_device_stats));
|
||||
memset(&local_stats, 0, sizeof(local_stats));
|
||||
|
||||
read_lock_bh(&bond->lock);
|
||||
|
||||
bond_for_each_slave(bond, slave, i) {
|
||||
const struct net_device_stats *sstats = dev_get_stats(slave->dev);
|
||||
const struct rtnl_link_stats64 *sstats =
|
||||
dev_get_stats(slave->dev);
|
||||
|
||||
local_stats.rx_packets += sstats->rx_packets;
|
||||
local_stats.rx_bytes += sstats->rx_bytes;
|
||||
@@ -4569,7 +4570,7 @@ static const struct net_device_ops bond_netdev_ops = {
|
||||
.ndo_stop = bond_close,
|
||||
.ndo_start_xmit = bond_start_xmit,
|
||||
.ndo_select_queue = bond_select_queue,
|
||||
.ndo_get_stats = bond_get_stats,
|
||||
.ndo_get_stats64 = bond_get_stats,
|
||||
.ndo_do_ioctl = bond_do_ioctl,
|
||||
.ndo_set_multicast_list = bond_set_multicast_list,
|
||||
.ndo_change_mtu = bond_change_mtu,
|
||||
|
Reference in New Issue
Block a user