From: Miroslav Lichvar <mlichvar@redhat.com>
To: netdev@vger.kernel.org
Cc: Miroslav Lichvar <mlichvar@redhat.com>,
"Jason A. Donenfeld" <Jason@zx2c4.com>
Subject: [PATCH net-next] wireguard: queuing: preserve napi_id on decapsulation
Date: Thu, 30 Oct 2025 11:48:20 +0100 [thread overview]
Message-ID: <20251030104828.4192906-1-mlichvar@redhat.com> (raw)
The socket timestamping option SOF_TIMESTAMPING_OPT_PKTINFO needs the
skb napi_id in order to provide the index of the device that captured
the receive hardware timestamp. However, wireguard resets most of the
skb headers, including the napi_id, which prevents the timestamping
option from working as expected and applications that rely on it (e.g.
chrony) from using the captured timestamps.
Preserve the napi_id in wg_reset_packet() on decapsulation in order to
make the timestamping option useful with wireguard tunnels and enable
highly-accurate synchronization.
Cc: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
---
Notes:
This is a minimal change that fixes the described problem for me, but
I don't really understand the code well enough to see if there are any
major side effects. If there is a better way to fix the option for wg or
tunnels in general, please let me know.
drivers/net/wireguard/queueing.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/wireguard/queueing.h b/drivers/net/wireguard/queueing.h
index 79b6d70de236..bcf03bc01992 100644
--- a/drivers/net/wireguard/queueing.h
+++ b/drivers/net/wireguard/queueing.h
@@ -75,6 +75,7 @@ static inline bool wg_check_packet_protocol(struct sk_buff *skb)
static inline void wg_reset_packet(struct sk_buff *skb, bool encapsulating)
{
+ unsigned int napi_id = skb_napi_id(skb);
u8 l4_hash = skb->l4_hash;
u8 sw_hash = skb->sw_hash;
u32 hash = skb->hash;
@@ -84,6 +85,10 @@ static inline void wg_reset_packet(struct sk_buff *skb, bool encapsulating)
skb->l4_hash = l4_hash;
skb->sw_hash = sw_hash;
skb->hash = hash;
+ } else {
+#if defined(CONFIG_NET_RX_BUSY_POLL) || defined(CONFIG_XPS)
+ skb->napi_id = napi_id;
+#endif
}
skb->queue_mapping = 0;
skb->nohdr = 0;
--
2.51.0
next reply other threads:[~2025-10-30 10:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-30 10:48 Miroslav Lichvar [this message]
2025-10-30 17:57 ` [PATCH net-next] wireguard: queuing: preserve napi_id on decapsulation Jason A. Donenfeld
2025-10-30 18:37 ` Miroslav Lichvar
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=20251030104828.4192906-1-mlichvar@redhat.com \
--to=mlichvar@redhat.com \
--cc=Jason@zx2c4.com \
--cc=netdev@vger.kernel.org \
/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