diff options
author | Eric Dumazet <edumazet@google.com> | 2012-10-27 19:16:46 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-11-03 14:45:00 -0400 |
commit | e6c022a4fa2d2d9ca9d0a7ac3b05ad988f39fc30 (patch) | |
tree | 6dcd4e2dfc7895f33329fb16653a93f7d52f4bd7 /net/ipv4/inet_connection_sock.c | |
parent | 25b1e67921f448cdddf70042ba233ffe43d33a9c (diff) |
tcp: better retrans tracking for defer-accept
For passive TCP connections using TCP_DEFER_ACCEPT facility,
we incorrectly increment req->retrans each time timeout triggers
while no SYNACK is sent.
SYNACK are not sent for TCP_DEFER_ACCEPT that were established (for
which we received the ACK from client). Only the last SYNACK is sent
so that we can receive again an ACK from client, to move the req into
accept queue. We plan to change this later to avoid the useless
retransmit (and potential problem as this SYNACK could be lost)
TCP_INFO later gives wrong information to user, claiming imaginary
retransmits.
Decouple req->retrans field into two independent fields :
num_retrans : number of retransmit
num_timeout : number of timeouts
num_timeout is the counter that is incremented at each timeout,
regardless of actual SYNACK being sent or not, and used to
compute the exponential timeout.
Introduce inet_rtx_syn_ack() helper to increment num_retrans
only if ->rtx_syn_ack() succeeded.
Use inet_rtx_syn_ack() from tcp_check_req() to increment num_retrans
when we re-send a SYNACK in answer to a (retransmitted) SYN.
Prior to this patch, we were not counting these retransmits.
Change tcp_v[46]_rtx_synack() to increment TCP_MIB_RETRANSSEGS
only if a synack packet was successfully queued.
Reported-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Julian Anastasov <ja@ssi.bg>
Cc: Vijay Subramanian <subramanian.vijay@gmail.com>
Cc: Elliott Hughes <enh@google.com>
Cc: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/inet_connection_sock.c')
-rw-r--r-- | net/ipv4/inet_connection_sock.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index d34ce2972c8f..2026542d6836 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c | |||
@@ -521,21 +521,31 @@ static inline void syn_ack_recalc(struct request_sock *req, const int thresh, | |||
521 | int *expire, int *resend) | 521 | int *expire, int *resend) |
522 | { | 522 | { |
523 | if (!rskq_defer_accept) { | 523 | if (!rskq_defer_accept) { |
524 | *expire = req->retrans >= thresh; | 524 | *expire = req->num_timeout >= thresh; |
525 | *resend = 1; | 525 | *resend = 1; |
526 | return; | 526 | return; |
527 | } | 527 | } |
528 | *expire = req->retrans >= thresh && | 528 | *expire = req->num_timeout >= thresh && |
529 | (!inet_rsk(req)->acked || req->retrans >= max_retries); | 529 | (!inet_rsk(req)->acked || req->num_timeout >= max_retries); |
530 | /* | 530 | /* |
531 | * Do not resend while waiting for data after ACK, | 531 | * Do not resend while waiting for data after ACK, |
532 | * start to resend on end of deferring period to give | 532 | * start to resend on end of deferring period to give |
533 | * last chance for data or ACK to create established socket. | 533 | * last chance for data or ACK to create established socket. |
534 | */ | 534 | */ |
535 | *resend = !inet_rsk(req)->acked || | 535 | *resend = !inet_rsk(req)->acked || |
536 | req->retrans >= rskq_defer_accept - 1; | 536 | req->num_timeout >= rskq_defer_accept - 1; |
537 | } | 537 | } |
538 | 538 | ||
539 | int inet_rtx_syn_ack(struct sock *parent, struct request_sock *req) | ||
540 | { | ||
541 | int err = req->rsk_ops->rtx_syn_ack(parent, req, NULL); | ||
542 | |||
543 | if (!err) | ||
544 | req->num_retrans++; | ||
545 | return err; | ||
546 | } | ||
547 | EXPORT_SYMBOL(inet_rtx_syn_ack); | ||
548 | |||
539 | void inet_csk_reqsk_queue_prune(struct sock *parent, | 549 | void inet_csk_reqsk_queue_prune(struct sock *parent, |
540 | const unsigned long interval, | 550 | const unsigned long interval, |
541 | const unsigned long timeout, | 551 | const unsigned long timeout, |
@@ -599,13 +609,14 @@ void inet_csk_reqsk_queue_prune(struct sock *parent, | |||
599 | req->rsk_ops->syn_ack_timeout(parent, req); | 609 | req->rsk_ops->syn_ack_timeout(parent, req); |
600 | if (!expire && | 610 | if (!expire && |
601 | (!resend || | 611 | (!resend || |
602 | !req->rsk_ops->rtx_syn_ack(parent, req, NULL) || | 612 | !inet_rtx_syn_ack(parent, req) || |
603 | inet_rsk(req)->acked)) { | 613 | inet_rsk(req)->acked)) { |
604 | unsigned long timeo; | 614 | unsigned long timeo; |
605 | 615 | ||
606 | if (req->retrans++ == 0) | 616 | if (req->num_timeout++ == 0) |
607 | lopt->qlen_young--; | 617 | lopt->qlen_young--; |
608 | timeo = min((timeout << req->retrans), max_rto); | 618 | timeo = min(timeout << req->num_timeout, |
619 | max_rto); | ||
609 | req->expires = now + timeo; | 620 | req->expires = now + timeo; |
610 | reqp = &req->dl_next; | 621 | reqp = &req->dl_next; |
611 | continue; | 622 | continue; |