Subject: Re: [PATCH net-next v4 6/7] docs: netlink: document struct support for genetlink-legacy

From: Donald Hunter <[email-masked]>
Date: Mon, 27 Mar 2023 09:12:50 +0100

Jakub Kicinski <[email-masked]> writes:

> On Fri, 24 Mar 2023 19:18:59 +0000 Donald Hunter wrote:
>>  Legacy families can define C structures both to be used as the contents
>> -of an attribute and as a fixed message header. The plan is to define
>> -the structs in ``definitions`` and link the appropriate attrs.
>> +of an attribute and as a fixed message header. Structs are defined
>> +in ``definitions`` and referenced in operations or attributes.
>
> We should call out that the structs in YAML are implicitly "packed"
> (in the C sense of the word), so struct { u8 a; u16 b; u8 c; } is 
> 4 bytes not 6 bytes.
>
> Any padding must be explicitly, C-like languages should infer the need
> for explicit packing from whether the members are naturally aligned.

I'll update the text to mention padding, with this example.

>> +.. code-block:: yaml
>> +
>> +  definitions:
>> +    -
>> +      name: message-header
>> +      type: struct
>> +      members:
>> +        -
>> +          name: a
>> +          type: u32
>> +        -
>> +          name: b
>> +          type: string
>
> Maybe not the most fortunate example :) cause I think that for
> string/binary we'll need an explicit length. Maybe not for
> last one if it's a flexible array... but that's rare in NL.

Ah, good point. I'll change the example to match the struct above.

> The rest LGTM, thanks!