Subject: Re: [RFC net-next v1] tools: ynl: Add an strace rendering mode to ynl-gen

From: Jakub Kicinski <[email-masked]>
Date: Mon, 19 Jun 2023 12:00:25 -0700

On Mon, 19 Jun 2023 11:04:11 +0100 Donald Hunter wrote:
> I tried these suggestions out and they seem a bit problematic. For
> struct references I don't see a way to validate them, when it's not C
> codegen. Non C consumers will need to enumarete the struct references
> they 'understand'. The printk formats are meaningful in kernel, but not
> directly usable elsewhere, without writing a parser for them.
> 
> It seems desirable to have schema validation for the values and I tried
> using the %p printk formats as the enumeration. Using this format, the
> values need to be quoted everywhere. See diff below.
> 
> The printk formats also carry specific opinions about formatting details
> such as the case and separator to be used for output. This seems
> orthogonal to a type annotation about meaning.
> 
> Perhaps the middle ground is to derive a list of format specificer
> enumerations from the printk formats, but that's maybe not much
> different from defining our own?

Fair point. Our own names would be easier to understand -- OTOH I like
how the print formats almost forcefully drive the point that these are
supposed to be used exclusively for printing. 

If someone needs to interpret the data they should add a struct.

But I guess a big fat warning above the documentation and calling the
attribute "print-format" / "print-hint" could work as well? Up to you.

Hope this makes sense.

> I currently have "%pI4", "%pI6", "%pM", "%pMF", "%pU", "%ph", which
> could be represented as ipv4, ipv6, mac, fddi, uuid, hex. From the
> printk formats documentation, the only other one I can see is bluetooth.
> The other formats all look like they cover composite values.

> diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml
> index b474889b49ff..f3ecdeb7c38c 100644
> --- a/Documentation/netlink/genetlink-legacy.yaml
> +++ b/Documentation/netlink/genetlink-legacy.yaml

If we're only talking about printing we will want to extend the support
to new families as well.