From: Donald Hunter <donald.hunter@gmail.com>
To: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Jonathan Corbet <corbet@lwn.net>,
linux-doc@vger.kernel.org,
Jacob Keller <jacob.e.keller@intel.com>,
Breno Leitao <leitao@debian.org>
Cc: donald.hunter@redhat.com, Donald Hunter <donald.hunter@gmail.com>
Subject: [PATCH net-next v5 02/13] doc/netlink: Add sub-message support to netlink-raw
Date: Fri, 15 Dec 2023 09:37:09 +0000 [thread overview]
Message-ID: <20231215093720.18774-3-donald.hunter@gmail.com> (raw)
In-Reply-To: <20231215093720.18774-1-donald.hunter@gmail.com>
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 <kuba@kernel.org>
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
---
Documentation/netlink/netlink-raw.yaml | 65 ++++++++++++++++++++++++--
1 file changed, 62 insertions(+), 3 deletions(-)
diff --git a/Documentation/netlink/netlink-raw.yaml b/Documentation/netlink/netlink-raw.yaml
index ad5395040765..04b92f1a5cd6 100644
--- a/Documentation/netlink/netlink-raw.yaml
+++ b/Documentation/netlink/netlink-raw.yaml
@@ -126,8 +126,10 @@ properties:
name:
type: string
type:
- description: The netlink attribute type
- enum: [ u8, u16, u32, u64, s8, s16, s32, s64, string, binary ]
+ description: |
+ The netlink attribute type. Members of type 'binary' or 'pad'
+ must also have the 'len' property set.
+ enum: [ u8, u16, u32, u64, s8, s16, s32, s64, string, binary, pad ]
len:
$ref: '#/$defs/len-or-define'
byte-order:
@@ -150,6 +152,14 @@ properties:
the right formatting mechanism when displaying values of this
type.
enum: [ hex, mac, fddi, ipv4, ipv6, uuid ]
+ if:
+ properties:
+ type:
+ oneOf:
+ - const: binary
+ - const: pad
+ then:
+ required: [ len ]
# End genetlink-legacy
attribute-sets:
@@ -202,7 +212,8 @@ 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,
+ sub-message ]
doc:
description: Documentation of the attribute.
type: string
@@ -261,6 +272,17 @@ properties:
description: Name of the struct type used for the attribute.
type: string
# End genetlink-legacy
+ # Start netlink-raw
+ sub-message:
+ description: |
+ Name of the sub-message definition to use for the attribute.
+ type: string
+ selector:
+ description: |
+ Name of the attribute to use for dynamic selection of sub-message
+ format specifier.
+ type: string
+ # End netlink-raw
# Make sure name-prefix does not appear in subsets (subsets inherit naming)
dependencies:
@@ -283,6 +305,43 @@ properties:
items:
required: [ type ]
+ # Start netlink-raw
+ sub-messages:
+ description: Definition of sub message attributes
+ type: array
+ items:
+ type: object
+ additionalProperties: False
+ required: [ name, formats ]
+ properties:
+ name:
+ description: Name of the sub-message definition
+ type: string
+ formats:
+ description: Dynamically selected format specifiers
+ type: array
+ items:
+ type: object
+ additionalProperties: False
+ required: [ value ]
+ properties:
+ value:
+ description: |
+ Value to match for dynamic selection of sub-message format
+ specifier.
+ type: string
+ fixed-header:
+ description: |
+ Name of the struct definition to use as the fixed header
+ for the sub message.
+ type: string
+ attribute-set:
+ description: |
+ Name of the attribute space from which to resolve attributes
+ in the sub message.
+ type: string
+ # End netlink-raw
+
operations:
description: Operations supported by the protocol.
type: object
--
2.42.0
next prev parent reply other threads:[~2023-12-15 9:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 9:37 [PATCH net-next v5 00/13] tools/net/ynl: Add 'sub-message' support to ynl Donald Hunter
2023-12-15 9:37 ` [PATCH net-next v5 01/13] tools/net/ynl: Use consistent array index expression formatting Donald Hunter
2023-12-15 9:37 ` Donald Hunter [this message]
2023-12-15 9:37 ` [PATCH net-next v5 03/13] doc/netlink: Document the sub-message format for netlink-raw Donald Hunter
2023-12-15 9:37 ` [PATCH net-next v5 04/13] tools/net/ynl: Add 'sub-message' attribute decoding to ynl Donald Hunter
2023-12-15 9:37 ` [PATCH net-next v5 05/13] tools/net/ynl: Add binary and pad support to structs for tc Donald Hunter
2023-12-15 9:37 ` [PATCH net-next v5 06/13] doc/netlink/specs: Add sub-message type to rt_link family Donald Hunter
2024-02-13 12:48 ` Jiri Pirko
2023-12-15 9:37 ` [PATCH net-next v5 07/13] doc/netlink/specs: use pad in structs in rt_link Donald Hunter
2023-12-15 9:37 ` [PATCH net-next v5 08/13] doc/netlink/specs: Add a spec for tc Donald Hunter
2023-12-15 9:37 ` [PATCH net-next v5 09/13] doc/netlink: Regenerate netlink .rst files if ynl-gen-rst changes Donald Hunter
2023-12-15 9:37 ` [PATCH net-next v5 10/13] tools/net/ynl-gen-rst: Add sub-messages to generated docs Donald Hunter
2023-12-15 9:37 ` [PATCH net-next v5 11/13] tools/net/ynl-gen-rst: Sort the index of generated netlink specs Donald Hunter
2023-12-15 9:37 ` [PATCH net-next v5 12/13] tools/net/ynl-gen-rst: Remove bold from attribute-set headings Donald Hunter
2023-12-15 9:37 ` [PATCH net-next v5 13/13] tools/net/ynl-gen-rst: Remove extra indentation from generated docs Donald Hunter
2023-12-18 23:10 ` [PATCH net-next v5 00/13] tools/net/ynl: Add 'sub-message' support to ynl patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231215093720.18774-3-donald.hunter@gmail.com \
--to=donald.hunter@gmail.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=donald.hunter@redhat.com \
--cc=edumazet@google.com \
--cc=jacob.e.keller@intel.com \
--cc=kuba@kernel.org \
--cc=leitao@debian.org \
--cc=linux-doc@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).