]> www.infradead.org Git - users/hch/misc.git/commitdiff
net: ethtool: tsinfo: Fix dump command
authorKory Maincent <kory.maincent@bootlin.com>
Fri, 7 Mar 2025 09:12:55 +0000 (10:12 +0100)
committerJakub Kicinski <kuba@kernel.org>
Mon, 10 Mar 2025 20:14:25 +0000 (13:14 -0700)
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>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20250307091255.463559-1-kory.maincent@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ethtool/tsinfo.c

index 691be6c445b3816e32c97388aa9d4fbf3386b35c..ad3866c5a902be78e0821cda81fe0c0631bad6c3 100644 (file)
@@ -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;
 }