Thread (1 message) 1 message, 1 author, 12d ago

[PATCH net-next v2 3/3] net: reject a netdev that implements only one hwtstamp NDO

DORMANTno replies IN NET-NEXT

From: Nicolai Buchwitz <nb@tipi-net.de>
Date: 2026-10-02 09:42:33
Also in: lkml
Subsystem: networking [general], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

Queued in net-next as 810a662abcd5 on 2026-10-06.

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 | 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help