Skip to content

Commit 45403b1

Browse files
leitaokuba-moo
authored andcommitted
ip_tunnel: Move stats allocation to core
With commit 34d21de ("net: Move {l,t,d}stats allocation to core and convert veth & vrf"), stats allocation could be done on net core instead of 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. Move ip_tunnel driver to leverage the core allocation. All the ip_tunnel_init() users call ip_tunnel_init() as part of their .ndo_init callback. The .ndo_init callback is called before the stats allocation in netdev_register(), thus, the allocation will happen before the netdev is visible. Signed-off-by: Breno Leitao <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 983e44f commit 45403b1

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

net/ipv4/ip_tunnel.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,6 @@ static void ip_tunnel_dev_free(struct net_device *dev)
10991099

11001100
gro_cells_destroy(&tunnel->gro_cells);
11011101
dst_cache_destroy(&tunnel->dst_cache);
1102-
free_percpu(dev->tstats);
11031102
}
11041103

11051104
void ip_tunnel_dellink(struct net_device *dev, struct list_head *head)
@@ -1313,20 +1312,15 @@ int ip_tunnel_init(struct net_device *dev)
13131312

13141313
dev->needs_free_netdev = true;
13151314
dev->priv_destructor = ip_tunnel_dev_free;
1316-
dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
1317-
if (!dev->tstats)
1318-
return -ENOMEM;
1315+
dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
13191316

13201317
err = dst_cache_init(&tunnel->dst_cache, GFP_KERNEL);
1321-
if (err) {
1322-
free_percpu(dev->tstats);
1318+
if (err)
13231319
return err;
1324-
}
13251320

13261321
err = gro_cells_init(&tunnel->gro_cells, dev);
13271322
if (err) {
13281323
dst_cache_destroy(&tunnel->dst_cache);
1329-
free_percpu(dev->tstats);
13301324
return err;
13311325
}
13321326

0 commit comments

Comments
 (0)