mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolai Buchwitz <nb@tipi-net.de>
To: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>
Cc: Nicolai Buchwitz <nb@tipi-net.de>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net-next] net: reject a netdev that implements only one hwtstamp NDO
Date: Tue, 29 Sep 2026 23:32:32 +0200	[thread overview]
Message-ID: <20260929213233.1555567-1-nb@tipi-net.de> (raw)

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


                 reply	other threads:[~2026-09-29 21:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260929213233.1555567-1-nb@tipi-net.de \
    --to=nb@tipi-net.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --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 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®