tools: ynl-gen: support struct for binary attributes
authorJakub Kicinski <kuba@kernel.org>
Fri, 9 May 2025 15:42:13 +0000 (08:42 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 13 May 2025 11:22:32 +0000 (13:22 +0200)
commit25e37418c87249369fe546f2cb6af578c16b68b9
tree9a4f9f12a27cede2744484a665d2d89afa3717eb
parent9ba8e351efd4d003a7fc22bc7455f0e95665cf44
tools: ynl-gen: support struct for binary attributes

Support using a struct pointer for binary attrs. Len field is maintained
because the structs may grow with newer kernel versions. Or, which matters
more, be shorter if the binary is built against newer uAPI than kernel
against which it's executed. Since we are storing a pointer to a struct
type - always allocate at least the amount of memory needed by the struct
per current uAPI headers (unused mem is zeroed). Technically users should
check the length field but per modern ASAN checks storing a short object
under a pointer seems like a bad idea.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://patch.msgid.link/20250509154213.1747885-4-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
tools/net/ynl/pyynl/ynl_gen_c.py