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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Fri, 31 May 2024 18:29:37 +0300
From: Vladimir Oltean <olteanv@...il.com>
To: "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>
Cc: Andrew Lunn <andrew@...n.ch>, Heiner Kallweit <hkallweit1@...il.com>,
	Florian Fainelli <f.fainelli@...il.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	netdev@...r.kernel.org
Subject: Re: [PATCH net-next] net: dsa: remove obsolete phylink dsa_switch
 operations

On Fri, May 31, 2024 at 09:21:29AM +0100, Russell King (Oracle) wrote:
> No driver now uses the DSA switch phylink members, so we can now remove
> the shim functions and method pointers. Arrange to print an error
> message and fail registration if a DSA driver does not provide the
> phylink MAC operations structure.
> 
> Signed-off-by: Russell King (oracle) <rmk+kernel@...linux.org.uk>
> ---
>  include/net/dsa.h | 15 ----------
>  net/dsa/dsa.c     |  9 ++----
>  net/dsa/port.c    | 74 +----------------------------------------------
>  3 files changed, 4 insertions(+), 94 deletions(-)
> 
> diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
> index 668c729946ea..ceeadb52d1cc 100644
> --- a/net/dsa/dsa.c
> +++ b/net/dsa/dsa.c
> @@ -1505,12 +1505,9 @@ static int dsa_switch_probe(struct dsa_switch *ds)
>  	if (!ds->num_ports)
>  		return -EINVAL;
>  
> -	if (ds->phylink_mac_ops) {
> -		if (ds->ops->phylink_mac_select_pcs ||
> -		    ds->ops->phylink_mac_config ||
> -		    ds->ops->phylink_mac_link_down ||
> -		    ds->ops->phylink_mac_link_up)
> -			return -EINVAL;
> +	if (!ds->phylink_mac_ops) {
> +		dev_err(ds->dev, "DSA switch driver does not provide phylink MAC operations");
> +		return -EINVAL;
>  	}
>  
>  	if (np) {
> diff --git a/net/dsa/port.c b/net/dsa/port.c
> index e23db9507546..a31a5517a12f 100644
> --- a/net/dsa/port.c
> +++ b/net/dsa/port.c
> @@ -1625,12 +1560,8 @@ int dsa_port_phylink_create(struct dsa_port *dp)
>  		}
>  	}
>  
> -	mac_ops = &dsa_port_phylink_mac_ops;
> -	if (ds->phylink_mac_ops)
> -		mac_ops = ds->phylink_mac_ops;
> -
>  	pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn), mode,
> -			    mac_ops);
> +			    ds->phylink_mac_ops);
>  	if (IS_ERR(pl)) {
>  		pr_err("error creating PHYLINK: %ld\n", PTR_ERR(pl));
>  		return PTR_ERR(pl);

Nack. The highlighted portions break dsa_loop, hellcreek and mv88e6060 [1],
which are currently trivially integrated with phylink through the
default dsa_port_phylink_mac_ops, but have no implementations of
ds->ops->phylink_mac_* of their own.

What I'm trying to point out is that we are not at the stage yet where
we can enforce all drivers to populate ds->phylink_mac_ops.

> @@ -1831,9 +1762,6 @@ static void dsa_shared_port_link_down(struct dsa_port *dp)
>  	if (ds->phylink_mac_ops && ds->phylink_mac_ops->mac_link_down)

Mostly irrelevant, but I'll point out an issue with the patch logic's
consistency anyway: there is no need to check "if (ds->phylink_mac_ops)"
more than once. The earlier probe failure is sufficient (although, as
mentioned, breaking for 3 drivers).

>  		ds->phylink_mac_ops->mac_link_down(&dp->pl_config, MLO_AN_FIXED,
>  						   PHY_INTERFACE_MODE_NA);
> -	else if (ds->ops->phylink_mac_link_down)
> -		ds->ops->phylink_mac_link_down(ds, dp->index, MLO_AN_FIXED,
> -					       PHY_INTERFACE_MODE_NA);
>  }
>  
>  int dsa_shared_port_link_register_of(struct dsa_port *dp)
> -- 
> 2.30.2
> 

[1] Quick way to check: compare the outputs of these 2 commands, and see
which drivers from the first category are absent from the second:
$ grep -r dsa_register_switch drivers/net/dsa/ | cut -d: -f1 | sort | uniq
$ grep -r phylink_mac_ops drivers/net/dsa/ | cut -d: -f1 | sort | uniq

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ