[PATCH net-next v2 3/3] net: reject a netdev that implements only one hwtstamp NDO
From: Nicolai Buchwitz
Date: Fri Oct 02 2026 - 05:47:30 EST
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@xxxxxxxxxx>
Signed-off-by: Nicolai Buchwitz <nb@xxxxxxxxxxx>
---
net/core/dev.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/core/dev.c b/net/core/dev.c
index ca7f4844cc40..db765cb5811e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -11462,6 +11462,11 @@ static int netdev_check_ops(struct net_device *dev)
return -EINVAL;
}
+ if (!ops->ndo_hwtstamp_get != !ops->ndo_hwtstamp_set) {
+ netdev_WARN(dev, "driver implements only one hwtstamp NDO\n");
+ return -EINVAL;
+ }
+
if (netdev_need_ops_lock(dev) && ops->ndo_set_rx_mode &&
!ops->ndo_set_rx_mode_async) {
netdev_WARN(dev, "ops-locked drivers should use ndo_set_rx_mode_async\n");
--
2.53.0