* [PATCH net-next v1] tools: ynl: process unknown for enum values
@ 2025-07-11 17:04 Donald Hunter
2025-07-11 22:58 ` Jakub Kicinski
2025-07-13 12:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Donald Hunter @ 2025-07-11 17:04 UTC (permalink / raw)
To: netdev, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Jan Stancek, Arkadiusz Kubalewski,
Stanislav Fomichev
Cc: donald.hunter, Donald Hunter
Extend the process_unknown handing to enum values and flags.
Tested by removing entries from rt-link.yaml and rt-neigh.yaml:
./tools/net/ynl/pyynl/cli.py --family rt-link --dump getlink \
--process-unknown --output-json | jq '.[0] | ."ifi-flags"'
[
"up",
"Unknown(6)",
"loopback",
"Unknown(16)"
]
./tools/net/ynl/pyynl/cli.py --family rt-neigh --dump getneigh \
--process-unknown --output-json | jq '.[] | ."ndm-type"'
"unicast"
"Unknown(5)"
"Unknown(5)"
"unicast"
"Unknown(5)"
"unicast"
"broadcast"
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
---
tools/net/ynl/pyynl/lib/ynl.py | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/net/ynl/pyynl/lib/ynl.py b/tools/net/ynl/pyynl/lib/ynl.py
index 7529bce174ff..006b359294a4 100644
--- a/tools/net/ynl/pyynl/lib/ynl.py
+++ b/tools/net/ynl/pyynl/lib/ynl.py
@@ -618,6 +618,16 @@ class YnlFamily(SpecFamily):
pad = b'\x00' * ((4 - len(attr_payload) % 4) % 4)
return struct.pack('HH', len(attr_payload) + 4, nl_type) + attr_payload + pad
+ def _get_enum_or_unknown(self, enum, raw):
+ try:
+ name = enum.entries_by_val[raw].name
+ except KeyError as error:
+ if self.process_unknown:
+ name = f"Unknown({raw})"
+ else:
+ raise error
+ return name
+
def _decode_enum(self, raw, attr_spec):
enum = self.consts[attr_spec['enum']]
if enum.type == 'flags' or attr_spec.get('enum-as-flags', False):
@@ -625,11 +635,11 @@ class YnlFamily(SpecFamily):
value = set()
while raw:
if raw & 1:
- value.add(enum.entries_by_val[i].name)
+ value.add(self._get_enum_or_unknown(enum, i))
raw >>= 1
i += 1
else:
- value = enum.entries_by_val[raw].name
+ value = self._get_enum_or_unknown(enum, raw)
return value
def _decode_binary(self, attr, attr_spec):
--
2.50.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next v1] tools: ynl: process unknown for enum values
2025-07-11 17:04 [PATCH net-next v1] tools: ynl: process unknown for enum values Donald Hunter
@ 2025-07-11 22:58 ` Jakub Kicinski
2025-07-13 12:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2025-07-11 22:58 UTC (permalink / raw)
To: Donald Hunter
Cc: netdev, David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman,
Jan Stancek, Arkadiusz Kubalewski, Stanislav Fomichev,
donald.hunter
On Fri, 11 Jul 2025 18:04:56 +0100 Donald Hunter wrote:
> Extend the process_unknown handing to enum values and flags.
>
> Tested by removing entries from rt-link.yaml and rt-neigh.yaml:
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next v1] tools: ynl: process unknown for enum values
2025-07-11 17:04 [PATCH net-next v1] tools: ynl: process unknown for enum values Donald Hunter
2025-07-11 22:58 ` Jakub Kicinski
@ 2025-07-13 12:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-07-13 12:20 UTC (permalink / raw)
To: Donald Hunter
Cc: netdev, kuba, davem, edumazet, pabeni, horms, jstancek,
arkadiusz.kubalewski, sdf, donald.hunter
Hello:
This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:
On Fri, 11 Jul 2025 18:04:56 +0100 you wrote:
> Extend the process_unknown handing to enum values and flags.
>
> Tested by removing entries from rt-link.yaml and rt-neigh.yaml:
>
> ./tools/net/ynl/pyynl/cli.py --family rt-link --dump getlink \
> --process-unknown --output-json | jq '.[0] | ."ifi-flags"'
> [
> "up",
> "Unknown(6)",
> "loopback",
> "Unknown(16)"
> ]
>
> [...]
Here is the summary with links:
- [net-next,v1] tools: ynl: process unknown for enum values
https://git.kernel.org/netdev/net-next/c/8c2e602225f0
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] 3+ messages in thread
end of thread, other threads:[~2025-07-13 12:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-11 17:04 [PATCH net-next v1] tools: ynl: process unknown for enum values Donald Hunter
2025-07-11 22:58 ` Jakub Kicinski
2025-07-13 12:20 ` 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