Re: [PATCH net-next 3/7] ethtool: set message mask with DEBUG_SET request

Michal Kubecek
2020-01-27T06:23:23Z

On Mon, Jan 27, 2020 at 01:22:06AM +0100, Andrew Lunn wrote:
> On Sun, Jan 26, 2020 at 11:11:07PM +0100, Michal Kubecek wrote:
> > Implement DEBUG_SET netlink request to set debugging settings for a device.
> > At the moment, only message mask corresponding to message level as set by
> > ETHTOOL_SMSGLVL ioctl request can be set. (It is called message level in
> > ioctl interface but almost all drivers interpret it as a bit mask.)
> >
> > Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
> > +int ethnl_set_debug(struct sk_buff *skb, struct genl_info *info)
> > +{
> > + struct nlattr *tb[ETHTOOL_A_DEBUG_MAX + 1];
> > + struct ethnl_req_info req_info = {};
> > + struct net_device *dev;
> > + bool mod = false;
> > + u32 msg_mask;
> > + int ret;
> > +
> > + ret = nlmsg_parse(info->nlhdr, GENL_HDRLEN, tb,
> > + ETHTOOL_A_DEBUG_MAX, debug_set_policy,
> > + info->extack);
> > + if (ret < 0)
> > + return ret;
> > + ret = ethnl_parse_header(&req_info, tb[ETHTOOL_A_DEBUG_HEADER],
> > + genl_info_net(info), info->extack, true);
> > + if (ret < 0)
> > + return ret;
> > + dev = req_info.dev;
> > + if (!dev->ethtool_ops->get_msglevel || !dev->ethtool_ops->set_msglevel)
> > + return -EOPNOTSUPP;
>
> This seems like a new requirement, that both get and set callbacks are
> implemented. However, A quick look thought the code suggests all
> drivers already do have both get and set. So i think this is safe.

Technically it's a new requirement but as ethtool (userspace utility)
always issues ETHTOOL_GMSGLVL before ETHTOOL_SMSGLVL and does so even
for command lines like "ethtool -s eth0 msglvl 5" where it's not really
needed, providing ->set_msglevel() without ->get_msglevel() wouldn't
be of much use even now.

Michal

>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
>
> Andrew