Skip to content

Commit f284424

Browse files
pmachatakuba-moo
authored andcommitted
net: bridge: Extract a helper to handle bridge_binding toggles
Currently, the BROPT_VLAN_BRIDGE_BINDING bridge option is only toggled when VLAN devices are added on top of a bridge or removed from it. Extract the toggling of the option to a function so that it could be invoked by a subsequent patch when the state of an upper VLAN device changes. Signed-off-by: Petr Machata <[email protected]> Reviewed-by: Ido Schimmel <[email protected]> Acked-by: Nikolay Aleksandrov <[email protected]> Link: https://patch.msgid.link/a7455f6fe1dfa7b13126ed8a7fb33d3b611eecb8.1734540770.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 05dd04b commit f284424

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

net/bridge/br_vlan.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,6 +1664,18 @@ static void br_vlan_set_all_vlan_dev_state(struct net_bridge_port *p)
16641664
}
16651665
}
16661666

1667+
static void br_vlan_toggle_bridge_binding(struct net_device *br_dev,
1668+
bool enable)
1669+
{
1670+
struct net_bridge *br = netdev_priv(br_dev);
1671+
1672+
if (enable)
1673+
br_opt_toggle(br, BROPT_VLAN_BRIDGE_BINDING, true);
1674+
else
1675+
br_opt_toggle(br, BROPT_VLAN_BRIDGE_BINDING,
1676+
br_vlan_has_upper_bind_vlan_dev(br_dev));
1677+
}
1678+
16671679
static void br_vlan_upper_change(struct net_device *dev,
16681680
struct net_device *upper_dev,
16691681
bool linking)
@@ -1673,13 +1685,9 @@ static void br_vlan_upper_change(struct net_device *dev,
16731685
if (!br_vlan_is_bind_vlan_dev(upper_dev))
16741686
return;
16751687

1676-
if (linking) {
1688+
br_vlan_toggle_bridge_binding(dev, linking);
1689+
if (linking)
16771690
br_vlan_set_vlan_dev_state(br, upper_dev);
1678-
br_opt_toggle(br, BROPT_VLAN_BRIDGE_BINDING, true);
1679-
} else {
1680-
br_opt_toggle(br, BROPT_VLAN_BRIDGE_BINDING,
1681-
br_vlan_has_upper_bind_vlan_dev(dev));
1682-
}
16831691
}
16841692

16851693
struct br_vlan_link_state_walk_data {

0 commit comments

Comments
 (0)