Thread (28 messages) 28 messages, 5 authors, 2025-07-08

Re: [PATCH v5 1/5] net: timestamp: add helper returning skb's tx tstamp

From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: 2025-06-17 16:30:56
Also in: io-uring

Willem de Bruijn wrote:
Pavel Begunkov wrote:
quoted
Add a helper function skb_get_tx_timestamp() that returns a tx timestamp
associated with an error queue skb.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 include/net/sock.h |  4 ++++
 net/socket.c       | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+)
diff --git a/include/net/sock.h b/include/net/sock.h
index 92e7c1aae3cc..f5f5a9ad290b 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2677,6 +2677,10 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
 void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk,
 			     struct sk_buff *skb);
 
+bool skb_has_tx_timestamp(struct sk_buff *skb, const struct sock *sk);
+int skb_get_tx_timestamp(struct sk_buff *skb, struct sock *sk,
+			 struct timespec64 *ts);
+
 static inline void
 sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
 {
diff --git a/net/socket.c b/net/socket.c
index 9a0e720f0859..2cab805943c0 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -843,6 +843,52 @@ static void put_ts_pktinfo(struct msghdr *msg, struct sk_buff *skb,
 		 sizeof(ts_pktinfo), &ts_pktinfo);
 }
 
+bool skb_has_tx_timestamp(struct sk_buff *skb, const struct sock *sk)
+{
I forgot to ask earlier, and not a reason for a respin.

Is the only reason that skb is not const here skb_hwtstamps?

I can send a patch to make that container_of_const
Just to follow up.

The container_of_const is not applicable here. As skb_shared_info is
a (cast) pointer, into skb linear.

So even simpler, the skb can be const even if what its member points
to is not. This works fine.

-static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
+static inline struct skb_shared_hwtstamps *skb_hwtstamps(const struct sk_buff *skb)
 {
        return &skb_shinfo(skb)->hwtstamps;
 }

And same for skb_zcopy, skb_zcopy_init, skb_zcopy_set,
skb_zcopy_set_nouarg, skb_zcopy_is_nouarg, skb_zcopy_get_nouarg,
skb_zcopy_clear, __skb_zcopy_downgrade_managed,
skb_zcopy_downgrade_managed, skb_frag_ref and the ubuf_info_ops
complete and link callbacks.

But that's a lot of churn, especially if including ubuf_info
implementations like io_uring.

Not sure it's worth that.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help