14e16b6a7SJakub Kicinski# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
2e616c07cSJakub Kicinski%YAML 1.2
3e616c07cSJakub Kicinski---
4e616c07cSJakub Kicinski$id: http://kernel.org/schemas/netlink/genetlink-legacy.yaml#
5e616c07cSJakub Kicinski$schema: https://json-schema.org/draft-07/schema
6e616c07cSJakub Kicinski
7e616c07cSJakub Kicinski# Common defines
8e616c07cSJakub Kicinski$defs:
9e616c07cSJakub Kicinski  uint:
10e616c07cSJakub Kicinski    type: integer
11e616c07cSJakub Kicinski    minimum: 0
12e616c07cSJakub Kicinski  len-or-define:
13e616c07cSJakub Kicinski    type: [ string, integer ]
14e616c07cSJakub Kicinski    pattern: ^[0-9A-Za-z_]+( - 1)?$
15e616c07cSJakub Kicinski    minimum: 0
16e616c07cSJakub Kicinski
17e616c07cSJakub Kicinski# Schema for specs
18e616c07cSJakub Kicinskititle: Protocol
19e616c07cSJakub Kicinskidescription: Specification of a genetlink protocol
20e616c07cSJakub Kicinskitype: object
21e616c07cSJakub Kicinskirequired: [ name, doc, attribute-sets, operations ]
22e616c07cSJakub KicinskiadditionalProperties: False
23e616c07cSJakub Kicinskiproperties:
24e616c07cSJakub Kicinski  name:
25e616c07cSJakub Kicinski    description: Name of the genetlink family.
26e616c07cSJakub Kicinski    type: string
27e616c07cSJakub Kicinski  doc:
28e616c07cSJakub Kicinski    type: string
29e616c07cSJakub Kicinski  version:
30e616c07cSJakub Kicinski    description: Generic Netlink family version. Default is 1.
31e616c07cSJakub Kicinski    type: integer
32e616c07cSJakub Kicinski    minimum: 1
33e616c07cSJakub Kicinski  protocol:
34e616c07cSJakub Kicinski    description: Schema compatibility level. Default is "genetlink".
35e616c07cSJakub Kicinski    enum: [ genetlink, genetlink-c, genetlink-legacy ] # Trim
36e616c07cSJakub Kicinski  uapi-header:
37e616c07cSJakub Kicinski    description: Path to the uAPI header, default is linux/${family-name}.h
38e616c07cSJakub Kicinski    type: string
3982b32970SJakub Kicinski  # Start genetlink-c
40e616c07cSJakub Kicinski  c-family-name:
41e616c07cSJakub Kicinski    description: Name of the define for the family name.
42e616c07cSJakub Kicinski    type: string
43e616c07cSJakub Kicinski  c-version-name:
44e616c07cSJakub Kicinski    description: Name of the define for the verion of the family.
45e616c07cSJakub Kicinski    type: string
46e616c07cSJakub Kicinski  max-by-define:
47e616c07cSJakub Kicinski    description: Makes the number of attributes and commands be specified by a define, not an enum value.
48e616c07cSJakub Kicinski    type: boolean
49e616c07cSJakub Kicinski  # End genetlink-c
50e616c07cSJakub Kicinski  # Start genetlink-legacy
51e616c07cSJakub Kicinski  kernel-policy:
52e616c07cSJakub Kicinski    description: |
53e616c07cSJakub Kicinski      Defines if the input policy in the kernel is global, per-operation, or split per operation type.
54e616c07cSJakub Kicinski      Default is split.
55e616c07cSJakub Kicinski    enum: [ split, per-op, global ]
56e616c07cSJakub Kicinski  # End genetlink-legacy
57e616c07cSJakub Kicinski
58e616c07cSJakub Kicinski  definitions:
59e616c07cSJakub Kicinski    description: List of type and constant definitions (enums, flags, defines).
60e616c07cSJakub Kicinski    type: array
61e616c07cSJakub Kicinski    items:
62e616c07cSJakub Kicinski      type: object
63e616c07cSJakub Kicinski      required: [ type, name ]
64e616c07cSJakub Kicinski      additionalProperties: False
65e616c07cSJakub Kicinski      properties:
66e616c07cSJakub Kicinski        name:
67e616c07cSJakub Kicinski          type: string
68e616c07cSJakub Kicinski        header:
69e616c07cSJakub Kicinski          description: For C-compatible languages, header which already defines this value.
70e616c07cSJakub Kicinski          type: string
71e616c07cSJakub Kicinski        type:
72e616c07cSJakub Kicinski          enum: [ const, enum, flags, struct ] # Trim
73e616c07cSJakub Kicinski        doc:
74e616c07cSJakub Kicinski          type: string
75e616c07cSJakub Kicinski        # For const
76e616c07cSJakub Kicinski        value:
77e616c07cSJakub Kicinski          description: For const - the value.
78e616c07cSJakub Kicinski          type: [ string, integer ]
79e616c07cSJakub Kicinski        # For enum and flags
80e616c07cSJakub Kicinski        value-start:
81e616c07cSJakub Kicinski          description: For enum or flags the literal initializer for the first value.
82e616c07cSJakub Kicinski          type: [ string, integer ]
83e616c07cSJakub Kicinski        entries:
84e616c07cSJakub Kicinski          description: For enum or flags array of values.
85e616c07cSJakub Kicinski          type: array
86e616c07cSJakub Kicinski          items:
87e616c07cSJakub Kicinski            oneOf:
88e616c07cSJakub Kicinski              - type: string
89e616c07cSJakub Kicinski              - type: object
90e616c07cSJakub Kicinski                required: [ name ]
91e616c07cSJakub Kicinski                additionalProperties: False
92e616c07cSJakub Kicinski                properties:
93e616c07cSJakub Kicinski                  name:
94e616c07cSJakub Kicinski                    type: string
95e616c07cSJakub Kicinski                  value:
96e616c07cSJakub Kicinski                    type: integer
97e616c07cSJakub Kicinski                  doc:
98e616c07cSJakub Kicinski                    type: string
99e616c07cSJakub Kicinski        render-max:
100e616c07cSJakub Kicinski          description: Render the max members for this enum.
101e616c07cSJakub Kicinski          type: boolean
102e616c07cSJakub Kicinski        # Start genetlink-c
103e616c07cSJakub Kicinski        enum-name:
104e616c07cSJakub Kicinski          description: Name for enum, if empty no name will be used.
105e616c07cSJakub Kicinski          type: [ string, "null" ]
106e616c07cSJakub Kicinski        name-prefix:
107e616c07cSJakub Kicinski          description: For enum the prefix of the values, optional.
108e616c07cSJakub Kicinski          type: string
109e616c07cSJakub Kicinski        # End genetlink-c
110e616c07cSJakub Kicinski        # Start genetlink-legacy
111e616c07cSJakub Kicinski        members:
112e616c07cSJakub Kicinski          description: List of struct members. Only scalars and strings members allowed.
113e616c07cSJakub Kicinski          type: array
114e616c07cSJakub Kicinski          items:
115e616c07cSJakub Kicinski            type: object
116e616c07cSJakub Kicinski            required: [ name, type ]
117e616c07cSJakub Kicinski            additionalProperties: False
118e616c07cSJakub Kicinski            properties:
119e616c07cSJakub Kicinski              name:
120e616c07cSJakub Kicinski                type: string
121e616c07cSJakub Kicinski              type:
122*737eab77SDonald Hunter                description: The netlink attribute type
123*737eab77SDonald Hunter                enum: [ u8, u16, u32, u64, s8, s16, s32, s64, string, binary ]
124e616c07cSJakub Kicinski              len:
125e616c07cSJakub Kicinski                $ref: '#/$defs/len-or-define'
126bddd2e56SDonald Hunter              byte-order:
127bddd2e56SDonald Hunter                enum: [ little-endian, big-endian ]
1286d6bae63SDonald Hunter              doc:
1296d6bae63SDonald Hunter                description: Documentation for the struct member attribute.
1306d6bae63SDonald Hunter                type: string
131313a7a80SDonald Hunter              enum:
132313a7a80SDonald Hunter                description: Name of the enum type used for the attribute.
133313a7a80SDonald Hunter                type: string
134*737eab77SDonald Hunter              display-hint: &display-hint
135*737eab77SDonald Hunter                description: |
136*737eab77SDonald Hunter                  Optional format indicator that is intended only for choosing
137*737eab77SDonald Hunter                  the right formatting mechanism when displaying values of this
138*737eab77SDonald Hunter                  type.
139*737eab77SDonald Hunter                enum: [ hex, mac, fddi, ipv4, ipv6, uuid ]
140e616c07cSJakub Kicinski        # End genetlink-legacy
141e616c07cSJakub Kicinski
142e616c07cSJakub Kicinski  attribute-sets:
143e616c07cSJakub Kicinski    description: Definition of attribute spaces for this family.
144e616c07cSJakub Kicinski    type: array
145e616c07cSJakub Kicinski    items:
146e616c07cSJakub Kicinski      description: Definition of a single attribute space.
147e616c07cSJakub Kicinski      type: object
148e616c07cSJakub Kicinski      required: [ name, attributes ]
149e616c07cSJakub Kicinski      additionalProperties: False
150e616c07cSJakub Kicinski      properties:
151e616c07cSJakub Kicinski        name:
152e616c07cSJakub Kicinski          description: |
153e616c07cSJakub Kicinski            Name used when referring to this space in other definitions, not used outside of the spec.
154e616c07cSJakub Kicinski          type: string
155e616c07cSJakub Kicinski        name-prefix:
156e616c07cSJakub Kicinski          description: |
157e616c07cSJakub Kicinski            Prefix for the C enum name of the attributes. Default family[name]-set[name]-a-
158e616c07cSJakub Kicinski          type: string
159e616c07cSJakub Kicinski        enum-name:
160e616c07cSJakub Kicinski          description: Name for the enum type of the attribute.
161e616c07cSJakub Kicinski          type: string
162e616c07cSJakub Kicinski        doc:
163e616c07cSJakub Kicinski          description: Documentation of the space.
164e616c07cSJakub Kicinski          type: string
165e616c07cSJakub Kicinski        subset-of:
166e616c07cSJakub Kicinski          description: |
167e616c07cSJakub Kicinski            Name of another space which this is a logical part of. Sub-spaces can be used to define
168e616c07cSJakub Kicinski            a limited group of attributes which are used in a nest.
169e616c07cSJakub Kicinski          type: string
170e616c07cSJakub Kicinski        # Start genetlink-c
171e616c07cSJakub Kicinski        attr-cnt-name:
172e616c07cSJakub Kicinski          description: The explicit name for constant holding the count of attributes (last attr + 1).
173e616c07cSJakub Kicinski          type: string
174e616c07cSJakub Kicinski        attr-max-name:
175e616c07cSJakub Kicinski          description: The explicit name for last member of attribute enum.
176e616c07cSJakub Kicinski          type: string
177e616c07cSJakub Kicinski        # End genetlink-c
178e616c07cSJakub Kicinski        attributes:
179e616c07cSJakub Kicinski          description: List of attributes in the space.
180e616c07cSJakub Kicinski          type: array
181e616c07cSJakub Kicinski          items:
182e616c07cSJakub Kicinski            type: object
183e616c07cSJakub Kicinski            required: [ name, type ]
184e616c07cSJakub Kicinski            additionalProperties: False
185e616c07cSJakub Kicinski            properties:
186e616c07cSJakub Kicinski              name:
187e616c07cSJakub Kicinski                type: string
188e616c07cSJakub Kicinski              type: &attr-type
189*737eab77SDonald Hunter                description: The netlink attribute type
190e616c07cSJakub Kicinski                enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
191e616c07cSJakub Kicinski                        string, nest, array-nest, nest-type-value ]
192e616c07cSJakub Kicinski              doc:
193e616c07cSJakub Kicinski                description: Documentation of the attribute.
194e616c07cSJakub Kicinski                type: string
195e616c07cSJakub Kicinski              value:
196e616c07cSJakub Kicinski                description: Value for the enum item representing this attribute in the uAPI.
197e616c07cSJakub Kicinski                $ref: '#/$defs/uint'
198e616c07cSJakub Kicinski              type-value:
199e616c07cSJakub Kicinski                description: Name of the value extracted from the type of a nest-type-value attribute.
200e616c07cSJakub Kicinski                type: array
201e616c07cSJakub Kicinski                items:
202e616c07cSJakub Kicinski                  type: string
203e616c07cSJakub Kicinski              byte-order:
204e616c07cSJakub Kicinski                enum: [ little-endian, big-endian ]
205e616c07cSJakub Kicinski              multi-attr:
206e616c07cSJakub Kicinski                type: boolean
207e616c07cSJakub Kicinski              nested-attributes:
208e616c07cSJakub Kicinski                description: Name of the space (sub-space) used inside the attribute.
209e616c07cSJakub Kicinski                type: string
210e616c07cSJakub Kicinski              enum:
211e616c07cSJakub Kicinski                description: Name of the enum type used for the attribute.
212e616c07cSJakub Kicinski                type: string
213e616c07cSJakub Kicinski              enum-as-flags:
214e616c07cSJakub Kicinski                description: |
215e616c07cSJakub Kicinski                  Treat the enum as flags. In most cases enum is either used as flags or as values.
216e616c07cSJakub Kicinski                  Sometimes, however, both forms are necessary, in which case header contains the enum
217e616c07cSJakub Kicinski                  form while specific attributes may request to convert the values into a bitfield.
218e616c07cSJakub Kicinski                type: boolean
219e616c07cSJakub Kicinski              checks:
220e616c07cSJakub Kicinski                description: Kernel input validation.
221e616c07cSJakub Kicinski                type: object
222e616c07cSJakub Kicinski                additionalProperties: False
223e616c07cSJakub Kicinski                properties:
224e616c07cSJakub Kicinski                  flags-mask:
225e616c07cSJakub Kicinski                    description: Name of the flags constant on which to base mask (unsigned scalar types only).
226e616c07cSJakub Kicinski                    type: string
227e616c07cSJakub Kicinski                  min:
228e616c07cSJakub Kicinski                    description: Min value for an integer attribute.
229e616c07cSJakub Kicinski                    type: integer
230e616c07cSJakub Kicinski                  min-len:
231e616c07cSJakub Kicinski                    description: Min length for a binary attribute.
232e616c07cSJakub Kicinski                    $ref: '#/$defs/len-or-define'
233e616c07cSJakub Kicinski                  max-len:
234e616c07cSJakub Kicinski                    description: Max length for a string or a binary attribute.
235e616c07cSJakub Kicinski                    $ref: '#/$defs/len-or-define'
236e616c07cSJakub Kicinski              sub-type: *attr-type
237*737eab77SDonald Hunter              display-hint: *display-hint
238ed2042ccSJakub Kicinski              # Start genetlink-c
239ed2042ccSJakub Kicinski              name-prefix:
240ed2042ccSJakub Kicinski                type: string
241ed2042ccSJakub Kicinski              # End genetlink-c
24226071913SDonald Hunter              # Start genetlink-legacy
24326071913SDonald Hunter              struct:
24426071913SDonald Hunter                description: Name of the struct type used for the attribute.
24526071913SDonald Hunter                type: string
24626071913SDonald Hunter              # End genetlink-legacy
247e616c07cSJakub Kicinski
248e616c07cSJakub Kicinski      # Make sure name-prefix does not appear in subsets (subsets inherit naming)
249e616c07cSJakub Kicinski      dependencies:
250e616c07cSJakub Kicinski        name-prefix:
251e616c07cSJakub Kicinski          not:
252e616c07cSJakub Kicinski            required: [ subset-of ]
253e616c07cSJakub Kicinski        subset-of:
254e616c07cSJakub Kicinski          not:
255e616c07cSJakub Kicinski            required: [ name-prefix ]
256e616c07cSJakub Kicinski
257e616c07cSJakub Kicinski  operations:
258e616c07cSJakub Kicinski    description: Operations supported by the protocol.
259e616c07cSJakub Kicinski    type: object
260e616c07cSJakub Kicinski    required: [ list ]
261e616c07cSJakub Kicinski    additionalProperties: False
262e616c07cSJakub Kicinski    properties:
263e616c07cSJakub Kicinski      enum-model:
264e616c07cSJakub Kicinski        description: |
265e616c07cSJakub Kicinski          The model of assigning values to the operations.
266e616c07cSJakub Kicinski          "unified" is the recommended model where all message types belong
267e616c07cSJakub Kicinski          to a single enum.
268e616c07cSJakub Kicinski          "directional" has the messages sent to the kernel and from the kernel
269e616c07cSJakub Kicinski          enumerated separately.
2708403bf04SJakub Kicinski        enum: [ unified, directional ] # Trim
271e616c07cSJakub Kicinski      name-prefix:
272e616c07cSJakub Kicinski        description: |
273e616c07cSJakub Kicinski          Prefix for the C enum name of the command. The name is formed by concatenating
274e616c07cSJakub Kicinski          the prefix with the upper case name of the command, with dashes replaced by underscores.
275e616c07cSJakub Kicinski        type: string
276e616c07cSJakub Kicinski      enum-name:
277e616c07cSJakub Kicinski        description: Name for the enum type with commands.
278e616c07cSJakub Kicinski        type: string
279e616c07cSJakub Kicinski      async-prefix:
280e616c07cSJakub Kicinski        description: Same as name-prefix but used to render notifications and events to separate enum.
281e616c07cSJakub Kicinski        type: string
282e616c07cSJakub Kicinski      async-enum:
283e616c07cSJakub Kicinski        description: Name for the enum type with notifications/events.
284e616c07cSJakub Kicinski        type: string
285f036d936SDonald Hunter      # Start genetlink-legacy
286f036d936SDonald Hunter      fixed-header: &fixed-header
287f036d936SDonald Hunter        description: |
288f036d936SDonald Hunter          Name of the structure defining the optional fixed-length protocol
289f036d936SDonald Hunter          header. This header is placed in a message after the netlink and
290f036d936SDonald Hunter          genetlink headers and before any attributes.
291f036d936SDonald Hunter        type: string
292f036d936SDonald Hunter      # End genetlink-legacy
293e616c07cSJakub Kicinski      list:
294e616c07cSJakub Kicinski        description: List of commands
295e616c07cSJakub Kicinski        type: array
296e616c07cSJakub Kicinski        items:
297e616c07cSJakub Kicinski          type: object
298e616c07cSJakub Kicinski          additionalProperties: False
299e616c07cSJakub Kicinski          required: [ name, doc ]
300e616c07cSJakub Kicinski          properties:
301e616c07cSJakub Kicinski            name:
302e616c07cSJakub Kicinski              description: Name of the operation, also defining its C enum value in uAPI.
303e616c07cSJakub Kicinski              type: string
304e616c07cSJakub Kicinski            doc:
305e616c07cSJakub Kicinski              description: Documentation for the command.
306e616c07cSJakub Kicinski              type: string
307e616c07cSJakub Kicinski            value:
308e616c07cSJakub Kicinski              description: Value for the enum in the uAPI.
309e616c07cSJakub Kicinski              $ref: '#/$defs/uint'
310e616c07cSJakub Kicinski            attribute-set:
311e616c07cSJakub Kicinski              description: |
312e616c07cSJakub Kicinski                Attribute space from which attributes directly in the requests and replies
313e616c07cSJakub Kicinski                to this command are defined.
314e616c07cSJakub Kicinski              type: string
315e616c07cSJakub Kicinski            flags: &cmd_flags
316e616c07cSJakub Kicinski              description: Command flags.
317e616c07cSJakub Kicinski              type: array
318e616c07cSJakub Kicinski              items:
319e616c07cSJakub Kicinski                enum: [ admin-perm ]
320e616c07cSJakub Kicinski            dont-validate:
321e616c07cSJakub Kicinski              description: Kernel attribute validation flags.
322e616c07cSJakub Kicinski              type: array
323e616c07cSJakub Kicinski              items:
324e616c07cSJakub Kicinski                enum: [ strict, dump ]
325f036d936SDonald Hunter            # Start genetlink-legacy
326f036d936SDonald Hunter            fixed-header: *fixed-header
327f036d936SDonald Hunter            # End genetlink-legacy
328e616c07cSJakub Kicinski            do: &subop-type
329e616c07cSJakub Kicinski              description: Main command handler.
330e616c07cSJakub Kicinski              type: object
331e616c07cSJakub Kicinski              additionalProperties: False
332e616c07cSJakub Kicinski              properties:
333e616c07cSJakub Kicinski                request: &subop-attr-list
334e616c07cSJakub Kicinski                  description: Definition of the request message for a given command.
335e616c07cSJakub Kicinski                  type: object
336e616c07cSJakub Kicinski                  additionalProperties: False
337e616c07cSJakub Kicinski                  properties:
338e616c07cSJakub Kicinski                    attributes:
339e616c07cSJakub Kicinski                      description: |
340e616c07cSJakub Kicinski                        Names of attributes from the attribute-set (not full attribute
341e616c07cSJakub Kicinski                        definitions, just names).
342e616c07cSJakub Kicinski                      type: array
343e616c07cSJakub Kicinski                      items:
344e616c07cSJakub Kicinski                        type: string
3458403bf04SJakub Kicinski                    # Start genetlink-legacy
3468403bf04SJakub Kicinski                    value:
3478403bf04SJakub Kicinski                      description: |
3488403bf04SJakub Kicinski                        ID of this message if value for request and response differ,
3498403bf04SJakub Kicinski                        i.e. requests and responses have different message enums.
3508403bf04SJakub Kicinski                      $ref: '#/$defs/uint'
3518403bf04SJakub Kicinski                    # End genetlink-legacy
352e616c07cSJakub Kicinski                reply: *subop-attr-list
353e616c07cSJakub Kicinski                pre:
354e616c07cSJakub Kicinski                  description: Hook for a function to run before the main callback (pre_doit or start).
355e616c07cSJakub Kicinski                  type: string
356e616c07cSJakub Kicinski                post:
357e616c07cSJakub Kicinski                  description: Hook for a function to run after the main callback (post_doit or done).
358e616c07cSJakub Kicinski                  type: string
359e616c07cSJakub Kicinski            dump: *subop-type
360e616c07cSJakub Kicinski            notify:
361e616c07cSJakub Kicinski              description: Name of the command sharing the reply type with this notification.
362e616c07cSJakub Kicinski              type: string
363e616c07cSJakub Kicinski            event:
364e616c07cSJakub Kicinski              type: object
365e616c07cSJakub Kicinski              additionalProperties: False
366e616c07cSJakub Kicinski              properties:
367e616c07cSJakub Kicinski                attributes:
368e616c07cSJakub Kicinski                  description: Explicit list of the attributes for the notification.
369e616c07cSJakub Kicinski                  type: array
370e616c07cSJakub Kicinski                  items:
371e616c07cSJakub Kicinski                    type: string
372e616c07cSJakub Kicinski            mcgrp:
373e616c07cSJakub Kicinski              description: Name of the multicast group generating given notification.
374e616c07cSJakub Kicinski              type: string
375e616c07cSJakub Kicinski  mcast-groups:
376e616c07cSJakub Kicinski    description: List of multicast groups.
377e616c07cSJakub Kicinski    type: object
378e616c07cSJakub Kicinski    required: [ list ]
379e616c07cSJakub Kicinski    additionalProperties: False
380e616c07cSJakub Kicinski    properties:
381e616c07cSJakub Kicinski      list:
382e616c07cSJakub Kicinski        description: List of groups.
383e616c07cSJakub Kicinski        type: array
384e616c07cSJakub Kicinski        items:
385e616c07cSJakub Kicinski          type: object
386e616c07cSJakub Kicinski          required: [ name ]
387e616c07cSJakub Kicinski          additionalProperties: False
388e616c07cSJakub Kicinski          properties:
389e616c07cSJakub Kicinski            name:
390e616c07cSJakub Kicinski              description: |
391e616c07cSJakub Kicinski                The name for the group, used to form the define and the value of the define.
392e616c07cSJakub Kicinski              type: string
393e616c07cSJakub Kicinski            # Start genetlink-c
394e616c07cSJakub Kicinski            c-define-name:
395e616c07cSJakub Kicinski              description: Override for the name of the define in C uAPI.
396e616c07cSJakub Kicinski              type: string
397e616c07cSJakub Kicinski            # End genetlink-c
398e616c07cSJakub Kicinski            flags: *cmd_flags
399