From: Jakub Kicinski <kuba@kernel.org>
To: "Asbjørn Sloth Tønnesen" <ast@fiberby.net>
Cc: "David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Paolo Abeni" <pabeni@redhat.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"Arkadiusz Kubalewski" <arkadiusz.kubalewski@intel.com>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Daniel Zahka" <daniel.zahka@gmail.com>,
"Donald Hunter" <donald.hunter@gmail.com>,
"Jacob Keller" <jacob.e.keller@intel.com>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"Jiri Pirko" <jiri@resnulli.us>,
"Joe Damato" <jdamato@fastly.com>,
"John Fastabend" <john.fastabend@gmail.com>,
"Jonathan Corbet" <corbet@lwn.net>,
"Simon Horman" <horms@kernel.org>,
"Stanislav Fomichev" <sdf@fomichev.me>,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"Vadim Fedorenko" <vadim.fedorenko@linux.dev>,
"Willem de Bruijn" <willemb@google.com>,
bpf@vger.kernel.org, netdev@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
"Jason A. Donenfeld" <Jason@zx2c4.com>
Subject: Re: [PATCH net-next 3/6] tools: ynl-gen: use uapi mask definition in NLA_POLICY_MASK
Date: Tue, 14 Oct 2025 12:32:01 -0700 [thread overview]
Message-ID: <20251014123201.6ecfd146@kernel.org> (raw)
In-Reply-To: <bbbdd1a0-2835-44c4-8b9f-942d2309e067@fiberby.net>
On Tue, 14 Oct 2025 17:29:30 +0000 Asbjørn Sloth Tønnesen wrote:
> On 10/14/25 12:59 AM, Jakub Kicinski wrote:
> > On Mon, 13 Oct 2025 16:50:00 +0000 Asbjørn Sloth Tønnesen wrote:
> >> Currently when generating policies using NLA_POLICY_MASK(), then
> >> we emit a pre-computed decimal mask.
> >>
> >> When render-max is set, then we can re-use the mask definition,
> >> that has been generated in the uapi header.
> >
> > This will encourage people to render masks in uAPI which just pollutes
> > the uAPI files.
>
> It might, but is that a problem, given that most flag-sets are rather small?
Problem is a strong word. But if the choice is having a constant in
auto-generated code, or pointless, cargo-cult'ed mask values in the
uAPI headers - I choose the former.
> Example from include/uapi/linux/wireguard.h:
> > enum wgpeer_flag {
> > WGPEER_F_REMOVE_ME = 1U << 0,
> > WGPEER_F_REPLACE_ALLOWEDIPS = 1U << 1,
> > WGPEER_F_UPDATE_ONLY = 1U << 2,
> > __WGPEER_F_ALL = WGPEER_F_REMOVE_ME | WGPEER_F_REPLACE_ALLOWEDIPS |
> > WGPEER_F_UPDATE_ONLY
> > };
>
> I agree that a private "WGPEER_F_ALL" would be pollution, but "__WGPEER_F_ALL"
> is less likely to accidentally be used by user-space.
>
> I get why Jason likes having the __WGPEER_F_ALL in a place where it is easy
> to review that it has contains all flags, and why he don't like a policy like
> NLA_POLICY_MASK(.., 0x7).
>
> We could do the mask definition in the kernel code, like many handwritten
> netlink families does, but we still need to keep NETDEV_XDP_ACT_MASK in
> netdev.h or remove it's YNL-GEN header for some time.
It's a transitional problem. People coming from hand-crafted code feel
like they need a human-readable mask. 6mo later once they are
comfortable with YNL codegen they won't care. But, sadly, at that point
it is too late to delete stuff from the uAPI header.
next prev parent reply other threads:[~2025-10-14 19:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-13 16:49 [PATCH net-next 0/6] tools: ynl-gen: generate flags better Asbjørn Sloth Tønnesen
2025-10-13 16:49 ` [PATCH net-next 1/6] tools: ynl-gen: bitshift the flag values in the generated code Asbjørn Sloth Tønnesen
2025-10-13 23:07 ` Jacob Keller
2025-10-14 16:27 ` Asbjørn Sloth Tønnesen
2025-10-14 0:53 ` Jakub Kicinski
2025-10-14 16:49 ` Asbjørn Sloth Tønnesen
2025-10-14 19:24 ` Jakub Kicinski
2025-10-13 16:49 ` [PATCH net-next 2/6] tools: ynl-gen: refactor render-max enum generation Asbjørn Sloth Tønnesen
2025-10-14 0:58 ` Jakub Kicinski
2025-10-14 17:04 ` Asbjørn Sloth Tønnesen
2025-10-14 19:26 ` Jakub Kicinski
2025-10-13 16:50 ` [PATCH net-next 3/6] tools: ynl-gen: use uapi mask definition in NLA_POLICY_MASK Asbjørn Sloth Tønnesen
2025-10-14 0:59 ` Jakub Kicinski
2025-10-14 17:29 ` Asbjørn Sloth Tønnesen
2025-10-14 19:32 ` Jakub Kicinski [this message]
2025-10-13 16:50 ` [PATCH net-next 4/6] tools: ynl-gen: add generic p_wrap() helper Asbjørn Sloth Tønnesen
2025-10-13 16:50 ` [PATCH net-next 5/6] tools: ynl-gen: construct bitflag masks in generated headers Asbjørn Sloth Tønnesen
2025-10-13 16:50 ` [PATCH net-next 6/6] tools: ynl-gen: allow custom naming of render-max definitions Asbjørn Sloth Tønnesen
2025-10-13 23:10 ` [PATCH net-next 0/6] tools: ynl-gen: generate flags better Jacob Keller
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=20251014123201.6ecfd146@kernel.org \
--to=kuba@kernel.org \
--cc=Jason@zx2c4.com \
--cc=andrew+netdev@lunn.ch \
--cc=arkadiusz.kubalewski@intel.com \
--cc=ast@fiberby.net \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=daniel.zahka@gmail.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=jdamato@fastly.com \
--cc=jiri@resnulli.us \
--cc=john.fastabend@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=toke@redhat.com \
--cc=vadim.fedorenko@linux.dev \
--cc=willemb@google.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;
as well as URLs for NNTP newsgroup(s).