Skip to content

Commit cdbab62

Browse files
edumazetdavem330
authored andcommitted
tcp: fix fastopen code vs usec TS
After blamed commit, TFO client-ack-dropped-then-recovery-ms-timestamps packetdrill test failed. David Morley and Neal Cardwell started investigating and Neal pointed that we had : tcp_conn_request() tcp_try_fastopen() -> tcp_fastopen_create_child -> child = inet_csk(sk)->icsk_af_ops->syn_recv_sock() -> tcp_create_openreq_child() -> copy req_usec_ts from req: newtp->tcp_usec_ts = treq->req_usec_ts; // now the new TFO server socket always does usec TS, no matter // what the route options are... send_synack() -> tcp_make_synack() // disable tcp_rsk(req)->req_usec_ts if route option is not present: if (tcp_rsk(req)->req_usec_ts < 0) tcp_rsk(req)->req_usec_ts = dst_tcp_usec_ts(dst); tcp_conn_request() has the initial dst, we can initialize tcp_rsk(req)->req_usec_ts there instead of later in send_synack(); This means tcp_rsk(req)->req_usec_ts can be a boolean. Many thanks to David an Neal for their help. Fixes: 614e831 ("tcp: add support for usec resolution in TCP TS values") Reported-by: kernel test robot <oliver.sang@intel.com> Closes: https://lore.kernel.org/oe-lkp/202310302216.f79d78bc-oliver.sang@intel.com Suggested-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: David Morley <morleyd@google.com> Acked-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 63e2019 commit cdbab62

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

include/linux/tcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ struct tcp_request_sock {
152152
u64 snt_synack; /* first SYNACK sent time */
153153
bool tfo_listener;
154154
bool is_mptcp;
155-
s8 req_usec_ts;
155+
bool req_usec_ts;
156156
#if IS_ENABLED(CONFIG_MPTCP)
157157
bool drop_req;
158158
#endif

net/ipv4/syncookies.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ struct request_sock *cookie_tcp_reqsk_alloc(const struct request_sock_ops *ops,
306306
treq->af_specific = af_ops;
307307

308308
treq->syn_tos = TCP_SKB_CB(skb)->ip_dsfield;
309-
treq->req_usec_ts = -1;
309+
treq->req_usec_ts = false;
310310

311311
#if IS_ENABLED(CONFIG_MPTCP)
312312
treq->is_mptcp = sk_is_mptcp(sk);

net/ipv4/tcp_input.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7115,7 +7115,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
71157115
req->syncookie = want_cookie;
71167116
tcp_rsk(req)->af_specific = af_ops;
71177117
tcp_rsk(req)->ts_off = 0;
7118-
tcp_rsk(req)->req_usec_ts = -1;
7118+
tcp_rsk(req)->req_usec_ts = false;
71197119
#if IS_ENABLED(CONFIG_MPTCP)
71207120
tcp_rsk(req)->is_mptcp = 0;
71217121
#endif
@@ -7143,9 +7143,10 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops,
71437143
if (!dst)
71447144
goto drop_and_free;
71457145

7146-
if (tmp_opt.tstamp_ok)
7146+
if (tmp_opt.tstamp_ok) {
7147+
tcp_rsk(req)->req_usec_ts = dst_tcp_usec_ts(dst);
71477148
tcp_rsk(req)->ts_off = af_ops->init_ts_off(net, skb);
7148-
7149+
}
71497150
if (!want_cookie && !isn) {
71507151
int max_syn_backlog = READ_ONCE(net->ipv4.sysctl_max_syn_backlog);
71517152

net/ipv4/tcp_output.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3693,8 +3693,6 @@ struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst,
36933693
mss = tcp_mss_clamp(tp, dst_metric_advmss(dst));
36943694

36953695
memset(&opts, 0, sizeof(opts));
3696-
if (tcp_rsk(req)->req_usec_ts < 0)
3697-
tcp_rsk(req)->req_usec_ts = dst_tcp_usec_ts(dst);
36983696
now = tcp_clock_ns();
36993697
#ifdef CONFIG_SYN_COOKIES
37003698
if (unlikely(synack_type == TCP_SYNACK_COOKIE && ireq->tstamp_ok))

0 commit comments

Comments
 (0)