aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_timer.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@ghostprotocols.net>2005-08-09 23:11:56 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2005-08-29 18:49:29 -0400
commit295f7324ff8d9ea58b4d3ec93b1aaa1d80e048a9 (patch)
tree509c113d2622a28836303590ba1a40cecea59d3b /net/ipv4/tcp_timer.c
parent0a5578cf8e5e045aaa68643c17ce885426697c6b (diff)
[ICSK]: Introduce reqsk_queue_prune from code in tcp_synack_timer
With this we're very close to getting all of the current TCP refactorings in my dccp-2.6 tree merged, next changeset will export some functions needed by the current DCCP code and then dccp-2.6.git will be born! Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_timer.c')
-rw-r--r--net/ipv4/tcp_timer.c46
1 files changed, 28 insertions, 18 deletions
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index c03930c48f42..b614ad4d30c9 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -424,16 +424,12 @@ out_unlock:
424 sock_put(sk); 424 sock_put(sk);
425} 425}
426 426
427/* 427void reqsk_queue_prune(struct request_sock_queue *queue, struct sock *parent,
428 * Timer for listening sockets 428 const unsigned long interval, const unsigned long timeout,
429 */ 429 const unsigned long max_rto, int max_retries)
430
431static void tcp_synack_timer(struct sock *sk)
432{ 430{
433 struct tcp_sock *tp = tcp_sk(sk); 431 struct inet_connection_sock *icsk = inet_csk(parent);
434 struct inet_connection_sock *icsk = inet_csk(sk); 432 struct listen_sock *lopt = queue->listen_opt;
435 struct listen_sock *lopt = icsk->icsk_accept_queue.listen_opt;
436 int max_retries = icsk->icsk_syn_retries ? : sysctl_tcp_synack_retries;
437 int thresh = max_retries; 433 int thresh = max_retries;
438 unsigned long now = jiffies; 434 unsigned long now = jiffies;
439 struct request_sock **reqp, *req; 435 struct request_sock **reqp, *req;
@@ -470,10 +466,10 @@ static void tcp_synack_timer(struct sock *sk)
470 } 466 }
471 } 467 }
472 468
473 if (tp->defer_accept) 469 if (queue->rskq_defer_accept)
474 max_retries = tp->defer_accept; 470 max_retries = queue->rskq_defer_accept;
475 471
476 budget = 2*(TCP_SYNQ_HSIZE/(TCP_TIMEOUT_INIT/TCP_SYNQ_INTERVAL)); 472 budget = 2 * (lopt->nr_table_entries / (timeout / interval));
477 i = lopt->clock_hand; 473 i = lopt->clock_hand;
478 474
479 do { 475 do {
@@ -482,20 +478,19 @@ static void tcp_synack_timer(struct sock *sk)
482 if (time_after_eq(now, req->expires)) { 478 if (time_after_eq(now, req->expires)) {
483 if ((req->retrans < thresh || 479 if ((req->retrans < thresh ||
484 (inet_rsk(req)->acked && req->retrans < max_retries)) 480 (inet_rsk(req)->acked && req->retrans < max_retries))
485 && !req->rsk_ops->rtx_syn_ack(sk, req, NULL)) { 481 && !req->rsk_ops->rtx_syn_ack(parent, req, NULL)) {
486 unsigned long timeo; 482 unsigned long timeo;
487 483
488 if (req->retrans++ == 0) 484 if (req->retrans++ == 0)
489 lopt->qlen_young--; 485 lopt->qlen_young--;
490 timeo = min((TCP_TIMEOUT_INIT << req->retrans), 486 timeo = min((timeout << req->retrans), max_rto);
491 TCP_RTO_MAX);
492 req->expires = now + timeo; 487 req->expires = now + timeo;
493 reqp = &req->dl_next; 488 reqp = &req->dl_next;
494 continue; 489 continue;
495 } 490 }
496 491
497 /* Drop this request */ 492 /* Drop this request */
498 inet_csk_reqsk_queue_unlink(sk, req, reqp); 493 inet_csk_reqsk_queue_unlink(parent, req, reqp);
499 reqsk_queue_removed(&icsk->icsk_accept_queue, req); 494 reqsk_queue_removed(&icsk->icsk_accept_queue, req);
500 reqsk_free(req); 495 reqsk_free(req);
501 continue; 496 continue;
@@ -503,14 +498,29 @@ static void tcp_synack_timer(struct sock *sk)
503 reqp = &req->dl_next; 498 reqp = &req->dl_next;
504 } 499 }
505 500
506 i = (i+1)&(TCP_SYNQ_HSIZE-1); 501 i = (i + 1) & (lopt->nr_table_entries - 1);
507 502
508 } while (--budget > 0); 503 } while (--budget > 0);
509 504
510 lopt->clock_hand = i; 505 lopt->clock_hand = i;
511 506
512 if (lopt->qlen) 507 if (lopt->qlen)
513 inet_csk_reset_keepalive_timer(sk, TCP_SYNQ_INTERVAL); 508 inet_csk_reset_keepalive_timer(parent, interval);
509}
510
511EXPORT_SYMBOL_GPL(reqsk_queue_prune);
512
513/*
514 * Timer for listening sockets
515 */
516
517static void tcp_synack_timer(struct sock *sk)
518{
519 struct inet_connection_sock *icsk = inet_csk(sk);
520 const int max_retries = icsk->icsk_syn_retries ? : sysctl_tcp_synack_retries;
521
522 reqsk_queue_prune(&icsk->icsk_accept_queue, sk, TCP_SYNQ_INTERVAL,
523 TCP_TIMEOUT_INIT, TCP_RTO_MAX, max_retries);
514} 524}
515 525
516void tcp_set_keepalive(struct sock *sk, int val) 526void tcp_set_keepalive(struct sock *sk, int val)