netlabel: Label incoming TCP connections correctly in SELinux
[safe/jmp/linux-2.6] / net / ipv4 / tcp_timer.c
index 5ab6ba1..b144a26 100644 (file)
@@ -65,7 +65,7 @@ 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 = atomic_read(&tcp_orphan_count);
+       int orphans = percpu_counter_read_positive(&tcp_orphan_count);
 
        /* If peer does not open window for long time, or did not transmit
         * anything for long time, penalize it. */
@@ -171,7 +171,7 @@ static int tcp_write_timeout(struct sock *sk)
 
 static void tcp_delack_timer(unsigned long data)
 {
-       struct sock *sk = (struct sock*)data;
+       struct sock *sk = (struct sock *)data;
        struct tcp_sock *tp = tcp_sk(sk);
        struct inet_connection_sock *icsk = inet_csk(sk);
 
@@ -201,7 +201,7 @@ static void tcp_delack_timer(unsigned long data)
                NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPSCHEDULERFAILED);
 
                while ((skb = __skb_dequeue(&tp->ucopy.prequeue)) != NULL)
-                       sk->sk_backlog_rcv(sk, skb);
+                       sk_backlog_rcv(sk, skb);
 
                tp->ucopy.memory = 0;
        }
@@ -299,15 +299,15 @@ static void tcp_retransmit_timer(struct sock *sk)
 #ifdef TCP_DEBUG
                struct inet_sock *inet = inet_sk(sk);
                if (sk->sk_family == AF_INET) {
-                       LIMIT_NETDEBUG(KERN_DEBUG "TCP: Treason uncloaked! Peer " NIPQUAD_FMT ":%u/%u shrinks window %u:%u. Repaired.\n",
-                              NIPQUAD(inet->daddr), ntohs(inet->dport),
+                       LIMIT_NETDEBUG(KERN_DEBUG "TCP: Peer %pI4:%u/%u unexpectedly shrunk window %u:%u (repaired)\n",
+                              &inet->daddr, ntohs(inet->dport),
                               inet->num, tp->snd_una, tp->snd_nxt);
                }
 #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
                else if (sk->sk_family == AF_INET6) {
                        struct ipv6_pinfo *np = inet6_sk(sk);
-                       LIMIT_NETDEBUG(KERN_DEBUG "TCP: Treason uncloaked! Peer " NIP6_FMT ":%u/%u shrinks window %u:%u. Repaired.\n",
-                              NIP6(np->daddr), ntohs(inet->dport),
+                       LIMIT_NETDEBUG(KERN_DEBUG "TCP: Peer %pI6:%u/%u unexpectedly shrunk window %u:%u (repaired)\n",
+                              &np->daddr, ntohs(inet->dport),
                               inet->num, tp->snd_una, tp->snd_nxt);
                }
 #endif
@@ -328,19 +328,16 @@ static void tcp_retransmit_timer(struct sock *sk)
        if (icsk->icsk_retransmits == 0) {
                int mib_idx;
 
-               if (icsk->icsk_ca_state == TCP_CA_Disorder ||
-                   icsk->icsk_ca_state == TCP_CA_Recovery) {
-                       if (tcp_is_sack(tp)) {
-                               if (icsk->icsk_ca_state == TCP_CA_Recovery)
-                                       mib_idx = LINUX_MIB_TCPSACKRECOVERYFAIL;
-                               else
-                                       mib_idx = LINUX_MIB_TCPSACKFAILURES;
-                       } else {
-                               if (icsk->icsk_ca_state == TCP_CA_Recovery)
-                                       mib_idx = LINUX_MIB_TCPRENORECOVERYFAIL;
-                               else
-                                       mib_idx = LINUX_MIB_TCPRENOFAILURES;
-                       }
+               if (icsk->icsk_ca_state == TCP_CA_Disorder) {
+                       if (tcp_is_sack(tp))
+                               mib_idx = LINUX_MIB_TCPSACKFAILURES;
+                       else
+                               mib_idx = LINUX_MIB_TCPRENOFAILURES;
+               } else if (icsk->icsk_ca_state == TCP_CA_Recovery) {
+                       if (tcp_is_sack(tp))
+                               mib_idx = LINUX_MIB_TCPSACKRECOVERYFAIL;
+                       else
+                               mib_idx = LINUX_MIB_TCPRENORECOVERYFAIL;
                } else if (icsk->icsk_ca_state == TCP_CA_Loss) {
                        mib_idx = LINUX_MIB_TCPLOSSFAILURES;
                } else {
@@ -396,7 +393,7 @@ out:;
 
 static void tcp_write_timer(unsigned long data)
 {
-       struct sock *sk = (struct sock*)data;
+       struct sock *sk = (struct sock *)data;
        struct inet_connection_sock *icsk = inet_csk(sk);
        int event;