From: Nicolai Buchwitz <nb@tipi-net.de>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>
Cc: Kuniyuki Iwashima <kuniyu@google.com>,
Nicolai Buchwitz <nb@tipi-net.de>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net-next v2 3/3] net: reject a netdev that implements only one hwtstamp NDO
Date: Fri, 2 Oct 2026 11:42:09 +0200 [thread overview]
Message-ID: <20261002094211.2350702-4-nb@tipi-net.de> (raw)
In-Reply-To: <20261002094211.2350702-1-nb@tipi-net.de>
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
prev parent reply other threads:[~2026-10-02 9:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261002094211.2350702-1-nb@tipi-net.de>
2026-10-02 9:42 ` [PATCH net-next v2 1/3] net: move the netdev_ops checks into a helper Nicolai Buchwitz
2026-10-06 0:10 ` patchwork-bot+netdevbpf
2026-10-02 9:42 ` [PATCH net-next v2 2/3] net: reject ops-locked drivers without ndo_set_rx_mode_async Nicolai Buchwitz
2026-10-02 9:42 ` Nicolai Buchwitz [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261002094211.2350702-4-nb@tipi-net.de \
--to=nb@tipi-net.de \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.