Skip to content

Commit

Permalink
net: bridge: Do not allocate stats in the driver
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 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 bridge driver and leverage the network
core allocation.

Signed-off-by: Breno Leitao <leitao@debian.org>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://lore.kernel.org/r/20240227182338.2739884-1-leitao@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Breno Leitao authored and Jakub Kicinski committed Feb 29, 2024
1 parent 8a77469 commit d35150c
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions net/bridge/br_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,34 +113,25 @@ static int br_dev_init(struct net_device *dev)
struct net_bridge *br = netdev_priv(dev);
int err;

dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
if (!dev->tstats)
return -ENOMEM;

err = br_fdb_hash_init(br);
if (err) {
free_percpu(dev->tstats);
if (err)
return err;
}

err = br_mdb_hash_init(br);
if (err) {
free_percpu(dev->tstats);
br_fdb_hash_fini(br);
return err;
}

err = br_vlan_init(br);
if (err) {
free_percpu(dev->tstats);
br_mdb_hash_fini(br);
br_fdb_hash_fini(br);
return err;
}

err = br_multicast_init_stats(br);
if (err) {
free_percpu(dev->tstats);
br_vlan_flush(br);
br_mdb_hash_fini(br);
br_fdb_hash_fini(br);
Expand All @@ -159,7 +150,6 @@ static void br_dev_uninit(struct net_device *dev)
br_vlan_flush(br);
br_mdb_hash_fini(br);
br_fdb_hash_fini(br);
free_percpu(dev->tstats);
}

static int br_dev_open(struct net_device *dev)
Expand Down Expand Up @@ -496,6 +486,7 @@ void br_dev_setup(struct net_device *dev)
dev->hw_features = COMMON_FEATURES | NETIF_F_HW_VLAN_CTAG_TX |
NETIF_F_HW_VLAN_STAG_TX;
dev->vlan_features = COMMON_FEATURES;
dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;

br->dev = dev;
spin_lock_init(&br->lock);
Expand Down

0 comments on commit d35150c

Please sign in to comment.