Subject: Re: [PATCH net-next V3 01/15] tools: ynl-gen: allow noncontiguous enums

From: Jakub Kicinski <[email-masked]>
Date: Mon, 28 Apr 2025 16:06:11 -0700

On Fri, 25 Apr 2025 14:47:54 -0700 Saeed Mahameed wrote:
> In case the enum has holes, instead of hard stop, avoid the policy value
> checking and it to the code.

We guarantee that YNL generates full type validation for enum types.
IOW that the policy will reject values outside of the enum.
We need to preserve this guarantee.
Best we can do for sparse enums is probably to generate a function
callback that does the checking.
We could add something like a bitmap validation for small sparse values
(treat the mask in the policy as mask of allowed values).
But hard to justify the complexity with just a single case of the
problem. (actually classic netlink has a similar problem for AF_*
values, but there "->mask as a bitmap" validation don't do, since 
the elements of the enum go up to 256).