]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv4/tcp_timer.c
tcp: Combat per-cpu skew in orphan tests.
[net-next-2.6.git] / net / ipv4 / tcp_timer.c
index 8a0ab2977f1fd8be8c4bf9f27d21efa9c214418e..c35b469e851c298814d69583bd593ec1c580dde5 100644 (file)
@@ -41,7 +41,6 @@ void tcp_init_xmit_timers(struct sock *sk)
        inet_csk_init_xmit_timers(sk, &tcp_write_timer, &tcp_delack_timer,
                                  &tcp_keepalive_timer);
 }
-
 EXPORT_SYMBOL(tcp_init_xmit_timers);
 
 static void tcp_write_err(struct sock *sk)
@@ -67,18 +66,18 @@ static void tcp_write_err(struct sock *sk)
 static int tcp_out_of_resources(struct sock *sk, int do_reset)
 {
        struct tcp_sock *tp = tcp_sk(sk);
-       int orphans = percpu_counter_read_positive(&tcp_orphan_count);
+       int shift = 0;
 
        /* If peer does not open window for long time, or did not transmit
         * anything for long time, penalize it. */
        if ((s32)(tcp_time_stamp - tp->lsndtime) > 2*TCP_RTO_MAX || !do_reset)
-               orphans <<= 1;
+               shift++;
 
        /* If some dubious ICMP arrived, penalize even more. */
        if (sk->sk_err_soft)
-               orphans <<= 1;
+               shift++;
 
-       if (tcp_too_many_orphans(sk, orphans)) {
+       if (tcp_too_many_orphans(sk, shift)) {
                if (net_ratelimit())
                        printk(KERN_INFO "Out of socket memory\n");
 
@@ -172,14 +171,14 @@ static int tcp_write_timeout(struct sock *sk)
 
        if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) {
                if (icsk->icsk_retransmits)
-                       dst_negative_advice(&sk->sk_dst_cache, sk);
+                       dst_negative_advice(sk);
                retry_until = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries;
        } else {
                if (retransmits_timed_out(sk, sysctl_tcp_retries1)) {
                        /* Black hole detection */
                        tcp_mtu_probing(icsk, sk);
 
-                       dst_negative_advice(&sk->sk_dst_cache, sk);
+                       dst_negative_advice(sk);
                }
 
                retry_until = sysctl_tcp_retries2;
@@ -517,7 +516,7 @@ static void tcp_keepalive_timer (unsigned long data)
        struct sock *sk = (struct sock *) data;
        struct inet_connection_sock *icsk = inet_csk(sk);
        struct tcp_sock *tp = tcp_sk(sk);
-       __u32 elapsed;
+       u32 elapsed;
 
        /* Only process if socket is not in use. */
        bh_lock_sock(sk);
@@ -554,7 +553,7 @@ static void tcp_keepalive_timer (unsigned long data)
        if (tp->packets_out || tcp_send_head(sk))
                goto resched;
 
-       elapsed = tcp_time_stamp - tp->rcv_tstamp;
+       elapsed = keepalive_time_elapsed(tp);
 
        if (elapsed >= keepalive_time_when(tp)) {
                if (icsk->icsk_probes_out >= keepalive_probes(tp)) {