netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Jakub Kicinski <kuba@kernel.org>, davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com,
	piergiorgio.beruto@gmail.com, gal@nvidia.com, tariqt@nvidia.com,
	dnlplm@gmail.com, sean.anderson@seco.com, linux@rempel-privat.de,
	lkp@intel.com, bagasdotme@gmail.com, wangjie125@huawei.com,
	huangguangbin2@huawei.com
Subject: Re: [PATCH net-next 2/2] ethtool: netlink: convert commands to common SET
Date: Tue, 24 Jan 2023 12:41:34 +0100	[thread overview]
Message-ID: <fe14f2c636718b5237cd31531260e4145bbd8a75.camel@redhat.com> (raw)
In-Reply-To: <20230121054430.642280-2-kuba@kernel.org>

Hi,

On Fri, 2023-01-20 at 21:44 -0800, Jakub Kicinski wrote:
> @@ -241,49 +229,41 @@ const struct nla_policy ethnl_coalesce_set_policy[] = {
>  	[ETHTOOL_A_COALESCE_TX_AGGR_TIME_USECS] = { .type = NLA_U32 },
>  };
>  
> -int ethnl_set_coalesce(struct sk_buff *skb, struct genl_info *info)
> +static int
> +ethnl_set_coalesce_validate(struct ethnl_req_info *req_info,
> +			    struct genl_info *info)
>  {
> -	struct kernel_ethtool_coalesce kernel_coalesce = {};
> -	struct ethtool_coalesce coalesce = {};
> -	struct ethnl_req_info req_info = {};
> +	const struct ethtool_ops *ops = req_info->dev->ethtool_ops;
>  	struct nlattr **tb = info->attrs;
> -	const struct ethtool_ops *ops;
> -	struct net_device *dev;
>  	u32 supported_params;
> -	bool mod = false;
> -	int ret;
>  	u16 a;
>  
> -	ret = ethnl_parse_header_dev_get(&req_info,
> -					 tb[ETHTOOL_A_COALESCE_HEADER],
> -					 genl_info_net(info), info->extack,
> -					 true);
> -	if (ret < 0)
> -		return ret;
> -	dev = req_info.dev;
> -	ops = dev->ethtool_ops;
> -	ret = -EOPNOTSUPP;
> -	if (!ops->get_coalesce || !ops->set_coalesce)
> -		goto out_dev;
> -
>  	/* make sure that only supported parameters are present */
>  	supported_params = ops->supported_coalesce_params;
>  	for (a = ETHTOOL_A_COALESCE_RX_USECS; a < __ETHTOOL_A_COALESCE_CNT; a++)
>  		if (tb[a] && !(supported_params & attr_to_mask(a))) {
> -			ret = -EINVAL;
>  			NL_SET_ERR_MSG_ATTR(info->extack, tb[a],
>  					    "cannot modify an unsupported parameter");
> -			goto out_dev;
> +			return -EINVAL;
>  		}
>  
> -	rtnl_lock();
> -	ret = ethnl_ops_begin(dev);
> -	if (ret < 0)
> -		goto out_rtnl;
> -	ret = ops->get_coalesce(dev, &coalesce, &kernel_coalesce,
> -				info->extack);
> +	return ops->get_coalesce && ops->set_coalesce ? 1 : -EOPNOTSUPP;

The above changes the error code in case a coalesce op is missing (and
likely supported_coalesce_params is zero) from EOPNOTSUPP to EINVAL.

I guess it's not a big deal but perhaps we can preserve the same error
code as prior to this patch? 

Not a big deal, I see other commands check the oops last.

Thanks,

Paolo



  parent reply	other threads:[~2023-01-24 11:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-21  5:44 [PATCH net-next 1/2] ethtool: netlink: handle SET intro/outro in the common code Jakub Kicinski
2023-01-21  5:44 ` [PATCH net-next 2/2] ethtool: netlink: convert commands to common SET Jakub Kicinski
2023-01-23  8:00   ` Gal Pressman
2023-01-23 11:20   ` Tariq Toukan
2023-01-23 12:17   ` Daniele Palmas
2023-01-24 11:41   ` Paolo Abeni [this message]
2023-01-24 11:34 ` [PATCH net-next 1/2] ethtool: netlink: handle SET intro/outro in the common code Paolo Abeni
2023-01-25  0:37   ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fe14f2c636718b5237cd31531260e4145bbd8a75.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=bagasdotme@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dnlplm@gmail.com \
    --cc=edumazet@google.com \
    --cc=gal@nvidia.com \
    --cc=huangguangbin2@huawei.com \
    --cc=kuba@kernel.org \
    --cc=linux@rempel-privat.de \
    --cc=lkp@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=piergiorgio.beruto@gmail.com \
    --cc=sean.anderson@seco.com \
    --cc=tariqt@nvidia.com \
    --cc=wangjie125@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).