* [PATCH net] tools/net/ynl: ethtool: fix crash when Hardware Clock info is missing
@ 2025-05-08 3:54 Hangbin Liu
2025-05-08 16:13 ` Stanislav Fomichev
2025-05-09 23:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Hangbin Liu @ 2025-05-08 3:54 UTC (permalink / raw)
To: netdev
Cc: Donald Hunter, Jakub Kicinski, David S. Miller, Eric Dumazet,
Paolo Abeni, Simon Horman, Jan Stancek, Stanislav Fomichev,
Hangbin Liu
Fix a crash in the ethtool YNL implementation when Hardware Clock information
is not present in the response. This ensures graceful handling of devices or
drivers that do not provide this optional field. e.g.
Traceback (most recent call last):
File "/net/tools/net/ynl/pyynl/./ethtool.py", line 438, in <module>
main()
~~~~^^
File "/net/tools/net/ynl/pyynl/./ethtool.py", line 341, in main
print(f'PTP Hardware Clock: {tsinfo["phc-index"]}')
~~~~~~^^^^^^^^^^^^^
KeyError: 'phc-index'
Fixes: f3d07b02b2b8 ("tools: ynl: ethtool testing tool")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
tools/net/ynl/pyynl/ethtool.py | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/tools/net/ynl/pyynl/ethtool.py b/tools/net/ynl/pyynl/ethtool.py
index af7fddd7b085..cab6b576c876 100755
--- a/tools/net/ynl/pyynl/ethtool.py
+++ b/tools/net/ynl/pyynl/ethtool.py
@@ -338,16 +338,24 @@ def main():
print('Capabilities:')
[print(f'\t{v}') for v in bits_to_dict(tsinfo['timestamping'])]
- print(f'PTP Hardware Clock: {tsinfo["phc-index"]}')
+ print(f'PTP Hardware Clock: {tsinfo.get("phc-index", "none")}')
- print('Hardware Transmit Timestamp Modes:')
- [print(f'\t{v}') for v in bits_to_dict(tsinfo['tx-types'])]
+ if 'tx-types' in tsinfo:
+ print('Hardware Transmit Timestamp Modes:')
+ [print(f'\t{v}') for v in bits_to_dict(tsinfo['tx-types'])]
+ else:
+ print('Hardware Transmit Timestamp Modes: none')
+
+ if 'rx-filters' in tsinfo:
+ print('Hardware Receive Filter Modes:')
+ [print(f'\t{v}') for v in bits_to_dict(tsinfo['rx-filters'])]
+ else:
+ print('Hardware Receive Filter Modes: none')
- print('Hardware Receive Filter Modes:')
- [print(f'\t{v}') for v in bits_to_dict(tsinfo['rx-filters'])]
+ if 'stats' in tsinfo and tsinfo['stats']:
+ print('Statistics:')
+ [print(f'\t{k}: {v}') for k, v in tsinfo['stats'].items()]
- print('Statistics:')
- [print(f'\t{k}: {v}') for k, v in tsinfo['stats'].items()]
return
print(f'Settings for {args.device}:')
--
2.46.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] tools/net/ynl: ethtool: fix crash when Hardware Clock info is missing
2025-05-08 3:54 [PATCH net] tools/net/ynl: ethtool: fix crash when Hardware Clock info is missing Hangbin Liu
@ 2025-05-08 16:13 ` Stanislav Fomichev
2025-05-09 23:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Stanislav Fomichev @ 2025-05-08 16:13 UTC (permalink / raw)
To: Hangbin Liu
Cc: netdev, Donald Hunter, Jakub Kicinski, David S. Miller,
Eric Dumazet, Paolo Abeni, Simon Horman, Jan Stancek,
Stanislav Fomichev
On 05/08, Hangbin Liu wrote:
> Fix a crash in the ethtool YNL implementation when Hardware Clock information
> is not present in the response. This ensures graceful handling of devices or
> drivers that do not provide this optional field. e.g.
>
> Traceback (most recent call last):
> File "/net/tools/net/ynl/pyynl/./ethtool.py", line 438, in <module>
> main()
> ~~~~^^
> File "/net/tools/net/ynl/pyynl/./ethtool.py", line 341, in main
> print(f'PTP Hardware Clock: {tsinfo["phc-index"]}')
> ~~~~~~^^^^^^^^^^^^^
> KeyError: 'phc-index'
>
> Fixes: f3d07b02b2b8 ("tools: ynl: ethtool testing tool")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] tools/net/ynl: ethtool: fix crash when Hardware Clock info is missing
2025-05-08 3:54 [PATCH net] tools/net/ynl: ethtool: fix crash when Hardware Clock info is missing Hangbin Liu
2025-05-08 16:13 ` Stanislav Fomichev
@ 2025-05-09 23:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-05-09 23:30 UTC (permalink / raw)
To: Hangbin Liu
Cc: netdev, donald.hunter, kuba, davem, edumazet, pabeni, horms,
jstancek, sdf
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 8 May 2025 03:54:14 +0000 you wrote:
> Fix a crash in the ethtool YNL implementation when Hardware Clock information
> is not present in the response. This ensures graceful handling of devices or
> drivers that do not provide this optional field. e.g.
>
> Traceback (most recent call last):
> File "/net/tools/net/ynl/pyynl/./ethtool.py", line 438, in <module>
> main()
> ~~~~^^
> File "/net/tools/net/ynl/pyynl/./ethtool.py", line 341, in main
> print(f'PTP Hardware Clock: {tsinfo["phc-index"]}')
> ~~~~~~^^^^^^^^^^^^^
> KeyError: 'phc-index'
>
> [...]
Here is the summary with links:
- [net] tools/net/ynl: ethtool: fix crash when Hardware Clock info is missing
https://git.kernel.org/netdev/net/c/45375814eb3f
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-05-09 23:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-08 3:54 [PATCH net] tools/net/ynl: ethtool: fix crash when Hardware Clock info is missing Hangbin Liu
2025-05-08 16:13 ` Stanislav Fomichev
2025-05-09 23:30 ` 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).