From patchwork Thu Aug 24 11:19:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13363995 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CB19DF46 for ; Thu, 24 Aug 2023 11:20:18 +0000 (UTC) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 582EC10FA; Thu, 24 Aug 2023 04:20:17 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-31aeedbb264so4494648f8f.0; Thu, 24 Aug 2023 04:20:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692876015; x=1693480815; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=guMXOiwH+7PQQTpnwzBFMxTJ+ih2dVZbmeyJv2NUgGc=; b=OS3YYLz9l6NBxtiAGDWVdQnHrrZPaImf2cF1cF+GuasSnBd2geakFM8oIxIErcuAij y4Ef0P6fNLjsl856KrLN1YSTbeU1b8PyXbwiXYmlDbDJDTUeMJwwTB/A9tXZqf6p4PDw TzTte0IcAjUcUvDTei+ALMWaH/PxQadRJYPHVUP00nDnjFQem1xgSl9+Ec1XuxQDstjn whDgc6xSZtqnsPlZHLYysSV2LJ/bSXBfsGKHsLykE00dRts66/5bLxJ7I0UtQqvl9guC 96KFrp/xML35Kr5sJl7AzxugvvBCyB0bHgBdzJkNuzQVz/kA31hLdFTueuNASOgxS/jd /dZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692876015; x=1693480815; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=guMXOiwH+7PQQTpnwzBFMxTJ+ih2dVZbmeyJv2NUgGc=; b=KR7mXh2C6Omcwzzb8/BLeEHk3o7VWDvyuQJysxf1ym/AuHNpxQB3sdtjUuTgBDSDxG xuYol+hzmkHhtD4v2GlIovCeGStw12I7i+JLW1OSM0bJ80r3PUwK8RCswDALmIV3IpB/ f/bZV9vHpP1JtamhnI3V6154QzwtgmdVNEkcgNZNIK41Xi/DhPRfs7xqtNbAnV82o9Ua N+g1EZSKrTE/VPWMz60URqIw5unj4cs9hHqAo/MLwPpq6fqXuZaLJ7BE5wsRzaCkZp27 Q3J/TR4vKUsbUsJ0M9gK+R8WGFUr3fTULG9TO4soo4eSp2taP5HcUTJ7uaHf9r/P2/zD xEig== X-Gm-Message-State: AOJu0YxfSr4Nt1s2cIWqCsHS4IqoTbE7oDbZr0JL4LNU3Tw+a8/TshMv CM+cgzI5oD4fIvwNpy/WumgZd9cQAvzdHQ== X-Google-Smtp-Source: AGHT+IFJ/Ft4r+NCLXk6RxHfgkxBlr1aYmpuHuN0w2hcOdOC0nr4JlP6LgmyAZbUQ8bJIfR83C2eYA== X-Received: by 2002:a5d:4a12:0:b0:318:7bc:122e with SMTP id m18-20020a5d4a12000000b0031807bc122emr11658199wrq.23.1692876015175; Thu, 24 Aug 2023 04:20:15 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:1a5:1436:c34c:226]) by smtp.gmail.com with ESMTPSA id i14-20020a5d630e000000b0031980783d78sm21875295wru.54.2023.08.24.04.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 04:20:14 -0700 (PDT) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , linux-doc@vger.kernel.org, Stanislav Fomichev , Arkadiusz Kubalewski Cc: donald.hunter@redhat.com, Donald Hunter , Jacob Keller Subject: [PATCH net-next v5 01/12] doc/netlink: Fix typo in genetlink-* schemas Date: Thu, 24 Aug 2023 12:19:52 +0100 Message-ID: <20230824112003.52939-2-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824112003.52939-1-donald.hunter@gmail.com> References: <20230824112003.52939-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Fix typo verion -> version in genetlink-c and genetlink-legacy. Signed-off-by: Donald Hunter Reviewed-by: Jacob Keller --- Documentation/netlink/genetlink-c.yaml | 2 +- Documentation/netlink/genetlink-legacy.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/netlink/genetlink-c.yaml b/Documentation/netlink/genetlink-c.yaml index 4c1f8c22627b..9806c44f604c 100644 --- a/Documentation/netlink/genetlink-c.yaml +++ b/Documentation/netlink/genetlink-c.yaml @@ -41,7 +41,7 @@ properties: description: Name of the define for the family name. type: string c-version-name: - description: Name of the define for the verion of the family. + description: Name of the define for the version of the family. type: string max-by-define: description: Makes the number of attributes and commands be specified by a define, not an enum value. diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml index 196076dfa309..12a0a045605d 100644 --- a/Documentation/netlink/genetlink-legacy.yaml +++ b/Documentation/netlink/genetlink-legacy.yaml @@ -41,7 +41,7 @@ properties: description: Name of the define for the family name. type: string c-version-name: - description: Name of the define for the verion of the family. + description: Name of the define for the version of the family. type: string max-by-define: description: Makes the number of attributes and commands be specified by a define, not an enum value. From patchwork Thu Aug 24 11:19:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13363996 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0574DF46 for ; Thu, 24 Aug 2023 11:20:21 +0000 (UTC) Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6156110F3; Thu, 24 Aug 2023 04:20:19 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-2b9b50be31aso101336731fa.3; Thu, 24 Aug 2023 04:20:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692876017; x=1693480817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FjFlGgYJ/VcknJ4bSD+VlvLuImhlEceVylX6Iw9THjg=; b=BcJKEZxHEuoyqAlluItBaspKbtf/bSHt1q5xDQVvKnEI3/JPIjIjVN+FY1T4plvNj3 Jx+AquFYeDKt3PMkHAJYmvbyUMFqsOV81JlunzcY1eH8OXlOPWXDPGQvDvIIaE2Jh28y l9l3jECbDbXGrUCRh+puyFwGqjeIocJiiEftQTUqgamGoib7z8KJoMmlEyLErWmwq9Hx Fivt1dXx0PRqqnMEEz7cXmwDDVcHrUkvDxYH0qBLQsfTrkWqbpTbEPx+aOV1dPYwuwN8 waawkUWPZDsuV0JxMRvnumzqG73tDCQ1oYWZ6xxv+QdJWqwsmH95xbK5tvXJarBU8OY4 QbaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692876017; x=1693480817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FjFlGgYJ/VcknJ4bSD+VlvLuImhlEceVylX6Iw9THjg=; b=eQxxZRudPJtY6/SR4jDY46qQg8zjMitc4cSsShFYKrgNiv7qlvKK8uH1mPJsmwdwoK 4dCeHgTqU3AOYFo4ZOnYMuG9wnp0k9yj9enqh55mpuEp0OYKoF2DyMWpvZLF1Gh6WEul SLBRWwQP00aA53iMLqZSdimxhCa3LahZZ7RQpvOBCJhiXHNT/y3H8gOVLgwWBYeClqek f2b9+wAMwoEPevP29VYpjVk8OEaaBN1TvYET4tr6LM6vstHY8up9wKc0+Tj7oHfJjWy3 CUoTDZJ7iSbOsFSNDMynP9bamjy2Fcymw5GnjFStkE2XHmuOhZgASBkKAnGIIh8N+qV0 NDKg== X-Gm-Message-State: AOJu0YxYaKd4OW+QIDByS/ZjELbydDTo0ACiZstL2V2yvxPq7RQp/JS/ 1h87TFNCjboPmp1e21zpydGyEeQ7AjJrUA== X-Google-Smtp-Source: AGHT+IHDXcTupMSrwHNAoB7kc+1UaLJPbzmoOCeGlW/obiu8wtvmSFiFAupE/+79+34I0J4k5ob9wQ== X-Received: by 2002:a2e:888f:0:b0:2b9:cd79:8f94 with SMTP id k15-20020a2e888f000000b002b9cd798f94mr11900878lji.39.1692876016440; Thu, 24 Aug 2023 04:20:16 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:1a5:1436:c34c:226]) by smtp.gmail.com with ESMTPSA id i14-20020a5d630e000000b0031980783d78sm21875295wru.54.2023.08.24.04.20.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 04:20:15 -0700 (PDT) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , linux-doc@vger.kernel.org, Stanislav Fomichev , Arkadiusz Kubalewski Cc: donald.hunter@redhat.com, Donald Hunter , Jacob Keller Subject: [PATCH net-next v5 02/12] doc/netlink: Add a schema for netlink-raw families Date: Thu, 24 Aug 2023 12:19:53 +0100 Message-ID: <20230824112003.52939-3-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824112003.52939-1-donald.hunter@gmail.com> References: <20230824112003.52939-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org This schema is largely a copy of the genetlink-legacy schema with the following modifications: - change the schema id to netlink-raw - add a top-level protonum property, e.g. 0 (for NETLINK_ROUTE) - change the protocol enumeration to netlink-raw, removing the genetlink options. - replace doc references to generic netlink with raw netlink - add a value property to mcast-group definitions Signed-off-by: Donald Hunter Reviewed-by: Jacob Keller --- Documentation/netlink/netlink-raw.yaml | 410 +++++++++++++++++++++++++ 1 file changed, 410 insertions(+) create mode 100644 Documentation/netlink/netlink-raw.yaml diff --git a/Documentation/netlink/netlink-raw.yaml b/Documentation/netlink/netlink-raw.yaml new file mode 100644 index 000000000000..896797876414 --- /dev/null +++ b/Documentation/netlink/netlink-raw.yaml @@ -0,0 +1,410 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +%YAML 1.2 +--- +$id: http://kernel.org/schemas/netlink/netlink-raw.yaml# +$schema: https://json-schema.org/draft-07/schema + +# Common defines +$defs: + uint: + type: integer + minimum: 0 + len-or-define: + type: [ string, integer ] + pattern: ^[0-9A-Za-z_]+( - 1)?$ + minimum: 0 + +# Schema for specs +title: Protocol +description: Specification of a raw netlink protocol +type: object +required: [ name, doc, attribute-sets, operations ] +additionalProperties: False +properties: + name: + description: Name of the netlink family. + type: string + doc: + type: string + protocol: + description: Schema compatibility level. + enum: [ netlink-raw ] # Trim + # Start netlink-raw + protonum: + description: Protocol number to use for netlink-raw + type: integer + # End netlink-raw + uapi-header: + description: Path to the uAPI header, default is linux/${family-name}.h + type: string + # Start genetlink-c + c-family-name: + description: Name of the define for the family name. + type: string + c-version-name: + description: Name of the define for the version of the family. + type: string + max-by-define: + description: Makes the number of attributes and commands be specified by a define, not an enum value. + type: boolean + # End genetlink-c + # Start genetlink-legacy + kernel-policy: + description: | + Defines if the input policy in the kernel is global, per-operation, or split per operation type. + Default is split. + enum: [ split, per-op, global ] + # End genetlink-legacy + + definitions: + description: List of type and constant definitions (enums, flags, defines). + type: array + items: + type: object + required: [ type, name ] + additionalProperties: False + properties: + name: + type: string + header: + description: For C-compatible languages, header which already defines this value. + type: string + type: + enum: [ const, enum, flags, struct ] # Trim + doc: + type: string + # For const + value: + description: For const - the value. + type: [ string, integer ] + # For enum and flags + value-start: + description: For enum or flags the literal initializer for the first value. + type: [ string, integer ] + entries: + description: For enum or flags array of values. + type: array + items: + oneOf: + - type: string + - type: object + required: [ name ] + additionalProperties: False + properties: + name: + type: string + value: + type: integer + doc: + type: string + render-max: + description: Render the max members for this enum. + type: boolean + # Start genetlink-c + enum-name: + description: Name for enum, if empty no name will be used. + type: [ string, "null" ] + name-prefix: + description: For enum the prefix of the values, optional. + type: string + # End genetlink-c + # Start genetlink-legacy + members: + description: List of struct members. Only scalars and strings members allowed. + type: array + items: + type: object + required: [ name, type ] + additionalProperties: False + properties: + name: + type: string + type: + description: The netlink attribute type + enum: [ u8, u16, u32, u64, s8, s16, s32, s64, string, binary ] + len: + $ref: '#/$defs/len-or-define' + byte-order: + enum: [ little-endian, big-endian ] + doc: + description: Documentation for the struct member attribute. + type: string + enum: + description: Name of the enum type used for the attribute. + type: string + enum-as-flags: + description: | + Treat the enum as flags. In most cases enum is either used as flags or as values. + Sometimes, however, both forms are necessary, in which case header contains the enum + form while specific attributes may request to convert the values into a bitfield. + type: boolean + display-hint: &display-hint + description: | + Optional format indicator that is intended only for choosing + the right formatting mechanism when displaying values of this + type. + enum: [ hex, mac, fddi, ipv4, ipv6, uuid ] + # End genetlink-legacy + + attribute-sets: + description: Definition of attribute spaces for this family. + type: array + items: + description: Definition of a single attribute space. + type: object + required: [ name, attributes ] + additionalProperties: False + properties: + name: + description: | + Name used when referring to this space in other definitions, not used outside of the spec. + type: string + name-prefix: + description: | + Prefix for the C enum name of the attributes. Default family[name]-set[name]-a- + type: string + enum-name: + description: Name for the enum type of the attribute. + type: string + doc: + description: Documentation of the space. + type: string + subset-of: + description: | + Name of another space which this is a logical part of. Sub-spaces can be used to define + a limited group of attributes which are used in a nest. + type: string + # Start genetlink-c + attr-cnt-name: + description: The explicit name for constant holding the count of attributes (last attr + 1). + type: string + attr-max-name: + description: The explicit name for last member of attribute enum. + type: string + # End genetlink-c + attributes: + description: List of attributes in the space. + type: array + items: + type: object + required: [ name, type ] + additionalProperties: False + properties: + name: + type: string + type: &attr-type + description: The netlink attribute type + enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64, + string, nest, array-nest, nest-type-value ] + doc: + description: Documentation of the attribute. + type: string + value: + description: Value for the enum item representing this attribute in the uAPI. + $ref: '#/$defs/uint' + type-value: + description: Name of the value extracted from the type of a nest-type-value attribute. + type: array + items: + type: string + byte-order: + enum: [ little-endian, big-endian ] + multi-attr: + type: boolean + nested-attributes: + description: Name of the space (sub-space) used inside the attribute. + type: string + enum: + description: Name of the enum type used for the attribute. + type: string + enum-as-flags: + description: | + Treat the enum as flags. In most cases enum is either used as flags or as values. + Sometimes, however, both forms are necessary, in which case header contains the enum + form while specific attributes may request to convert the values into a bitfield. + type: boolean + checks: + description: Kernel input validation. + type: object + additionalProperties: False + properties: + flags-mask: + description: Name of the flags constant on which to base mask (unsigned scalar types only). + type: string + min: + description: Min value for an integer attribute. + type: integer + min-len: + description: Min length for a binary attribute. + $ref: '#/$defs/len-or-define' + max-len: + description: Max length for a string or a binary attribute. + $ref: '#/$defs/len-or-define' + sub-type: *attr-type + display-hint: *display-hint + # Start genetlink-c + name-prefix: + type: string + # End genetlink-c + # Start genetlink-legacy + struct: + description: Name of the struct type used for the attribute. + type: string + # End genetlink-legacy + + # Make sure name-prefix does not appear in subsets (subsets inherit naming) + dependencies: + name-prefix: + not: + required: [ subset-of ] + subset-of: + not: + required: [ name-prefix ] + + operations: + description: Operations supported by the protocol. + type: object + required: [ list ] + additionalProperties: False + properties: + enum-model: + description: | + The model of assigning values to the operations. + "unified" is the recommended model where all message types belong + to a single enum. + "directional" has the messages sent to the kernel and from the kernel + enumerated separately. + enum: [ unified, directional ] # Trim + name-prefix: + description: | + Prefix for the C enum name of the command. The name is formed by concatenating + the prefix with the upper case name of the command, with dashes replaced by underscores. + type: string + enum-name: + description: Name for the enum type with commands. + type: string + async-prefix: + description: Same as name-prefix but used to render notifications and events to separate enum. + type: string + async-enum: + description: Name for the enum type with notifications/events. + type: string + # Start genetlink-legacy + fixed-header: &fixed-header + description: | + Name of the structure defining the optional fixed-length protocol + header. This header is placed in a message after the netlink and + genetlink headers and before any attributes. + type: string + # End genetlink-legacy + list: + description: List of commands + type: array + items: + type: object + additionalProperties: False + required: [ name, doc ] + properties: + name: + description: Name of the operation, also defining its C enum value in uAPI. + type: string + doc: + description: Documentation for the command. + type: string + value: + description: Value for the enum in the uAPI. + $ref: '#/$defs/uint' + attribute-set: + description: | + Attribute space from which attributes directly in the requests and replies + to this command are defined. + type: string + flags: &cmd_flags + description: Command flags. + type: array + items: + enum: [ admin-perm ] + dont-validate: + description: Kernel attribute validation flags. + type: array + items: + enum: [ strict, dump ] + # Start genetlink-legacy + fixed-header: *fixed-header + # End genetlink-legacy + do: &subop-type + description: Main command handler. + type: object + additionalProperties: False + properties: + request: &subop-attr-list + description: Definition of the request message for a given command. + type: object + additionalProperties: False + properties: + attributes: + description: | + Names of attributes from the attribute-set (not full attribute + definitions, just names). + type: array + items: + type: string + # Start genetlink-legacy + value: + description: | + ID of this message if value for request and response differ, + i.e. requests and responses have different message enums. + $ref: '#/$defs/uint' + # End genetlink-legacy + reply: *subop-attr-list + pre: + description: Hook for a function to run before the main callback (pre_doit or start). + type: string + post: + description: Hook for a function to run after the main callback (post_doit or done). + type: string + dump: *subop-type + notify: + description: Name of the command sharing the reply type with this notification. + type: string + event: + type: object + additionalProperties: False + properties: + attributes: + description: Explicit list of the attributes for the notification. + type: array + items: + type: string + mcgrp: + description: Name of the multicast group generating given notification. + type: string + mcast-groups: + description: List of multicast groups. + type: object + required: [ list ] + additionalProperties: False + properties: + list: + description: List of groups. + type: array + items: + type: object + required: [ name ] + additionalProperties: False + properties: + name: + description: | + The name for the group, used to form the define and the value of the define. + type: string + # Start genetlink-c + c-define-name: + description: Override for the name of the define in C uAPI. + type: string + # End genetlink-c + flags: *cmd_flags + # Start netlink-raw + value: + description: Value of the netlink multicast group in the uAPI. + type: integer + # End netlink-raw From patchwork Thu Aug 24 11:19:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13363997 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 590A5DF72 for ; Thu, 24 Aug 2023 11:20:22 +0000 (UTC) Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24AD010FE; Thu, 24 Aug 2023 04:20:20 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fe32016bc8so60952075e9.1; Thu, 24 Aug 2023 04:20:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692876018; x=1693480818; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=g7vOTpfqqD54MzrSkWe2MWcCQ4puu0V5khTsQz3wBjk=; b=gX0nkGheG1sRPBoeQMDLbfUmiG+4DDE/iTbFCcgh7vJft0YXXdOdZAMBZtZnV0bGO8 H9EhrPbfprMrOXnqedlSe73TawfVH2Lz9BGhvU1RW5+gNpFHNqYXnwMQUhx+rm5LpOXM sd8FVexhOMoL/2hAjLXm32cDPSnQFcSw8UzzbhCyTBiWHwwdDuPxZe9ZG12cmO2SZNAI /CBe+2qH4m8fInoHDuYcGabuAyxhYuPdotPCU4nCXZ0efDfr84h/Ud1FVN3HCQdrEyY8 /mU83Z7tRUVSFb6p7471yzb8JWxPrKa7sMU2zImjFrI1AIBGtUne4xnV+tPt/FDdbvKH XSbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692876018; x=1693480818; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g7vOTpfqqD54MzrSkWe2MWcCQ4puu0V5khTsQz3wBjk=; b=e8PacALFTIKzHg4fGcHryT7wljrMvEVqpYBvPojAcmnugdsrmFah35lksguUy3xA4R 70Yh+GRAonm3hq/4P+nVe0i+LvjXXyfDaoahdc3fWcfgZhK9OZr8jtv4IS4XnFBg5QSu h74pP5qhoHfv8gl7qDXzql+X6InWM9wyVLvm3wx7aL262OqV+zcKVDQ7GQiwgNQux2jK QT4NQkwh+ljqzhtIZci6Kz1knBIqfxC3+Gu03y5eQke8/no+hMeINskQgVuj4D/RIHWK wjYk6DKtGModKGpPGvxUM97vCPRTITg7tsNnwISgL8ytzy/ovIjbzdZHcRhqw9t7Znsw CRQg== X-Gm-Message-State: AOJu0Yym0auwqEGurF15IH5rds/Dv0MTB9xSdZ/jhCmG1tr89J62/I0+ 7HTFINIDXOM7GhFDPTAfctD07zLCT+25nA== X-Google-Smtp-Source: AGHT+IGF2jFxGvIfRpD+4B8vndfe9neRU6b/o6Y33RUFXhznitXDjlZdWCN2vClWiBH6jlxMxxI0mw== X-Received: by 2002:adf:f043:0:b0:317:5b29:f10a with SMTP id t3-20020adff043000000b003175b29f10amr11177920wro.47.1692876017717; Thu, 24 Aug 2023 04:20:17 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:1a5:1436:c34c:226]) by smtp.gmail.com with ESMTPSA id i14-20020a5d630e000000b0031980783d78sm21875295wru.54.2023.08.24.04.20.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 04:20:17 -0700 (PDT) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , linux-doc@vger.kernel.org, Stanislav Fomichev , Arkadiusz Kubalewski Cc: donald.hunter@redhat.com, Donald Hunter , Jacob Keller Subject: [PATCH net-next v5 03/12] doc/netlink: Update genetlink-legacy documentation Date: Thu, 24 Aug 2023 12:19:54 +0100 Message-ID: <20230824112003.52939-4-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824112003.52939-1-donald.hunter@gmail.com> References: <20230824112003.52939-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add documentation for recently added genetlink-legacy schema attributes. Remove statements about 'work in progress' and 'todo'. Signed-off-by: Donald Hunter Reviewed-by: Jacob Keller --- Documentation/core-api/netlink.rst | 9 ++++--- .../netlink/genetlink-legacy.rst | 26 ++++++++++++------- Documentation/userspace-api/netlink/specs.rst | 13 ++++++++++ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/Documentation/core-api/netlink.rst b/Documentation/core-api/netlink.rst index e4a938a05cc9..9f692b02bfe6 100644 --- a/Documentation/core-api/netlink.rst +++ b/Documentation/core-api/netlink.rst @@ -67,10 +67,11 @@ Globals kernel-policy ~~~~~~~~~~~~~ -Defines if the kernel validation policy is per operation (``per-op``) -or for the entire family (``global``). New families should use ``per-op`` -(default) to be able to narrow down the attributes accepted by a specific -command. +Defines whether the kernel validation policy is ``global`` i.e. the same for all +operations of the family, defined for each operation individually - ``per-op``, +or separately for each operation and operation type (do vs dump) - ``split``. +New families should use ``per-op`` (default) to be able to narrow down the +attributes accepted by a specific command. checks ------ diff --git a/Documentation/userspace-api/netlink/genetlink-legacy.rst b/Documentation/userspace-api/netlink/genetlink-legacy.rst index 802875a37a27..40b82ad5d54a 100644 --- a/Documentation/userspace-api/netlink/genetlink-legacy.rst +++ b/Documentation/userspace-api/netlink/genetlink-legacy.rst @@ -8,11 +8,8 @@ This document describes the many additional quirks and properties required to describe older Generic Netlink families which form the ``genetlink-legacy`` protocol level. -The spec is a work in progress, some of the quirks are just documented -for future reference. - -Specification (defined) -======================= +Specification +============= Attribute type nests -------------------- @@ -156,16 +153,27 @@ it will be allocated 3 for the request (``a`` is the previous operation with a request section and the value of 2) and 8 for response (``c`` is the previous operation in the "from-kernel" direction). -Other quirks (todo) -=================== +Other quirks +============ Structures ---------- Legacy families can define C structures both to be used as the contents of an attribute and as a fixed message header. Structures are defined in -``definitions`` and referenced in operations or attributes. Note that -structures defined in YAML are implicitly packed according to C +``definitions`` and referenced in operations or attributes. + +members +~~~~~~~ + + - ``name`` - The attribute name of the struct member + - ``type`` - One of the scalar types ``u8``, ``u16``, ``u32``, ``u64``, ``s8``, + ``s16``, ``s32``, ``s64``, ``string`` or ``binary``. + - ``byte-order`` - ``big-endian`` or ``little-endian`` + - ``doc``, ``enum``, ``enum-as-flags``, ``display-hint`` - Same as for + :ref:`attribute definitions ` + +Note that structures defined in YAML are implicitly packed according to C conventions. For example, the following struct is 4 bytes, not 6 bytes: .. code-block:: c diff --git a/Documentation/userspace-api/netlink/specs.rst b/Documentation/userspace-api/netlink/specs.rst index 2e4acde890b7..cc4e2430997e 100644 --- a/Documentation/userspace-api/netlink/specs.rst +++ b/Documentation/userspace-api/netlink/specs.rst @@ -68,6 +68,10 @@ The following sections describe the properties of the most modern ``genetlink`` schema. See the documentation of :doc:`genetlink-c ` for information on how C names are derived from name properties. +See also :ref:`Documentation/core-api/netlink.rst ` for +information on the Netlink specification properties that are only relevant to +the kernel space and not part of the user space API. + genetlink ========= @@ -180,6 +184,8 @@ attributes List of attributes in the set. +.. _attribute_properties: + Attribute properties -------------------- @@ -264,6 +270,13 @@ a C array of u32 values can be specified with ``type: binary`` and ``sub-type: u32``. Binary types and legacy array formats are described in more detail in :doc:`genetlink-legacy`. +display-hint +~~~~~~~~~~~~ + +Optional format indicator that is intended only for choosing the right +formatting mechanism when displaying values of this type. Currently supported +hints are ``hex``, ``mac``, ``fddi``, ``ipv4``, ``ipv6`` and ``uuid``. + operations ---------- From patchwork Thu Aug 24 11:19:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13363998 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 040F6100C1 for ; Thu, 24 Aug 2023 11:20:22 +0000 (UTC) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C0D510FA; Thu, 24 Aug 2023 04:20:21 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3110ab7110aso5834691f8f.3; Thu, 24 Aug 2023 04:20:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692876019; x=1693480819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=A/J+nnRKTc28Dk8Gc4n3hxG5SwysHcm0JHfwpZXUZ6k=; b=lo4DwLE1Cp5fF2bSj3PFtwSjmPKqKmNpD7zDlYhu4imxcqAdjDl8kNlYVkKPcHsnRy DvVEoLy7Av6loK47RRL09cF+9hA7Yjpx06nvYOzwMVblN4Jwft7SUq0i0ZmTOvPAYHo8 bvtd+8VwTIRySbIdJBY0A5Xxd2i6g8O05cQm/VcRh6oDorJI6v9zdqlHIMXuHtOPbbcw TV7FJVKlpOja2a3+SN4/GyhtKAUbbQCTpW8AbLEwf+BeHV7A9oxYWvRiIQ5lFAQ2v0KH ICe8NggbLpQLjo8nPh7FLwPKEpar/ekGGL58BCbUt2R+A6ikuZZ9zSC+UhtIDhtEJtD6 VfiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692876019; x=1693480819; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A/J+nnRKTc28Dk8Gc4n3hxG5SwysHcm0JHfwpZXUZ6k=; b=Yy2KCx+SVOHbW+d2n7KurBfpJr7y/BFGxoigkeIlDwiKgxSa1fEqSrOxeZ57HMm90e kAK+h+hLjtdsbv/AdfivXTq+oRmm9xpXTpKqtJtv+oZUQ33nsQjDJiTVjauZcFfswSTH M9oclykG3i1UnmdIKxEg5tsI8k/qd0ha+q/9v/rsSesyqb9xet/V+Nil8ciDis7o8BPl Tv4hObkhSxM56f2NScN9XbIQ2CtSZTZBdwAH24WsJb1CE1dp6gT/WcAG7BR4xgemj4Jl ngpcMu0rj8HLUFhyIj8LbU/IYvEeQmu1mr52cAUG2Z654qFb0zLtqrn8NSisdR6ElpzC XroA== X-Gm-Message-State: AOJu0YwRcpkrY7kgfrrf4NofCixq4xNWPvq8u0ZIRAKKXLsAxNbT2sE/ x4ULLjn8utdUlbmUrLJwGYDGrswJwUdFZA== X-Google-Smtp-Source: AGHT+IFe3rJf1OAwwyToE8mEHlXPoCdVvNiZoGg/eGCT/AS6oPXpV7rtjdId32YG2+TyJUK4CInWig== X-Received: by 2002:a05:6000:10b:b0:315:a74c:f627 with SMTP id o11-20020a056000010b00b00315a74cf627mr11060337wrx.16.1692876019010; Thu, 24 Aug 2023 04:20:19 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:1a5:1436:c34c:226]) by smtp.gmail.com with ESMTPSA id i14-20020a5d630e000000b0031980783d78sm21875295wru.54.2023.08.24.04.20.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 04:20:18 -0700 (PDT) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , linux-doc@vger.kernel.org, Stanislav Fomichev , Arkadiusz Kubalewski Cc: donald.hunter@redhat.com, Donald Hunter , Jacob Keller Subject: [PATCH net-next v5 04/12] doc/netlink: Document the netlink-raw schema extensions Date: Thu, 24 Aug 2023 12:19:55 +0100 Message-ID: <20230824112003.52939-5-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824112003.52939-1-donald.hunter@gmail.com> References: <20230824112003.52939-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add a doc page for netlink-raw that describes the schema attributes needed for netlink-raw. Signed-off-by: Donald Hunter Reviewed-by: Jacob Keller --- Documentation/userspace-api/netlink/index.rst | 1 + .../userspace-api/netlink/netlink-raw.rst | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 Documentation/userspace-api/netlink/netlink-raw.rst diff --git a/Documentation/userspace-api/netlink/index.rst b/Documentation/userspace-api/netlink/index.rst index 26f3720cb3be..62725dafbbdb 100644 --- a/Documentation/userspace-api/netlink/index.rst +++ b/Documentation/userspace-api/netlink/index.rst @@ -14,5 +14,6 @@ Netlink documentation for users. specs c-code-gen genetlink-legacy + netlink-raw See also :ref:`Documentation/core-api/netlink.rst `. diff --git a/Documentation/userspace-api/netlink/netlink-raw.rst b/Documentation/userspace-api/netlink/netlink-raw.rst new file mode 100644 index 000000000000..f07fb9b9c101 --- /dev/null +++ b/Documentation/userspace-api/netlink/netlink-raw.rst @@ -0,0 +1,58 @@ +.. SPDX-License-Identifier: BSD-3-Clause + +====================================================== +Netlink specification support for raw Netlink families +====================================================== + +This document describes the additional properties required by raw Netlink +families such as ``NETLINK_ROUTE`` which use the ``netlink-raw`` protocol +specification. + +Specification +============= + +The netlink-raw schema extends the :doc:`genetlink-legacy ` +schema with properties that are needed to specify the protocol numbers and +multicast IDs used by raw netlink families. See :ref:`classic_netlink` for more +information. + +Globals +------- + +protonum +~~~~~~~~ + +The ``protonum`` property is used to specify the protocol number to use when +opening a netlink socket. + +.. code-block:: yaml + + # SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) + + name: rt-addr + protocol: netlink-raw + protonum: 0 # part of the NETLINK_ROUTE protocol + + +Multicast group properties +-------------------------- + +value +~~~~~ + +The ``value`` property is used to specify the group ID to use for multicast +group registration. + +.. code-block:: yaml + + mcast-groups: + list: + - + name: rtnlgrp-ipv4-ifaddr + value: 5 + - + name: rtnlgrp-ipv6-ifaddr + value: 9 + - + name: rtnlgrp-mctp-ifaddr + value: 34 From patchwork Thu Aug 24 11:19:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13363999 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 409E1100C1 for ; Thu, 24 Aug 2023 11:20:24 +0000 (UTC) Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DE921981; Thu, 24 Aug 2023 04:20:22 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3fee843b44cso44752715e9.1; Thu, 24 Aug 2023 04:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692876020; x=1693480820; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JkzaqjYN/HOcy5KlOajuUNuvh0OnrW3AlKCpAsfPAW0=; b=J43onzf3QCsCqpbICEk2r8qLd9GtiaDu9hTxWJd2R/iKlTVc2gmOUhMUlVK7Gp+98S vlPzsHuG134qYP5KBhQ+zu7A2ab52MquHkuv0ab2HWyJ2cx/3bV+iwWZKbGeQtskGgES 6Y5MsB1eko3xDl1T2ezIAUS8HKMavhXP6YClEvX2z1QNRX7PAW3/f2Ki4iky27rx9zP1 IZOv9l41glIgdpgZtdS0iaUhGlMKnhbgoFJHfIdNlGkVvAw/iSNM76bn+Hwgi7lE/r8L ixEzl8F+1jTddeGKE/O43qfD1vCsUcRgRrnFI2Kh3f0lZF06oQKds6tl0F/iDvlOoI// zx8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692876020; x=1693480820; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JkzaqjYN/HOcy5KlOajuUNuvh0OnrW3AlKCpAsfPAW0=; b=TmLtqdH8/A1j9QXujbtQ9Cjj2aKGShR+1Ie4xY6RXELyu5B+/MBI9VL3wEhRia+OGo Skghd2mpW88lUiiLSI3mX0U4cCcbipJfAZb8PHYxgo91nv3vXmUJcrLXvcCVPmirMP+8 J724536QKjdXZRjjA4oAg3kYjo/kxtMo9/I31AGYovsEg840yBzymXL7aaJFpLdLCDNB wQTxsf6NToqNlS88UeroaVPghdyU5iNxxqkiDM/euZcupKgmiKJkLls6LnHlO1sqlT0v 5JHWogB5CTnzuEZFaRsWm4VhyyC/fW4oQdt5aMKvYpRajxTfnx3aWgpLBHcTT+a5hmLW B+5g== X-Gm-Message-State: AOJu0Yznv5eJBjj/Ij+9bpoC38Hmxh7DB4szSsF/OzhMoXKxcsie4QuT IZ76BjpgCdr9Jay9uKmVVPehYhndi5fC8A== X-Google-Smtp-Source: AGHT+IEke2NAoukpB1MdHJB6IME3DLYH3BeAlHvNbsMF0cZnMxhsUmHQjuRdCm2bsVSQ4Oxo/vL+PQ== X-Received: by 2002:a5d:6a84:0:b0:317:ec04:ee0c with SMTP id s4-20020a5d6a84000000b00317ec04ee0cmr11028276wru.47.1692876020433; Thu, 24 Aug 2023 04:20:20 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:1a5:1436:c34c:226]) by smtp.gmail.com with ESMTPSA id i14-20020a5d630e000000b0031980783d78sm21875295wru.54.2023.08.24.04.20.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 04:20:19 -0700 (PDT) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , linux-doc@vger.kernel.org, Stanislav Fomichev , Arkadiusz Kubalewski Cc: donald.hunter@redhat.com, Donald Hunter , Jacob Keller Subject: [PATCH net-next v5 05/12] tools/ynl: Add mcast-group schema parsing to ynl Date: Thu, 24 Aug 2023 12:19:56 +0100 Message-ID: <20230824112003.52939-6-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824112003.52939-1-donald.hunter@gmail.com> References: <20230824112003.52939-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add a SpecMcastGroup class to the nlspec lib. Signed-off-by: Donald Hunter Reviewed-by: Jacob Keller --- tools/net/ynl/lib/nlspec.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py index 0ff0d18666b2..37bcb4d8b37b 100644 --- a/tools/net/ynl/lib/nlspec.py +++ b/tools/net/ynl/lib/nlspec.py @@ -322,6 +322,26 @@ class SpecOperation(SpecElement): self.attr_set = self.family.attr_sets[attr_set_name] +class SpecMcastGroup(SpecElement): + """Netlink Multicast Group + + Information about a multicast group. + + Value is only used for classic netlink families that use the + netlink-raw schema. Genetlink families use dynamic ID allocation + where the ids of multicast groups get resolved at runtime. Value + will be None for genetlink families. + + Attributes: + name name of the mulitcast group + value integer id of this multicast group for netlink-raw or None + yaml raw spec as loaded from the spec file + """ + def __init__(self, family, yaml): + super().__init__(family, yaml) + self.value = self.yaml.get('value') + + class SpecFamily(SpecElement): """ Netlink Family Spec class. @@ -343,6 +363,7 @@ class SpecFamily(SpecElement): ntfs dict of all async events consts dict of all constants/enums fixed_header string, optional name of family default fixed header struct + mcast_groups dict of all multicast groups (index by name) """ def __init__(self, spec_path, schema_path=None, exclude_ops=None): with open(spec_path, "r") as stream: @@ -384,6 +405,7 @@ class SpecFamily(SpecElement): self.ops = collections.OrderedDict() self.ntfs = collections.OrderedDict() self.consts = collections.OrderedDict() + self.mcast_groups = collections.OrderedDict() last_exception = None while len(self._resolution_list) > 0: @@ -416,6 +438,9 @@ class SpecFamily(SpecElement): def new_operation(self, elem, req_val, rsp_val): return SpecOperation(self, elem, req_val, rsp_val) + def new_mcast_group(self, elem): + return SpecMcastGroup(self, elem) + def add_unresolved(self, elem): self._resolution_list.append(elem) @@ -512,3 +537,9 @@ class SpecFamily(SpecElement): self.ops[op.name] = op elif op.is_async: self.ntfs[op.name] = op + + mcgs = self.yaml.get('mcast-groups') + if mcgs: + for elem in mcgs['list']: + mcg = self.new_mcast_group(elem) + self.mcast_groups[elem['name']] = mcg From patchwork Thu Aug 24 11:19:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13364000 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F06B310966 for ; Thu, 24 Aug 2023 11:20:25 +0000 (UTC) Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A38C419B3; Thu, 24 Aug 2023 04:20:23 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fee769fd53so46231275e9.1; Thu, 24 Aug 2023 04:20:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692876021; x=1693480821; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xeOioWQbqu83Tsvvw7lSdRkXGk4CEXA20oNSkobpGlo=; b=gQiAqhcEyDPLomsMQQriZQ1l0Coxk2CvtQvZg5590+VoWiyK5ollT714vKPx4+e8id rn4OXWQUBY0mEjjsZBpQipIcueevB6c1roYyNmgCXxkXY1tkl1K2+U0nreze0678Kxm6 fMlgmQW20xhsB/ClKH6wQoxOcsjT6JXmtqbLYmgg5GzzRuPhEduwQ9LtuNTUNLwO9u/j 25N+AbhdFV4NNIG8J+ezLbZTFiwfSo4DepXzAgdj2jtTZj+Q66IZzUtSRph45hA5uskN GVrOGdRsv7MEa3JEJiz2DNmZgoVaGLdhYxfKXew2tjNhd7XGsj2Mb1uby4TpOyzXg4lq 7s4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692876021; x=1693480821; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xeOioWQbqu83Tsvvw7lSdRkXGk4CEXA20oNSkobpGlo=; b=a0qVrlKEC4RHORqjf4+a6KAc4AraX1ryMuR/wAGDFGmKY40PUbzgqteWIHLHmoAUPk W1bT+maDD0LG9furgtXU9y7pE5j2HR6g/Yn9gD0OhdJFvWYwbA6gyp00awtO9iDqLU9C ISEPBTch2/w1WSU2OgnPjXyeDQcjlgl8UXVlGux5HkB4RA96hQ9ShxjDgprhmJVYUKQf NMOX81oxSFVou7v6fQ7E0TyEk9rZDaPyxZKtLqDuM3lZ+9n990okERt9/nNK4s5lDXb6 JQLDDWUTFct0qnHHqwSNQ4cuktXs75r+CpNEfUa1u+23gRj2uqzDiKwys3biEdPtaGws Ndzg== X-Gm-Message-State: AOJu0YzTgOmZ6JfJyfOxqt0AMxDyT5M1FtZoqdb0W5vt2c/P5jNFZTzi 1YXsS2FhckFzmNMjgvrUN5rYvQh1jZ9k1g== X-Google-Smtp-Source: AGHT+IFT9viTQGZfSCa2lc1BmKh/+O6Tw3CHex9hWU4YutSgY9OO8Yvva5+/DCQijJ6QVWKzl52nbQ== X-Received: by 2002:a5d:595f:0:b0:317:5b32:b2c3 with SMTP id e31-20020a5d595f000000b003175b32b2c3mr11926390wri.6.1692876021562; Thu, 24 Aug 2023 04:20:21 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:1a5:1436:c34c:226]) by smtp.gmail.com with ESMTPSA id i14-20020a5d630e000000b0031980783d78sm21875295wru.54.2023.08.24.04.20.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 04:20:21 -0700 (PDT) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , linux-doc@vger.kernel.org, Stanislav Fomichev , Arkadiusz Kubalewski Cc: donald.hunter@redhat.com, Donald Hunter , Jacob Keller Subject: [PATCH net-next v5 06/12] tools/net/ynl: Fix extack parsing with fixed header genlmsg Date: Thu, 24 Aug 2023 12:19:57 +0100 Message-ID: <20230824112003.52939-7-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824112003.52939-1-donald.hunter@gmail.com> References: <20230824112003.52939-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Move decode_fixed_header into YnlFamily and add a _fixed_header_size method to allow extack decoding to skip the fixed header. Signed-off-by: Donald Hunter Reviewed-by: Jacob Keller --- tools/net/ynl/lib/ynl.py | 65 ++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index 6951bcc7efdc..1d1bc712456e 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -293,7 +293,7 @@ def _genl_load_families(): gm = GenlMsg(nl_msg) fam = dict() - for attr in gm.raw_attrs: + for attr in NlAttrs(gm.raw): if attr.type == Netlink.CTRL_ATTR_FAMILY_ID: fam['id'] = attr.as_scalar('u16') elif attr.type == Netlink.CTRL_ATTR_FAMILY_NAME: @@ -317,23 +317,10 @@ def _genl_load_families(): class GenlMsg: - def __init__(self, nl_msg, fixed_header_members=[]): + def __init__(self, nl_msg): self.nl = nl_msg - - self.hdr = nl_msg.raw[0:4] - offset = 4 - - self.genl_cmd, self.genl_version, _ = struct.unpack("BBH", self.hdr) - - self.fixed_header_attrs = dict() - for m in fixed_header_members: - format = NlAttr.get_format(m.type, m.byte_order) - decoded = format.unpack_from(nl_msg.raw, offset) - offset += format.size - self.fixed_header_attrs[m.name] = decoded[0] - - self.raw = nl_msg.raw[offset:] - self.raw_attrs = NlAttrs(self.raw) + self.genl_cmd, self.genl_version, _ = struct.unpack_from("BBH", nl_msg.raw, 0) + self.raw = nl_msg.raw[4:] def __repr__(self): msg = repr(self.nl) @@ -509,17 +496,44 @@ class YnlFamily(SpecFamily): return None - def _decode_extack(self, request, attr_space, extack): + def _decode_extack(self, request, op, extack): if 'bad-attr-offs' not in extack: return - genl_req = GenlMsg(NlMsg(request, 0, attr_space=attr_space)) - path = self._decode_extack_path(genl_req.raw_attrs, attr_space, - 20, extack['bad-attr-offs']) + genl_req = GenlMsg(NlMsg(request, 0, op.attr_set)) + fixed_header_size = self._fixed_header_size(op) + offset = 20 + fixed_header_size + path = self._decode_extack_path(NlAttrs(genl_req.raw[fixed_header_size:]), + op.attr_set, offset, + extack['bad-attr-offs']) if path: del extack['bad-attr-offs'] extack['bad-attr'] = path + def _fixed_header_size(self, op): + if op.fixed_header: + fixed_header_members = self.consts[op.fixed_header].members + size = 0 + for m in fixed_header_members: + format = NlAttr.get_format(m.type, m.byte_order) + size += format.size + return size + else: + return 0 + + def _decode_fixed_header(self, msg, name): + fixed_header_members = self.consts[name].members + fixed_header_attrs = dict() + offset = 0 + for m in fixed_header_members: + format = NlAttr.get_format(m.type, m.byte_order) + [ value ] = format.unpack_from(msg.raw, offset) + offset += format.size + if m.enum: + value = self._decode_enum(value, m) + fixed_header_attrs[m.name] = value + return fixed_header_attrs + def handle_ntf(self, nl_msg, genl_msg): msg = dict() if self.include_raw: @@ -594,7 +608,7 @@ class YnlFamily(SpecFamily): nms = NlMsgs(reply, attr_space=op.attr_set) for nl_msg in nms: if nl_msg.extack: - self._decode_extack(msg, op.attr_set, nl_msg.extack) + self._decode_extack(msg, op, nl_msg.extack) if nl_msg.error: raise NlError(nl_msg) @@ -605,7 +619,7 @@ class YnlFamily(SpecFamily): done = True break - gm = GenlMsg(nl_msg, fixed_header_members) + gm = GenlMsg(nl_msg) # Check if this is a reply to our request if nl_msg.nl_seq != req_seq or gm.genl_cmd != op.rsp_value: if gm.genl_cmd in self.async_msg_ids: @@ -615,8 +629,9 @@ class YnlFamily(SpecFamily): print('Unexpected message: ' + repr(gm)) continue - rsp_msg = self._decode(gm.raw_attrs, op.attr_set.name) - rsp_msg.update(gm.fixed_header_attrs) + rsp_msg = self._decode(NlAttrs(gm.raw), op.attr_set.name) + if op.fixed_header: + rsp_msg.update(self._decode_fixed_header(gm, op.fixed_header)) rsp.append(rsp_msg) if not rsp: From patchwork Thu Aug 24 11:19:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13364001 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 903F21119D for ; Thu, 24 Aug 2023 11:20:27 +0000 (UTC) Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C031119B7; Thu, 24 Aug 2023 04:20:24 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-31c71898109so862230f8f.2; Thu, 24 Aug 2023 04:20:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692876023; x=1693480823; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6xYApsDeilR/lh/FduE88Yq5t+89QhdT6EgnUVD7mho=; b=CGZK0n4tTp/q5XNWidUDWXMGNBfMaaLV86EKEJQW1HP2ugu3okeP8THIJQxkb4ptUz 1KHJ1uEARhmuFlvwBlJ+y9CTj21KQX9bKpYCOCm5JLfwQhF1OISQk0qEGprzvfsxKj9Y 0v0KRx3RnZIpyA3neEkM2GRgNJcxiCjGFLFOi0Q2iSH5yFu2Xe7wqvxnnZ1Y5CjB32F1 ikj+cYcwBWu3f59/LxoG31W/9Pc/bPW5heVKtrKzDK/OwdNNKK22tB5Q08YXtTFzshUk pM6ryIzMnNWPjhY55LoJQ2Qyb167Q+ZGCsN1AiR6oc1qXNwFaXWZVI22HSBljm3feu45 UiYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692876023; x=1693480823; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6xYApsDeilR/lh/FduE88Yq5t+89QhdT6EgnUVD7mho=; b=GRObB0nr1/AvTYzW3QQ9nydV6hVdvi8AshwztV+NCkYNnzo9wAJjFXdSgkjqMnEwBB 0aBNN57VOdW/UUPhcFdgNz32dFndCVdeDe9FHkdYCmO9mAKgyvigelDLM71fATTBih9A zL8nXtwJe7k7kmjkeXUsWMT3KMRI6YejpUjY1yfGGvzLyXKs44OpnqSBm9gyHtCq6zOy QXEiYRVVeLiIzobKmGb4tTCEldC1Dsc/IVxUb7wx7CkRvCMjMjn39JTI5/bvHdWYlL6h ybEPYiqbCzdedqPjZ/jhJ8r6Hg7hx4NZiKQ/vrUxLbN8i/3yTFZYw/kXcPTY98Gx2qet jSRQ== X-Gm-Message-State: AOJu0Yy13plJONvX/jiPdUonUbvxO1VqTWkeP6hx+R1ajGUDj1dU+QQi f3ryXnLbnpB6Z7Qd61HUJSmQklEt8Onc0g== X-Google-Smtp-Source: AGHT+IHXvVtFv2KHiZuXteTdT1D+ep7x1kdon/zlQoA11jMGffRK4x8Bg6gdkd2HxXYrrWTssUY3AQ== X-Received: by 2002:adf:fa88:0:b0:319:7abf:d8e2 with SMTP id h8-20020adffa88000000b003197abfd8e2mr11196464wrr.24.1692876022754; Thu, 24 Aug 2023 04:20:22 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:1a5:1436:c34c:226]) by smtp.gmail.com with ESMTPSA id i14-20020a5d630e000000b0031980783d78sm21875295wru.54.2023.08.24.04.20.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 04:20:22 -0700 (PDT) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , linux-doc@vger.kernel.org, Stanislav Fomichev , Arkadiusz Kubalewski Cc: donald.hunter@redhat.com, Donald Hunter Subject: [PATCH net-next v5 07/12] tools/net/ynl: Add support for netlink-raw families Date: Thu, 24 Aug 2023 12:19:58 +0100 Message-ID: <20230824112003.52939-8-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824112003.52939-1-donald.hunter@gmail.com> References: <20230824112003.52939-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Refactor the ynl code to encapsulate protocol specifics into NetlinkProtocol and GenlProtocol. Signed-off-by: Donald Hunter --- tools/net/ynl/lib/ynl.py | 124 ++++++++++++++++++++++++++++----------- 1 file changed, 91 insertions(+), 33 deletions(-) diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index 1d1bc712456e..e5001356ad0c 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -25,6 +25,7 @@ class Netlink: NETLINK_ADD_MEMBERSHIP = 1 NETLINK_CAP_ACK = 10 NETLINK_EXT_ACK = 11 + NETLINK_GET_STRICT_CHK = 12 # Netlink message NLMSG_ERROR = 2 @@ -228,6 +229,9 @@ class NlMsg: desc += f" ({spec['doc']})" self.extack['miss-type'] = desc + def cmd(self): + return self.nl_type + def __repr__(self): msg = f"nl_len = {self.nl_len} ({len(self.raw)}) nl_flags = 0x{self.nl_flags:x} nl_type = {self.nl_type}\n" if self.error: @@ -322,6 +326,9 @@ class GenlMsg: self.genl_cmd, self.genl_version, _ = struct.unpack_from("BBH", nl_msg.raw, 0) self.raw = nl_msg.raw[4:] + def cmd(self): + return self.genl_cmd + def __repr__(self): msg = repr(self.nl) msg += f"\tgenl_cmd = {self.genl_cmd} genl_ver = {self.genl_version}\n" @@ -330,9 +337,41 @@ class GenlMsg: return msg -class GenlFamily: - def __init__(self, family_name): +class NetlinkProtocol: + def __init__(self, family_name, proto_num): self.family_name = family_name + self.proto_num = proto_num + + def _message(self, nl_type, nl_flags, seq=None): + if seq is None: + seq = random.randint(1, 1024) + nlmsg = struct.pack("HHII", nl_type, nl_flags, seq, 0) + return nlmsg + + def message(self, flags, command, version, seq=None): + return self._message(command, flags, seq) + + def _decode(self, nl_msg): + return nl_msg + + def decode(self, ynl, nl_msg): + msg = self._decode(nl_msg) + fixed_header_size = 0 + if ynl: + op = ynl.rsp_by_value[msg.cmd()] + fixed_header_size = ynl._fixed_header_size(op) + msg.raw_attrs = NlAttrs(msg.raw[fixed_header_size:]) + return msg + + def get_mcast_id(self, mcast_name, mcast_groups): + if mcast_name not in mcast_groups: + raise Exception(f'Multicast group "{mcast_name}" not present in the spec') + return mcast_groups[mcast_name].value + + +class GenlProtocol(NetlinkProtocol): + def __init__(self, family_name): + super().__init__(family_name, Netlink.NETLINK_GENERIC) global genl_family_name_to_id if genl_family_name_to_id is None: @@ -341,6 +380,19 @@ class GenlFamily: self.genl_family = genl_family_name_to_id[family_name] self.family_id = genl_family_name_to_id[family_name]['id'] + def message(self, flags, command, version, seq=None): + nlmsg = self._message(self.family_id, flags, seq) + genlmsg = struct.pack("BBH", command, version, 0) + return nlmsg + genlmsg + + def _decode(self, nl_msg): + return GenlMsg(nl_msg) + + def get_mcast_id(self, mcast_name, mcast_groups): + if mcast_name not in self.genl_family['mcast']: + raise Exception(f'Multicast group "{mcast_name}" not present in the family') + return self.genl_family['mcast'][mcast_name] + # # YNL implementation details. @@ -353,9 +405,19 @@ class YnlFamily(SpecFamily): self.include_raw = False - self.sock = socket.socket(socket.AF_NETLINK, socket.SOCK_RAW, Netlink.NETLINK_GENERIC) + try: + if self.proto == "netlink-raw": + self.nlproto = NetlinkProtocol(self.yaml['name'], + self.yaml['protonum']) + else: + self.nlproto = GenlProtocol(self.yaml['name']) + except KeyError: + raise Exception(f"Family '{self.yaml['name']}' not supported by the kernel") + + self.sock = socket.socket(socket.AF_NETLINK, socket.SOCK_RAW, self.nlproto.proto_num) self.sock.setsockopt(Netlink.SOL_NETLINK, Netlink.NETLINK_CAP_ACK, 1) self.sock.setsockopt(Netlink.SOL_NETLINK, Netlink.NETLINK_EXT_ACK, 1) + self.sock.setsockopt(Netlink.SOL_NETLINK, Netlink.NETLINK_GET_STRICT_CHK, 1) self.async_msg_ids = set() self.async_msg_queue = [] @@ -368,18 +430,12 @@ class YnlFamily(SpecFamily): bound_f = functools.partial(self._op, op_name) setattr(self, op.ident_name, bound_f) - try: - self.family = GenlFamily(self.yaml['name']) - except KeyError: - raise Exception(f"Family '{self.yaml['name']}' not supported by the kernel") def ntf_subscribe(self, mcast_name): - if mcast_name not in self.family.genl_family['mcast']: - raise Exception(f'Multicast group "{mcast_name}" not present in the family') - + mcast_id = self.nlproto.get_mcast_id(mcast_name, self.mcast_groups) self.sock.bind((0, 0)) self.sock.setsockopt(Netlink.SOL_NETLINK, Netlink.NETLINK_ADD_MEMBERSHIP, - self.family.genl_family['mcast'][mcast_name]) + mcast_id) def _add_attr(self, space, name, value): try: @@ -500,11 +556,9 @@ class YnlFamily(SpecFamily): if 'bad-attr-offs' not in extack: return - genl_req = GenlMsg(NlMsg(request, 0, op.attr_set)) - fixed_header_size = self._fixed_header_size(op) - offset = 20 + fixed_header_size - path = self._decode_extack_path(NlAttrs(genl_req.raw[fixed_header_size:]), - op.attr_set, offset, + msg = self.nlproto.decode(self, NlMsg(request, 0, op.attr_set)) + offset = 20 + self._fixed_header_size(op) + path = self._decode_extack_path(msg.raw_attrs, op.attr_set, offset, extack['bad-attr-offs']) if path: del extack['bad-attr-offs'] @@ -534,14 +588,17 @@ class YnlFamily(SpecFamily): fixed_header_attrs[m.name] = value return fixed_header_attrs - def handle_ntf(self, nl_msg, genl_msg): + def handle_ntf(self, decoded): msg = dict() if self.include_raw: - msg['nlmsg'] = nl_msg - msg['genlmsg'] = genl_msg - op = self.rsp_by_value[genl_msg.genl_cmd] + msg['raw'] = decoded + op = self.rsp_by_value[decoded.cmd()] + attrs = self._decode(decoded.raw_attrs, op.attr_set.name) + if op.fixed_header: + attrs.update(self._decode_fixed_header(decoded, op.fixed_header)) + msg['name'] = op['name'] - msg['msg'] = self._decode(genl_msg.raw_attrs, op.attr_set.name) + msg['msg'] = attrs self.async_msg_queue.append(msg) def check_ntf(self): @@ -561,12 +618,12 @@ class YnlFamily(SpecFamily): print("Netlink done while checking for ntf!?") continue - gm = GenlMsg(nl_msg) - if gm.genl_cmd not in self.async_msg_ids: - print("Unexpected msg id done while checking for ntf", gm) + decoded = self.nlproto.decode(self, nl_msg) + if decoded.cmd() not in self.async_msg_ids: + print("Unexpected msg id done while checking for ntf", decoded) continue - self.handle_ntf(nl_msg, gm) + self.handle_ntf(decoded) def operation_do_attributes(self, name): """ @@ -587,7 +644,7 @@ class YnlFamily(SpecFamily): nl_flags |= Netlink.NLM_F_DUMP req_seq = random.randint(1024, 65535) - msg = _genl_msg(self.family.family_id, nl_flags, op.req_value, 1, req_seq) + msg = self.nlproto.message(nl_flags, op.req_value, 1, req_seq) fixed_header_members = [] if op.fixed_header: fixed_header_members = self.consts[op.fixed_header].members @@ -619,19 +676,20 @@ class YnlFamily(SpecFamily): done = True break - gm = GenlMsg(nl_msg) + decoded = self.nlproto.decode(self, nl_msg) + # Check if this is a reply to our request - if nl_msg.nl_seq != req_seq or gm.genl_cmd != op.rsp_value: - if gm.genl_cmd in self.async_msg_ids: - self.handle_ntf(nl_msg, gm) + if nl_msg.nl_seq != req_seq or decoded.cmd() != op.rsp_value: + if decoded.cmd() in self.async_msg_ids: + self.handle_ntf(decoded) continue else: - print('Unexpected message: ' + repr(gm)) + print('Unexpected message: ' + repr(decoded)) continue - rsp_msg = self._decode(NlAttrs(gm.raw), op.attr_set.name) + rsp_msg = self._decode(decoded.raw_attrs, op.attr_set.name) if op.fixed_header: - rsp_msg.update(self._decode_fixed_header(gm, op.fixed_header)) + rsp_msg.update(self._decode_fixed_header(decoded, op.fixed_header)) rsp.append(rsp_msg) if not rsp: From patchwork Thu Aug 24 11:19:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13364002 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C1EC1119D for ; Thu, 24 Aug 2023 11:20:28 +0000 (UTC) Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1752219BD; Thu, 24 Aug 2023 04:20:26 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-401b0d97850so2371455e9.2; Thu, 24 Aug 2023 04:20:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692876024; x=1693480824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lHo0WyP8xgW16yDEg6dBt6z1hcOwztrudJTUIb2n8nc=; b=seq9zvt5ElfFLErccMzSgjRYXACItf1unV/E6WOrf4yInZgbx3A29TwlPpRXG4NLUu 3nwGAl9G+PPwTo2kBU4O1b031ycLJxCavKi3AiQPHigyl40Ol9VuIqunYrCSZqi3XAoH frUBdH5PpPECooLacJT7Ai337TtfiUA6QKiw/gtc/+RUTDyF2rjABnJ47hm+WEDSUz8a k0vySsd9AmmB2Ouxa5MNCRUsaPA7pUFkUFUKeEbPWtTMipR3jA+6Raqw43qZpWGGk9G7 tUT6hE1m8/wN5mdNdtSx2lFrQDp7i99vbriX8tlRPjlQtjkhT2Rmjts2gvgA8sxsDnkn jnbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692876024; x=1693480824; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lHo0WyP8xgW16yDEg6dBt6z1hcOwztrudJTUIb2n8nc=; b=Hjg6KlS9/xI5I2J8H4UxY85bSeYCSketQEU7WScHLsmtihtrVwvsVsIrlhScdfSvqz 7Qz3TLeHskuDG7QhhawT+JJgpIoHDwdJIdLwzxTE23EsNVg2GKKqIVNhsz0ja6/wRPez miEyI+YLRcJ8RtrJrSa7p75EXdYmg2ypBKy8YBikhZ5b2QXze/9RXmryAvClhvZze4jG XRA6aSR67hprS4O9yaviJEJSoxOzOEUvMyK6H9/8t6g78SEZHdME3wdpvFoKaSeTyoIH iX/GBKbatThNm/bIKff7MmcxciCEzAy3sw4JcF62eVVTMeBePGQzrzOOX5+e+dVIJM7h xlqw== X-Gm-Message-State: AOJu0YzDzUttCZCq0yzEDSKNXUjdaxyEOPdWIGJBy7RPhPGe4Vl057pt Fykjb2dZ/hGmS/3gey+KxmPm0Rd6v0pNQQ== X-Google-Smtp-Source: AGHT+IHnl200izGVnvM+E3LfWpfRIWzbCiPiStalVBBSzXeLRQxTd+f0zXrlXR9BPkRnv3YAdWIhtQ== X-Received: by 2002:a05:6000:8b:b0:314:36f0:2214 with SMTP id m11-20020a056000008b00b0031436f02214mr10472163wrx.6.1692876024049; Thu, 24 Aug 2023 04:20:24 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:1a5:1436:c34c:226]) by smtp.gmail.com with ESMTPSA id i14-20020a5d630e000000b0031980783d78sm21875295wru.54.2023.08.24.04.20.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 04:20:23 -0700 (PDT) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , linux-doc@vger.kernel.org, Stanislav Fomichev , Arkadiusz Kubalewski Cc: donald.hunter@redhat.com, Donald Hunter , Jacob Keller Subject: [PATCH net-next v5 08/12] tools/net/ynl: Implement nlattr array-nest decoding in ynl Date: Thu, 24 Aug 2023 12:19:59 +0100 Message-ID: <20230824112003.52939-9-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824112003.52939-1-donald.hunter@gmail.com> References: <20230824112003.52939-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add support for the 'array-nest' attribute type that is used by several netlink-raw families. Signed-off-by: Donald Hunter Reviewed-by: Jakub Kicinski Reviewed-by: Jacob Keller --- tools/net/ynl/lib/ynl.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index e5001356ad0c..5d04a2b5fc78 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -492,6 +492,17 @@ class YnlFamily(SpecFamily): decoded = NlAttr.formatted_string(decoded, attr_spec.display_hint) return decoded + def _decode_array_nest(self, attr, attr_spec): + decoded = [] + offset = 0 + while offset < len(attr.raw): + item = NlAttr(attr.raw, offset) + offset += item.full_len + + subattrs = self._decode(NlAttrs(item.raw), attr_spec['nested-attributes']) + decoded.append({ item.type: subattrs }) + return decoded + def _decode(self, attrs, space): attr_space = self.attr_sets[space] rsp = dict() @@ -511,6 +522,8 @@ class YnlFamily(SpecFamily): decoded = True elif attr_spec["type"] in NlAttr.type_formats: decoded = attr.as_scalar(attr_spec['type'], attr_spec.byte_order) + elif attr_spec["type"] == 'array-nest': + decoded = self._decode_array_nest(attr, attr_spec) else: raise Exception(f'Unknown {attr_spec["type"]} with name {attr_spec["name"]}') From patchwork Thu Aug 24 11:20:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13364003 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0520CA7E for ; Thu, 24 Aug 2023 11:20:31 +0000 (UTC) Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8022110FC; Thu, 24 Aug 2023 04:20:27 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-31adc5c899fso5957536f8f.2; Thu, 24 Aug 2023 04:20:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692876025; x=1693480825; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gwU5ZIdx6k1IITw9kHNMNIZu5zHc1LPTGr73mesHXQY=; b=dMeXOZ7G/Ldgw/c5bpbvWrK1wCI0FC6XJtPz5WZ7PlHvt6vsi8IuoUY4zyy0z/iyiY NoD9+Eo1ckJE35G5V0Fs9QjTMYEkmId/9FOS8f/2trY78GNe5zsTv9zNYQuQI7RtK9V1 qd1ptqCwwbyD9gAYyhJlO8/Tz9YmAzXDQVbN+JtvJbdJA5mBGIr2BhoDEiUIUG43pSwR nih4yNcYaPoS+h9QpzrSSR6jDI5qWfc3cyl/QSvWRTzScmcBj/nVQGGbGKu0WYkLbpaa xU65/IkPY2J6JvG7Ed6YfULchGA0HDmV5K8Dk86KObLIYjisat3hcpXzLs/7JhBu/J5o nhmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692876025; x=1693480825; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gwU5ZIdx6k1IITw9kHNMNIZu5zHc1LPTGr73mesHXQY=; b=j33NwuwQbMeqwQayMLxxQCO1O4/DiGbx+KpO8hNS3Ij4GrTKlj+HQokgThG5JRsOkO pCQxcMZhc4WJw2OY2ps5mkRLXf/ECYMfpVtO96v3ZSvGyy2PligWzk1qKD9SSE8tr9DI 0hA0eocBFWTXXU+zJDdAxu3ifmDnCaT3TroWSQGKUvqSY5Ncf+pHc6S9vyhySJkNoYB/ byHLx7BZQzUr8nUe65tDDkdrYdfAkqOOIrRjyhFSj3jQ5VRh6cVThPBgtvR+9/xfhUa4 c2L6PJsq43tx8C4HLylxaV8bABC5SMlVBd3OwKl6cKsCK/xqJ/vHN1zs7ip+AjLGZnL7 sQKw== X-Gm-Message-State: AOJu0YxsDg8LJygPmwwWTp8f2LZo4KLXC0NUP/bFOTPWB5IePyp8RpJu 9S7jFZy6VzmlmhO1QU+k8PZ+oEsz9zKCBQ== X-Google-Smtp-Source: AGHT+IGPJMTCHuHAURonkq/dP4UPR34XmUGS8PJq9njIfCvONssFWW6+rj/y84kxWoryKIcCL0Yjkw== X-Received: by 2002:a5d:5242:0:b0:317:5351:e428 with SMTP id k2-20020a5d5242000000b003175351e428mr11768497wrc.4.1692876025453; Thu, 24 Aug 2023 04:20:25 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:1a5:1436:c34c:226]) by smtp.gmail.com with ESMTPSA id i14-20020a5d630e000000b0031980783d78sm21875295wru.54.2023.08.24.04.20.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 04:20:25 -0700 (PDT) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , linux-doc@vger.kernel.org, Stanislav Fomichev , Arkadiusz Kubalewski Cc: donald.hunter@redhat.com, Donald Hunter , Jacob Keller Subject: [PATCH net-next v5 09/12] tools/net/ynl: Add support for create flags Date: Thu, 24 Aug 2023 12:20:00 +0100 Message-ID: <20230824112003.52939-10-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824112003.52939-1-donald.hunter@gmail.com> References: <20230824112003.52939-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add support for using NLM_F_REPLACE, _EXCL, _CREATE and _APPEND flags in requests. Signed-off-by: Donald Hunter Reviewed-by: Jacob Keller --- tools/net/ynl/cli.py | 12 ++++++++++-- tools/net/ynl/lib/__init__.py | 4 ++-- tools/net/ynl/lib/ynl.py | 14 ++++++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/tools/net/ynl/cli.py b/tools/net/ynl/cli.py index ffaa8038aa8c..564ecf07cd2c 100755 --- a/tools/net/ynl/cli.py +++ b/tools/net/ynl/cli.py @@ -6,7 +6,7 @@ import json import pprint import time -from lib import YnlFamily +from lib import YnlFamily, Netlink def main(): @@ -19,6 +19,14 @@ def main(): parser.add_argument('--dump', dest='dump', type=str) parser.add_argument('--sleep', dest='sleep', type=int) parser.add_argument('--subscribe', dest='ntf', type=str) + parser.add_argument('--replace', dest='flags', action='append_const', + const=Netlink.NLM_F_REPLACE) + parser.add_argument('--excl', dest='flags', action='append_const', + const=Netlink.NLM_F_EXCL) + parser.add_argument('--create', dest='flags', action='append_const', + const=Netlink.NLM_F_CREATE) + parser.add_argument('--append', dest='flags', action='append_const', + const=Netlink.NLM_F_APPEND) args = parser.parse_args() if args.no_schema: @@ -37,7 +45,7 @@ def main(): time.sleep(args.sleep) if args.do: - reply = ynl.do(args.do, attrs) + reply = ynl.do(args.do, attrs, args.flags) pprint.PrettyPrinter().pprint(reply) if args.dump: reply = ynl.dump(args.dump, attrs) diff --git a/tools/net/ynl/lib/__init__.py b/tools/net/ynl/lib/__init__.py index 4b3797fe784b..f7eaa07783e7 100644 --- a/tools/net/ynl/lib/__init__.py +++ b/tools/net/ynl/lib/__init__.py @@ -2,7 +2,7 @@ from .nlspec import SpecAttr, SpecAttrSet, SpecEnumEntry, SpecEnumSet, \ SpecFamily, SpecOperation -from .ynl import YnlFamily +from .ynl import YnlFamily, Netlink __all__ = ["SpecAttr", "SpecAttrSet", "SpecEnumEntry", "SpecEnumSet", - "SpecFamily", "SpecOperation", "YnlFamily"] + "SpecFamily", "SpecOperation", "YnlFamily", "Netlink"] diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index 5d04a2b5fc78..484b42354ae7 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -35,6 +35,10 @@ class Netlink: NLM_F_ACK = 4 NLM_F_ROOT = 0x100 NLM_F_MATCH = 0x200 + + NLM_F_REPLACE = 0x100 + NLM_F_EXCL = 0x200 + NLM_F_CREATE = 0x400 NLM_F_APPEND = 0x800 NLM_F_CAPPED = 0x100 @@ -649,10 +653,12 @@ class YnlFamily(SpecFamily): return op['do']['request']['attributes'].copy() - def _op(self, method, vals, dump=False): + def _op(self, method, vals, flags, dump=False): op = self.ops[method] nl_flags = Netlink.NLM_F_REQUEST | Netlink.NLM_F_ACK + for flag in flags or []: + nl_flags |= flag if dump: nl_flags |= Netlink.NLM_F_DUMP @@ -711,8 +717,8 @@ class YnlFamily(SpecFamily): return rsp[0] return rsp - def do(self, method, vals): - return self._op(method, vals) + def do(self, method, vals, flags): + return self._op(method, vals, flags) def dump(self, method, vals): - return self._op(method, vals, dump=True) + return self._op(method, vals, [], dump=True) From patchwork Thu Aug 24 11:20:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13364004 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1DF212B61 for ; Thu, 24 Aug 2023 11:20:32 +0000 (UTC) Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D108173F; Thu, 24 Aug 2023 04:20:28 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-31ae6bf91a9so5310867f8f.2; Thu, 24 Aug 2023 04:20:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692876026; x=1693480826; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1k2c+S87WCB4lJiVUlOWTjysEI6jQeXql9esC75zLPA=; b=DYWZZ/NFpJhi3t35abTx240wv8PDExMsNsZ16K4vi0EKJhV/WMvFPwiuWq2UiGF+zs Tmf2sTCL8xk40l0KJ7H8RA0NVcUbboo40qxOwfawAJUzzt+J4WbmWyMUP/ZAhAioKj6f FXj74X5zurIKc+kGa5l8JW/EH9xDIpTpm4LfSuLZX+JlerdCxQEkqS/0hrhrCH/67cJf l/rAXUlQCjASO+KBWp7wdczf9+QVCVVddR+bQaDaBFP9QwOAhK7kti2kM3jT5TlElKOL 9lOfvBXJKv2L9AurSCK6wBVnw7arn2dxR/cReEvuqO+i9cfJ4WG1mm2SWo1F1ymC3pIq TogQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692876026; x=1693480826; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1k2c+S87WCB4lJiVUlOWTjysEI6jQeXql9esC75zLPA=; b=K6eEu73uR629uSS/3seUfVc4F6OcAZob5i/1xibtf7rYqSe9lZz7pVT2li0nQOZMRw ESkdz4dNDf491ZWy9sZDzi79UfavFIOVCdWXiilODnd2I5dAHR+uKsu4NZutUpij5F5k TFKyKeOvwd8YuaAQSJMKKAthg4oSTwgk7eyOfPinHWRZgpWvPcT72/Y95kKWXPGeqj2L IEVmvWoiB2KsiA4QjoKuIRcDLo5Ym/blCYYE8ujq4LNmc0n75ZnVN+RZZWllyMaBUPiK NCDPOTPEqUmlp9lrx661/LnWYxwLF7CGU7W51oTDzwgCioMMn0JQhKO71TfcCe3rT1Le qajA== X-Gm-Message-State: AOJu0YwHTf0zwBnY6cQcUNS0O17RxbgAZRJ2RR+QPdXVvD5I9+bCMXoQ xMrVsrr9z4CkwEHUFdVSoSHdTZKoD9WxlQ== X-Google-Smtp-Source: AGHT+IHlaqzCazPZzYK4L2tWHizJqDVc8RQ2/ZfF8xIpRCP7thmE8uOg2mZHuIh2Jm2snQZObma28A== X-Received: by 2002:a5d:4904:0:b0:317:4cf8:35f9 with SMTP id x4-20020a5d4904000000b003174cf835f9mr10569729wrq.16.1692876026607; Thu, 24 Aug 2023 04:20:26 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:1a5:1436:c34c:226]) by smtp.gmail.com with ESMTPSA id i14-20020a5d630e000000b0031980783d78sm21875295wru.54.2023.08.24.04.20.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 04:20:26 -0700 (PDT) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , linux-doc@vger.kernel.org, Stanislav Fomichev , Arkadiusz Kubalewski Cc: donald.hunter@redhat.com, Donald Hunter , Jacob Keller Subject: [PATCH net-next v5 10/12] doc/netlink: Add spec for rt addr messages Date: Thu, 24 Aug 2023 12:20:01 +0100 Message-ID: <20230824112003.52939-11-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824112003.52939-1-donald.hunter@gmail.com> References: <20230824112003.52939-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add schema for rt addr with support for: - newaddr, deladdr, getaddr (dump) Signed-off-by: Donald Hunter Reviewed-by: Jacob Keller --- Documentation/netlink/specs/rt_addr.yaml | 179 +++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 Documentation/netlink/specs/rt_addr.yaml diff --git a/Documentation/netlink/specs/rt_addr.yaml b/Documentation/netlink/specs/rt_addr.yaml new file mode 100644 index 000000000000..cbee1cedb177 --- /dev/null +++ b/Documentation/netlink/specs/rt_addr.yaml @@ -0,0 +1,179 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) + +name: rt-addr +protocol: netlink-raw +protonum: 0 + +doc: + Address configuration over rtnetlink. + +definitions: + - + name: ifaddrmsg + type: struct + members: + - + name: ifa-family + type: u8 + - + name: ifa-prefixlen + type: u8 + - + name: ifa-flags + type: u8 + enum: ifa-flags + enum-as-flags: true + - + name: ifa-scope + type: u8 + - + name: ifa-index + type: u32 + - + name: ifa-cacheinfo + type: struct + members: + - + name: ifa-prefered + type: u32 + - + name: ifa-valid + type: u32 + - + name: cstamp + type: u32 + - + name: tstamp + type: u32 + + - + name: ifa-flags + type: flags + entries: + - + name: secondary + - + name: nodad + - + name: optimistic + - + name: dadfailed + - + name: homeaddress + - + name: deprecated + - + name: tentative + - + name: permanent + - + name: managetempaddr + - + name: noprefixroute + - + name: mcautojoin + - + name: stable-privacy + +attribute-sets: + - + name: addr-attrs + attributes: + - + name: ifa-address + type: binary + display-hint: ipv4 + - + name: ifa-local + type: binary + display-hint: ipv4 + - + name: ifa-label + type: string + - + name: ifa-broadcast + type: binary + display-hint: ipv4 + - + name: ifa-anycast + type: binary + - + name: ifa-cacheinfo + type: binary + struct: ifa-cacheinfo + - + name: ifa-multicast + type: binary + - + name: ifa-flags + type: u32 + enum: ifa-flags + enum-as-flags: true + - + name: ifa-rt-priority + type: u32 + - + name: ifa-target-netnsid + type: binary + - + name: ifa-proto + type: u8 + + +operations: + fixed-header: ifaddrmsg + enum-model: directional + list: + - + name: newaddr + doc: Add new address + attribute-set: addr-attrs + do: + request: + value: 20 + attributes: &ifaddr-all + - ifa-family + - ifa-flags + - ifa-prefixlen + - ifa-scope + - ifa-index + - ifa-address + - ifa-label + - ifa-local + - ifa-cacheinfo + - + name: deladdr + doc: Remove address + attribute-set: addr-attrs + do: + request: + value: 21 + attributes: + - ifa-family + - ifa-flags + - ifa-prefixlen + - ifa-scope + - ifa-index + - ifa-address + - ifa-local + - + name: getaddr + doc: Dump address information. + attribute-set: addr-attrs + dump: + request: + value: 22 + attributes: + - ifa-index + reply: + value: 20 + attributes: *ifaddr-all + +mcast-groups: + list: + - + name: rtnlgrp-ipv4-ifaddr + value: 5 + - + name: rtnlgrp-ipv6-ifaddr + value: 9 From patchwork Thu Aug 24 11:20:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13364006 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF2A2134A0 for ; Thu, 24 Aug 2023 11:20:36 +0000 (UTC) Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D02D19A6; Thu, 24 Aug 2023 04:20:30 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3fed963273cso4684735e9.1; Thu, 24 Aug 2023 04:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692876028; x=1693480828; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f8iIAHi3lFfN0udMRzFXyr4NBWLHe3jhbTAPRyW9SKM=; b=db3PBPj+M/FtPBOE96mc48hjJV8DbtqE6cOhH6os66ZJYJbIYv/11QW2b70erZJbp4 1p3ECBtTKTEYlKPj0smr0I6chbNTgIPupqupeIsWWbvAbB77CLNPIp/zeM4Ay3UhBMHS RWHFjFzkAH0B+mM8Hzsl5GisdlSQ2wWZYCotTytI+3+GwbHGqlOngHv7B8mowkmtX25B XylQp6po6wS4jADq4J64BdutgrlKYgkTw+97Ov66GHiDB4q70DeinYI/aLprKgYy0AI2 7c6Hw2iV+RHSMSjmiiJzkUTzpJXlxn1CAuWVdUrb8JMlt15QNcImxiMjEazNs4EXaM+8 hckQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692876028; x=1693480828; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f8iIAHi3lFfN0udMRzFXyr4NBWLHe3jhbTAPRyW9SKM=; b=LJA9WQ2o/1qYNQGlMUmyMzpoYfP/0e0ptB0dHfATXOHsCUApgY3r1HMs091jEhKKvc oQnwxFExgcK8tFhdbd06eGwWZiJP4qCNt+WFR3Dq4cg7c6z9ucooz90JA+fAVt5xV9Rv ZJTf0YFwKQaBl1M9sBBeJ2AXlpQOhBHo1qW40YhgjzHSO2DmEjq3e+OynB4CncCTQGXv Hf6cvpBKjFrfyAf4QYxLUD/FSX7LJoaVOjzEhQqDH7yVP0g7adqJNvQvtuB2xGy61qHS +Uif/AdnEe7DlYrlfcM7l8IZeDmgiNz3o4U4DCsVj4LR3a13pnuAO7IUM0wTVTp6V0/N NmwA== X-Gm-Message-State: AOJu0YzJ8U3rjAPJCf1jsQRjvPyaUMMGDlhmxIJRJP2/oj2T8IjZhYqq LPI0Puo+lHK1lboUv3l9x/hO7ZeCm+/vLA== X-Google-Smtp-Source: AGHT+IHR0DwHixf+iB5Zvtd3nYmMzGdwvomjWv6a13fEtNb/MjfDC2D8yOWxMvGzreb1S+ISGYdV/g== X-Received: by 2002:adf:f9c4:0:b0:319:7abb:4112 with SMTP id w4-20020adff9c4000000b003197abb4112mr13223153wrr.21.1692876028001; Thu, 24 Aug 2023 04:20:28 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:1a5:1436:c34c:226]) by smtp.gmail.com with ESMTPSA id i14-20020a5d630e000000b0031980783d78sm21875295wru.54.2023.08.24.04.20.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 04:20:27 -0700 (PDT) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , linux-doc@vger.kernel.org, Stanislav Fomichev , Arkadiusz Kubalewski Cc: donald.hunter@redhat.com, Donald Hunter , Jacob Keller Subject: [PATCH net-next v5 11/12] doc/netlink: Add spec for rt link messages Date: Thu, 24 Aug 2023 12:20:02 +0100 Message-ID: <20230824112003.52939-12-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824112003.52939-1-donald.hunter@gmail.com> References: <20230824112003.52939-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add schema for rt link with support for newlink, dellink, getlink, setlink and getstats. A dummy link can be created like this: sudo ./tools/net/ynl/cli.py \ --spec Documentation/netlink/specs/rt_link.yaml \ --do newlink --create \ --json '{"ifname": "dummy0", "linkinfo": {"kind": "dummy"}}' For example, offload stats can be fetched like this: ./tools/net/ynl/cli.py \ --spec Documentation/netlink/specs/rt_link.yaml \ --dump getstats --json '{ "filter-mask": 8 }' Signed-off-by: Donald Hunter Reviewed-by: Jacob Keller --- Documentation/netlink/specs/rt_link.yaml | 1499 ++++++++++++++++++++++ 1 file changed, 1499 insertions(+) create mode 100644 Documentation/netlink/specs/rt_link.yaml diff --git a/Documentation/netlink/specs/rt_link.yaml b/Documentation/netlink/specs/rt_link.yaml new file mode 100644 index 000000000000..794125c8ed71 --- /dev/null +++ b/Documentation/netlink/specs/rt_link.yaml @@ -0,0 +1,1499 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) + +name: rt-link +protocol: netlink-raw +protonum: 0 + +doc: + Link configuration over rtnetlink. + +definitions: + - + name: ifinfo-flags + type: flags + entries: + - + name: up + - + name: broadcast + - + name: debug + - + name: loopback + - + name: point-to-point + - + name: no-trailers + - + name: running + - + name: no-arp + - + name: promisc + - + name: all-multi + - + name: master + - + name: slave + - + name: multicast + - + name: portsel + - + name: auto-media + - + name: dynamic + - + name: lower-up + - + name: dormant + - + name: echo + + - + name: rtgenmsg + type: struct + members: + - + name: family + type: u8 + - + name: ifinfomsg + type: struct + members: + - + name: ifi-family + type: u8 + - + name: padding + type: u8 + - + name: ifi-type + type: u16 + - + name: ifi-index + type: s32 + - + name: ifi-flags + type: u32 + enum: ifinfo-flags + enum-as-flags: true + - + name: ifi-change + type: u32 + - + name: ifla-cacheinfo + type: struct + members: + - + name: max-reasm-len + type: u32 + - + name: tstamp + type: u32 + - + name: reachable-time + type: s32 + - + name: retrans-time + type: u32 + - + name: rtnl-link-stats + type: struct + members: + - + name: rx-packets + type: u32 + - + name: tx-packets + type: u32 + - + name: rx-bytes + type: u32 + - + name: tx-bytes + type: u32 + - + name: rx-errors + type: u32 + - + name: tx-errors + type: u32 + - + name: rx-dropped + type: u32 + - + name: tx-dropped + type: u32 + - + name: multicast + type: u32 + - + name: collisions + type: u32 + - + name: rx-length-errors + type: u32 + - + name: rx-over-errors + type: u32 + - + name: rx-crc-errors + type: u32 + - + name: rx-frame-errors + type: u32 + - + name: rx-fifo-errors + type: u32 + - + name: rx-missed-errors + type: u32 + - + name: tx-aborted-errors + type: u32 + - + name: tx-carrier-errors + type: u32 + - + name: tx-fifo-errors + type: u32 + - + name: tx-heartbeat-errors + type: u32 + - + name: tx-window-errors + type: u32 + - + name: rx-compressed + type: u32 + - + name: tx-compressed + type: u32 + - + name: rx-nohandler + type: u32 + - + name: rtnl-link-stats64 + type: struct + members: + - + name: rx-packets + type: u64 + - + name: tx-packets + type: u64 + - + name: rx-bytes + type: u64 + - + name: tx-bytes + type: u64 + - + name: rx-errors + type: u64 + - + name: tx-errors + type: u64 + - + name: rx-dropped + type: u64 + - + name: tx-dropped + type: u64 + - + name: multicast + type: u64 + - + name: collisions + type: u64 + - + name: rx-length-errors + type: u64 + - + name: rx-over-errors + type: u64 + - + name: rx-crc-errors + type: u64 + - + name: rx-frame-errors + type: u64 + - + name: rx-fifo-errors + type: u64 + - + name: rx-missed-errors + type: u64 + - + name: tx-aborted-errors + type: u64 + - + name: tx-carrier-errors + type: u64 + - + name: tx-fifo-errors + type: u64 + - + name: tx-heartbeat-errors + type: u64 + - + name: tx-window-errors + type: u64 + - + name: rx-compressed + type: u64 + - + name: tx-compressed + type: u64 + - + name: rx-nohandler + type: u64 + - + name: rx-otherhost-dropped + type: u64 + - + name: rtnl-link-ifmap + type: struct + members: + - + name: mem-start + type: u64 + - + name: mem-end + type: u64 + - + name: base-addr + type: u64 + - + name: irq + type: u16 + - + name: dma + type: u8 + - + name: port + type: u8 + - + name: ipv4-devconf + type: struct + members: + - + name: forwarding + type: u32 + - + name: mc-forwarding + type: u32 + - + name: proxy-arp + type: u32 + - + name: accept-redirects + type: u32 + - + name: secure-redirects + type: u32 + - + name: send-redirects + type: u32 + - + name: shared-media + type: u32 + - + name: rp-filter + type: u32 + - + name: accept-source-route + type: u32 + - + name: bootp-relay + type: u32 + - + name: log-martians + type: u32 + - + name: tag + type: u32 + - + name: arpfilter + type: u32 + - + name: medium-id + type: u32 + - + name: noxfrm + type: u32 + - + name: nopolicy + type: u32 + - + name: force-igmp-version + type: u32 + - + name: arp-announce + type: u32 + - + name: arp-ignore + type: u32 + - + name: promote-secondaries + type: u32 + - + name: arp-accept + type: u32 + - + name: arp-notify + type: u32 + - + name: accept-local + type: u32 + - + name: src-vmark + type: u32 + - + name: proxy-arp-pvlan + type: u32 + - + name: route-localnet + type: u32 + - + name: igmpv2-unsolicited-report-interval + type: u32 + - + name: igmpv3-unsolicited-report-interval + type: u32 + - + name: ignore-routes-with-linkdown + type: u32 + - + name: drop-unicast-in-l2-multicast + type: u32 + - + name: drop-gratuitous-arp + type: u32 + - + name: bc-forwarding + type: u32 + - + name: arp-evict-nocarrier + type: u32 + - + name: ipv6-devconf + type: struct + members: + - + name: forwarding + type: u32 + - + name: hoplimit + type: u32 + - + name: mtu6 + type: u32 + - + name: accept-ra + type: u32 + - + name: accept-redirects + type: u32 + - + name: autoconf + type: u32 + - + name: dad-transmits + type: u32 + - + name: rtr-solicits + type: u32 + - + name: rtr-solicit-interval + type: u32 + - + name: rtr-solicit-delay + type: u32 + - + name: use-tempaddr + type: u32 + - + name: temp-valid-lft + type: u32 + - + name: temp-prefered-lft + type: u32 + - + name: regen-max-retry + type: u32 + - + name: max-desync-factor + type: u32 + - + name: max-addresses + type: u32 + - + name: force-mld-version + type: u32 + - + name: accept-ra-defrtr + type: u32 + - + name: accept-ra-pinfo + type: u32 + - + name: accept-ra-rtr-pref + type: u32 + - + name: rtr-probe-interval + type: u32 + - + name: accept-ra-rt-info-max-plen + type: u32 + - + name: proxy-ndp + type: u32 + - + name: optimistic-dad + type: u32 + - + name: accept-source-route + type: u32 + - + name: mc-forwarding + type: u32 + - + name: disable-ipv6 + type: u32 + - + name: accept-dad + type: u32 + - + name: force-tllao + type: u32 + - + name: ndisc-notify + type: u32 + - + name: mldv1-unsolicited-report-interval + type: u32 + - + name: mldv2-unsolicited-report-interval + type: u32 + - + name: suppress-frag-ndisc + type: u32 + - + name: accept-ra-from-local + type: u32 + - + name: use-optimistic + type: u32 + - + name: accept-ra-mtu + type: u32 + - + name: stable-secret + type: u32 + - + name: use-oif-addrs-only + type: u32 + - + name: accept-ra-min-hop-limit + type: u32 + - + name: ignore-routes-with-linkdown + type: u32 + - + name: drop-unicast-in-l2-multicast + type: u32 + - + name: drop-unsolicited-na + type: u32 + - + name: keep-addr-on-down + type: u32 + - + name: rtr-solicit-max-interval + type: u32 + - + name: seg6-enabled + type: u32 + - + name: seg6-require-hmac + type: u32 + - + name: enhanced-dad + type: u32 + - + name: addr-gen-mode + type: u32 + - + name: disable-policy + type: u32 + - + name: accept-ra-rt-info-min-plen + type: u32 + - + name: ndisc-tclass + type: u32 + - + name: rpl-seg-enabled + type: u32 + - + name: ra-defrtr-metric + type: u32 + - + name: ioam6-enabled + type: u32 + - + name: ioam6-id + type: u32 + - + name: ioam6-id-wide + type: u32 + - + name: ndisc-evict-nocarrier + type: u32 + - + name: accept-untracked-na + type: u32 + - + name: ifla-icmp6-stats + type: struct + members: + - + name: inmsgs + type: u64 + - + name: inerrors + type: u64 + - + name: outmsgs + type: u64 + - + name: outerrors + type: u64 + - + name: csumerrors + type: u64 + - + name: ratelimithost + type: u64 + - + name: ifla-inet6-stats + type: struct + members: + - + name: inpkts + type: u64 + - + name: inoctets + type: u64 + - + name: indelivers + type: u64 + - + name: outforwdatagrams + type: u64 + - + name: outpkts + type: u64 + - + name: outoctets + type: u64 + - + name: inhdrerrors + type: u64 + - + name: intoobigerrors + type: u64 + - + name: innoroutes + type: u64 + - + name: inaddrerrors + type: u64 + - + name: inunknownprotos + type: u64 + - + name: intruncatedpkts + type: u64 + - + name: indiscards + type: u64 + - + name: outdiscards + type: u64 + - + name: outnoroutes + type: u64 + - + name: reasmtimeout + type: u64 + - + name: reasmreqds + type: u64 + - + name: reasmoks + type: u64 + - + name: reasmfails + type: u64 + - + name: fragoks + type: u64 + - + name: fragfails + type: u64 + - + name: fragcreates + type: u64 + - + name: inmcastpkts + type: u64 + - + name: outmcastpkts + type: u64 + - + name: inbcastpkts + type: u64 + - + name: outbcastpkts + type: u64 + - + name: inmcastoctets + type: u64 + - + name: outmcastoctets + type: u64 + - + name: inbcastoctets + type: u64 + - + name: outbcastoctets + type: u64 + - + name: csumerrors + type: u64 + - + name: noectpkts + type: u64 + - + name: ect1-pkts + type: u64 + - + name: ect0-pkts + type: u64 + - + name: cepkts + type: u64 + - + name: reasm-overlaps + type: u64 + - name: br-boolopt-multi + type: struct + members: + - + name: optval + type: u32 + - + name: optmask + type: u32 + - + name: if_stats_msg + type: struct + members: + - + name: family + type: u8 + - + name: pad1 + type: u8 + - + name: pad2 + type: u16 + - + name: ifindex + type: u32 + - + name: filter-mask + type: u32 + + +attribute-sets: + - + name: link-attrs + name-prefix: ifla- + attributes: + - + name: address + type: binary + display-hint: mac + value: 1 + - + name: broadcast + type: binary + display-hint: mac + value: 2 + - + name: ifname + type: string + value: 3 + - + name: mtu + type: u32 + value: 4 + - + name: link + type: u32 + value: 5 + - + name: qdisc + type: string + value: 6 + - + name: stats + type: binary + value: 7 + struct: rtnl-link-stats + - + name: cost + type: string + value: 8 + - + name: priority + type: string + value: 9 + - + name: master + type: u32 + value: 10 + - + name: wireless + type: string + value: 11 + - + name: protinfo + type: string + value: 12 + - + name: txqlen + type: u32 + value: 13 + - + name: map + type: binary + value: 14 + struct: rtnl-link-ifmap + - + name: weight + type: u32 + value: 15 + - + name: operstate + type: u8 + value: 16 + - + name: linkmode + type: u8 + value: 17 + - + name: linkinfo + type: nest + value: 18 + nested-attributes: linkinfo-attrs + - + name: net-ns-pid + type: u32 + value: 19 + - + name: ifalias + type: string + value: 20 + - + name: num-vf + type: u32 + value: 21 + - + name: vfinfo-list + type: nest + value: 22 + nested-attributes: vfinfo-attrs + - + name: stats64 + type: binary + value: 23 + struct: rtnl-link-stats64 + - + name: vf-ports + type: nest + value: 24 + nested-attributes: vf-ports-attrs + - + name: port-self + type: nest + value: 25 + nested-attributes: port-self-attrs + - + name: af-spec + type: nest + value: 26 + nested-attributes: af-spec-attrs + - + name: group + type: u32 + value: 27 + - + name: net-ns-fd + type: u32 + value: 28 + - + name: ext-mask + type: u32 + value: 29 + - + name: promiscuity + type: u32 + value: 30 + - + name: num-tx-queues + type: u32 + value: 31 + - + name: num-rx-queues + type: u32 + value: 32 + - + name: carrier + type: u8 + value: 33 + - + name: phys-port-id + type: binary + value: 34 + - + name: carrier-changes + type: u32 + value: 35 + - + name: phys-switch-id + type: binary + value: 36 + - + name: link-netnsid + type: s32 + value: 37 + - + name: phys-port-name + type: string + value: 38 + - + name: proto-down + type: u8 + value: 39 + - + name: gso-max-segs + type: u32 + value: 40 + - + name: gso-max-size + type: u32 + value: 41 + - + name: pad + type: string + value: 42 + - + name: xdp + type: nest + value: 43 + nested-attributes: xdp-attrs + - + name: event + type: u32 + value: 44 + - + name: new-netnsid + type: s32 + value: 45 + - + name: if-netnsid + type: s32 + value: 46 + - + name: target-netnsid + type: s32 + value: 46 + - + name: carrier-up-count + type: u32 + value: 47 + - + name: carrier-down-count + type: u32 + value: 48 + - + name: new-ifindex + type: s32 + value: 49 + - + name: min-mtu + type: u32 + value: 50 + - + name: max-mtu + type: u32 + value: 51 + - + name: prop-list + type: nest + nested-attributes: link-attrs + value: 52 + - + name: alt-ifname + type: string + multi-attr: true + value: 53 + - + name: perm-address + type: binary + display-hint: mac + value: 54 + - + name: proto-down-reason + type: string + value: 55 + - + name: parent-dev-name + type: string + value: 56 + - + name: parent-dev-bus-name + type: string + value: 57 + - + name: gro-max-size + type: u32 + value: 58 + - + name: tso-max-size + type: u32 + value: 59 + - + name: tso-max-segs + type: u32 + value: 60 + - + name: allmulti + type: u32 + - + name: devlink-port + type: binary + - + name: gso-ipv4-max-size + type: u32 + - + name: gro-ipv4-max-size + type: u32 + - + name: af-spec-attrs + attributes: + - + name: "inet" + type: nest + value: 2 + nested-attributes: ifla-attrs + - + name: "inet6" + type: nest + value: 10 + nested-attributes: ifla6-attrs + - + name: "mctp" + type: nest + value: 45 + nested-attributes: mctp-attrs + - + name: vfinfo-attrs + attributes: [] + - + name: vf-ports-attrs + attributes: [] + - + name: port-self-attrs + attributes: [] + - + name: linkinfo-attrs + attributes: + - + name: kind + type: string + - + name: data + type: binary + nested-attributes: linkinfo-bridge-attrs + - + name: xstats + type: binary + - + name: slave-kind + type: string + - + name: slave-data + type: nest + nested-attributes: linkinfo-slave-data-attrs + - + name: linkinfo-bridge-attrs + attributes: + - + name: forward-delay + type: u32 + - + name: hello-time + type: u32 + - + name: max-age + type: u32 + - + name: ageing-time + type: u32 + - + name: stp-state + type: u32 + - + name: priority + type: u16 + - + name: vlan-filtering + type: u8 + - + name: vlan-protocol + type: u16 + - + name: group-fwd-mask + type: u16 + - + name: root-id + type: binary + - + name: bridge-id + type: binary + - + name: root-port + type: u16 + - + name: root-path-cost + type: u32 + - + name: topology-change + type: u8 + - + name: topology-change-detected + type: u8 + - + name: hello-timer + type: u64 + - + name: tcn-timer + type: u64 + - + name: topology-change-timer + type: u64 + - + name: gc-timer + type: u64 + - + name: group-addr + type: binary + - + name: fdb-flush + type: binary + - + name: mcast-router + type: u8 + - + name: mcast-snooping + type: u8 + - + name: mcast-query-use-ifaddr + type: u8 + - + name: mcast-querier + type: u8 + - + name: mcast-hash-elasticity + type: u32 + - + name: mcast-hash-max + type: u32 + - + name: mcast-last-member-cnt + type: u32 + - + name: mcast-startup-query-cnt + type: u32 + - + name: mcast-last-member-intvl + type: u64 + - + name: mcast-membership-intvl + type: u64 + - + name: mcast-querier-intvl + type: u64 + - + name: mcast-query-intvl + type: u64 + - + name: mcast-query-response-intvl + type: u64 + - + name: mcast-startup-query-intvl + type: u64 + - + name: nf-call-iptables + type: u8 + - + name: nf-call-ip6-tables + type: u8 + - + name: nf-call-arptables + type: u8 + - + name: vlan-default-pvid + type: u16 + - + name: pad + type: u32 + - + name: vlan-stats-enabled + type: u8 + - + name: mcast-stats-enabled + type: u8 + - + name: mcast-igmp-version + type: u8 + - + name: mcast-mld-version + type: u8 + - + name: vlan-stats-per-port + type: u8 + - + name: multi-boolopt + type: binary + struct: br-boolopt-multi + - + name: mcast-querier-state + type: binary + - + name: linkinfo-slave-data-attrs + attributes: [] + - + name: xdp-attrs + attributes: + - + name: fd + type: s32 + - + name: attached + type: u8 + - + name: flags + type: u32 + - + name: prog-id + type: u32 + - + name: drv-prog-id + type: u32 + - + name: skb-prog-id + type: u32 + - + name: hw-prog-id + type: u32 + - + name: expected-fd + type: s32 + - + name: ifla-attrs + attributes: + - + name: conf + type: binary + struct: ipv4-devconf + - + name: ifla6-attrs + attributes: + - + name: flags + type: u32 + - + name: conf + type: binary + struct: ipv6-devconf + - + name: stats + type: binary + struct: ifla-inet6-stats + - + name: mcast + type: binary + - + name: cacheinfo + type: binary + struct: ifla-cacheinfo + - + name: icmp6-stats + type: binary + struct: ifla-icmp6-stats + - + name: token + type: binary + - + name: addr-gen-mode + type: u8 + - + name: ra-mtu + type: u32 + - + name: mctp-attrs + attributes: + - + name: mctp-net + type: u32 + - + name: stats-attrs + name-prefix: ifla-stats- + attributes: + - + name: link-64 + type: binary + struct: rtnl-link-stats64 + - + name: link-xstats + type: binary + - + name: link-xstats-slave + type: binary + - + name: link-offload-xstats + type: nest + nested-attributes: link-offload-xstats + - + name: af-spec + type: binary + - + name: link-offload-xstats + attributes: + - + name: cpu-hit + type: binary + - + name: hw-s-info + type: array-nest + nested-attributes: hw-s-info-one + - + name: l3-stats + type: binary + - + name: hw-s-info-one + attributes: + - + name: request + type: u8 + - + name: used + type: u8 + +operations: + enum-model: directional + list: + - + name: newlink + doc: Create a new link. + attribute-set: link-attrs + fixed-header: ifinfomsg + do: + request: + value: 16 + attributes: &link-new-attrs + - ifi-index + - ifname + - net-ns-pid + - net-ns-fd + - target-netnsid + - link-netnsid + - linkinfo + - group + - num-tx-queues + - num-rx-queues + - address + - broadcast + - mtu + - txqlen + - operstate + - linkmode + - group + - gso-max-size + - gso-max-segs + - gro-max-size + - gso-ipv4-max-size + - gro-ipv4-max-size + - af-spec + - + name: dellink + doc: Delete an existing link. + attribute-set: link-attrs + fixed-header: ifinfomsg + do: + request: + value: 17 + attributes: + - ifi-index + - ifname + - + name: getlink + doc: Get / dump information about a link. + attribute-set: link-attrs + fixed-header: ifinfomsg + do: + request: + value: 18 + attributes: + - ifi-index + - ifname + - alt-ifname + - ext-mask + - target-netnsid + reply: + value: 16 + attributes: &link-all-attrs + - ifi-family + - ifi-type + - ifi-index + - ifi-flags + - ifi-change + - address + - broadcast + - ifname + - mtu + - link + - qdisc + - stats + - cost + - priority + - master + - wireless + - protinfo + - txqlen + - map + - weight + - operstate + - linkmode + - linkinfo + - net-ns-pid + - ifalias + - num-vf + - vfinfo-list + - stats64 + - vf-ports + - port-self + - af-spec + - group + - net-ns-fd + - ext-mask + - promiscuity + - num-tx-queues + - num-rx-queues + - carrier + - phys-port-id + - carrier-changes + - phys-switch-id + - link-netnsid + - phys-port-name + - proto-down + - gso-max-segs + - gso-max-size + - pad + - xdp + - event + - new-netnsid + - if-netnsid + - target-netnsid + - carrier-up-count + - carrier-down-count + - new-ifindex + - min-mtu + - max-mtu + - prop-list + - alt-ifname + - perm-address + - proto-down-reason + - parent-dev-name + - parent-dev-bus-name + - gro-max-size + - tso-max-size + - tso-max-segs + - allmulti + - devlink-port + - gso-ipv4-max-size + - gro-ipv4-max-size + dump: + request: + value: 18 + attributes: + - target-netnsid + - ext-mask + - master + - linkinfo + reply: + value: 16 + attributes: *link-all-attrs + - + name: setlink + doc: Set information about a link. + attribute-set: link-attrs + fixed-header: ifinfomsg + do: + request: + value: 19 + attributes: *link-all-attrs + - + name: getstats + doc: Get / dump link stats. + attribute-set: stats-attrs + fixed-header: if_stats_msg + do: + request: + value: 94 + attributes: + - ifindex + reply: + value: 92 + attributes: &link-stats-attrs + - family + - ifindex + - filter-mask + - link-64 + - link-xstats + - link-xstats-slave + - link-offload-xstats + - af-spec + dump: + request: + value: 94 + reply: + value: 92 + attributes: *link-stats-attrs + +mcast-groups: + list: + - + name: rtnlgrp-link + value: 1 + - + name: rtnlgrp-stats + value: 36 From patchwork Thu Aug 24 11:20:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13364005 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A292712B61 for ; Thu, 24 Aug 2023 11:20:36 +0000 (UTC) Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BD3710FA; Thu, 24 Aug 2023 04:20:31 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40061928e5aso12226605e9.3; Thu, 24 Aug 2023 04:20:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692876029; x=1693480829; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kjfqjRgnje5cPHodoqa0yOt9g/nnGOz6OtgeJ4an+9k=; b=HqT30jT9I9v3xPcWik2GUImh6yPXLn/am2J3XlAVKkRhYfcyx9PU9zKgb2ecXbF48w Xic8/FFID36/Xwf25gJmN+fQQHQj9OyPXZxdIdnePIcRP+3HM58wffeYe6qF3Naohl/7 4loSd3Ng7jyeRe2IU31671DQr3Qaipx3pOiyNxumnPougN4AJJjlbmwyPaVEIyq9gj6z rSclmXXb5MnwWIYKe2RY+fCT/iaw6I0LZudt/zRZu+8yZSrp8nYy+MpIiKc8JdG2iuqy zsYefw6qHg7TFoBizuLXff+wrdOaLWgY8pOTFMAThGKMIK3svKYARlfKaMKbXmzUZRsk x8Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692876029; x=1693480829; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kjfqjRgnje5cPHodoqa0yOt9g/nnGOz6OtgeJ4an+9k=; b=VRBW5TcbVVv8HHafAvTa/FcqvohLVj//8bcSX+54xQovIm5f+yRnSSVf/Cs1HmbW9/ rco/ToYq/CBqsXgBkO+T7pgz8iP2BhsqjwwK9D2zuIQ79bTlra0ZFO/+VEC0xtvOUZ9W KoukWyB/UqnJxfAQIrNOgy+0DdpZQ+TQi/Q42SqFFK70RFBlSIU15O1SMkvDvmt0cjg9 SZjpaywzr26KGw871OSQy0LuYbfHPpZQxHOg17UatowI6wOgT6EclA9wtyXF0Xhk0DUA MJ2z/d/I5hQ8adl1/vP8Xs7LSL7R/f58xpjjfhGeYH3FKZk3N8y4GkbmJR1s3cS4tn4x CFGA== X-Gm-Message-State: AOJu0YyQnB1xvem2f3p9M4afz+lQVlwuvJZWiP72ka8vlhp4z/4K+IKe n6lJnrxojibj0xUsHki9OMBwlovWsVMzFQ== X-Google-Smtp-Source: AGHT+IH5Ayoui4udJ8Ix3BrhMUupuZ1s5VBVfc8o+t1Y0Wb7FmaYPn6LR1uJiBit938hAIKCu0ioNQ== X-Received: by 2002:a1c:ed09:0:b0:3f9:82f:bad1 with SMTP id l9-20020a1ced09000000b003f9082fbad1mr11689472wmh.40.1692876029300; Thu, 24 Aug 2023 04:20:29 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:1a5:1436:c34c:226]) by smtp.gmail.com with ESMTPSA id i14-20020a5d630e000000b0031980783d78sm21875295wru.54.2023.08.24.04.20.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 04:20:28 -0700 (PDT) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jonathan Corbet , linux-doc@vger.kernel.org, Stanislav Fomichev , Arkadiusz Kubalewski Cc: donald.hunter@redhat.com, Donald Hunter , Jacob Keller Subject: [PATCH net-next v5 12/12] doc/netlink: Add spec for rt route messages Date: Thu, 24 Aug 2023 12:20:03 +0100 Message-ID: <20230824112003.52939-13-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230824112003.52939-1-donald.hunter@gmail.com> References: <20230824112003.52939-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org Add schema for rt route with support for getroute, newroute and delroute. Routes can be dumped with filter attributes like this: ./tools/net/ynl/cli.py \ --spec Documentation/netlink/specs/rt_route.yaml \ --dump getroute --json '{"rtm-family": 2, "rtm-table": 254}' Signed-off-by: Donald Hunter Reviewed-by: Jacob Keller --- Documentation/netlink/specs/rt_route.yaml | 327 ++++++++++++++++++++++ 1 file changed, 327 insertions(+) create mode 100644 Documentation/netlink/specs/rt_route.yaml diff --git a/Documentation/netlink/specs/rt_route.yaml b/Documentation/netlink/specs/rt_route.yaml new file mode 100644 index 000000000000..f4368be0caed --- /dev/null +++ b/Documentation/netlink/specs/rt_route.yaml @@ -0,0 +1,327 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) + +name: rt-route +protocol: netlink-raw +protonum: 0 + +doc: + Route configuration over rtnetlink. + +definitions: + - + name: rtm-type + name-prefix: rtn- + type: enum + entries: + - unspec + - unicast + - local + - broadcast + - anycast + - multicast + - blackhole + - unreachable + - prohibit + - throw + - nat + - xresolve + - + name: rtmsg + type: struct + members: + - + name: rtm-family + type: u8 + - + name: rtm-dst-len + type: u8 + - + name: rtm-src-len + type: u8 + - + name: rtm-tos + type: u8 + - + name: rtm-table + type: u8 + - + name: rtm-protocol + type: u8 + - + name: rtm-scope + type: u8 + - + name: rtm-type + type: u8 + enum: rtm-type + - + name: rtm-flags + type: u32 + - + name: rta-cacheinfo + type: struct + members: + - + name: rta-clntref + type: u32 + - + name: rta-lastuse + type: u32 + - + name: rta-expires + type: u32 + - + name: rta-error + type: u32 + - + name: rta-used + type: u32 + +attribute-sets: + - + name: route-attrs + attributes: + - + name: rta-dst + type: binary + display-hint: ipv4 + - + name: rta-src + type: binary + display-hint: ipv4 + - + name: rta-iif + type: u32 + - + name: rta-oif + type: u32 + - + name: rta-gateway + type: binary + display-hint: ipv4 + - + name: rta-priority + type: u32 + - + name: rta-prefsrc + type: binary + display-hint: ipv4 + - + name: rta-metrics + type: nest + nested-attributes: rta-metrics + - + name: rta-multipath + type: binary + - + name: rta-protoinfo # not used + type: binary + - + name: rta-flow + type: u32 + - + name: rta-cacheinfo + type: binary + struct: rta-cacheinfo + - + name: rta-session # not used + type: binary + - + name: rta-mp-algo # not used + type: binary + - + name: rta-table + type: u32 + - + name: rta-mark + type: u32 + - + name: rta-mfc-stats + type: binary + - + name: rta-via + type: binary + - + name: rta-newdst + type: binary + - + name: rta-pref + type: u8 + - + name: rta-encap-type + type: u16 + - + name: rta-encap + type: binary # tunnel specific nest + - + name: rta-expires + type: u32 + - + name: rta-pad + type: binary + - + name: rta-uid + type: u32 + - + name: rta-ttl-propagate + type: u8 + - + name: rta-ip-proto + type: u8 + - + name: rta-sport + type: u16 + - + name: rta-dport + type: u16 + - + name: rta-nh-id + type: u32 + - + name: rta-metrics + attributes: + - + name: rtax-unspec + type: unused + value: 0 + - + name: rtax-lock + type: u32 + - + name: rtax-mtu + type: u32 + - + name: rtax-window + type: u32 + - + name: rtax-rtt + type: u32 + - + name: rtax-rttvar + type: u32 + - + name: rtax-ssthresh + type: u32 + - + name: rtax-cwnd + type: u32 + - + name: rtax-advmss + type: u32 + - + name: rtax-reordering + type: u32 + - + name: rtax-hoplimit + type: u32 + - + name: rtax-initcwnd + type: u32 + - + name: rtax-features + type: u32 + - + name: rtax-rto-min + type: u32 + - + name: rtax-initrwnd + type: u32 + - + name: rtax-quickack + type: u32 + - + name: rtax-cc-algo + type: string + - + name: rtax-fastopen-no-cookie + type: u32 + +operations: + enum-model: directional + list: + - + name: getroute + doc: Dump route information. + attribute-set: route-attrs + fixed-header: rtmsg + do: + request: + value: 26 + attributes: + - rtm-family + - rta-src + - rtm-src-len + - rta-dst + - rtm-dst-len + - rta-iif + - rta-oif + - rta-ip-proto + - rta-sport + - rta-dport + - rta-mark + - rta-uid + reply: + value: 24 + attributes: &all-route-attrs + - rtm-family + - rtm-dst-len + - rtm-src-len + - rtm-tos + - rtm-table + - rtm-protocol + - rtm-scope + - rtm-type + - rtm-flags + - rta-dst + - rta-src + - rta-iif + - rta-oif + - rta-gateway + - rta-priority + - rta-prefsrc + - rta-metrics + - rta-multipath + - rta-flow + - rta-cacheinfo + - rta-table + - rta-mark + - rta-mfc-stats + - rta-via + - rta-newdst + - rta-pref + - rta-encap-type + - rta-encap + - rta-expires + - rta-pad + - rta-uid + - rta-ttl-propagate + - rta-ip-proto + - rta-sport + - rta-dport + - rta-nh-id + dump: + request: + value: 26 + attributes: + - rtm-family + reply: + value: 24 + attributes: *all-route-attrs + - + name: newroute + doc: Create a new route + attribute-set: route-attrs + fixed-header: rtmsg + do: + request: + value: 24 + attributes: *all-route-attrs + - + name: delroute + doc: Delete an existing route + attribute-set: route-attrs + fixed-header: rtmsg + do: + request: + value: 25 + attributes: *all-route-attrs