From: Chia-Yu Chang <[email protected]>

Before this patch, num_retrans = 0 for the first SYN/ACK and the first
retransmitted SYN/ACK; however, an upcoming change will need to
differentiate between those two conditions. This patch moves the
increment of num_tranns before rtx_syn_ack() so we can distinguish
between these two cases when making SYN/ACK.

Signed-off-by: Chia-Yu Chang <[email protected]>
---
 net/ipv4/tcp_output.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 71f65bb26675..90a71556b93c 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -4609,6 +4609,7 @@ int tcp_rtx_synack(const struct sock *sk, struct 
request_sock *req)
        /* Paired with WRITE_ONCE() in sock_setsockopt() */
        if (READ_ONCE(sk->sk_txrehash) == SOCK_TXREHASH_ENABLED)
                WRITE_ONCE(tcp_rsk(req)->txhash, net_tx_rndhash());
+       WRITE_ONCE(req->num_retrans, req->num_retrans + 1);
        res = af_ops->send_synack(sk, NULL, &fl, req, NULL, TCP_SYNACK_NORMAL,
                                  NULL);
        if (!res) {
@@ -4622,7 +4623,8 @@ int tcp_rtx_synack(const struct sock *sk, struct 
request_sock *req)
                        tcp_sk_rw(sk)->total_retrans++;
                }
                trace_tcp_retransmit_synack(sk, req);
-               WRITE_ONCE(req->num_retrans, req->num_retrans + 1);
+       } else {
+               WRITE_ONCE(req->num_retrans, req->num_retrans - 1);
        }
        return res;
 }
-- 
2.34.1


Reply via email to