Re: [PATCH net] tcp: Fix error ts_recent time during three-way handshake

From: Eric Dumazet
Date: Thu Feb 20 2025 - 03:43:37 EST


On Wed, Feb 19, 2025 at 4:08 AM Wang Hai <wanghai38@xxxxxxxxxx> wrote:
>

> Hi Eric,
>
> According to the plan, can we fix it like this?
>
> diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
> index b089b08e9617..1210d4967b94 100644
> --- a/net/ipv4/tcp_minisocks.c
> +++ b/net/ipv4/tcp_minisocks.c
> @@ -814,13 +814,6 @@ struct sock *tcp_check_req(struct sock *sk, struct
> sk_buff *skb,
> }
>
> /* In sequence, PAWS is OK. */
> -
> - /* TODO: We probably should defer ts_recent change once
> - * we take ownership of @req.
> - */
> - if (tmp_opt.saw_tstamp && !after(TCP_SKB_CB(skb)->seq,
> tcp_rsk(req)->rcv_nxt))
> - WRITE_ONCE(req->ts_recent, tmp_opt.rcv_tsval);
> -
> if (TCP_SKB_CB(skb)->seq == tcp_rsk(req)->rcv_isn) {
> /* Truncate SYN, it is out of window starting
> at tcp_rsk(req)->rcv_isn + 1. */
> @@ -878,6 +871,9 @@ struct sock *tcp_check_req(struct sock *sk, struct
> sk_buff *skb,
> sock_rps_save_rxhash(child, skb);
> tcp_synack_rtt_meas(child, req);
> *req_stolen = !own_req;
> + if (own_req && tmp_opt.saw_tstamp && !after(TCP_SKB_CB(skb)-
> seq, tcp_rsk(req)->rcv_nxt))
> + tcp_sk(child)->rx_opt.ts_recent = tmp_opt.rcv_tsval;
> +
> return inet_csk_complete_hashdance(sk, child, req, own_req);

Yes, this was the plan ;)