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

From: wangjie (L)
Date: Mon Apr 11 2022 - 04:01:24 EST




On 2022/4/9 5:58, Jakub Kicinski wrote:
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.

I have checked user space code and tested the delete version on my server, these value checking will be dropped in v2.
+ !(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;
+ }

.