Re: [PATCH net v1 1/1] ethtool: netlink: do not return SQI value if link is down
From: Oleksij Rempel
Date: Fri Jul 05 2024 - 03:05:51 EST
On Thu, Jul 04, 2024 at 04:01:31PM +0200, Andrew Lunn wrote:
...
> > ret = linkstate_get_sqi(dev);
> > - if (ret < 0 && ret != -EOPNOTSUPP)
> > + if (ret < 0 && ret != -EOPNOTSUPP && ret != -ENETDOWN)
> > goto out;
> > data->sqi = ret;
>
> So data->sqi becomes -ENETDOWN
>
>
> > - if (data->sqi != -EOPNOTSUPP &&
> > + if (data->sqi != -EOPNOTSUPP && data->sqi != -ENETDOWN &&
> > nla_put_u32(skb, ETHTOOL_A_LINKSTATE_SQI, data->sqi))
> > return -EMSGSIZE;
>
> Thinking about the old code, if the driver returned something other
> than -EOPNOTSUPP, it looks like the error code would make it to user
> space. Is ethtool/iproute2 setup to correctly handle this? If it is,
> maybe pass the -ENETDOWN to user space?
In current state with ethtool v6.5 i'll get following results.
If no -ENETDOWN is returned:
Settings for spe4:
Supported ports: [ TP ]
Supported link modes: 100baseT1/Full
Supported pause frame use: No
Supports auto-negotiation: No
Supported FEC modes: Not reported
Advertised link modes: 100baseT1/Full
Advertised pause frame use: No
Advertised auto-negotiation: No
Advertised FEC modes: Not reported
Speed: 100Mb/s
Duplex: Full
Auto-negotiation: off
master-slave cfg: forced slave
master-slave status: unknown
Port: Twisted Pair
PHYAD: 6
Transceiver: external
MDI-X: Unknown
Supports Wake-on: d
Wake-on: d
Link detected: no
If -ENETDOWN is returned:
Settings for spe4:
Supported ports: [ TP ]
Supported link modes: 100baseT1/Fulli
Supported pause frame use: No
Supports auto-negotiation: No
Supported FEC modes: Not reported
Advertised link modes: 100baseT1/Full
Advertised pause frame use: No
Advertised auto-negotiation: No
Advertised FEC modes: Not reported
Speed: 100Mb/s
Duplex: Full
Auto-negotiation: off
master-slave cfg: forced slave
master-slave status: unknown
Port: Twisted Pair
PHYAD: 6
Transceiver: external
MDI-X: Unknown
Supports Wake-on: d
Wake-on: d
netlink error: Network is down
Instead of "Link detected: no", we will get netlink error.
Regards,
Oleksij
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |