[PATCHv6 net-next 4/4] net: bridge: use common function to compute the features

Hangbin Liu
2025-10-17T03:42:34Z

Previously, bridge ignored all features propagation and DST retention,
only handling explicitly the GSO limits.

By switching to the new helper netdev_compute_master_upper_features(), the bridge
now expose additional features, depending on the lowers capabilities.

Since br_set_gso_limits() is already covered by the helper, it can be
removed safely.

Bridge has it's own way to update needed_headroom. So we don't need to
update it in the helper.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
net/bridge/br_if.c | 22 +++-------------------
1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index 98c5b9c3145f..a6d4c44890fd 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -525,20 +525,6 @@ void br_mtu_auto_adjust(struct net_bridge *br)
br_opt_toggle(br, BROPT_MTU_SET_BY_USER, false);
}

-static void br_set_gso_limits(struct net_bridge *br)
-{
- unsigned int tso_max_size = TSO_MAX_SIZE;
- const struct net_bridge_port *p;
- u16 tso_max_segs = TSO_MAX_SEGS;
-
- list_for_each_entry(p, &br->port_list, list) {
- tso_max_size = min(tso_max_size, p->dev->tso_max_size);
- tso_max_segs = min(tso_max_segs, p->dev->tso_max_segs);
- }
- netif_set_tso_max_size(br->dev, tso_max_size);
- netif_set_tso_max_segs(br->dev, tso_max_segs);
-}
-
/*
* Recomputes features using slave's features
*/
@@ -652,8 +638,6 @@ int br_add_if(struct net_bridge *br, struct net_device *dev,
netdev_err(dev, "failed to sync bridge static fdb addresses to this port\n");
}

- netdev_update_features(br->dev);
-
br_hr = br->dev->needed_headroom;
dev_hr = netdev_get_fwd_headroom(dev);
if (br_hr < dev_hr)
@@ -694,7 +678,8 @@ int br_add_if(struct net_bridge *br, struct net_device *dev,
call_netdevice_notifiers(NETDEV_CHANGEADDR, br->dev);

br_mtu_auto_adjust(br);
- br_set_gso_limits(br);
+
+ netdev_compute_master_upper_features(br->dev, false);

kobject_uevent(&p->kobj, KOBJ_ADD);

@@ -740,7 +725,6 @@ int br_del_if(struct net_bridge *br, struct net_device *dev)
del_nbp(p);

br_mtu_auto_adjust(br);
- br_set_gso_limits(br);

spin_lock_bh(&br->lock);
changed_addr = br_stp_recalculate_bridge_id(br);
@@ -749,7 +733,7 @@ int br_del_if(struct net_bridge *br, struct net_device *dev)
if (changed_addr)
call_netdevice_notifiers(NETDEV_CHANGEADDR, br->dev);

- netdev_update_features(br->dev);
+ netdev_compute_master_upper_features(br->dev, false);

return 0;
}
--
2.50.1