diff options
| author | Jakub Kicinski <kuba@kernel.org> | 2026-03-10 03:53:37 +0300 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-03-11 05:33:00 +0300 |
| commit | d6df5e9b2a565be08330e46a8a615aac9ed8711b (patch) | |
| tree | c42567f99ee9fe10b9c7404e651253ee90c9c888 | |
| parent | 77a6401a8722be20ea8db98ac900c93ccc7068ff (diff) | |
| download | linux-d6df5e9b2a565be08330e46a8a615aac9ed8711b.tar.xz | |
tools: ynl: cli: add --policy support
Add --policy flag which can be combined with --do or --dump to query
the kernel's netlink policy for an operation instead of executing it.
Examples:
$ ynl --family netdev --do dev-get --policy
{'ifindex': {'max-value': 4294967295, 'min-value': 1, 'type': 'u32'}}
$ ynl --family ethtool --do channels-get --policy --output-json
{"header": {"type": "nested", "policy": {"dev-index": ...}}}
$ ynl --family netdev --dump dev-get --policy
{}
Link: https://patch.msgid.link/20260310005337.3594225-6-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| -rwxr-xr-x | tools/net/ynl/pyynl/cli.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/net/ynl/pyynl/cli.py b/tools/net/ynl/pyynl/cli.py index b452d4fb9434..fc9e84754e4b 100755 --- a/tools/net/ynl/pyynl/cli.py +++ b/tools/net/ynl/pyynl/cli.py @@ -256,6 +256,8 @@ def main(): schema_group.add_argument('--no-schema', action='store_true') dbg_group = parser.add_argument_group('Debug options') + io_group.add_argument('--policy', action='store_true', + help='Query kernel policy for the operation instead of executing it') dbg_group.add_argument('--dbg-small-recv', default=0, const=4000, action='store', nargs='?', type=int, metavar='INT', help="Length of buffers used for recv()") @@ -308,6 +310,16 @@ def main(): if args.dbg_small_recv: ynl.set_recv_dbg(True) + if args.policy: + if args.do: + pol = ynl.get_policy(args.do, 'do') + output(pol.attrs if pol else None) + args.do = None + if args.dump: + pol = ynl.get_policy(args.dump, 'dump') + output(pol.attrs if pol else None) + args.dump = None + if args.ntf: ynl.ntf_subscribe(args.ntf) |
