diff mbox series

[net-next,02/12] mlxsw: spectrum_span: Ignore VLAN entries not used by the bridge in mirroring

Message ID 20220222171703.499645-3-idosch@nvidia.com (mailing list archive)
State Accepted
Commit 42c9135fef9b0a6f82072494b0c00d625a2d5573
Delegated to: Netdev Maintainers
Headers show
Series mlxsw: Various updates | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
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/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
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, 9 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ido Schimmel Feb. 22, 2022, 5:16 p.m. UTC
Only VLAN entries installed on the bridge device itself should be
considered when checking whether a packet with a specific VLAN can be
mirrored via a bridge device. VLAN entries only used to keep context
(i.e., entries with 'BRIDGE_VLAN_INFO_BRENTRY' unset) should be ignored.

Fix this by preventing mirroring when the VLAN entry does not have the
'BRIDGE_VLAN_INFO_BRENTRY' flag set.

Fixes: ddaff5047003 ("mlxsw: spectrum: remove guards against !BRIDGE_VLAN_INFO_BRENTRY")
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
---
Cc: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Vladimir Oltean Feb. 22, 2022, 5:26 p.m. UTC | #1
On Tue, Feb 22, 2022 at 07:16:53PM +0200, Ido Schimmel wrote:
> Only VLAN entries installed on the bridge device itself should be
> considered when checking whether a packet with a specific VLAN can be
> mirrored via a bridge device. VLAN entries only used to keep context
> (i.e., entries with 'BRIDGE_VLAN_INFO_BRENTRY' unset) should be ignored.
> 
> Fix this by preventing mirroring when the VLAN entry does not have the
> 'BRIDGE_VLAN_INFO_BRENTRY' flag set.
> 
> Fixes: ddaff5047003 ("mlxsw: spectrum: remove guards against !BRIDGE_VLAN_INFO_BRENTRY")
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
> Reviewed-by: Petr Machata <petrm@nvidia.com>
> ---

Sorry, I didn't realize br_vlan_get_info() doesn't have a
br_vlan_should_use() check. Maybe we should add it, for the same
consideration that a !BRENTRY master VLAN is still a data structure
private to the bridge, that shouldn't be revealed to other modules?

Anyway, this works too.

Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>

> Cc: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
> index 5459490c7790..b73466470f75 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
> @@ -269,7 +269,8 @@ mlxsw_sp_span_entry_bridge_8021q(const struct net_device *br_dev,
>  
>  	if (!vid && WARN_ON(br_vlan_get_pvid(br_dev, &vid)))
>  		return NULL;
> -	if (!vid || br_vlan_get_info(br_dev, vid, &vinfo))
> +	if (!vid || br_vlan_get_info(br_dev, vid, &vinfo) ||
> +	    !(vinfo.flags & BRIDGE_VLAN_INFO_BRENTRY))
>  		return NULL;
>  
>  	edev = br_fdb_find_port(br_dev, dmac, vid);
> -- 
> 2.33.1
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
index 5459490c7790..b73466470f75 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
@@ -269,7 +269,8 @@  mlxsw_sp_span_entry_bridge_8021q(const struct net_device *br_dev,
 
 	if (!vid && WARN_ON(br_vlan_get_pvid(br_dev, &vid)))
 		return NULL;
-	if (!vid || br_vlan_get_info(br_dev, vid, &vinfo))
+	if (!vid || br_vlan_get_info(br_dev, vid, &vinfo) ||
+	    !(vinfo.flags & BRIDGE_VLAN_INFO_BRENTRY))
 		return NULL;
 
 	edev = br_fdb_find_port(br_dev, dmac, vid);