Subject: Re: [PATCH net-next 2/3] net: ethtool: move checks before rtnl_lock() in ethnl_set_rings

From: Jakub Kicinski <[email-masked]>
Date: Fri, 8 Apr 2022 14:58:50 -0700

On Fri, 8 Apr 2022 15:12:44 +0800 Guangbin Huang wrote:
> +	if (tb[ETHTOOL_A_RINGS_RX_BUF_LEN] &&
> +	    nla_get_u32(tb[ETHTOOL_A_RINGS_RX_BUF_LEN]) != 0 &&

I think we can drop the value checking. If attribute is present and
drivers doesn't support - reject. I don't think that would require 
any changes to existing user space but please double check.

> +	    !(ops->supported_ring_params & ETHTOOL_RING_USE_RX_BUF_LEN)) {
> +		ret = -EOPNOTSUPP;
> +		NL_SET_ERR_MSG_ATTR(info->extack,
> +				    tb[ETHTOOL_A_RINGS_RX_BUF_LEN],
> +				    "setting rx buf len not supported");
> +		goto out_dev;
> +	}
> +
> +	if (tb[ETHTOOL_A_RINGS_CQE_SIZE] &&
> +	    nla_get_u32(tb[ETHTOOL_A_RINGS_CQE_SIZE]) &&
> +	    !(ops->supported_ring_params & ETHTOOL_RING_USE_CQE_SIZE)) {
> +		ret = -EOPNOTSUPP;
> +		NL_SET_ERR_MSG_ATTR(info->extack,
> +				    tb[ETHTOOL_A_RINGS_CQE_SIZE],
> +				    "setting cqe size not supported");
> +		goto out_dev;
> +	}