Subject: RFC [PATCH 2/3] TCP_DEFER_ACCEPT updates: don't retransmit syn-ack while waiting for first data byte

From: Patrick McManus <[email-masked]>
Date: Tue, 26 Feb 2008 20:49:05 -0500

Signed-off-by: Patrick McManus <[email-masked]>

    a socket in LISTEN that had completed its 3 way handshake, but not notified
    userspace because of SO_DEFER_ACCEPT, would retransmit the already
    acked syn-ack during the time it was waiting for the first data byte
    from the peer.

diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 03cc323..7216f5e 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -461,8 +461,9 @@ void inet_csk_reqsk_queue_prune(struct sock *parent,
                reqp=&lopt->syn_table[i];
                while ((req = *reqp) != NULL) {
                        if (time_after_eq(now, req->expires)) {
-                               if ((req->retrans < (inet_rsk(req)->acked ? max_retries : thresh))
-                                   && !req->rsk_ops->rtx_syn_ack(parent, req, NULL)) {
+                               if ((req->retrans < (inet_rsk(req)->acked ? max_retries : thresh))
+                                   &&  (inet_rsk(req)->acked ||
+                                        !req->rsk_ops->rtx_syn_ack(parent, req, NULL))) {
                                        unsigned long timeo;

                                        if (req->retrans++ == 0)