Subject: Re: [PATCH net-next v4 1/4] ethtool: provide customized dim profile management

From: Jakub Kicinski <[email-masked]>
Date: Mon, 8 Apr 2024 12:13:24 -0700

On Mon,  8 Apr 2024 11:44:27 +0800 Heng Qi wrote:
> +	nla_for_each_nested(nest, nests, rem) {
> +		if (WARN_ONCE(nla_type(nest) != ETHTOOL_A_MODERATIONS_MODERATION,
> +			      "unexpected nest attrtype %u\n", nla_type(nest)))

Maybe just use the newly added nla_for_each_nested_type() 

> +			return;
> +
> +		ret = nla_parse_nested(tb_moder,
> +				       ARRAY_SIZE(coalesce_set_profile_policy) - 1,
> +				       nest, coalesce_set_profile_policy,
> +				       extack);
> +		if (ret ||

if parsing failed it will set the right error and extack, just return
the error

> +		    !tb_moder[ETHTOOL_A_MODERATION_USEC] ||
> +		    !tb_moder[ETHTOOL_A_MODERATION_PKTS] ||
> +		    !tb_moder[ETHTOOL_A_MODERATION_COMPS]) {

If you miss an attr you should use NL_SET_ERR_ATTR_MISS() or such.

> +			NL_SET_ERR_MSG(extack, "wrong ETHTOOL_A_MODERATION_* attribute\n");

no new line at the end of the exact string