Subject: Re: [PATCH net-next 2/2] net/sched: sch_qfq: use extack on errors messages

From: Jakub Kicinski <[email-masked]>
Date: Fri, 14 Apr 2023 18:15:37 -0700

On Fri, 14 Apr 2023 15:53:10 -0300 Pedro Tammela wrote:
>  	if (tca[TCA_OPTIONS] == NULL) {
> -		pr_notice("qfq: no options\n");
> +		NL_SET_ERR_MSG_MOD(extack, "missing options");

NL_REQ_ATTR_CHECK() (probably in addition to the string message)
since it's legacy netlink.

>  		return -EINVAL;
>  	}
>  
>  	err = nla_parse_nested_deprecated(tb, TCA_QFQ_MAX, tca[TCA_OPTIONS],
> -					  qfq_policy, NULL);
> +					  qfq_policy, extack);
>  	if (err < 0)
>  		return err;
>  
>  	if (tb[TCA_QFQ_WEIGHT]) {
>  		weight = nla_get_u32(tb[TCA_QFQ_WEIGHT]);
>  		if (!weight || weight > (1UL << QFQ_MAX_WSHIFT)) {
> -			pr_notice("qfq: invalid weight %u\n", weight);
> +			NL_SET_ERR_MSG_FMT_MOD(extack, "invalid weight %u\n",
> +					       weight);

The checks should be expressed as part of the policy and parsing will
take care of the extack

>  			return -EINVAL;
>  		}
>  	} else
> @@ -424,7 +425,8 @@ static int qfq_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
>  	if (tb[TCA_QFQ_LMAX]) {
>  		lmax = nla_get_u32(tb[TCA_QFQ_LMAX]);
>  		if (lmax < QFQ_MIN_LMAX || lmax > (1UL << QFQ_MTU_SHIFT)) {
> -			pr_notice("qfq: invalid max length %u\n", lmax);
> +			NL_SET_ERR_MSG_FMT_MOD(extack,
> +					       "invalid max length %u\n", lmax);
>  			return -EINVAL;

ditto