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

From: Andrew Lunn
Date: Sun Jan 26 2020 - 19:22:14 EST


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@xxxxxxx>
> +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.

Reviewed-by: Andrew Lunn <andrew@xxxxxxx>

Andrew