Thread (1 message) 1 message, 1 author, 2023-03-27

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

From: Donald Hunter <donald.hunter@gmail.com>
Date: 2023-03-27 08:14:31
Also in: linux-doc

Jakub Kicinski [off-list ref] writes:
On Fri, 24 Mar 2023 19:18:59 +0000 Donald Hunter wrote:
quoted
 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.
quoted
+.. 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!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help