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]
Message-ID: <BL0PR11MB29132C0293B487EBEAFF4532E7DB2@BL0PR11MB2913.namprd11.prod.outlook.com>
Date: Tue, 9 Jul 2024 18:02:20 +0000
From: <Woojung.Huh@...rochip.com>
To: <o.rempel@...gutronix.de>
CC: <mkubecek@...e.cz>, <davem@...emloft.net>, <edumazet@...gle.com>,
	<kuba@...nel.org>, <pabeni@...hat.com>, <jiri@...nulli.us>,
	<vladimir.oltean@....com>, <andrew@...n.ch>, <Arun.Ramadoss@...rochip.com>,
	<kernel@...gutronix.de>, <netdev@...r.kernel.org>,
	<UNGLinuxDriver@...rochip.com>, <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH net v2 1/1] ethtool: netlink: do not return SQI value if
 link is down

Hi Oleksij,

> > > diff --git a/net/ethtool/linkstate.c b/net/ethtool/linkstate.c
> > > index b2de2108b356a..4efd327ba5d92 100644
> > > --- a/net/ethtool/linkstate.c
> > > +++ b/net/ethtool/linkstate.c
> > > @@ -37,6 +37,8 @@ static int linkstate_get_sqi(struct net_device *dev)
> > >         mutex_lock(&phydev->lock);
> > >         if (!phydev->drv || !phydev->drv->get_sqi)
> > >                 ret = -EOPNOTSUPP;
> > > +       else if (!phydev->link)
> > > +               ret = -ENETDOWN;
> > >         else
> > >                 ret = phydev->drv->get_sqi(phydev);
> > >         mutex_unlock(&phydev->lock);
> > > @@ -55,6 +57,8 @@ static int linkstate_get_sqi_max(struct net_device
> *dev)
> > >         mutex_lock(&phydev->lock);
> > >         if (!phydev->drv || !phydev->drv->get_sqi_max)
> > >                 ret = -EOPNOTSUPP;
> > > +       else if (!phydev->link)
> > > +               ret = -ENETDOWN;
> > >         else
> > >                 ret = phydev->drv->get_sqi_max(phydev);
> > >         mutex_unlock(&phydev->lock);
> > > @@ -62,6 +66,16 @@ static int linkstate_get_sqi_max(struct net_device
> *dev)
> > >         return ret;
> > >  };
> > >
> > > +static bool linkstate_sqi_critical_error(int sqi)
> > > +{
> > > +       return sqi < 0 && sqi != -EOPNOTSUPP && sqi != -ENETDOWN;
> > > +}
> > > +
> > > +static bool linkstate_sqi_valid(struct linkstate_reply_data *data)
> > > +{
> > > +       return data->sqi >= 0 && data->sqi_max >= 0;
> >
> > If PHY driver has get_sqi, but not get_sqi_max, then data->sqi could have
> > a valid value, but data->sqi_max will have -EOPNOTSUPP.
> > In this case, linkstate_sqi_valid() will return FALSE and not getting
> > SQI value at all.
> 
> SQI without max will not able to describe quality of the link, it is
> just value saying nothing to the user.
> 

Honestly, I'm not 100% confident that max is really needed because
SQI range shall be 0 (worst) and 7 (best) per OpenAlliance specification.
On the other side, some devices could not go up to 7 and limit by max.
So, agree that both APIs are needed here.

> > If both APIs are required, then we could add another condition of
> > data->sqi <= data->sqi_max in linkstate_sqi_valid()
> 
> Ack. I was thinking about it, but was not sure if it is a good idea. This
> will silently filer our a bag. Passing a baggy value to the users space
> is not good too. I'll fix.
> 

Thanks. Will reply in v3.

> > And, beside this, calling linkstate_get_sqi and linkstate_get_sqi_max
> > could be moved under "if (dev->flags & IFF_UP)" with setting default
> > value to data->sqi & data->sqi_max.
> 
> IFF_UP is administrative up state, it is not the link/L1 up. sqi_max and
> sqi should be initialized anyway, otherwise we will show 0/0 if
> interface is in admin down.

Thanks for correcting me.

Woojung

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ