Re: [PATCH net-next v3 6/7] ethtool: add interface to interact with Ethernet Power Equipment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Aug 27, 2022 at 08:38:34PM +0200, Andrew Lunn wrote:
> > +static int pse_set_pse_config(struct net_device *dev,
> > +			      struct netlink_ext_ack *extack,
> > +			      struct nlattr **tb)
> > +{
> > +	struct phy_device *phydev = dev->phydev;
> > +	struct pse_control_config config = {};
> > +	int ret;
> > +
> > +	if (!tb[ETHTOOL_A_PODL_PSE_ADMIN_CONTROL])
> > +		return -EINVAL;
> 
> I would make use of extack here, and report what is missing.
> 
> > +
> > +	config.admin_cotrol = nla_get_u8(tb[ETHTOOL_A_PODL_PSE_ADMIN_CONTROL]);
> 
> It would be good to have some basic validation here, make sure user
> space has passed a reasonable value.

this values are already validate by the ethnl_pse_set_policy

> You should also define what 0 and
> ETHTOOL_A_PODL_PSE_ADMIN_CONTROL_UNKNOWN means here when passed in. In
> future, there could be additional things which could be configured, so
> struct pse_control_config gets additional members.
> ETHTOOL_A_PODL_PSE_ADMIN_CONTROL appears to be mandatory, you return
> -EVINAL if missing, so if you don't want to change it, but change some
> other new thing, maybe 0 should be passed here? And the driver should
> not consider it an error?

ack. changed to 0 and added comment.

> ETHTOOL_A_PODL_PSE_ADMIN_CONTROL_UNKNOWN
> however seems invalid and so should be rejected here?

yes. it is already rejected. I added comment to make it more visible

-- 
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 |



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux