Skip to content

Commit de2d987

Browse files
donaldhkuba-moo
authored andcommitted
doc/netlink: Add sub-message support to netlink-raw
Add a 'sub-message' attribute type with a selector that supports polymorphic attribute formats for raw netlink families like tc. A sub-message attribute uses the value of another attribute as a selector key to choose the right sub-message format. For example if the following attribute has already been decoded: { "kind": "gre" } and we encounter the following attribute spec: - name: data type: sub-message sub-message: linkinfo-data-msg selector: kind Then we look for a sub-message definition called 'linkinfo-data-msg' and use the value of the 'kind' attribute i.e. 'gre' as the key to choose the correct format for the sub-message: sub-messages: name: linkinfo-data-msg formats: - value: bridge attribute-set: linkinfo-bridge-attrs - value: gre attribute-set: linkinfo-gre-attrs - value: geneve attribute-set: linkinfo-geneve-attrs This would decode the attribute value as a sub-message with the attribute-set called 'linkinfo-gre-attrs' as the attribute space. A sub-message can have an optional 'fixed-header' followed by zero or more attributes from an attribute-set. For example the following 'tc-options-msg' sub-message defines message formats that use a mixture of fixed-header, attribute-set or both together: sub-messages: - name: tc-options-msg formats: - value: bfifo fixed-header: tc-fifo-qopt - value: cake attribute-set: tc-cake-attrs - value: netem fixed-header: tc-netem-qopt attribute-set: tc-netem-attrs Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: Donald Hunter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 62691b8 commit de2d987

File tree

1 file changed

+62
-3
lines changed

1 file changed

+62
-3
lines changed

Documentation/netlink/netlink-raw.yaml

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,10 @@ properties:
126126
name:
127127
type: string
128128
type:
129-
description: The netlink attribute type
130-
enum: [ u8, u16, u32, u64, s8, s16, s32, s64, string, binary ]
129+
description: |
130+
The netlink attribute type. Members of type 'binary' or 'pad'
131+
must also have the 'len' property set.
132+
enum: [ u8, u16, u32, u64, s8, s16, s32, s64, string, binary, pad ]
131133
len:
132134
$ref: '#/$defs/len-or-define'
133135
byte-order:
@@ -150,6 +152,14 @@ properties:
150152
the right formatting mechanism when displaying values of this
151153
type.
152154
enum: [ hex, mac, fddi, ipv4, ipv6, uuid ]
155+
if:
156+
properties:
157+
type:
158+
oneOf:
159+
- const: binary
160+
- const: pad
161+
then:
162+
required: [ len ]
153163
# End genetlink-legacy
154164

155165
attribute-sets:
@@ -202,7 +212,8 @@ properties:
202212
description: The netlink attribute type
203213
enum: [ unused, pad, flag, binary, bitfield32,
204214
u8, u16, u32, u64, s8, s16, s32, s64,
205-
string, nest, array-nest, nest-type-value ]
215+
string, nest, array-nest, nest-type-value,
216+
sub-message ]
206217
doc:
207218
description: Documentation of the attribute.
208219
type: string
@@ -261,6 +272,17 @@ properties:
261272
description: Name of the struct type used for the attribute.
262273
type: string
263274
# End genetlink-legacy
275+
# Start netlink-raw
276+
sub-message:
277+
description: |
278+
Name of the sub-message definition to use for the attribute.
279+
type: string
280+
selector:
281+
description: |
282+
Name of the attribute to use for dynamic selection of sub-message
283+
format specifier.
284+
type: string
285+
# End netlink-raw
264286

265287
# Make sure name-prefix does not appear in subsets (subsets inherit naming)
266288
dependencies:
@@ -283,6 +305,43 @@ properties:
283305
items:
284306
required: [ type ]
285307

308+
# Start netlink-raw
309+
sub-messages:
310+
description: Definition of sub message attributes
311+
type: array
312+
items:
313+
type: object
314+
additionalProperties: False
315+
required: [ name, formats ]
316+
properties:
317+
name:
318+
description: Name of the sub-message definition
319+
type: string
320+
formats:
321+
description: Dynamically selected format specifiers
322+
type: array
323+
items:
324+
type: object
325+
additionalProperties: False
326+
required: [ value ]
327+
properties:
328+
value:
329+
description: |
330+
Value to match for dynamic selection of sub-message format
331+
specifier.
332+
type: string
333+
fixed-header:
334+
description: |
335+
Name of the struct definition to use as the fixed header
336+
for the sub message.
337+
type: string
338+
attribute-set:
339+
description: |
340+
Name of the attribute space from which to resolve attributes
341+
in the sub message.
342+
type: string
343+
# End netlink-raw
344+
286345
operations:
287346
description: Operations supported by the protocol.
288347
type: object

0 commit comments

Comments
 (0)