netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] net-timestamp: support TCP GSO case for a few missing flags
@ 2025-03-04  0:44 Jason Xing
  2025-03-04 14:01 ` Willem de Bruijn
  2025-03-05 13:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Jason Xing @ 2025-03-04  0:44 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, ncardwell, kuniyu, dsahern,
	willemb, willemdebruijn.kernel, horms
  Cc: netdev, Jason Xing

When I read through the TSO codes, I found out that we probably
miss initializing the tx_flags of last seg when TSO is turned
off, which means at the following points no more timestamp
(for this last one) will be generated. There are three flags
to be handled in this patch:
1. SKBTX_HW_TSTAMP
2. SKBTX_BPF
3. SKBTX_SCHED_TSTAMP
Note that SKBTX_BPF[1] was added in 6.14.0-rc2 by commit
6b98ec7e882af ("bpf: Add BPF_SOCK_OPS_TSTAMP_SCHED_CB callback")
and only belongs to net-next branch material for now. The common
issue of the above three flags can be fixed by this single patch.

This patch initializes the tx_flags to SKBTX_ANY_TSTAMP like what
the UDP GSO does to make the newly segmented last skb inherit the
tx_flags so that requested timestamp will be generated in each
certain layer, or else that last one has zero value of tx_flags
which leads to no timestamp at all.

Fixes: 4ed2d765dfacc ("net-timestamp: TCP timestamping")
Signed-off-by: Jason Xing <kerneljasonxing@gmail.com>
---
v2
Link: https://lore.kernel.org/all/20250228164904.47511-1-kerneljasonxing@gmail.com/
1. remove unnecessary parentheses
2. adjust commit log
3. target net branch
4. add Fixes tag
---
 net/ipv4/tcp_offload.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c
index 2308665b51c5..2dfac79dc78b 100644
--- a/net/ipv4/tcp_offload.c
+++ b/net/ipv4/tcp_offload.c
@@ -13,12 +13,15 @@
 #include <net/tcp.h>
 #include <net/protocol.h>
 
-static void tcp_gso_tstamp(struct sk_buff *skb, unsigned int ts_seq,
+static void tcp_gso_tstamp(struct sk_buff *skb, struct sk_buff *gso_skb,
 			   unsigned int seq, unsigned int mss)
 {
+	u32 flags = skb_shinfo(gso_skb)->tx_flags & SKBTX_ANY_TSTAMP;
+	u32 ts_seq = skb_shinfo(gso_skb)->tskey;
+
 	while (skb) {
 		if (before(ts_seq, seq + mss)) {
-			skb_shinfo(skb)->tx_flags |= SKBTX_SW_TSTAMP;
+			skb_shinfo(skb)->tx_flags |= flags;
 			skb_shinfo(skb)->tskey = ts_seq;
 			return;
 		}
@@ -193,8 +196,8 @@ struct sk_buff *tcp_gso_segment(struct sk_buff *skb,
 	th = tcp_hdr(skb);
 	seq = ntohl(th->seq);
 
-	if (unlikely(skb_shinfo(gso_skb)->tx_flags & SKBTX_SW_TSTAMP))
-		tcp_gso_tstamp(segs, skb_shinfo(gso_skb)->tskey, seq, mss);
+	if (unlikely(skb_shinfo(gso_skb)->tx_flags & SKBTX_ANY_TSTAMP))
+		tcp_gso_tstamp(segs, gso_skb, seq, mss);
 
 	newcheck = ~csum_fold(csum_add(csum_unfold(th->check), delta));
 
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net-timestamp: support TCP GSO case for a few missing flags
  2025-03-04  0:44 [PATCH net v2] net-timestamp: support TCP GSO case for a few missing flags Jason Xing
@ 2025-03-04 14:01 ` Willem de Bruijn
  2025-03-05 13:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Willem de Bruijn @ 2025-03-04 14:01 UTC (permalink / raw)
  To: Jason Xing, davem, edumazet, kuba, pabeni, ncardwell, kuniyu,
	dsahern, willemb, willemdebruijn.kernel, horms
  Cc: netdev, Jason Xing

Jason Xing wrote:
> When I read through the TSO codes, I found out that we probably
> miss initializing the tx_flags of last seg when TSO is turned
> off, which means at the following points no more timestamp
> (for this last one) will be generated. There are three flags
> to be handled in this patch:
> 1. SKBTX_HW_TSTAMP
> 2. SKBTX_BPF
> 3. SKBTX_SCHED_TSTAMP
> Note that SKBTX_BPF[1] was added in 6.14.0-rc2 by commit
> 6b98ec7e882af ("bpf: Add BPF_SOCK_OPS_TSTAMP_SCHED_CB callback")
> and only belongs to net-next branch material for now. The common
> issue of the above three flags can be fixed by this single patch.
> 
> This patch initializes the tx_flags to SKBTX_ANY_TSTAMP like what
> the UDP GSO does to make the newly segmented last skb inherit the
> tx_flags so that requested timestamp will be generated in each
> certain layer, or else that last one has zero value of tx_flags
> which leads to no timestamp at all.
> 
> Fixes: 4ed2d765dfacc ("net-timestamp: TCP timestamping")
> Signed-off-by: Jason Xing <kerneljasonxing@gmail.com>

Reviewed-by: Willem de Bruijn <willemb@google.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net-timestamp: support TCP GSO case for a few missing flags
  2025-03-04  0:44 [PATCH net v2] net-timestamp: support TCP GSO case for a few missing flags Jason Xing
  2025-03-04 14:01 ` Willem de Bruijn
@ 2025-03-05 13:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-03-05 13:40 UTC (permalink / raw)
  To: Jason Xing
  Cc: davem, edumazet, kuba, pabeni, ncardwell, kuniyu, dsahern,
	willemb, willemdebruijn.kernel, horms, netdev

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Tue,  4 Mar 2025 08:44:29 +0800 you wrote:
> When I read through the TSO codes, I found out that we probably
> miss initializing the tx_flags of last seg when TSO is turned
> off, which means at the following points no more timestamp
> (for this last one) will be generated. There are three flags
> to be handled in this patch:
> 1. SKBTX_HW_TSTAMP
> 2. SKBTX_BPF
> 3. SKBTX_SCHED_TSTAMP
> Note that SKBTX_BPF[1] was added in 6.14.0-rc2 by commit
> 6b98ec7e882af ("bpf: Add BPF_SOCK_OPS_TSTAMP_SCHED_CB callback")
> and only belongs to net-next branch material for now. The common
> issue of the above three flags can be fixed by this single patch.
> 
> [...]

Here is the summary with links:
  - [net,v2] net-timestamp: support TCP GSO case for a few missing flags
    https://git.kernel.org/netdev/net/c/3c9231ea6497

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-05 13:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-04  0:44 [PATCH net v2] net-timestamp: support TCP GSO case for a few missing flags Jason Xing
2025-03-04 14:01 ` Willem de Bruijn
2025-03-05 13:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).