[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZX1hXMhJLwgg5S1v@Laptop-X1>
Date: Sat, 16 Dec 2023 16:35:40 +0800
From: Hangbin Liu <liuhangbin@...il.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: netdev@...r.kernel.org, Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH net-next 1/3] tools: ynl-gen: use correct len for string
and binary
On Fri, Dec 15, 2023 at 06:06:03PM -0800, Jakub Kicinski wrote:
> On Fri, 15 Dec 2023 11:50:07 +0800 Hangbin Liu wrote:
> > As the description of 'struct nla_policy', the len means the maximum length
> > of string, binary. Or minimum length of attribute payload for others.
> > But most time we only use it for string and binary.
>
> The meaning of 'len' in nla_policy is confusing to people writing new
> families. IIRC I used max-len / min-len / extact-len and not len on
> purpose in the YAML, so that there's no confusion what means what for
> which type...
>
> Obviously it is slightly confusing for people like you who convert
> the existing families to YAML specs, but the risk of bugs seems lower
> there. So I'd prefer to stick to the existing set of options.
>
> Is the existing code gen incorrect or just hard to wrap one's head
> around?
>
The max-len / min-len / extact-len micro are used by binary. For string we
need to use "len" to define the max length. e.g.
static const struct nla_policy
team_nl_option_policy[TEAM_ATTR_OPTION_MAX + 1] = {
[TEAM_ATTR_OPTION_UNSPEC] = { .type = NLA_UNSPEC, },
[TEAM_ATTR_OPTION_NAME] = {
.type = NLA_STRING,
.len = TEAM_STRING_MAX_LEN,
},
Thanks
Hangbin
Powered by blists - more mailing lists