diff mbox series

[RFC,net-next,v1,2/6] doc/netlink: Add a nest selector to netlink-raw schema

Message ID 20231129101159.99197-3-donald.hunter@gmail.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series tools/net/ynl: Add dynamic selector for options attrs | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/codegen success Generated files up to date
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 50 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Donald Hunter Nov. 29, 2023, 10:11 a.m. UTC
Add a 'dynamic' attribute type with a selector that declares how to
choose the attribute-space for nested attributes. Use the value of
another attribute as the selector key. For example if the following
attribute has already been decoded:

  { "kind": "gre" }

then the following selector:

  selector:
    attribute: kind
    list:
      -
        value: bridge
        type: nest
        nested-attributes: linkinfo-bridge-attrs
      -
        value: gre
        type: nest
        nested-attributes: linkinfo-gre-attrs
      -
        value: geneve
        type: nest
        nested-attributes: linkinfo-geneve-attrs

would decode the value as nested attributes, using the
'linkinfo-gre-attrs' attribute space.

This approach was chosen so that different value types can be handled by
the same selector, allowing a mix of e.g. nest, struct and binary.

Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
---
 Documentation/netlink/netlink-raw.yaml | 38 +++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/Documentation/netlink/netlink-raw.yaml b/Documentation/netlink/netlink-raw.yaml
index ad5395040765..62061e180f8f 100644
--- a/Documentation/netlink/netlink-raw.yaml
+++ b/Documentation/netlink/netlink-raw.yaml
@@ -202,7 +202,7 @@  properties:
                 description: The netlink attribute type
                 enum: [ unused, pad, flag, binary, bitfield32,
                         u8, u16, u32, u64, s8, s16, s32, s64,
-                        string, nest, array-nest, nest-type-value ]
+                        string, nest, array-nest, nest-type-value, dynamic ]
               doc:
                 description: Documentation of the attribute.
                 type: string
@@ -261,6 +261,42 @@  properties:
                 description: Name of the struct type used for the attribute.
                 type: string
               # End genetlink-legacy
+              # Start netlink-raw
+              selector:
+                description:
+                  Map of attribute definitions for dynamic selection of type
+                  specific attribute spaces.
+                type: object
+                required: [ attribute, list ]
+                additionalProperties: false
+                properties:
+                  attribute:
+                    description:
+                      Name of the attribute that contains the type identifier
+                      string.
+                    type: string
+                  list:
+                    type: array
+                    items:
+                      type: object
+                      required: [ value, type ]
+                      additionalProperties: false
+                      properties:
+                        value:
+                          description: Type identifier string to match.
+                          type: string
+                        type:
+                          description: The netlink attribute type.
+                          enum: [ binary, nest ]
+                        nested-attributes:
+                          description:
+                            Name of the sub-space used inside the attribute.
+                          type: string
+                        struct:
+                          description:
+                            Name of the struct type used for the attribute.
+                          type: string
+              # End netlink-raw
 
       # Make sure name-prefix does not appear in subsets (subsets inherit naming)
       dependencies: