* [PATCH net-next v1 0/4] tools: ynl: add schema checking
@ 2025-11-27 12:34 Donald Hunter
2025-11-27 12:34 ` [PATCH net-next v1 1/4] " Donald Hunter
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Donald Hunter @ 2025-11-27 12:34 UTC (permalink / raw)
To: Jakub Kicinski, David S. Miller, Eric Dumazet, Paolo Abeni,
Simon Horman, Andrew Lunn, Matthieu Baerts (NGI0), Chuck Lever,
Florian Westphal, Remy D. Farley, Kory Maincent (Dent Project),
Gal Pressman, Oleksij Rempel, Stanislav Fomichev, Jan Stancek,
Hangbin Liu, Nimrod Oren, netdev
Cc: Donald Hunter
Add schema checking and yaml linting for the YNL specs.
Patch 1 adds a schema_check make target using a pyynl --validate option
Patch 2 adds a lint make target using yamllint
Patches 3,4 fix issues reported by make -C tools/net/ynl lint schema_check
Donald Hunter (4):
tools: ynl: add schema checking
tools: ynl: add a lint makefile target
ynl: fix a yamllint warning in ethtool spec
ynl: fix schema check errors
Documentation/netlink/specs/conntrack.yaml | 2 +-
Documentation/netlink/specs/ethtool.yaml | 2 +-
Documentation/netlink/specs/nftables.yaml | 2 +-
tools/net/ynl/Makefile | 22 +++++++++++++++++++++-
tools/net/ynl/pyynl/cli.py | 21 ++++++++++++++++-----
5 files changed, 40 insertions(+), 9 deletions(-)
--
2.51.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next v1 1/4] tools: ynl: add schema checking
2025-11-27 12:34 [PATCH net-next v1 0/4] tools: ynl: add schema checking Donald Hunter
@ 2025-11-27 12:34 ` Donald Hunter
2025-11-27 12:35 ` [PATCH net-next v1 2/4] tools: ynl: add a lint makefile target Donald Hunter
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Donald Hunter @ 2025-11-27 12:34 UTC (permalink / raw)
To: Jakub Kicinski, David S. Miller, Eric Dumazet, Paolo Abeni,
Simon Horman, Andrew Lunn, Matthieu Baerts (NGI0), Chuck Lever,
Florian Westphal, Remy D. Farley, Kory Maincent (Dent Project),
Gal Pressman, Oleksij Rempel, Stanislav Fomichev, Jan Stancek,
Hangbin Liu, Nimrod Oren, netdev
Cc: Donald Hunter
Add a --validate flag to pyynl for explicit schema check with error
reporting and add a schema_check make target to check all YNL specs.
make -C tools/net/ynl schema_check
make: Entering directory '/home/donaldh/net-next/tools/net/ynl'
ok 1 binder.yaml schema validation
not ok 2 conntrack.yaml schema validation
'labels mask' does not match '^[0-9a-z-]+$'
Failed validating 'pattern' in schema['properties']['attribute-sets']['items']['properties']['attributes']['items']['properties']['name']:
{'type': 'string', 'pattern': '^[0-9a-z-]+$'}
On instance['attribute-sets'][14]['attributes'][22]['name']:
'labels mask'
ok 3 devlink.yaml schema validation
[...]
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
---
tools/net/ynl/Makefile | 20 +++++++++++++++++++-
tools/net/ynl/pyynl/cli.py | 21 ++++++++++++++++-----
2 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/tools/net/ynl/Makefile b/tools/net/ynl/Makefile
index a40591e513b7..b23083b2dfb2 100644
--- a/tools/net/ynl/Makefile
+++ b/tools/net/ynl/Makefile
@@ -12,6 +12,8 @@ endif
libdir ?= $(prefix)/$(libdir_relative)
includedir ?= $(prefix)/include
+SPECDIR=../../../Documentation/netlink/specs
+
SUBDIRS = lib generated samples ynltool tests
all: $(SUBDIRS) libynl.a
@@ -54,4 +56,20 @@ install: libynl.a lib/*.h
run_tests:
@$(MAKE) -C tests run_tests
-.PHONY: all clean distclean install run_tests $(SUBDIRS)
+
+schema_check:
+ @N=1; \
+ for spec in $(SPECDIR)/*.yaml ; do \
+ NAME=$$(basename $$spec) ; \
+ OUTPUT=$$(./pyynl/cli.py --spec $$spec --validate) ; \
+ if [ $$? -eq 0 ] ; then \
+ echo "ok $$N $$NAME schema validation" ; \
+ else \
+ echo "not ok $$N $$NAME schema validation" ; \
+ echo "$$OUTPUT" ; \
+ echo ; \
+ fi ; \
+ N=$$((N+1)) ; \
+ done
+
+.PHONY: all clean distclean install run_tests schema_check $(SUBDIRS)
diff --git a/tools/net/ynl/pyynl/cli.py b/tools/net/ynl/pyynl/cli.py
index ff81ff083764..af02a5b7e5a2 100755
--- a/tools/net/ynl/pyynl/cli.py
+++ b/tools/net/ynl/pyynl/cli.py
@@ -10,7 +10,7 @@ import sys
import textwrap
sys.path.append(pathlib.Path(__file__).resolve().parent.as_posix())
-from lib import YnlFamily, Netlink, NlError
+from lib import YnlFamily, Netlink, NlError, SpecFamily
sys_schema_dir='/usr/share/ynl'
relative_schema_dir='../../../../Documentation/netlink'
@@ -127,6 +127,7 @@ def main():
group.add_argument('--list-msgs', action='store_true')
group.add_argument('--list-attrs', dest='list_attrs', metavar='OPERATION', type=str,
help='List attributes for an operation')
+ group.add_argument('--validate', action='store_true')
parser.add_argument('--duration', dest='duration', type=int,
help='when subscribed, watch for DURATION seconds')
@@ -168,15 +169,25 @@ def main():
if args.family:
spec = f"{spec_dir()}/{args.family}.yaml"
- if args.schema is None and spec.startswith(sys_schema_dir):
- args.schema = '' # disable schema validation when installed
- if args.process_unknown is None:
- args.process_unknown = True
else:
spec = args.spec
if not os.path.isfile(spec):
raise Exception(f"Spec file {spec} does not exist")
+ if args.validate:
+ try:
+ SpecFamily(spec, args.schema)
+ except Exception as error:
+ print(error)
+ exit(1)
+ return
+
+ if args.family: # set behaviour when using installed specs
+ if args.schema is None and spec.startswith(sys_schema_dir):
+ args.schema = '' # disable schema validation when installed
+ if args.process_unknown is None:
+ args.process_unknown = True
+
ynl = YnlFamily(spec, args.schema, args.process_unknown,
recv_size=args.dbg_small_recv)
if args.dbg_small_recv:
--
2.51.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v1 2/4] tools: ynl: add a lint makefile target
2025-11-27 12:34 [PATCH net-next v1 0/4] tools: ynl: add schema checking Donald Hunter
2025-11-27 12:34 ` [PATCH net-next v1 1/4] " Donald Hunter
@ 2025-11-27 12:35 ` Donald Hunter
2025-11-27 12:35 ` [PATCH net-next v1 3/4] ynl: fix a yamllint warning in ethtool spec Donald Hunter
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Donald Hunter @ 2025-11-27 12:35 UTC (permalink / raw)
To: Jakub Kicinski, David S. Miller, Eric Dumazet, Paolo Abeni,
Simon Horman, Andrew Lunn, Matthieu Baerts (NGI0), Chuck Lever,
Florian Westphal, Remy D. Farley, Kory Maincent (Dent Project),
Gal Pressman, Oleksij Rempel, Stanislav Fomichev, Jan Stancek,
Hangbin Liu, Nimrod Oren, netdev
Cc: Donald Hunter
Add a lint target to run yamllint on the YNL specs.
make -C tools/net/ynl lint
make: Entering directory '/home/donaldh/net-next/tools/net/ynl'
yamllint ../../../Documentation/netlink/specs/*.yaml
../../../Documentation/netlink/specs/ethtool.yaml
1272:21 warning truthy value should be one of [false, true] (truthy)
make: Leaving directory '/home/donaldh/net-next/tools/net/ynl'
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
---
tools/net/ynl/Makefile | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/net/ynl/Makefile b/tools/net/ynl/Makefile
index b23083b2dfb2..7736b492f559 100644
--- a/tools/net/ynl/Makefile
+++ b/tools/net/ynl/Makefile
@@ -56,6 +56,8 @@ install: libynl.a lib/*.h
run_tests:
@$(MAKE) -C tests run_tests
+lint:
+ yamllint $(SPECDIR)
schema_check:
@N=1; \
@@ -72,4 +74,4 @@ schema_check:
N=$$((N+1)) ; \
done
-.PHONY: all clean distclean install run_tests schema_check $(SUBDIRS)
+.PHONY: all clean distclean install run_tests lint schema_check $(SUBDIRS)
--
2.51.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v1 3/4] ynl: fix a yamllint warning in ethtool spec
2025-11-27 12:34 [PATCH net-next v1 0/4] tools: ynl: add schema checking Donald Hunter
2025-11-27 12:34 ` [PATCH net-next v1 1/4] " Donald Hunter
2025-11-27 12:35 ` [PATCH net-next v1 2/4] tools: ynl: add a lint makefile target Donald Hunter
@ 2025-11-27 12:35 ` Donald Hunter
2025-11-27 12:35 ` [PATCH net-next v1 4/4] ynl: fix schema check errors Donald Hunter
2025-11-29 4:00 ` [PATCH net-next v1 0/4] tools: ynl: add schema checking patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: Donald Hunter @ 2025-11-27 12:35 UTC (permalink / raw)
To: Jakub Kicinski, David S. Miller, Eric Dumazet, Paolo Abeni,
Simon Horman, Andrew Lunn, Matthieu Baerts (NGI0), Chuck Lever,
Florian Westphal, Remy D. Farley, Kory Maincent (Dent Project),
Gal Pressman, Oleksij Rempel, Stanislav Fomichev, Jan Stancek,
Hangbin Liu, Nimrod Oren, netdev
Cc: Donald Hunter
Fix warning reported by yamllint:
../../../Documentation/netlink/specs/ethtool.yaml
1272:21 warning truthy value should be one of [false, true] (truthy)
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
---
Documentation/netlink/specs/ethtool.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/netlink/specs/ethtool.yaml b/Documentation/netlink/specs/ethtool.yaml
index 05d2b6508b59..0a2d2343f79a 100644
--- a/Documentation/netlink/specs/ethtool.yaml
+++ b/Documentation/netlink/specs/ethtool.yaml
@@ -1269,7 +1269,7 @@ attribute-sets:
-
name: hist
type: nest
- multi-attr: True
+ multi-attr: true
nested-attributes: fec-hist
-
name: fec
--
2.51.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH net-next v1 4/4] ynl: fix schema check errors
2025-11-27 12:34 [PATCH net-next v1 0/4] tools: ynl: add schema checking Donald Hunter
` (2 preceding siblings ...)
2025-11-27 12:35 ` [PATCH net-next v1 3/4] ynl: fix a yamllint warning in ethtool spec Donald Hunter
@ 2025-11-27 12:35 ` Donald Hunter
2025-11-29 4:00 ` [PATCH net-next v1 0/4] tools: ynl: add schema checking patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: Donald Hunter @ 2025-11-27 12:35 UTC (permalink / raw)
To: Jakub Kicinski, David S. Miller, Eric Dumazet, Paolo Abeni,
Simon Horman, Andrew Lunn, Matthieu Baerts (NGI0), Chuck Lever,
Florian Westphal, Remy D. Farley, Kory Maincent (Dent Project),
Gal Pressman, Oleksij Rempel, Stanislav Fomichev, Jan Stancek,
Hangbin Liu, Nimrod Oren, netdev
Cc: Donald Hunter
Fix two schema check errors that have lurked since the attribute name
validation was made more strict:
not ok 2 conntrack.yaml schema validation
'labels mask' does not match '^[0-9a-z-]+$'
not ok 13 nftables.yaml schema validation
'set id' does not match '^[0-9a-z-]+$'
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
---
Documentation/netlink/specs/conntrack.yaml | 2 +-
Documentation/netlink/specs/nftables.yaml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/netlink/specs/conntrack.yaml b/Documentation/netlink/specs/conntrack.yaml
index bef528633b17..db7cddcda50a 100644
--- a/Documentation/netlink/specs/conntrack.yaml
+++ b/Documentation/netlink/specs/conntrack.yaml
@@ -457,7 +457,7 @@ attribute-sets:
name: labels
type: binary
-
- name: labels mask
+ name: labels-mask
type: binary
-
name: synproxy
diff --git a/Documentation/netlink/specs/nftables.yaml b/Documentation/netlink/specs/nftables.yaml
index cce88819ba71..17ad707fa0d5 100644
--- a/Documentation/netlink/specs/nftables.yaml
+++ b/Documentation/netlink/specs/nftables.yaml
@@ -915,7 +915,7 @@ attribute-sets:
type: string
doc: Name of set to use
-
- name: set id
+ name: set-id
type: u32
byte-order: big-endian
doc: ID of set to use
--
2.51.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next v1 0/4] tools: ynl: add schema checking
2025-11-27 12:34 [PATCH net-next v1 0/4] tools: ynl: add schema checking Donald Hunter
` (3 preceding siblings ...)
2025-11-27 12:35 ` [PATCH net-next v1 4/4] ynl: fix schema check errors Donald Hunter
@ 2025-11-29 4:00 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-29 4:00 UTC (permalink / raw)
To: Donald Hunter
Cc: kuba, davem, edumazet, pabeni, horms, andrew, matttbe,
chuck.lever, fw, one-d-wide, kory.maincent, gal, o.rempel, sdf,
jstancek, liuhangbin, noren, netdev
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 27 Nov 2025 12:34:58 +0000 you wrote:
> Add schema checking and yaml linting for the YNL specs.
>
> Patch 1 adds a schema_check make target using a pyynl --validate option
> Patch 2 adds a lint make target using yamllint
> Patches 3,4 fix issues reported by make -C tools/net/ynl lint schema_check
>
> Donald Hunter (4):
> tools: ynl: add schema checking
> tools: ynl: add a lint makefile target
> ynl: fix a yamllint warning in ethtool spec
> ynl: fix schema check errors
>
> [...]
Here is the summary with links:
- [net-next,v1,1/4] tools: ynl: add schema checking
https://git.kernel.org/netdev/net-next/c/362d051c90b6
- [net-next,v1,2/4] tools: ynl: add a lint makefile target
https://git.kernel.org/netdev/net-next/c/129dc6075a15
- [net-next,v1,3/4] ynl: fix a yamllint warning in ethtool spec
https://git.kernel.org/netdev/net-next/c/acce9d7200e2
- [net-next,v1,4/4] ynl: fix schema check errors
https://git.kernel.org/netdev/net-next/c/1adc241f3940
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-11-29 4:03 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-27 12:34 [PATCH net-next v1 0/4] tools: ynl: add schema checking Donald Hunter
2025-11-27 12:34 ` [PATCH net-next v1 1/4] " Donald Hunter
2025-11-27 12:35 ` [PATCH net-next v1 2/4] tools: ynl: add a lint makefile target Donald Hunter
2025-11-27 12:35 ` [PATCH net-next v1 3/4] ynl: fix a yamllint warning in ethtool spec Donald Hunter
2025-11-27 12:35 ` [PATCH net-next v1 4/4] ynl: fix schema check errors Donald Hunter
2025-11-29 4:00 ` [PATCH net-next v1 0/4] tools: ynl: add schema checking patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).