netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] net: ethtool: tsinfo: Fix dump command
@ 2025-03-07  9:12 Kory Maincent
  2025-03-08  9:33 ` Vadim Fedorenko
  2025-03-10 20:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Kory Maincent @ 2025-03-07  9:12 UTC (permalink / raw)
  To: David S. Miller, Kory Maincent, netdev, linux-kernel
  Cc: Vadim Fedorenko, thomas.petazzoni, Andrew Lunn, Jakub Kicinski,
	Eric Dumazet, Paolo Abeni, Simon Horman

Fix missing initialization of ts_info->phc_index in the dump command,
which could cause a netdev interface to incorrectly display a PTP provider
at index 0 instead of "none".
Fix it by initializing the phc_index to -1.

In the same time, restore missing initialization of ts_info.cmd for the
IOCTL case, as it was before the transition from ethnl_default_dumpit to
custom ethnl_tsinfo_dumpit.

Also, remove unnecessary zeroing of ts_info, as it is embedded within
reply_data, which is fully zeroed two lines earlier.

Fixes: b9e3f7dc9ed95 ("net: ethtool: tsinfo: Enhance tsinfo to support several hwtstamp by net topology")
Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---

Change in v2:
- Remove useless zeroed of ts_info.
---
 net/ethtool/tsinfo.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ethtool/tsinfo.c b/net/ethtool/tsinfo.c
index 691be6c445b38..ad3866c5a902b 100644
--- a/net/ethtool/tsinfo.c
+++ b/net/ethtool/tsinfo.c
@@ -290,7 +290,8 @@ static void *ethnl_tsinfo_prepare_dump(struct sk_buff *skb,
 	reply_data = ctx->reply_data;
 	memset(reply_data, 0, sizeof(*reply_data));
 	reply_data->base.dev = dev;
-	memset(&reply_data->ts_info, 0, sizeof(reply_data->ts_info));
+	reply_data->ts_info.cmd = ETHTOOL_GET_TS_INFO;
+	reply_data->ts_info.phc_index = -1;
 
 	return ehdr;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net: ethtool: tsinfo: Fix dump command
  2025-03-07  9:12 [PATCH net v2] net: ethtool: tsinfo: Fix dump command Kory Maincent
@ 2025-03-08  9:33 ` Vadim Fedorenko
  2025-03-10 20:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Vadim Fedorenko @ 2025-03-08  9:33 UTC (permalink / raw)
  To: Kory Maincent, David S. Miller, netdev, linux-kernel
  Cc: thomas.petazzoni, Andrew Lunn, Jakub Kicinski, Eric Dumazet,
	Paolo Abeni, Simon Horman

On 07/03/2025 09:12, Kory Maincent wrote:
> Fix missing initialization of ts_info->phc_index in the dump command,
> which could cause a netdev interface to incorrectly display a PTP provider
> at index 0 instead of "none".
> Fix it by initializing the phc_index to -1.
> 
> In the same time, restore missing initialization of ts_info.cmd for the
> IOCTL case, as it was before the transition from ethnl_default_dumpit to
> custom ethnl_tsinfo_dumpit.
> 
> Also, remove unnecessary zeroing of ts_info, as it is embedded within
> reply_data, which is fully zeroed two lines earlier.
> 
> Fixes: b9e3f7dc9ed95 ("net: ethtool: tsinfo: Enhance tsinfo to support several hwtstamp by net topology")
> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> ---
> 
> Change in v2:
> - Remove useless zeroed of ts_info.
> ---
>   net/ethtool/tsinfo.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/ethtool/tsinfo.c b/net/ethtool/tsinfo.c
> index 691be6c445b38..ad3866c5a902b 100644
> --- a/net/ethtool/tsinfo.c
> +++ b/net/ethtool/tsinfo.c
> @@ -290,7 +290,8 @@ static void *ethnl_tsinfo_prepare_dump(struct sk_buff *skb,
>   	reply_data = ctx->reply_data;
>   	memset(reply_data, 0, sizeof(*reply_data));
>   	reply_data->base.dev = dev;
> -	memset(&reply_data->ts_info, 0, sizeof(reply_data->ts_info));
> +	reply_data->ts_info.cmd = ETHTOOL_GET_TS_INFO;
> +	reply_data->ts_info.phc_index = -1;
>   
>   	return ehdr;
>   }

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net: ethtool: tsinfo: Fix dump command
  2025-03-07  9:12 [PATCH net v2] net: ethtool: tsinfo: Fix dump command Kory Maincent
  2025-03-08  9:33 ` Vadim Fedorenko
@ 2025-03-10 20:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-03-10 20:20 UTC (permalink / raw)
  To: Kory Maincent
  Cc: davem, netdev, linux-kernel, vadim.fedorenko, thomas.petazzoni,
	andrew, kuba, edumazet, pabeni, horms

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri,  7 Mar 2025 10:12:55 +0100 you wrote:
> Fix missing initialization of ts_info->phc_index in the dump command,
> which could cause a netdev interface to incorrectly display a PTP provider
> at index 0 instead of "none".
> Fix it by initializing the phc_index to -1.
> 
> In the same time, restore missing initialization of ts_info.cmd for the
> IOCTL case, as it was before the transition from ethnl_default_dumpit to
> custom ethnl_tsinfo_dumpit.
> 
> [...]

Here is the summary with links:
  - [net,v2] net: ethtool: tsinfo: Fix dump command
    https://git.kernel.org/netdev/net/c/d0a4a1b36d7a

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-03-10 20:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-07  9:12 [PATCH net v2] net: ethtool: tsinfo: Fix dump command Kory Maincent
2025-03-08  9:33 ` Vadim Fedorenko
2025-03-10 20: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;
as well as URLs for NNTP newsgroup(s).