Skip to content

Commit

Permalink
vxlan: Do not alloc tstats manually
Browse files Browse the repository at this point in the history
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 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 vxlan driver and leverage the network
core allocation instead.

Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Subbaraya Sundeep <sbhatta@marvell.com>
Link: https://lore.kernel.org/r/20240311112437.3813987-1-leitao@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Breno Leitao authored and Jakub Kicinski committed Mar 11, 2024
1 parent eaf657f commit e28c5ef
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions drivers/net/vxlan/vxlan_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -2841,15 +2841,9 @@ static int vxlan_init(struct net_device *dev)
if (vxlan->cfg.flags & VXLAN_F_VNIFILTER)
vxlan_vnigroup_init(vxlan);

dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
if (!dev->tstats) {
err = -ENOMEM;
goto err_vnigroup_uninit;
}

err = gro_cells_init(&vxlan->gro_cells, dev);
if (err)
goto err_free_percpu;
goto err_vnigroup_uninit;

err = vxlan_mdb_init(vxlan);
if (err)
Expand All @@ -2860,8 +2854,6 @@ static int vxlan_init(struct net_device *dev)

err_gro_cells_destroy:
gro_cells_destroy(&vxlan->gro_cells);
err_free_percpu:
free_percpu(dev->tstats);
err_vnigroup_uninit:
if (vxlan->cfg.flags & VXLAN_F_VNIFILTER)
vxlan_vnigroup_uninit(vxlan);
Expand Down Expand Up @@ -2892,8 +2884,6 @@ static void vxlan_uninit(struct net_device *dev)
gro_cells_destroy(&vxlan->gro_cells);

vxlan_fdb_delete_default(vxlan, vxlan->cfg.vni);

free_percpu(dev->tstats);
}

/* Start ageing timer and join group when device is brought up */
Expand Down Expand Up @@ -3316,6 +3306,7 @@ static void vxlan_setup(struct net_device *dev)
dev->min_mtu = ETH_MIN_MTU;
dev->max_mtu = ETH_MAX_MTU;

dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
INIT_LIST_HEAD(&vxlan->next);

timer_setup(&vxlan->age_timer, vxlan_cleanup, TIMER_DEFERRABLE);
Expand Down

0 comments on commit e28c5ef

Please sign in to comment.