Skip to content

Commit 3c9231e

Browse files
JasonXingdavem330
authored andcommitted
net-timestamp: support TCP GSO case for a few missing flags
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 6b98ec7 ("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: 4ed2d76 ("net-timestamp: TCP timestamping") Signed-off-by: Jason Xing <kerneljasonxing@gmail.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b33a534 commit 3c9231e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

net/ipv4/tcp_offload.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@
1313
#include <net/tcp.h>
1414
#include <net/protocol.h>
1515

16-
static void tcp_gso_tstamp(struct sk_buff *skb, unsigned int ts_seq,
16+
static void tcp_gso_tstamp(struct sk_buff *skb, struct sk_buff *gso_skb,
1717
unsigned int seq, unsigned int mss)
1818
{
19+
u32 flags = skb_shinfo(gso_skb)->tx_flags & SKBTX_ANY_TSTAMP;
20+
u32 ts_seq = skb_shinfo(gso_skb)->tskey;
21+
1922
while (skb) {
2023
if (before(ts_seq, seq + mss)) {
21-
skb_shinfo(skb)->tx_flags |= SKBTX_SW_TSTAMP;
24+
skb_shinfo(skb)->tx_flags |= flags;
2225
skb_shinfo(skb)->tskey = ts_seq;
2326
return;
2427
}
@@ -193,8 +196,8 @@ struct sk_buff *tcp_gso_segment(struct sk_buff *skb,
193196
th = tcp_hdr(skb);
194197
seq = ntohl(th->seq);
195198

196-
if (unlikely(skb_shinfo(gso_skb)->tx_flags & SKBTX_SW_TSTAMP))
197-
tcp_gso_tstamp(segs, skb_shinfo(gso_skb)->tskey, seq, mss);
199+
if (unlikely(skb_shinfo(gso_skb)->tx_flags & SKBTX_ANY_TSTAMP))
200+
tcp_gso_tstamp(segs, gso_skb, seq, mss);
198201

199202
newcheck = ~csum_fold(csum_add(csum_unfold(th->check), delta));
200203

0 commit comments

Comments
 (0)