From patchwork Tue Aug 15 19:42:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13354216 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 636EA18AE8 for ; Tue, 15 Aug 2023 19:43:36 +0000 (UTC) Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1552D10C1; Tue, 15 Aug 2023 12:43:34 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3178dd771ceso5116525f8f.2; Tue, 15 Aug 2023 12:43:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692128612; x=1692733412; 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=QnQ7XSvIHXwLuxrIq/EZ9Hip9Qu/5iyxqsG2XS50cdk=; b=aXscVsgdjriOo8KXg0LdiKAEghGJhUkO8L5h1f3+kS729hhd2zsPNzeStVTkBMoxtT 1etxj64pm1sx1PTvbvlL4R87X5gNjSFrKtEKhwierD0G0Z9xe5+y/AWFhVoyXVM3Cn0x NwxEnFZnx8L1LC46KLUAJYhYkRtiBhoyYPYIgJXLFytZiix/EYsg//jT/7hdwr1Vbrm1 r5qvfuh9O5mT036jUo+VUIHCi5qvk693WDneKvEHiIwMUdn7YZyYDMzQpMQ0uHAp6avQ 4nWnoosk7x/FB7p2LO5ZuwEDG8ULrGsdY7xxWHCnsQ5ZFXtYuXmDFWA42KORNWwgaMBU AONw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692128612; x=1692733412; 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=QnQ7XSvIHXwLuxrIq/EZ9Hip9Qu/5iyxqsG2XS50cdk=; b=hn7kU8wFZlQqUFoVhFtpB1EoAsH1nZWGOD5V1jmtxjoew3sFiib3CB3E2WecfxnLQT LpT7bBUl6MPMBA1naggsoHsD7zYuFxmK1LifEIWDSDbFLctU9Q30rmbpV6bZjOVjpejL NyXbJlLk9vfENPycZUSHaQ/KzznvsKc7ztl7eTqLz8g1Ks6mpXQHgmLIikbHf4wkX9Kv 0Gi3FBNSTcIBeuZCZghPmRKXG02U9ID4lL1MVBfEdOhrbkbaPFTJrh0zEH7t+AwkjdRe HCYHsAUYqg1oOgEUf4t555TW0/gfI3OkdrSSx10uz+fpRdY5LehIbn5fh2k56BZ1Gy0L y4xw== X-Gm-Message-State: AOJu0YyZDhl2zvYk5GjLge7qeOiicDhapo92NXgsKYYjByXTTn+luy9h fXLPhiwTn7c7YHdMnd5zduoauu9AXch9Fruq X-Google-Smtp-Source: AGHT+IHmXcMIlibNz25VibzdZ3BJBBrWchcsV7jhEpqOcnYR6qAgcGaWDCQK9G66gah6BR/B7vZing== X-Received: by 2002:adf:fdc7:0:b0:319:778f:be17 with SMTP id i7-20020adffdc7000000b00319778fbe17mr5060656wrs.49.1692128611876; Tue, 15 Aug 2023 12:43:31 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:9934:e2f7:cd0e:75a6]) by smtp.gmail.com with ESMTPSA id n16-20020a5d6610000000b003179d5aee67sm18814892wru.94.2023.08.15.12.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 12:43:31 -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 v2 01/10] doc/netlink: Add a schema for netlink-raw families Date: Tue, 15 Aug 2023 20:42:45 +0100 Message-ID: <20230815194254.89570-2-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815194254.89570-1-donald.hunter@gmail.com> References: <20230815194254.89570-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,URIBL_BLOCKED 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 additions: - a top-level protonum property, e.g. 0 (for NETLINK_ROUTE) - add netlink-raw to the list of protocols supported by the schema - add a value property to mcast-group definitions This schema is very similar to genetlink-legacy and I considered making the changes there and symlinking to it. On balance I felt that might be problematic for accurate schema validation. Signed-off-by: Donald Hunter --- Documentation/netlink/netlink-raw.yaml | 414 +++++++++++++++++++++++++ 1 file changed, 414 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..a5ec6f3e41cc --- /dev/null +++ b/Documentation/netlink/netlink-raw.yaml @@ -0,0 +1,414 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +%YAML 1.2 +--- +$id: http://kernel.org/schemas/netlink/genetlink-legacy.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 genetlink protocol +type: object +required: [ name, doc, attribute-sets, operations ] +additionalProperties: False +properties: + name: + description: Name of the genetlink family. + type: string + doc: + type: string + version: + description: Generic Netlink family version. Default is 1. + type: integer + minimum: 1 + protocol: + description: Schema compatibility level. Default is "genetlink". + enum: [ genetlink, genetlink-c, genetlink-legacy, 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 verion 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 Tue Aug 15 19:42:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13354215 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 72BC01805D for ; Tue, 15 Aug 2023 19:43:36 +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 4E36B10EC; Tue, 15 Aug 2023 12:43:35 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3178dd771ceso5116541f8f.2; Tue, 15 Aug 2023 12:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692128613; x=1692733413; 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=CZ6MSqKSG4VDbBY3Ml3NZpJP7+4pxYoFOTAuqiAIKcM=; b=HasmAn0dMuhojznORZajoyzRaW+8/M4knHqV6rYKfdwAUwmut4LqJsh9PDkB/Wq2is ud8nTtIANVSaASebAruGPVJMl7irX82sJXsulVY9ff5wXf2o02jPKJ76YAPxX1jlDng2 PIf+IGzT2iLxH3JEYE+gnfpuJSS2mGA+xJyIm5X/j2Yki82aP6wsbxtF5txb4shTzt1c kNGFJB9QRY8ii2M0lArHhbiqLQUC7eYFzAi+8HOIEYgaMq0zIeAf0aQv8qWcIJhs0Z52 y1vBbvPDV0nETSsHyct7EQcSgvlHPDSrykoilF27Y2inZBqsbwfi4DvW1EZgnNx+8gIa 1U4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692128613; x=1692733413; 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=CZ6MSqKSG4VDbBY3Ml3NZpJP7+4pxYoFOTAuqiAIKcM=; b=H2v583By0Fh/thm6tYdkdRY2N014SexMSeM0rtP/8WzPs+55rd9H1yCx8n7My4/JlG i1tFRBKNfaG/Gm96b37/mvnVee8hglYxuD+ujp3l9op5Bb+Rmb3jGTVqFUl4u9wJO3/T tBBywkKLp4dy4RseitPpWFnFAeUedZIjzhw9tSHgKPfSbfaCtBOH4uRkzCBqThK+BrRM HMKKALxNB0Y6yylJt2yGA6myhl5P8H4YvMmPct5SDQLyg1p5cj4UBjihRUwRY+2sxZwl zas0prWBrot3GgNnipEK01sDNuFqlKN6MtbJ7eW0gL1vhA3d4gqdxnVcCvywxB8AnrD/ aXiw== X-Gm-Message-State: AOJu0YyFzqvz+zkQQhTaWma/mB1SHcKRQkYKVh0sFT1jULxIHLtNKg+R oj0EFpHLrWmERtgL5qwOFro3Cx/DyXIVqIve X-Google-Smtp-Source: AGHT+IEsUDkz9X21kr8hsqAmcX7t8hx++rvo+XjF64s1RpulX6DE9NEUyQ5CvNl8DdyA+MzhS+tFdQ== X-Received: by 2002:a5d:4d0a:0:b0:317:70da:abdd with SMTP id z10-20020a5d4d0a000000b0031770daabddmr8806549wrt.59.1692128613166; Tue, 15 Aug 2023 12:43:33 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:9934:e2f7:cd0e:75a6]) by smtp.gmail.com with ESMTPSA id n16-20020a5d6610000000b003179d5aee67sm18814892wru.94.2023.08.15.12.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 12:43:32 -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 v2 02/10] doc/netlink: Document the genetlink-legacy schema extensions Date: Tue, 15 Aug 2023 20:42:46 +0100 Message-ID: <20230815194254.89570-3-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815194254.89570-1-donald.hunter@gmail.com> References: <20230815194254.89570-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 description of genetlink-legacy specific attributes to the ynl spec documentation. Signed-off-by: Donald Hunter --- Documentation/userspace-api/netlink/specs.rst | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/Documentation/userspace-api/netlink/specs.rst b/Documentation/userspace-api/netlink/specs.rst index 2e4acde890b7..dde70f9674d4 100644 --- a/Documentation/userspace-api/netlink/specs.rst +++ b/Documentation/userspace-api/netlink/specs.rst @@ -443,3 +443,50 @@ nest Attribute containing other (nested) attributes. ``nested-attributes`` specifies which attribute set is used inside. + +genetlink-legacy +================ + +The genetlink-legacy schema extends the genetlink schema with some additional +properties that are needed to support legacy genetlink families. + +Globals +------- + + - ``kernel-policy`` - Specify whether the kernel input policy is ``global``, + ``per-op`` or ``split``. + +Struct definitions +------------------ + +There is a new type of definition called ``struct`` which is used for declaring +the C struct format of fixed headers and binary 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 + attribute definitions. + +Attributes +---------- + +The genetlink-legacy families can use binary attributes that contain C struct +data. This is specified using a ``struct`` property containing the name of the +struct definition. + + - ``struct`` - Name of the struct definition to be used for the attribute. + +Operations +---------- + +The genetlink-legacy families can use a binary fixed header that contains C +struct data. + + - ``fixed-header`` - name of the struct definition to be used for the fixed + header data. This can be specified as a default for all operations and on a + per-operation basis. From patchwork Tue Aug 15 19:42:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13354217 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 9871F18AE8 for ; Tue, 15 Aug 2023 19:43:37 +0000 (UTC) Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65ADE10FF; Tue, 15 Aug 2023 12:43:36 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-31969580797so3072197f8f.3; Tue, 15 Aug 2023 12:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692128614; x=1692733414; 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=1DnSCiXvfY5FNrAsfEnGGwj0Odz/F6bzy+R7iZsmgtU=; b=chjSy1zu7IvSWCjU6mmwv27pLw8Bx+hR4eyw9HrcLXlYD+Aq+gARv2l4KOf7zXeN78 jdMxccODxelQ2om08AXLyaPT77bNgLKRK7nqCV+wUAPzufNhXhV/C3YO/9Fjl0EakYhd UPI0lTGD9kvd769ih754rWAwGklwvH9qoU2CU4QHpUdvkz+nXtG2BUmoW5jlAuxR1Nxj 087F1DHjIGxkYYo+xQjwOGAIP4qenGwoS/IhCbRymChplDKuUFuI4WJVCsnVG4h03Rvh Q/2839VEAgd5WtAJlq5bt37mgDUYlNtBUpxvyw6r0i7OM6eQDCMaXRhrEikzGBwwzb8i dnzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692128614; x=1692733414; 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=1DnSCiXvfY5FNrAsfEnGGwj0Odz/F6bzy+R7iZsmgtU=; b=DUzVsd6H/+G8YWMyZer1o8fkgRUxPNR73kvdRLAsBerKcIYC/AFEKkpGaVSaTgVfzg AoWv2F2y3SLEdQFwFPyFqAUhoyyjV7ITjvnXCgQDtENeMQlEbJvAjsdscGc4ygFkiQ+e JOt8ZNuKFj7IUVDv2WAgIDV1dSmV54RRZKvSx1AAlDTIqM5KNc4xfUinJ1tn4hPJSzVM h1rhhDVwyMzbhIvhakRvrzM6Z/Lsl9pbYINXZ8F9c9e+VUYEkQ6ks5nhGlZaW4mQXXdz eiU14Vc8gJrt3+BqZMpnxD0EhoDjo9qYT0CoBj0IwbnzDkESWpHnCGJjyGfS1SE+GAEu LE1Q== X-Gm-Message-State: AOJu0YychAE1be7HmghgskTZg3uaKb4W5ieo0yqdw9w1Ji5iXxe+63JW Gd4ViJuO/KVkn3fyD/v0xTAI0l5N+l7b3+9V X-Google-Smtp-Source: AGHT+IEL7AohZuGVmOsqi0DMyxeaMXnJ69Ncu7JR7wTgQPHZ/tuHkm/1pWcRUDsxtblA3fkzSuHx0Q== X-Received: by 2002:a5d:6202:0:b0:313:dee2:e052 with SMTP id y2-20020a5d6202000000b00313dee2e052mr9129260wru.26.1692128614424; Tue, 15 Aug 2023 12:43:34 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:9934:e2f7:cd0e:75a6]) by smtp.gmail.com with ESMTPSA id n16-20020a5d6610000000b003179d5aee67sm18814892wru.94.2023.08.15.12.43.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 12:43:33 -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 v2 03/10] doc/netlink: Document the netlink-raw schema extensions Date: Tue, 15 Aug 2023 20:42:47 +0100 Message-ID: <20230815194254.89570-4-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815194254.89570-1-donald.hunter@gmail.com> References: <20230815194254.89570-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 description of netlink-raw specific attributes to the ynl spec documentation and refer to the classic netlink documentation. Signed-off-by: Donald Hunter --- Documentation/userspace-api/netlink/intro.rst | 2 ++ Documentation/userspace-api/netlink/specs.rst | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Documentation/userspace-api/netlink/intro.rst b/Documentation/userspace-api/netlink/intro.rst index 0955e9f203d3..3ea70ad53c58 100644 --- a/Documentation/userspace-api/netlink/intro.rst +++ b/Documentation/userspace-api/netlink/intro.rst @@ -528,6 +528,8 @@ families may, however, require a larger buffer. 32kB buffer is recommended for most efficient handling of dumps (larger buffer fits more dumped objects and therefore fewer recvmsg() calls are needed). +.. _classic_netlink: + Classic Netlink =============== diff --git a/Documentation/userspace-api/netlink/specs.rst b/Documentation/userspace-api/netlink/specs.rst index dde70f9674d4..98978a014488 100644 --- a/Documentation/userspace-api/netlink/specs.rst +++ b/Documentation/userspace-api/netlink/specs.rst @@ -490,3 +490,20 @@ struct data. - ``fixed-header`` - name of the struct definition to be used for the fixed header data. This can be specified as a default for all operations and on a per-operation basis. + +netlink-raw +=========== + +The netlink-raw schema extends the 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`` - Protocol number to use when opening a netlink socket. + +Multicast group properties +-------------------------- + + - ``value`` - ID to use for multicast group registration. From patchwork Tue Aug 15 19:42:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13354218 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 C66B51426C for ; Tue, 15 Aug 2023 19:43:38 +0000 (UTC) Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BD8810C1; Tue, 15 Aug 2023 12:43:37 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3fe2048c910so53309825e9.1; Tue, 15 Aug 2023 12:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692128615; x=1692733415; 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=qDx4UweuNbOniPGlCFbOuSXwgxgV3XvqIUyY5uAZbZI=; b=jozvqTnHbUBkcZLEfQY4U3sMIaVGJ2e+StTjbeuPsbeZ/ozhisINZVC5OusOS6SOqB hJMj75Ma20RAy2sAvnqFUBZxUqV2FvdJ5BW4qFFH537T7NEKLEC/XWcDPJzMQzzbXKKL ICTKvPPcXe75rYF1B6RZAM5S8gwBWp6NhU7D+S98Z5RZqjoV4eSPxGbzVR1usqPg4DWt P7+Z8kgdjG7kcNqzcEcTQ/zj2obVOYEtgn4oLs/MuSaWVMKlt+X++WHu3VTlBGJI195D 8uwhz7N6aQ14E8tMQEfNzAvJRErU2k2TkuytDlLaRB3G0TPhhWsRIYpS0qkBP43x7RG7 L3gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692128615; x=1692733415; 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=qDx4UweuNbOniPGlCFbOuSXwgxgV3XvqIUyY5uAZbZI=; b=ChamTA2+QCp35lDx42R3giTtInA/GMMj9xVDyaRV5BHIx2Dls9Hu7UgVkp2JogJbV7 4CRBjnLUuUDHKZD68c8uXvqDKeB2unX++6XdRhdKreTenrrd9P4itUa80tj1o/ELYmfP dGwyLpXB/CLv7kKKvvWCFq8y7tlAQveye2tt/ih1USX4lPxBB/gLQDVnjcjj53k3m74j fTtrzwGZYu+0+CqPZ7/LwZs1QHsLQfSQc68VyRwIv9ri+l6RNdjIrixEVpZlZWRLGi84 r04+lpr3QGnoHCxiQ49vb94wYA4RyjpbZCgpycfSzu11UJ2Hds6zgefLPqujx7U8WW0Q 03GA== X-Gm-Message-State: AOJu0YzAqNVCt8eDPeQFNH/R7SsWttnGnQUsSRvgMrPNffbpbHKTBeiz ozqKuabxor+BC8ezTsgdXBejrxnbEgU7NmJ2 X-Google-Smtp-Source: AGHT+IECMUljCAPhztgn1+ddIKC9zxQJx97KyZhNkxLLOd+cVD2CN4DDVZU3cnQYXXZCZPVgxf4EmQ== X-Received: by 2002:a7b:cd97:0:b0:3fe:4900:db95 with SMTP id y23-20020a7bcd97000000b003fe4900db95mr11064524wmj.37.1692128615548; Tue, 15 Aug 2023 12:43:35 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:9934:e2f7:cd0e:75a6]) by smtp.gmail.com with ESMTPSA id n16-20020a5d6610000000b003179d5aee67sm18814892wru.94.2023.08.15.12.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 12:43:35 -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 v2 04/10] tools/ynl: Add mcast-group schema parsing to ynl Date: Tue, 15 Aug 2023 20:42:48 +0100 Message-ID: <20230815194254.89570-5-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815194254.89570-1-donald.hunter@gmail.com> References: <20230815194254.89570-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,URIBL_BLOCKED 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 --- tools/net/ynl/lib/nlspec.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py index 0ff0d18666b2..a41ad89eb369 100644 --- a/tools/net/ynl/lib/nlspec.py +++ b/tools/net/ynl/lib/nlspec.py @@ -322,6 +322,21 @@ class SpecOperation(SpecElement): self.attr_set = self.family.attr_sets[attr_set_name] +class SpecMcastGroup(SpecElement): + """Netlink Multicast Group + + Information about a multicast group. + + Attributes: + name name of the mulitcast group + value numerical id of this multicast group for netlink-raw + 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 +358,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 +400,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 +433,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 +532,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 Tue Aug 15 19:42:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13354219 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 E642D18053 for ; Tue, 15 Aug 2023 19:43:40 +0000 (UTC) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9801310EC; Tue, 15 Aug 2023 12:43:38 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-307d20548adso5137299f8f.0; Tue, 15 Aug 2023 12:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692128617; x=1692733417; 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=mFjY37lwo4N/hdruwu62FUgbt07yrT9B4CemMUeBHlg=; b=deKmEK3EVC0relv6FoeLV/hBmopAbaf56boedCAzAk5jVleG3i48b5kPendYyM4b9x S805j8zdqZHR0tPCt01xzPS8Xvh45mxSDpx/Z7+mPZ3rL742Oz2yQfilR/BURj06YVP1 ErLSjpu2jOYZ3Z4zufAPFR0spyq7rSI1ZQuM0Na1LB7S1pbOYd0mMlqU86STXjBQyk41 Iq0+4UzSCFC3TqOY3tGysi/Dfd3J/11c1bAOGUCIpiFHzDYFfPgIe+ZW19irhCxknenR jjufLbn5gU0WA7ODpoDqB2pWmjydvGXYXUpSE314+qC+8IAxzEn6j5aQacduNI9fHFsk UEXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692128617; x=1692733417; 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=mFjY37lwo4N/hdruwu62FUgbt07yrT9B4CemMUeBHlg=; b=GfwhOSA92o9ZdHkCo517/0E53JNLnZxN4uAbK0g9uh0z/NIW2BsnGOx/VwoKniVs4j mFnbmwN5zi03a+GpvATls9a5ee1lPaBUsTDnwvj77oNMzE2WZ01p7B2L/yBzMMeuQcB7 HXGAWd+Dl4kjALUJqCeSAMljoEwvi5y7g0NyOR14awphAsaP9me5LAeYkmbQKo/E3ReY BhWXohtiRu41HBQvLKEoUGpVAJN50//o+Pyxx/BdrFG4+oJ7GGJNXA1s7hXlJP4xobwG k29sNC7douiGt5cC00G5mKfTH3NXwpSj6tiL0JlUF8vzXQDRNUrwfY85YfbqbbtdFRpA LsEg== X-Gm-Message-State: AOJu0YxoIxw1QSLmhBZKOLb6gD6pHCrLc/dmOFk3pNjE5NlSPtYLH5Wy DkML2M0qjUzZtHsEip5cGSr2K+2guG6Hbc89 X-Google-Smtp-Source: AGHT+IH1n4EEnPCvQC0zMSUwJ7mYVnh7ge0qJgekyXhXDSefHl53GlcAN1nd13h90OBVbXn+1T4lig== X-Received: by 2002:a5d:5482:0:b0:319:8a21:6f9a with SMTP id h2-20020a5d5482000000b003198a216f9amr1730728wrv.63.1692128616694; Tue, 15 Aug 2023 12:43:36 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:9934:e2f7:cd0e:75a6]) by smtp.gmail.com with ESMTPSA id n16-20020a5d6610000000b003179d5aee67sm18814892wru.94.2023.08.15.12.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 12:43:36 -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 v2 05/10] tools/net/ynl: Refactor decode_fixed_header into NlMsg Date: Tue, 15 Aug 2023 20:42:49 +0100 Message-ID: <20230815194254.89570-6-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815194254.89570-1-donald.hunter@gmail.com> References: <20230815194254.89570-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,URIBL_BLOCKED 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 NlMsg in preparation for adding netlink-raw support. Signed-off-by: Donald Hunter --- tools/net/ynl/lib/ynl.py | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index 3ca28d4bcb18..4fa42a7c5955 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -189,6 +189,7 @@ class NlMsg: self.error = 0 self.done = 0 + self.fixed_header_attrs = [] extack_off = None if self.nl_type == Netlink.NLMSG_ERROR: @@ -228,6 +229,19 @@ class NlMsg: desc += f" ({spec['doc']})" self.extack['miss-type'] = desc + def decode_fixed_header(self, ynl, name): + fixed_header_members = ynl.consts[name].members + self.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(self.raw, offset) + offset += format.size + if m.enum: + value = ynl._decode_enum(value, m) + self.fixed_header_attrs[m.name] = value + self.raw = self.raw[offset:] + 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: @@ -317,23 +331,18 @@ def _genl_load_families(): class GenlMsg: - def __init__(self, nl_msg, fixed_header_members=[]): - self.nl = nl_msg + def __init__(self, nl_msg, ynl=None): + self.genl_cmd, self.genl_version, _ = struct.unpack_from("BBH", nl_msg.raw, 0) + nl_msg.raw = nl_msg.raw[4:] - 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] + if ynl: + op = ynl.rsp_by_value[self.genl_cmd] + if op.fixed_header: + nl_msg.decode_fixed_header(ynl, op.fixed_header) - self.raw = nl_msg.raw[offset:] + self.raw = nl_msg.raw self.raw_attrs = NlAttrs(self.raw) + self.fixed_header_attrs = nl_msg.fixed_header_attrs def __repr__(self): msg = repr(self.nl) @@ -596,7 +605,7 @@ class YnlFamily(SpecFamily): done = True break - gm = GenlMsg(nl_msg, fixed_header_members) + gm = GenlMsg(nl_msg, self) # 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: From patchwork Tue Aug 15 19:42:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13354220 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 E1688198AD for ; Tue, 15 Aug 2023 19:43:41 +0000 (UTC) Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACC6410FF; Tue, 15 Aug 2023 12:43:39 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-31427ddd3fbso5085014f8f.0; Tue, 15 Aug 2023 12:43:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692128618; x=1692733418; 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=r8mNYBAbLghexAM2MZEbEhjesH9w35WH3ToK8+snsTQ=; b=S/R6TvnziwdQCfEmLaAxwEFqLxyeyhLK8HlN12cm0j/onoD0kciTsxG6+9B7MCZjC9 RDc5OMfm0zrdwupIrF1C6n4CTerBqW7IQ5gK2tDBZ1XYlIl+jZWBpUIW2uO+j6iREjAX WQ1CORQi4kbixREhoUqsIIG0n8AshRk/WZeSRNJntAQ2nCR5QpFr7DIjaJmILhPt84gj GrTZ4RdNNVOGoxY1SIqw9TsZ2aMNnNqN0wF7m1f3C6E1sw5P5BpO45WAsXnPN1ZzzORn zcLoCe9/cB9M3SmcZzQk7fMSaAYN2mOBzsaGrYzkg2/Gdf4LgOMk/4rfu3nNfE4UeaEt 30SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692128618; x=1692733418; 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=r8mNYBAbLghexAM2MZEbEhjesH9w35WH3ToK8+snsTQ=; b=U9NUx+/Z+zPF0XxnycmGVnxR/2MMfJDsmr8gO57QR4+YIfoFuYh/rod38jkT51lcFx S15NYHRmQ2McFwCTPoNBWfkjoYeONtB7nm+4JlFkTerV8o0Lg6U+/OQWQCQsYk4EKO8G IlhIPcmVcKaUT5qFe17bubWl+tfarpGtt9glKvO1It6UC1P6AysEItb6Rh1gpSlS7+TV oqJ+vIeKrjK9UdFH1yyynDHB3nFQdJyJnSHCviuo7pgKTUHnfTNEYwm20OsSBx/FkPaZ fZqSfwcPJxCJj/FgosCqiBHxBNYIogBCzIXumcvqJ6SAft2xX2CeCKNhtTL6C8Mjhyds DP3Q== X-Gm-Message-State: AOJu0Yw7YDP4havYJZwGyH9HAJf4WOKzEuvLrZNl4hiJG1nNN1MwSY4V 4qGNUfMWr052lD31Lm70ECFsaud0rktHX/Ry X-Google-Smtp-Source: AGHT+IFkleXFNg2i9h29/7SaHyG9UpQTmAV6ugClAkOzeEi7KdmXVPRMKU37sULfjQBOS93+yKbqxA== X-Received: by 2002:a5d:4ec1:0:b0:317:5e0a:545e with SMTP id s1-20020a5d4ec1000000b003175e0a545emr9038845wrv.58.1692128617737; Tue, 15 Aug 2023 12:43:37 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:9934:e2f7:cd0e:75a6]) by smtp.gmail.com with ESMTPSA id n16-20020a5d6610000000b003179d5aee67sm18814892wru.94.2023.08.15.12.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 12:43:37 -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 v2 06/10] tools/net/ynl: Add support for netlink-raw families Date: Tue, 15 Aug 2023 20:42:50 +0100 Message-ID: <20230815194254.89570-7-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815194254.89570-1-donald.hunter@gmail.com> References: <20230815194254.89570-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,URIBL_BLOCKED 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 | 103 +++++++++++++++++++++++++++++---------- 1 file changed, 78 insertions(+), 25 deletions(-) diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index 4fa42a7c5955..325dc0d9c5b5 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 @@ -242,6 +243,9 @@ class NlMsg: self.fixed_header_attrs[m.name] = value self.raw = self.raw[offset:] + 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: @@ -344,6 +348,9 @@ class GenlMsg: self.raw_attrs = NlAttrs(self.raw) self.fixed_header_attrs = nl_msg.fixed_header_attrs + 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" @@ -352,9 +359,35 @@ 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, ynl, nl_msg): + op = ynl.rsp_by_value[nl_msg.nl_type] + if op.fixed_header: + nl_msg.decode_fixed_header(ynl, op.fixed_header) + nl_msg.raw_attrs = NlAttrs(nl_msg.raw) + return nl_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].id + +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: @@ -363,6 +396,18 @@ 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, ynl, nl_msg): + return GenlMsg(nl_msg, ynl) + + 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. @@ -375,9 +420,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 = [] @@ -390,18 +445,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): attr = self.attr_sets[space][name] @@ -525,9 +574,12 @@ class YnlFamily(SpecFamily): if self.include_raw: msg['nlmsg'] = nl_msg msg['genlmsg'] = genl_msg - op = self.rsp_by_value[genl_msg.genl_cmd] + op = self.rsp_by_value[genl_msg.cmd()] + decoded = self._decode(genl_msg.raw_attrs, op.attr_set.name) + decoded.update(genl_msg.fixed_header_attrs) + msg['name'] = op['name'] - msg['msg'] = self._decode(genl_msg.raw_attrs, op.attr_set.name) + msg['msg'] = decoded self.async_msg_queue.append(msg) def check_ntf(self): @@ -547,12 +599,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(nl_msg, decoded) def operation_do_attributes(self, name): """ @@ -573,7 +625,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 @@ -605,18 +657,19 @@ class YnlFamily(SpecFamily): done = True break - gm = GenlMsg(nl_msg, self) + 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(nl_msg, decoded) continue else: - print('Unexpected message: ' + repr(gm)) + print('Unexpected message: ' + repr(decoded)) continue - rsp_msg = self._decode(gm.raw_attrs, op.attr_set.name) - rsp_msg.update(gm.fixed_header_attrs) + rsp_msg = self._decode(decoded.raw_attrs, op.attr_set.name) + rsp_msg.update(decoded.fixed_header_attrs) rsp.append(rsp_msg) if not rsp: From patchwork Tue Aug 15 19:42:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13354221 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 1F998198B5 for ; Tue, 15 Aug 2023 19:43:42 +0000 (UTC) Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2F5010C1; Tue, 15 Aug 2023 12:43:40 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3fe490c05c9so39499105e9.0; Tue, 15 Aug 2023 12:43:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692128619; x=1692733419; 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=YXA9U813FnAWD4PJve2CXlaLWAIglzuQR7ZCqQRSFQU=; b=bNrtfCkQRIpMcMG/2YEHuELjJWlZATUFc2qa7QC8u12GPeNq5NrH6qsSqzQhMc9bO9 KKVJ5a1y2gNRi5kOjKMWvF18HVERo1TNVl1y9Ax6IrZ/+pvqj/B1rpHo1dJhBTKD0seI ElY31jtxvpCXzlLvC/9EiXmRAWsR074YZ0IeFwgGRKgdOyIdCz7R5jCWW1G5nYebGV8c aaVtwXzrEqadb8i2Fy0oqZXsE3wdT3O6LFK16r12iIc2Qb0Y2LBB75CMlE5iFB6Ss1Qm IUoQAGeQF4AqtKw4xIM0XW75ycYnCXHjJ3Dfj9o4x8bMjy3V4hkSYpDe/gj4xwqr454a s8hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692128619; x=1692733419; 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=YXA9U813FnAWD4PJve2CXlaLWAIglzuQR7ZCqQRSFQU=; b=MeUzws5CHmJMnJ3uCJhELUv/Z1KZpbel4xDhCmMTBF9Rs+61lKoMmMffREtFyHXnZa fPGJiUjFrD2qo9O6e4xvNwTYB5auNrLnILHDixzWkR6lX7sQLOXOtISDUsAWS5U2OdL2 dlSP1W9YVyIc7cJGZzwFO5+OIjbdz+Ni9qBcpaEkVcYZIA2Kx/Ypsod9UNFvUr8nGz+N v474QTQkJ33XqEfXX6zWTRFpgVMCeWH4Fnvafjx4HqHYrzjbDeY62Z5Avf+Nq/dMrrNH GI55fqIofijltrL8pZ5KSBcoHf8kYCA4SBQ4zqE+Xi52trL0mMPhsUhBELud1zg6Z+Wp cizw== X-Gm-Message-State: AOJu0Yyl0bmSSCnxFZx/IlWCSeeTTYQX8VFFJVK5CXW0aSMZOgdSryLy 1jmf/hiNGDT0OiAh1UheML9LjNknGUI8oXBT X-Google-Smtp-Source: AGHT+IEniH0DBVSNyAt3o0n/OxjyUXL6ApdAtQBj7gh7bWMN9gr2SATcu6UbpqTkXN4LYF6LC/VQaQ== X-Received: by 2002:a7b:cb96:0:b0:3fc:1a6:79a9 with SMTP id m22-20020a7bcb96000000b003fc01a679a9mr2415052wmi.16.1692128619090; Tue, 15 Aug 2023 12:43:39 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:9934:e2f7:cd0e:75a6]) by smtp.gmail.com with ESMTPSA id n16-20020a5d6610000000b003179d5aee67sm18814892wru.94.2023.08.15.12.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 12:43:38 -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 v2 07/10] tools/net/ynl: Implement nlattr array-nest decoding in ynl Date: Tue, 15 Aug 2023 20:42:51 +0100 Message-ID: <20230815194254.89570-8-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815194254.89570-1-donald.hunter@gmail.com> References: <20230815194254.89570-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,URIBL_BLOCKED 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 --- 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 325dc0d9c5b5..cd983d1f2ee6 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -504,6 +504,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() @@ -520,6 +531,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 Tue Aug 15 19:42: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: 13354222 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 749B41AA70 for ; Tue, 15 Aug 2023 19:43:44 +0000 (UTC) Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05D7D10C1; Tue, 15 Aug 2023 12:43:43 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4ff882397ecso1356417e87.3; Tue, 15 Aug 2023 12:43:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692128620; x=1692733420; 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=eLnNqJMl/isE73N1mbjQXGEF/pmHif2ExuIghaJq2uU=; b=E4+EyGTgk55Ar+/aND32Egi/A6TLfOSqpz+0MIVtzXHpSm5PzXmP9l3Si6nqdyOsKK KiZNxtoeVQzdrwpSa9H+2cafKa1nTuRdGVCsJlw/WoRK8+Wq8DO6PI8vswJpDfXAfUij J/h9rS/E12dc61HzBgdVSjjUKfsUeC5fmgeQEktIQzedYV2Zk+Yg4VD2t6sJYfSv5+D2 xHSUe5ET3DfAZd6PmmFsFqimM6mvkxFmVhzKc+eIFsfV4nHsHWgVFB/IcLsVaknoOT89 P0KfGY08qVJBTmfce37f9QdFhl0OC6r7p3nIrTkNDrTtQI/7SNIIGJvSxvzb6qZfREU5 ucBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692128620; x=1692733420; 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=eLnNqJMl/isE73N1mbjQXGEF/pmHif2ExuIghaJq2uU=; b=SQukz78zEcIYK4FzVFZ1f4u44vpy3NvUsb1K07SQtNMAylfeBFhnfjg9NcyMWJc8pZ 1wsMWpw+O/e7mM5OZDit1v1RBQ3nyeiuj5SyxqWsEeGI/zmkekpbn0p2JXrQqIodP5to 2ZBY2E9STF0oXswIzBi/cHbQvkk0fn7FBd/ECPOZAfVWAZS9ls/VjZ4BnRCqs+zmm4HG 1b/j1B3azD3s5wOx6wU9ewYzWJX45IF+YvQ1OwMAcLfKjkywKLimJR5VRqbHIaiEibpX ate5LvPQaq5MoCqOi7zIOgqvbxW+ZCCHjXj3qpNOoiUJuiLN18IWcuZSu7vTZRSaBtlC rpQQ== X-Gm-Message-State: AOJu0YxkhrNFsV6EYQkDVJC/6QWOdgoQzPrujhLluEEG5ZMVr9g/vbHb OH5SwHZcV6AoSLp/Ibgg91xb0CBUmtEkxjNb X-Google-Smtp-Source: AGHT+IE/RtXNaazgveIWWB1QqfU3PBMO+3SgcBve1Hu2CgMQ8U7BQMDMUCdmYTJ1YwXRprZ+3EfK2w== X-Received: by 2002:ac2:5fd1:0:b0:4f7:6775:2a66 with SMTP id q17-20020ac25fd1000000b004f767752a66mr7256085lfg.53.1692128620327; Tue, 15 Aug 2023 12:43:40 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:9934:e2f7:cd0e:75a6]) by smtp.gmail.com with ESMTPSA id n16-20020a5d6610000000b003179d5aee67sm18814892wru.94.2023.08.15.12.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 12:43:39 -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 v2 08/10] doc/netlink: Add spec for rt addr messages Date: Tue, 15 Aug 2023 20:42:52 +0100 Message-ID: <20230815194254.89570-9-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815194254.89570-1-donald.hunter@gmail.com> References: <20230815194254.89570-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 --- 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 Tue Aug 15 19:42: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: 13354224 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 CC7961AA8B for ; Tue, 15 Aug 2023 19:43:46 +0000 (UTC) Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09B4710EC; Tue, 15 Aug 2023 12:43:44 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3fe8242fc4dso49168885e9.1; Tue, 15 Aug 2023 12:43:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692128622; x=1692733422; 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=sza1dz6WmL/GT5roY8MfWlvq/+iGBlek7VPr6hIoieU=; b=T6C1i+d7YQgFJclK8IaVnudNZCnNRPW7EifbA94eDkXYK1RA/mImWyHpCFwGkGPJBx wDcs7mE++CWekAG9vZfjPOQIR/PAUTfpM7rg07FJpD/jISZyf708dsY8sWVg/lJPb8at MXYHHXZcvVZKEluUpP4mDdZfNzxz39/oiXU10N7HYFK+Tmiargd0flzIwS7P5SzF5vRz Z7rbO+NqrKRDol1eTYUMtneSXPnc8kIU+ba3G3/Zl5DEjEpGmvF3QKvFrrKi+WJIB1ru nWJd1USkLZAsFGk2AGAd+v5lxYUtkY/7sEGSHlT+j0AiT4+umZKw96dHE02fGkr5xvYP nT/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692128622; x=1692733422; 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=sza1dz6WmL/GT5roY8MfWlvq/+iGBlek7VPr6hIoieU=; b=lj+C3bmYR6uKfgzFV33w0fEtcDnwphis7a3xUx3LwDQMC01z/uRFy1rNNlyzNBIlSN ciRWVZvzD/zijoC650TqZ69E+acX1dMQ/LGbs/okjzS2Nb087sLGMfR7eMNDvUWWQ5JK B+VbDw5hHTlPXUPDs68vEiD03TsSMynRJ/MADrDs4np0dUR3pSbgqeRF8oegoQH8IkUj /BXfajEdnNOcGzM7G2OszsqxHGGZedw+d3FNXF1E/SUWY/3UHOgDJxAmbbVa7G0pP/GY DaX1M9J88qdUibDr/w1oVR6tYaBP1JjCYucPia5P0Q7vytXHqzCxH7BNe6UVXec5MhVX up5g== X-Gm-Message-State: AOJu0YwvGH5/UfF5HB+/pO1nyJA42oXxWg24lL33gjtxT0/lamXPuai+ 8Lcu3O5vTMIUHSZNXZUCxV4SqQR83hdgwswc X-Google-Smtp-Source: AGHT+IEcwUjS5Q3EZDtJ3HZHCg14GGtrAG8oCFYLyewWFF8yneaUeF5FXSCqh/AsnbADJOCvhoYMkA== X-Received: by 2002:a05:600c:3648:b0:3fd:29cf:20c5 with SMTP id y8-20020a05600c364800b003fd29cf20c5mr10725740wmq.7.1692128621971; Tue, 15 Aug 2023 12:43:41 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:9934:e2f7:cd0e:75a6]) by smtp.gmail.com with ESMTPSA id n16-20020a5d6610000000b003179d5aee67sm18814892wru.94.2023.08.15.12.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 12:43:41 -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 v2 09/10] doc/netlink: Add spec for rt link messages Date: Tue, 15 Aug 2023 20:42:53 +0100 Message-ID: <20230815194254.89570-10-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815194254.89570-1-donald.hunter@gmail.com> References: <20230815194254.89570-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,URIBL_BLOCKED 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. 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 --- Documentation/netlink/specs/rt_link.yaml | 1374 ++++++++++++++++++++++ 1 file changed, 1374 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..f9b7aedbc0ac --- /dev/null +++ b/Documentation/netlink/specs/rt_link.yaml @@ -0,0 +1,1374 @@ +# 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: string + value: 52 + - + name: alt-ifname + type: string + value: 53 + - + name: perm-address + type: string + 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: + - ifi-index + - + name: dellink + doc: Delete an existing link. + attribute-set: link-attrs + fixed-header: ifinfomsg + do: + request: + value: 16 + attributes: + - ifi-index + - + name: getlink + doc: Get / dump information about a link. + attribute-set: link-attrs + fixed-header: ifinfomsg + do: + request: + value: 18 + attributes: + - ifi-index + reply: + value: 16 + attributes: + - ifi-index + - + name: setlink + doc: Set information about a link. + value: 19 + attribute-set: link-attrs + fixed-header: ifinfomsg + do: + request: + attributes: + - ifname + - + name: getstats + doc: Get / dump link stats. + attribute-set: stats-attrs + fixed-header: if_stats_msg + dump: + request: + value: 94 + attributes: + - ifindex + reply: + value: 92 + + +mcast-groups: + list: + - + name: rtnlgrp-link + value: 1 From patchwork Tue Aug 15 19:42: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: 13354223 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 6C7681AA70 for ; Tue, 15 Aug 2023 19:43:46 +0000 (UTC) Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C01810C1; Tue, 15 Aug 2023 12:43:45 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3fe12baec61so52363075e9.2; Tue, 15 Aug 2023 12:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692128623; x=1692733423; 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=E1LGjCQUqcrNY0alG6lWK84AzftAjPlRFsXyMgA7/MU=; b=KhA5goXJwj8cJWFlmNkLcnXNViZLqK5ppltBZ5uCv0sY3H8kEL6An39nuKE/68cvZN /Tr6bIxv96NksGRIvD5sXSKj8iDtOPPAHGRbWttkoqyml/QLqgaYgR7JpALr04lUR3/m xqAzic6RNhFToWEsKJ6mgVV1sXweO0BxMeN+CCIAdfEuoa10R4p3Jx3/F5IQfkT5D1iL duCN5bAIgAAXzE7BY8sadMotFb7volgtjNWSrW3xjsXqU5I5yIU3mrC0mpsvU5am35tc Gpuppiv8eStoR1mlYtp89U4z3svTkkfS3ifwEYMXxUjmQlESNAKggL4qj+/l14z20zVa G2ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692128623; x=1692733423; 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=E1LGjCQUqcrNY0alG6lWK84AzftAjPlRFsXyMgA7/MU=; b=OMR8NphrkRWh76+P8d7ll+d+eXy4LO0KSXSaGEqC3IgnzJ7y8vUtHgCQLy5WvBfRZg TZpmgilLxcaEJ9z5RQBFttvoLs8F1nY7XqdYN+g3xGdvcgkXB1BbyHp6DKrDhZPfkxkm E+qtJs1NIEAYkESsvaxEUoqsI4+/SN//HE9BSNI6mSyhwCulJUgMaqhGFSZ0ESuFrkg0 D+vkT+anr2r2P+UDClhnYOIbV+Dq7Gt5U6Ve0IcYcACnDsrLr/2q44GZnIcTb8DFt6xt wOLZBgT2ppSB9Ywfw5jfFKUclCX4WqvStOPEV+zbqcECGhudhm8topTIhJtyUbCSdzPq cvQw== X-Gm-Message-State: AOJu0YxWAWaY9iqBBs0Z5l9B4sfDWQEMIP3dmw+0L4P2LzbEXy4I7qEU 5W9Qw73hsMafwXmlOi7YB1NdcQt8QhylErm3 X-Google-Smtp-Source: AGHT+IEqevzzUxvLf4B29y/5WfXNAG9nvK2eScl009GC4kSDJaNRfPL6zi9Ld7Ty8XhA9wiobnih3g== X-Received: by 2002:a5d:6202:0:b0:319:52a5:569f with SMTP id y2-20020a5d6202000000b0031952a5569fmr8483021wru.11.1692128623145; Tue, 15 Aug 2023 12:43:43 -0700 (PDT) Received: from imac.fritz.box ([2a02:8010:60a0:0:9934:e2f7:cd0e:75a6]) by smtp.gmail.com with ESMTPSA id n16-20020a5d6610000000b003179d5aee67sm18814892wru.94.2023.08.15.12.43.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Aug 2023 12:43:42 -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 v2 10/10] doc/netlink: Add spec for rt route messages Date: Tue, 15 Aug 2023 20:42:54 +0100 Message-ID: <20230815194254.89570-11-donald.hunter@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230815194254.89570-1-donald.hunter@gmail.com> References: <20230815194254.89570-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 route with support for getroute. Signed-off-by: Donald Hunter --- Documentation/netlink/specs/rt_route.yaml | 288 ++++++++++++++++++++++ 1 file changed, 288 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..eb4f6bb80100 --- /dev/null +++ b/Documentation/netlink/specs/rt_route.yaml @@ -0,0 +1,288 @@ +# 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 + dump: + request: + value: 26 + reply: + value: 24 + attributes: + - 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