[PATCH net-next mlxsw 3/3] mlxsw: spectrum_span: Support VLAN under mirror-to-gretap

Ido Schimmel idosch at mellanox.com
Tue May 8 17:22:20 AEST 2018


On Mon, May 07, 2018 at 04:29:39PM +0200, Petr Machata wrote:
> When mirroring to a gretap or ip6gretap device, allow the underlay
> packet path to include VLAN devices. The following configurations are
> supported in underlay:
> 
> - vlan over phys
> - vlan-unaware bridge where the egress device is vlan over phys
> - vlan over vlan-aware bridge where the egress device is phys
> 
> Signed-off-by: Petr Machata <petrm at mellanox.com>
> ---
>  drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
> index f6b3ca9..ac70a71 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_span.c
> @@ -176,9 +176,9 @@ mlxsw_sp_span_entry_bridge_8021q(const struct net_device *br_dev,
>  {
>  	struct bridge_vlan_info vinfo;
>  	struct net_device *edev;
> -	u16 pvid;
> +	u16 pvid = *p_vid;

IIUC, in case we got here from a VLAN device configured on top of a
VLAN-aware bridge, then 'p_vid' is actually the VID of the VLAN device.
If so, then calling it PVID is incorrect. PVID is only used for untagged
traffic.

Also, I'm missing the check where packets with this VLAN are even
allowed to ingress the bridge through the bridge device.

Note that we don't get notified about changes to the bridge device's
VLAN filter, so this is something that needs to be added as well.

>  
> -	if (WARN_ON(br_vlan_get_pvid(br_dev, &pvid)))
> +	if (!pvid && WARN_ON(br_vlan_get_pvid(br_dev, &pvid)))
>  		return NULL;
>  	if (!pvid)
>  		return NULL;
> @@ -208,13 +208,13 @@ mlxsw_sp_span_entry_bridge(const struct net_device *br_dev,
>  {
>  	struct mlxsw_sp_bridge_port *bridge_port;
>  	enum mlxsw_reg_spms_state spms_state;
> +	struct net_device *dev = NULL;
>  	struct mlxsw_sp_port *port;
> -	struct net_device *dev;
>  	u8 stp_state;
>  
>  	if (br_vlan_enabled(br_dev))
>  		dev = mlxsw_sp_span_entry_bridge_8021q(br_dev, dmac, p_vid);
> -	else
> +	else if (!*p_vid)
>  		dev = mlxsw_sp_span_entry_bridge_8021d(br_dev, dmac);
>  	if (!dev)
>  		return NULL;
> @@ -261,12 +261,21 @@ mlxsw_sp_span_entry_tunnel_parms_common(struct net_device *l3edev,
>  	if (!l3edev || mlxsw_sp_span_dmac(tbl, &gw, l3edev, dmac))
>  		goto unoffloadable;
>  
> +	if (is_vlan_dev(l3edev))
> +		l3edev = mlxsw_sp_span_entry_vlan(l3edev, &vid);
> +
>  	if (netif_is_bridge_master(l3edev)) {
>  		l3edev = mlxsw_sp_span_entry_bridge(l3edev, dmac, &vid);
>  		if (!l3edev)
>  			goto unoffloadable;
>  	}
>  
> +	if (is_vlan_dev(l3edev)) {
> +		if (vid || !(l3edev->flags & IFF_UP))
> +			goto unoffloadable;
> +		l3edev = mlxsw_sp_span_entry_vlan(l3edev, &vid);
> +	}
> +
>  	if (!mlxsw_sp_port_dev_check(l3edev))
>  		goto unoffloadable;
>  
> -- 
> 2.4.11
> 


More information about the Linux-mlxsw mailing list