mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-27 22:24:11 +08:00
net: loopback: Do not allocate lstats explicitly
With commit 34d21de99c
("net: Move {l,t,d}stats allocation to core and
convert veth & vrf"), stats allocation could be done on net core
instead of in this driver.
With this new approach, the driver doesn't have to bother with error
handling (allocation failure checking, making sure free happens in the
right spot, etc). This is core responsibility now.
Remove the allocation in the loopback driver and leverage the network
core allocation instead.
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Link: https://lore.kernel.org/r/20240429085559.2841918-1-leitao@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
035ec29257
commit
3b5933e99c
@ -141,9 +141,6 @@ static const struct ethtool_ops loopback_ethtool_ops = {
|
||||
|
||||
static int loopback_dev_init(struct net_device *dev)
|
||||
{
|
||||
dev->lstats = netdev_alloc_pcpu_stats(struct pcpu_lstats);
|
||||
if (!dev->lstats)
|
||||
return -ENOMEM;
|
||||
netdev_lockdep_set_classes(dev);
|
||||
return 0;
|
||||
}
|
||||
@ -151,7 +148,6 @@ static int loopback_dev_init(struct net_device *dev)
|
||||
static void loopback_dev_free(struct net_device *dev)
|
||||
{
|
||||
dev_net(dev)->loopback_dev = NULL;
|
||||
free_percpu(dev->lstats);
|
||||
}
|
||||
|
||||
static const struct net_device_ops loopback_ops = {
|
||||
@ -191,6 +187,7 @@ static void gen_lo_setup(struct net_device *dev,
|
||||
dev->header_ops = hdr_ops;
|
||||
dev->netdev_ops = dev_ops;
|
||||
dev->needs_free_netdev = true;
|
||||
dev->pcpu_stat_type = NETDEV_PCPU_STAT_LSTATS;
|
||||
dev->priv_destructor = dev_destructor;
|
||||
|
||||
netif_set_tso_max_size(dev, GSO_MAX_SIZE);
|
||||
|
Loading…
Reference in New Issue
Block a user