public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Hangbin Liu <liuhangbin@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH net-next 1/3] tools: ynl-gen: use correct len for string and binary
Date: Sat, 16 Dec 2023 16:35:40 +0800	[thread overview]
Message-ID: <ZX1hXMhJLwgg5S1v@Laptop-X1> (raw)
In-Reply-To: <20231215180603.576748b1@kernel.org>

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

  reply	other threads:[~2023-12-16  8:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-15  3:50 [PATCH net-next 0/3] ynl-gen: update check format Hangbin Liu
2023-12-15  3:50 ` [PATCH net-next 1/3] tools: ynl-gen: use correct len for string and binary Hangbin Liu
2023-12-16  2:06   ` Jakub Kicinski
2023-12-16  8:35     ` Hangbin Liu [this message]
2023-12-18 22:22       ` Jakub Kicinski
2023-12-19 10:01         ` Hangbin Liu
2023-12-15  3:50 ` [PATCH net-next 2/3] tools: ynl-gen: support using defines in checks Hangbin Liu
2023-12-16  2:08   ` Jakub Kicinski
2023-12-16  8:44     ` Hangbin Liu
2023-12-18 22:23       ` Jakub Kicinski
2023-12-15  3:50 ` [PATCH net-next 3/3] netlink: specs: use exact-len for IPv6 addr Hangbin Liu
2023-12-16  2:09   ` Jakub Kicinski
2023-12-16  8:48     ` Hangbin Liu
2023-12-18 22:24       ` Jakub Kicinski
2023-12-18 11:40   ` Davide Caratti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZX1hXMhJLwgg5S1v@Laptop-X1 \
    --to=liuhangbin@gmail.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox