Re: [PATCH net-next v2] netlink: specs: fix duplicate if/then keys in netlink-raw schema
From: Hangbin Liu
Date: Mon Sep 14 2026 - 23:01:36 EST
On Mon, Sep 14, 2026 at 09:53:15PM -0400, Taylor Bates wrote:
> Currently netlink-raw.yaml contains two if keys and two then keys in a
> single mapping that enforces a "len" for "pad" members and a "len" or
> "struct" for binary members.
>
> During validation PyYAML resolves duplicate keys last-wins, so only the
> binary rule survives. Pad has not been validated since commit
> bf08f32c8ced ("tools/net/ynl: Add support for nested structs") added
> the second if/then pair in January 2024.
>
> None of the current specs violate this rule, but this validation should
> not be parser dependent and unspecified. Strict YAML validators such as
> Red Hat's VS Code YAML extension and Adrien Verge's yamllint will
> reject the netlink-raw.yaml schema:
>
> Command:
> $ yamllint Documentation/netlink/netlink-raw.yaml
>
> Output:
> 185:13 error duplication of key "if" in mapping (key-duplicates)
> 189:13 error duplication of key "then" in mapping (key-duplicates)
>
> The following invalid netlink family spec will pass validation in the
> current ynl tooling:
>
> # SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
> ---
> name: minimal-raw
> doc: Minimal netlink-raw family for schema validation testing.
> protocol: netlink-raw
> protonum: 0
>
> definitions:
> -
> name: test-struct
> type: struct
> members:
> -
> name: reserved
> type: pad
> # len intentionally omitted
>
> attribute-sets: []
>
> operations:
> list: []
>
> Signed-off-by: Taylor Bates <tmbates12@xxxxxxxxx>
> ---
> This is a repost of patch 1 from the "netlink: fix ynl spec tooling
> robustness bugs" series, reduced to this single fix as requested.
>
> The netlink-raw spec for the Bridge VLAN family that motivated the
> original series will be sent separately once this has landed.
> ---
> Changes in v2:
> - Drop patches 2/4, 3/4 and 4/4 from the series; this schema fix stands
> on its own.
> - Drop the Fixes tag. This is developer tooling only and is not a bug
> that needs to reach stable. The offending commit is now cited in the
> commit message instead.
> - Link to v1: https://patch.msgid.link/20260908-ynl-robustness-v1-0-f255214c0f30@xxxxxxxxx
>
> To: Donald Hunter <donald.hunter@xxxxxxxxx>
> To: Jakub Kicinski <kuba@xxxxxxxxxx>
> To: "David S. Miller" <davem@xxxxxxxxxxxxx>
> To: Eric Dumazet <edumazet@xxxxxxxxxx>
> To: Paolo Abeni <pabeni@xxxxxxxxxx>
> To: Simon Horman <horms@xxxxxxxxxx>
> Cc: netdev@xxxxxxxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx
> ---
> Documentation/netlink/netlink-raw.yaml | 31 +++++++++++++++++--------------
> 1 file changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/Documentation/netlink/netlink-raw.yaml b/Documentation/netlink/netlink-raw.yaml
> index 4c436b59a34b..18ccfe05048a 100644
> --- a/Documentation/netlink/netlink-raw.yaml
> +++ b/Documentation/netlink/netlink-raw.yaml
> @@ -176,20 +176,23 @@ properties:
> struct:
> description: Name of the nested struct type.
> type: string
> - if:
> - properties:
> - type:
> - const: pad
> - then:
> - required: [ len ]
> - if:
> - properties:
> - type:
> - const: binary
> - then:
> - oneOf:
> - - required: [ len ]
> - - required: [ struct ]
> + allOf:
> + -
> + if:
> + properties:
> + type:
> + const: pad
> + then:
> + required: [ len ]
> + -
> + if:
> + properties:
> + type:
> + const: binary
> + then:
> + oneOf:
> + - required: [ len ]
> + - required: [ struct ]
> # End genetlink-legacy
>
> attribute-sets:
>
> ---
> base-commit: 043777e948807b5f335f58a0b9f5ed04bba681cf
> change-id: 20260907-ynl-robustness-d62d9693cc12
>
> Best regards,
> --
> Taylor Bates <tmbates12@xxxxxxxxx>
>
Reviewed-by: Hangbin Liu <liuhangbin@xxxxxxxxxx>