lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 17 Dec 2020 11:04:27 +0000
From:   Vladimir Oltean <vladimir.oltean@....com>
To:     "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC:     Florian Fainelli <f.fainelli@...il.com>,
        Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Vladimir Oltean <olteanv@...il.com>,
        Kurt Kanzenbach <kurt@...utronix.de>,
        Hauke Mehrtens <hauke@...ke-m.de>,
        Woojung Huh <woojung.huh@...rochip.com>,
        Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
        Sean Wang <sean.wang@...iatek.com>,
        Landen Chao <Landen.Chao@...iatek.com>,
        Claudiu Manoil <claudiu.manoil@....com>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        Vadym Kochan <vkochan@...vell.com>,
        Taras Chornyi <tchornyi@...vell.com>,
        Jiri Pirko <jiri@...dia.com>, Ido Schimmel <idosch@...dia.com>,
        Grygorii Strashko <grygorii.strashko@...com>,
        Ioana Ciornei <ioana.ciornei@....com>,
        Ivan Vecera <ivecera@...hat.com>
Subject: Re: [RFC PATCH net-next 6/9] net: dsa: remove the transactional logic
 from VLAN objects

On Thu, Dec 17, 2020 at 03:58:19AM +0200, Vladimir Oltean wrote:
> It should be the driver's business to logically separate its VLAN
> offloading into a preparation and a commit phase, and some drivers don't
> need / can't do this.
> 
> So remove the transactional shim from DSA and let drivers to propagate
> errors directly from the .port_vlan_add callback.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
> ---
[...]
> diff --git a/net/dsa/switch.c b/net/dsa/switch.c
> index 65124bc3ddfb..bd00ef6296f9 100644
> --- a/net/dsa/switch.c
> +++ b/net/dsa/switch.c
> @@ -217,35 +217,13 @@ static bool dsa_switch_vlan_match(struct dsa_switch *ds, int port,
>  	return false;
>  }
>  
> -static int dsa_switch_vlan_prepare(struct dsa_switch *ds,
> -				   struct dsa_notifier_vlan_info *info)
> -{
> -	int port, err;
> -
> -	if (!ds->ops->port_vlan_prepare || !ds->ops->port_vlan_add)
> -		return -EOPNOTSUPP;
> -
> -	for (port = 0; port < ds->num_ports; port++) {
> -		if (dsa_switch_vlan_match(ds, port, info)) {
> -			err = ds->ops->port_vlan_prepare(ds, port, info->vlan);
> -			if (err)
> -				return err;
> -		}
> -	}
> -
> -	return 0;
> -}
> -
>  static int dsa_switch_vlan_add(struct dsa_switch *ds,
>  			       struct dsa_notifier_vlan_info *info)
>  {
>  	int port;
>  
> -	if (switchdev_trans_ph_prepare(info->trans))
> -		return dsa_switch_vlan_prepare(ds, info);
> -
>  	if (!ds->ops->port_vlan_add)
> -		return 0;
> +		return -EOPNOTSUPP;
>  
>  	for (port = 0; port < ds->num_ports; port++)
>  		if (dsa_switch_vlan_match(ds, port, info))
> -- 
> 2.25.1
> 

For anybody who wants to test, please paste this instead of the existing
dsa_switch_vlan_add, to propagate the errors:

static int dsa_switch_vlan_add(struct dsa_switch *ds,
			       struct dsa_notifier_vlan_info *info)
{
	int err = 0;
	int port;

	if (!ds->ops->port_vlan_add)
		return -EOPNOTSUPP;

	for (port = 0; port < ds->num_ports; port++) {
		if (dsa_switch_vlan_match(ds, port, info)) {
			err = ds->ops->port_vlan_add(ds, port, info->vlan);
			if (err)
				break;
		}
	}

	return err;
}

Powered by blists - more mailing lists