Re: [PATCH net-next 3/6] tools: ynl-gen: use uapi mask definition in NLA_POLICY_MASK

From: Asbjørn Sloth Tønnesen

Date: Tue Oct 14 2025 - 13:29:48 EST


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?

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.