summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaylor Bates <tmbates12@gmail.com>2026-09-14 21:53:15 -0400
committerPaolo Abeni <pabeni@redhat.com>2026-09-17 16:16:30 +0200
commit5ccdfb2c3203207deb17e7c5b0db8c7f475639a7 (patch)
tree3d2d11e7deb5d8c1bfc5cf5fd3f3cfd1f4820583
parentb8a6f2340999bedd3b83ded2e909d855b6db1f41 (diff)
netlink: specs: fix duplicate if/then keys in netlink-raw schema
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@gmail.com> Reviewed-by: Hangbin Liu <liuhangbin@kylinos.cn> Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20260914-ynl-robustness-v2-1-c6125003b21e@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
-rw-r--r--Documentation/netlink/netlink-raw.yaml31
1 files 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: