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:08 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2005-08-29 18:49:14 -0400
commit3f421baa4720b708022f8bcc52a61e5cd6f10bf8 (patch)
treee4201b1e2356cea8b7bd8d68dfba06e84002a77d /net/ipv4/tcp_timer.c
parent463c84b97f24010a67cd871746d6a7e4c925a5f9 (diff)
[NET]: Just move the inet_connection_sock function from tcp sources
Completing the previous changeset, this also generalises tcp_v4_synq_add, renaming it to inet_csk_reqsk_queue_hash_add, already geing used in the DCCP tree, which I plan to merge RSN. 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.c65
1 files changed, 5 insertions, 60 deletions
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 0b71380ee42f..c03930c48f42 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -36,55 +36,14 @@ static void tcp_write_timer(unsigned long);
36static void tcp_delack_timer(unsigned long); 36static void tcp_delack_timer(unsigned long);
37static void tcp_keepalive_timer (unsigned long data); 37static void tcp_keepalive_timer (unsigned long data);
38 38
39#ifdef INET_CSK_DEBUG
40const char inet_csk_timer_bug_msg[] = "inet_csk BUG: unknown timer value\n";
41EXPORT_SYMBOL(inet_csk_timer_bug_msg);
42#endif
43
44/*
45 * Using different timers for retransmit, delayed acks and probes
46 * We may wish use just one timer maintaining a list of expire jiffies
47 * to optimize.
48 */
49void inet_csk_init_xmit_timers(struct sock *sk,
50 void (*retransmit_handler)(unsigned long),
51 void (*delack_handler)(unsigned long),
52 void (*keepalive_handler)(unsigned long))
53{
54 struct inet_connection_sock *icsk = inet_csk(sk);
55
56 init_timer(&icsk->icsk_retransmit_timer);
57 init_timer(&icsk->icsk_delack_timer);
58 init_timer(&sk->sk_timer);
59
60 icsk->icsk_retransmit_timer.function = retransmit_handler;
61 icsk->icsk_delack_timer.function = delack_handler;
62 sk->sk_timer.function = keepalive_handler;
63
64 icsk->icsk_retransmit_timer.data =
65 icsk->icsk_delack_timer.data =
66 sk->sk_timer.data = (unsigned long)sk;
67
68 icsk->icsk_pending = icsk->icsk_ack.pending = 0;
69}
70
71void inet_csk_clear_xmit_timers(struct sock *sk)
72{
73 struct inet_connection_sock *icsk = inet_csk(sk);
74
75 icsk->icsk_pending = icsk->icsk_ack.pending = icsk->icsk_ack.blocked = 0;
76
77 sk_stop_timer(sk, &icsk->icsk_retransmit_timer);
78 sk_stop_timer(sk, &icsk->icsk_delack_timer);
79 sk_stop_timer(sk, &sk->sk_timer);
80}
81
82void tcp_init_xmit_timers(struct sock *sk) 39void tcp_init_xmit_timers(struct sock *sk)
83{ 40{
84 inet_csk_init_xmit_timers(sk, &tcp_write_timer, &tcp_delack_timer, 41 inet_csk_init_xmit_timers(sk, &tcp_write_timer, &tcp_delack_timer,
85 &tcp_keepalive_timer); 42 &tcp_keepalive_timer);
86} 43}
87 44
45EXPORT_SYMBOL(tcp_init_xmit_timers);
46
88static void tcp_write_err(struct sock *sk) 47static void tcp_write_err(struct sock *sk)
89{ 48{
90 sk->sk_err = sk->sk_err_soft ? : ETIMEDOUT; 49 sk->sk_err = sk->sk_err_soft ? : ETIMEDOUT;
@@ -392,7 +351,8 @@ static void tcp_retransmit_timer(struct sock *sk)
392 if (!icsk->icsk_retransmits) 351 if (!icsk->icsk_retransmits)
393 icsk->icsk_retransmits = 1; 352 icsk->icsk_retransmits = 1;
394 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, 353 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
395 min(icsk->icsk_rto, TCP_RESOURCE_PROBE_INTERVAL)); 354 min(icsk->icsk_rto, TCP_RESOURCE_PROBE_INTERVAL),
355 TCP_RTO_MAX);
396 goto out; 356 goto out;
397 } 357 }
398 358
@@ -416,7 +376,7 @@ static void tcp_retransmit_timer(struct sock *sk)
416 376
417out_reset_timer: 377out_reset_timer:
418 icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX); 378 icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX);
419 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto); 379 inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, TCP_RTO_MAX);
420 if (icsk->icsk_retransmits > sysctl_tcp_retries1) 380 if (icsk->icsk_retransmits > sysctl_tcp_retries1)
421 __sk_dst_reset(sk); 381 __sk_dst_reset(sk);
422 382
@@ -553,16 +513,6 @@ static void tcp_synack_timer(struct sock *sk)
553 inet_csk_reset_keepalive_timer(sk, TCP_SYNQ_INTERVAL); 513 inet_csk_reset_keepalive_timer(sk, TCP_SYNQ_INTERVAL);
554} 514}
555 515
556void inet_csk_delete_keepalive_timer(struct sock *sk)
557{
558 sk_stop_timer(sk, &sk->sk_timer);
559}
560
561void inet_csk_reset_keepalive_timer(struct sock *sk, unsigned long len)
562{
563 sk_reset_timer(sk, &sk->sk_timer, jiffies + len);
564}
565
566void tcp_set_keepalive(struct sock *sk, int val) 516void tcp_set_keepalive(struct sock *sk, int val)
567{ 517{
568 if ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN)) 518 if ((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))
@@ -653,8 +603,3 @@ out:
653 bh_unlock_sock(sk); 603 bh_unlock_sock(sk);
654 sock_put(sk); 604 sock_put(sk);
655} 605}
656
657EXPORT_SYMBOL(inet_csk_clear_xmit_timers);
658EXPORT_SYMBOL(inet_csk_delete_keepalive_timer);
659EXPORT_SYMBOL(tcp_init_xmit_timers);
660EXPORT_SYMBOL(inet_csk_reset_keepalive_timer);