From: Jason Xing <kerneljasonxing@gmail.com>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, willemb@google.com,
kuniyu@google.com
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
Jason Xing <kerneljasonxing@gmail.com>
Subject: [PATCH RFC net-next 9/9] tcp: handle the start time of each split skb in the tx path
Date: Sat, 19 Sep 2026 22:37:32 +0800 [thread overview]
Message-ID: <20260919143732.11772-10-kerneljasonxing@gmail.com> (raw)
In-Reply-To: <20260919143732.11772-1-kerneljasonxing@gmail.com>
Segmentation and collapsing create or reuse skbs with a fresh
shared_info, which would otherwise drop the start time recorded
on the original skb.
Handle every TCP path that manipulates the shared hwtstamps:
- tcp_gso_segment(): handle the gso case. Propagate the same
gso_skb's start time to every resulting segment.
- tcp_fragment/tso_fragment(): handle the tso/recovery.. cases.
Copy the start time onto the second half of the split so both
fragments keep it.
- tcp_skb_collapse_tstamp(): handle collapse case. Copy the eaten
skb's start time onto the survivor.
- __tcp_retransmit_skb(): handle retrans case - the retransmit
path __tcp_retransmit_skb->__pskb_copy.
Signed-off-by: Jason Xing <kerneljasonxing@gmail.com>
---
rx path logic: https://lore.kernel.org/all/20260917132742.87117-1-kerneljasonxing@gmail.com/
---
include/linux/skbuff.h | 6 ++++++
net/ipv4/tcp_offload.c | 3 +++
net/ipv4/tcp_output.c | 5 +++++
3 files changed, 14 insertions(+)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index c5347be72ff9..5f01239af191 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -5491,6 +5491,12 @@ static inline void skb_mark_for_recycle(struct sk_buff *skb)
#endif
}
+static inline void skb_copy_start_time(struct sk_buff *dst, struct sk_buff *src)
+{
+ if (static_branch_unlikely(&bpfts_v2_needed_key))
+ skb_hwtstamps(dst)->start_time = skb_hwtstamps(src)->start_time;
+}
+
ssize_t skb_splice_from_iter(struct sk_buff *skb, struct iov_iter *iter,
ssize_t maxsize);
diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c
index 3b1fdcd3cb29..3b33e9f4fbc9 100644
--- a/net/ipv4/tcp_offload.c
+++ b/net/ipv4/tcp_offload.c
@@ -201,6 +201,8 @@ struct sk_buff *tcp_gso_segment(struct sk_buff *skb,
if (unlikely(skb_shinfo(gso_skb)->tx_flags & SKBTX_ANY_TSTAMP))
tcp_gso_tstamp(segs, gso_skb, seq, mss);
+ skb_copy_start_time(segs, gso_skb);
+
newcheck = ~csum_fold(csum_add(csum_unfold(th->check), delta));
ecn_cwr_mask = !!(skb_shinfo(gso_skb)->gso_type & SKB_GSO_TCP_ACCECN);
@@ -226,6 +228,7 @@ struct sk_buff *tcp_gso_segment(struct sk_buff *skb,
th->seq = htonl(seq);
th->cwr &= ecn_cwr_mask;
+ skb_copy_start_time(skb, gso_skb);
}
/* Following permits TCP Small Queues to work well with GSO :
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 6f4dca4a4de9..006157321f49 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1900,6 +1900,7 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue,
tcp_skb_fragment_eor(skb, buff);
skb_split(skb, buff, len);
+ skb_copy_start_time(buff, skb);
skb_set_delivery_time(buff, skb->tstamp, SKB_CLOCK_MONOTONIC);
tcp_fragment_tstamp(skb, buff);
@@ -2431,6 +2432,7 @@ static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len,
tcp_skb_fragment_eor(skb, buff);
skb_split(skb, buff, len);
+ skb_copy_start_time(buff, skb);
tcp_fragment_tstamp(skb, buff);
/* Fix up tso_factor for both original and new SKB. */
@@ -3445,6 +3447,8 @@ void tcp_skb_collapse_tstamp(struct sk_buff *skb,
TCP_SKB_CB(skb)->txstamp_ack |=
TCP_SKB_CB(next_skb)->txstamp_ack;
}
+ if (!skb_hwtstamps(skb)->start_time)
+ skb_copy_start_time(skb, (struct sk_buff *)next_skb);
}
/* Collapses two adjacent SKB's during retransmission. */
@@ -3661,6 +3665,7 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs)
nskb = __pskb_copy(skb, MAX_TCP_HEADER, GFP_ATOMIC);
if (nskb) {
nskb->dev = NULL;
+ skb_copy_start_time(nskb, skb);
err = tcp_transmit_skb(sk, nskb, 0, GFP_ATOMIC);
} else {
err = -ENOBUFS;
--
2.43.7
next prev parent reply other threads:[~2026-09-19 14:39 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 14:37 [PATCH RFC net-next 0/9] net: BPF Timestamping 2.0 for TCP Jason Xing
2026-09-19 14:37 ` [PATCH RFC net-next 1/9] net: add bpf_setsockopt for SK_BPF_CB_TIMESTAMPING_V2 Jason Xing
2026-09-20 14:39 ` sashiko-bot
2026-09-19 14:37 ` [PATCH RFC net-next 2/9] bpf: add bpf_ktime_get_real_ns() kfunc Jason Xing
2026-09-20 14:39 ` sashiko-bot
2026-09-19 14:37 ` [PATCH RFC net-next 3/9] tcp: record a start time in the tx path for SK_BPF_CB_TIMESTAMPING_V2 Jason Xing
2026-09-20 14:39 ` sashiko-bot
2026-09-19 14:37 ` [PATCH RFC net-next 4/9] net: reuse skb_shared_hwtstamps for BPF Timestamping v2 Jason Xing
2026-09-20 14:39 ` sashiko-bot
2026-09-19 14:37 ` [PATCH RFC net-next 5/9] net-timestamp: use pskb_copy to avoid polluting the orig skb's start time Jason Xing
2026-09-20 14:39 ` sashiko-bot
2026-09-19 14:37 ` [PATCH RFC net-next 6/9] bpf-timestamping: restore skb hwtstamp if it is used by " Jason Xing
2026-09-20 14:39 ` sashiko-bot
2026-09-19 14:37 ` [PATCH RFC net-next 7/9] tcp: propagate the start time onto every skb in the tx path Jason Xing
2026-09-20 14:39 ` sashiko-bot
2026-09-19 14:37 ` [PATCH RFC net-next 8/9] net: generate the start time for every skb in the rx path Jason Xing
2026-09-20 14:39 ` sashiko-bot
2026-09-19 14:37 ` Jason Xing [this message]
2026-09-20 14:39 ` [PATCH RFC net-next 9/9] tcp: handle the start time of each split skb in the tx path sashiko-bot
2026-09-19 18:12 ` [PATCH RFC net-next 0/9] net: BPF Timestamping 2.0 for TCP Alexei Starovoitov
2026-09-20 0:41 ` Jason Xing
2026-09-21 18:45 ` Stanislav Fomichev
2026-09-22 1:20 ` Jason Xing
2026-09-22 20:53 ` Stanislav Fomichev
2026-09-23 9:40 ` Jason Xing
2026-09-24 16:11 ` Stanislav Fomichev
2026-09-30 10:21 ` Jason Xing
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=20260919143732.11772-10-kerneljasonxing@gmail.com \
--to=kerneljasonxing@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.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