mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next] net: reject a netdev that implements only one hwtstamp NDO
@ 2026-09-29 21:32 Nicolai Buchwitz
  2026-10-02  0:25 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Nicolai Buchwitz @ 2026-09-29 21:32 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman
  Cc: Nicolai Buchwitz, netdev, linux-kernel

ndo_hwtstamp_get and ndo_hwtstamp_set only make sense as a pair. A
driver providing just one gets no complaint today, and the mismatch
turns up in user space, where a set can succeed while the matching get
fails.

Catch it at registration instead.

Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de>
---
 net/core/dev.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index f660fccfc0db..574fd0ba9080 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -11447,6 +11447,13 @@ int register_netdevice(struct net_device *dev)
 		goto err_uninit;
 	}
 
+	if (!dev->netdev_ops->ndo_hwtstamp_get !=
+	    !dev->netdev_ops->ndo_hwtstamp_set) {
+		netdev_WARN(dev, "driver implements only one hwtstamp NDO\n");
+		ret = -EINVAL;
+		goto err_uninit;
+	}
+
 	if (netdev_need_ops_lock(dev) &&
 	    dev->netdev_ops->ndo_set_rx_mode &&
 	    !dev->netdev_ops->ndo_set_rx_mode_async)

base-commit: 014d795c73837ea2339a4ea8e8f82c6e959b845d
-- 
2.53.0


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

* Re: [PATCH net-next] net: reject a netdev that implements only one hwtstamp NDO
  2026-09-29 21:32 [PATCH net-next] net: reject a netdev that implements only one hwtstamp NDO Nicolai Buchwitz
@ 2026-10-02  0:25 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2026-10-02  0:25 UTC (permalink / raw)
  To: Nicolai Buchwitz
  Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman, netdev,
	linux-kernel

On Tue, 29 Sep 2026 23:32:32 +0200 Nicolai Buchwitz wrote:
> @@ -11447,6 +11447,13 @@ int register_netdevice(struct net_device *dev)
>  		goto err_uninit;
>  	}
>  
> +	if (!dev->netdev_ops->ndo_hwtstamp_get !=
> +	    !dev->netdev_ops->ndo_hwtstamp_set) {
> +		netdev_WARN(dev, "driver implements only one hwtstamp NDO\n");
> +		ret = -EINVAL;
> +		goto err_uninit;
> +	}
> +
>  	if (netdev_need_ops_lock(dev) &&
>  	    dev->netdev_ops->ndo_set_rx_mode &&
>  	    !dev->netdev_ops->ndo_set_rx_mode_async)

Third such check added here.. we should probably factor all three
out of register_netdevice(). Hardest part is probably naming the
new helper. netdev_check_ops() ? We already have ethtool_check_ops()
We can't move it earlier because some drivers set features form
ndo_init And while you move it you can also make the warning
about not using _async return an error. It was "soft" to avoid
bricking people's systems on boot, but it's been there since v7.1
people will have enough time to spot offenders by v7.4
-- 
pw-bot: cr

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

end of thread, other threads:[~2026-10-02  0:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-29 21:32 [PATCH net-next] net: reject a netdev that implements only one hwtstamp NDO Nicolai Buchwitz
2026-10-02  0:25 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®