Re: [PATCH v4 net-next 6/9] net/sched: mqprio: allow per-TC user input of FP adminStatus

From: Vladimir Oltean
Date: Tue Apr 11 2023 - 13:03:08 EST


On Wed, Apr 05, 2023 at 06:12:34PM -0700, Jakub Kicinski wrote:
> On Mon, 3 Apr 2023 13:34:37 +0300 Vladimir Oltean wrote:
> > +static int mqprio_parse_tc_entry(u32 fp[TC_QOPT_MAX_QUEUE],
> > + struct nlattr *opt,
> > + unsigned long *seen_tcs,
> > + struct netlink_ext_ack *extack)
> > +{
> > + struct nlattr *tb[TCA_MQPRIO_TC_ENTRY_MAX + 1] = { };
>
> nit: no need to clear it nla_parse*() zeros the memory

ok.

> > + int err, tc;
> > +
> > + err = nla_parse_nested(tb, TCA_MQPRIO_TC_ENTRY_MAX, opt,
> > + mqprio_tc_entry_policy, extack);
> > + if (err < 0)
> > + return err;
> > +
> > + if (!tb[TCA_MQPRIO_TC_ENTRY_INDEX]) {
> > + NL_SET_ERR_MSG(extack, "TC entry index missing");
>
> Are you not using NL_REQ_ATTR_CHECK() because iproute can't actually
> parse the result? :(

I could use it though.. let's assume that iproute2 is "reference code"
and gets the nlattr structure right. Thus, the NLMSGERR_ATTR_MISS_NEST
would be of more interest for custom user programs.

Speaking of which, is there any reference example of how to use
NLMSGERR_ATTR_MISS_NEST? My search came up empty handed:
https://github.com/search?p=1&q=NLMSGERR_ATTR_MISS_NEST&type=Code

I usually steal from hostap's error_handler(), but it looks like it
hasn't gotten that advanced yet as to re-parse the netlink message to
understand the reason why it got rejected.

>
> > + return -EINVAL;
> > + }
> > +
> > + tc = nla_get_u32(tb[TCA_MQPRIO_TC_ENTRY_INDEX]);
> > + if (*seen_tcs & BIT(tc)) {
> > + NL_SET_ERR_MSG(extack, "Duplicate tc entry");
>
> set attr in extack?

ok

> minor heads up - I'll take the trivial cleanup patch from Pedro
> so make sure you rebase:
> https://lore.kernel.org/all/20230404203449.1627033-1-pctammela@xxxxxxxxxxxx/

ok