diff mbox series

[net-next,1/4] net: bridge: Extract a helper to handle bridge_binding toggles

Message ID a7455f6fe1dfa7b13126ed8a7fb33d3b611eecb8.1734540770.git.petrm@nvidia.com (mailing list archive)
State Accepted
Commit f284424dc17b57d779a03dfc9a66489a67150b30
Delegated to: Netdev Maintainers
Headers show
Series bridge: Handle changes in VLAN_FLAG_BRIDGE_BINDING | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 1 this patch: 1
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 33 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-12-19--12-00 (tests: 881)

Commit Message

Petr Machata Dec. 18, 2024, 5:15 p.m. UTC
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 <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
---
 net/bridge/br_vlan.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

Comments

Nikolay Aleksandrov Dec. 20, 2024, 12:27 p.m. UTC | #1
On 12/18/24 19:15, Petr Machata wrote:
> 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 <petrm@nvidia.com>
> Reviewed-by: Ido Schimmel <idosch@nvidia.com>
> ---
>  net/bridge/br_vlan.c | 20 ++++++++++++++------
>  1 file changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
> index 89f51ea4cabe..b728b71e693f 100644
> --- a/net/bridge/br_vlan.c
> +++ b/net/bridge/br_vlan.c
> @@ -1664,6 +1664,18 @@ static void br_vlan_set_all_vlan_dev_state(struct net_bridge_port *p)
>  	}
>  }
>  
> +static void br_vlan_toggle_bridge_binding(struct net_device *br_dev,
> +					  bool enable)
> +{
> +	struct net_bridge *br = netdev_priv(br_dev);
> +
> +	if (enable)
> +		br_opt_toggle(br, BROPT_VLAN_BRIDGE_BINDING, true);
> +	else
> +		br_opt_toggle(br, BROPT_VLAN_BRIDGE_BINDING,
> +			      br_vlan_has_upper_bind_vlan_dev(br_dev));
> +}
> +
>  static void br_vlan_upper_change(struct net_device *dev,
>  				 struct net_device *upper_dev,
>  				 bool linking)
> @@ -1673,13 +1685,9 @@ static void br_vlan_upper_change(struct net_device *dev,
>  	if (!br_vlan_is_bind_vlan_dev(upper_dev))
>  		return;
>  
> -	if (linking) {
> +	br_vlan_toggle_bridge_binding(dev, linking);
> +	if (linking)
>  		br_vlan_set_vlan_dev_state(br, upper_dev);
> -		br_opt_toggle(br, BROPT_VLAN_BRIDGE_BINDING, true);
> -	} else {
> -		br_opt_toggle(br, BROPT_VLAN_BRIDGE_BINDING,
> -			      br_vlan_has_upper_bind_vlan_dev(dev));
> -	}
>  }
>  
>  struct br_vlan_link_state_walk_data {

Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
diff mbox series

Patch

diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index 89f51ea4cabe..b728b71e693f 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -1664,6 +1664,18 @@  static void br_vlan_set_all_vlan_dev_state(struct net_bridge_port *p)
 	}
 }
 
+static void br_vlan_toggle_bridge_binding(struct net_device *br_dev,
+					  bool enable)
+{
+	struct net_bridge *br = netdev_priv(br_dev);
+
+	if (enable)
+		br_opt_toggle(br, BROPT_VLAN_BRIDGE_BINDING, true);
+	else
+		br_opt_toggle(br, BROPT_VLAN_BRIDGE_BINDING,
+			      br_vlan_has_upper_bind_vlan_dev(br_dev));
+}
+
 static void br_vlan_upper_change(struct net_device *dev,
 				 struct net_device *upper_dev,
 				 bool linking)
@@ -1673,13 +1685,9 @@  static void br_vlan_upper_change(struct net_device *dev,
 	if (!br_vlan_is_bind_vlan_dev(upper_dev))
 		return;
 
-	if (linking) {
+	br_vlan_toggle_bridge_binding(dev, linking);
+	if (linking)
 		br_vlan_set_vlan_dev_state(br, upper_dev);
-		br_opt_toggle(br, BROPT_VLAN_BRIDGE_BINDING, true);
-	} else {
-		br_opt_toggle(br, BROPT_VLAN_BRIDGE_BINDING,
-			      br_vlan_has_upper_bind_vlan_dev(dev));
-	}
 }
 
 struct br_vlan_link_state_walk_data {