diff mbox series

[net] team: Fix feature exposure when no ports are present

Message ID 20241213123657.401868-1-daniel@iogearbox.net (mailing list archive)
State Accepted
Commit e78c20f327bd94dabac68b98218dff069a8780f0
Delegated to: Netdev Maintainers
Headers show
Series [net] team: Fix feature exposure when no ports are present | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-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 warning 3 maintainers not CCed: edumazet@google.com andrew+netdev@lunn.ch kuba@kernel.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
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 Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 26 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-13--15-00 (tests: 795)

Commit Message

Daniel Borkmann Dec. 13, 2024, 12:36 p.m. UTC
Small follow-up to align this to an equivalent behavior as the bond driver.
The change in 3625920b62c3 ("teaming: fix vlan_features computing") removed
the netdevice vlan_features when there is no team port attached, yet it
leaves the full set of enc_features intact.

Instead, leave the default features as pre 3625920b62c3, and recompute once
we do have ports attached. Also, similarly as in bonding case, call the
netdev_base_features() helper on the enc_features.

Fixes: 3625920b62c3 ("teaming: fix vlan_features computing")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
 drivers/net/team/team_core.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Nikolay Aleksandrov Dec. 13, 2024, 1:24 p.m. UTC | #1
On 12/13/24 14:36, Daniel Borkmann wrote:
> Small follow-up to align this to an equivalent behavior as the bond driver.
> The change in 3625920b62c3 ("teaming: fix vlan_features computing") removed
> the netdevice vlan_features when there is no team port attached, yet it
> leaves the full set of enc_features intact.
> 
> Instead, leave the default features as pre 3625920b62c3, and recompute once
> we do have ports attached. Also, similarly as in bonding case, call the
> netdev_base_features() helper on the enc_features.
> 
> Fixes: 3625920b62c3 ("teaming: fix vlan_features computing")
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> ---
>  drivers/net/team/team_core.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c
> index 69ea2c3c76bf..c7690adec8db 100644
> --- a/drivers/net/team/team_core.c
> +++ b/drivers/net/team/team_core.c
> @@ -998,9 +998,13 @@ static void __team_compute_features(struct team *team)
>  	unsigned int dst_release_flag = IFF_XMIT_DST_RELEASE |
>  					IFF_XMIT_DST_RELEASE_PERM;
>  
> +	rcu_read_lock();
> +	if (list_empty(&team->port_list))
> +		goto done;
> +
>  	vlan_features = netdev_base_features(vlan_features);
> +	enc_features = netdev_base_features(enc_features);
>  
> -	rcu_read_lock();
>  	list_for_each_entry_rcu(port, &team->port_list, list) {
>  		vlan_features = netdev_increment_features(vlan_features,
>  					port->dev->vlan_features,
> @@ -1010,11 +1014,11 @@ static void __team_compute_features(struct team *team)
>  						  port->dev->hw_enc_features,
>  						  TEAM_ENC_FEATURES);
>  
> -
>  		dst_release_flag &= port->dev->priv_flags;
>  		if (port->dev->hard_header_len > max_hard_header_len)
>  			max_hard_header_len = port->dev->hard_header_len;
>  	}
> +done:
>  	rcu_read_unlock();
>  
>  	team->dev->vlan_features = vlan_features;

Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
patchwork-bot+netdevbpf@kernel.org Dec. 17, 2024, 2:30 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 13 Dec 2024 13:36:57 +0100 you wrote:
> Small follow-up to align this to an equivalent behavior as the bond driver.
> The change in 3625920b62c3 ("teaming: fix vlan_features computing") removed
> the netdevice vlan_features when there is no team port attached, yet it
> leaves the full set of enc_features intact.
> 
> Instead, leave the default features as pre 3625920b62c3, and recompute once
> we do have ports attached. Also, similarly as in bonding case, call the
> netdev_base_features() helper on the enc_features.
> 
> [...]

Here is the summary with links:
  - [net] team: Fix feature exposure when no ports are present
    https://git.kernel.org/netdev/net/c/e78c20f327bd

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/team/team_core.c b/drivers/net/team/team_core.c
index 69ea2c3c76bf..c7690adec8db 100644
--- a/drivers/net/team/team_core.c
+++ b/drivers/net/team/team_core.c
@@ -998,9 +998,13 @@  static void __team_compute_features(struct team *team)
 	unsigned int dst_release_flag = IFF_XMIT_DST_RELEASE |
 					IFF_XMIT_DST_RELEASE_PERM;
 
+	rcu_read_lock();
+	if (list_empty(&team->port_list))
+		goto done;
+
 	vlan_features = netdev_base_features(vlan_features);
+	enc_features = netdev_base_features(enc_features);
 
-	rcu_read_lock();
 	list_for_each_entry_rcu(port, &team->port_list, list) {
 		vlan_features = netdev_increment_features(vlan_features,
 					port->dev->vlan_features,
@@ -1010,11 +1014,11 @@  static void __team_compute_features(struct team *team)
 						  port->dev->hw_enc_features,
 						  TEAM_ENC_FEATURES);
 
-
 		dst_release_flag &= port->dev->priv_flags;
 		if (port->dev->hard_header_len > max_hard_header_len)
 			max_hard_header_len = port->dev->hard_header_len;
 	}
+done:
 	rcu_read_unlock();
 
 	team->dev->vlan_features = vlan_features;