diff options
| author | Hangbin Liu <[email protected]> | 2024-03-27 12:31:28 +0000 |
|---|---|---|
| committer | Jakub Kicinski <[email protected]> | 2024-03-29 01:07:08 +0000 |
| commit | b334f5ed3d914d46652db2b8aad7d135ad4a50ad (patch) | |
| tree | 61e95e5e0536b296266a1112ace8d371a6c42d8d /tools/net/ynl/lib/ynl.py | |
| parent | Merge branch 'selftests-fixes-for-kernel-ci' (diff) | |
| download | kernel-b334f5ed3d914d46652db2b8aad7d135ad4a50ad.tar.gz kernel-b334f5ed3d914d46652db2b8aad7d135ad4a50ad.zip | |
ynl: support hex display_hint for integer
Some times it would be convenient to read the integer as hex, like
mask values.
Suggested-by: Donald Hunter <[email protected]>
Reviewed-by: Donald Hunter <[email protected]>
Signed-off-by: Hangbin Liu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Diffstat (limited to 'tools/net/ynl/lib/ynl.py')
| -rw-r--r-- | tools/net/ynl/lib/ynl.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index 5fa7957f6e0f..e73b027c5624 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -819,7 +819,10 @@ class YnlFamily(SpecFamily): if display_hint == 'mac': formatted = ':'.join('%02x' % b for b in raw) elif display_hint == 'hex': - formatted = bytes.hex(raw, ' ') + if isinstance(raw, int): + formatted = hex(raw) + else: + formatted = bytes.hex(raw, ' ') elif display_hint in [ 'ipv4', 'ipv6' ]: formatted = format(ipaddress.ip_address(raw)) elif display_hint == 'uuid': |
