]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/tcp_diag.c
[NET]: Just move the inet_connection_sock function from tcp sources
[linux-2.6-omap-h63xx.git] / net / ipv4 / tcp_diag.c
index 1a89a03c449b47016bf0b27d525ecc6fb95a9b62..5f4c74f45e82e147b8688cf64a2e68fa0a309b7b 100644 (file)
@@ -48,8 +48,9 @@ static struct sock *tcpnl;
 static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
                        int ext, u32 pid, u32 seq, u16 nlmsg_flags)
 {
-       struct inet_sock *inet = inet_sk(sk);
+       const struct inet_sock *inet = inet_sk(sk);
        struct tcp_sock *tp = tcp_sk(sk);
+       const struct inet_connection_sock *icsk = inet_csk(sk);
        struct tcpdiagmsg *r;
        struct nlmsghdr  *nlh;
        struct tcp_info  *info = NULL;
@@ -81,7 +82,7 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
        r->id.tcpdiag_cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
 
        if (r->tcpdiag_state == TCP_TIME_WAIT) {
-               struct tcp_tw_bucket *tw = (struct tcp_tw_bucket*)sk;
+               const struct inet_timewait_sock *tw = inet_twsk(sk);
                long tmo = tw->tw_ttd - jiffies;
                if (tmo < 0)
                        tmo = 0;
@@ -99,10 +100,12 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
                r->tcpdiag_inode = 0;
 #ifdef CONFIG_IP_TCPDIAG_IPV6
                if (r->tcpdiag_family == AF_INET6) {
+                       const struct tcp6_timewait_sock *tcp6tw = tcp6_twsk(sk);
+
                        ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src,
-                                      &tw->tw_v6_rcv_saddr);
+                                      &tcp6tw->tw_v6_rcv_saddr);
                        ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst,
-                                      &tw->tw_v6_daddr);
+                                      &tcp6tw->tw_v6_daddr);
                }
 #endif
                nlh->nlmsg_len = skb->tail - b;
@@ -127,14 +130,14 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
 
 #define EXPIRES_IN_MS(tmo)  ((tmo-jiffies)*1000+HZ-1)/HZ
 
-       if (tp->pending == TCP_TIME_RETRANS) {
+       if (icsk->icsk_pending == ICSK_TIME_RETRANS) {
                r->tcpdiag_timer = 1;
-               r->tcpdiag_retrans = tp->retransmits;
-               r->tcpdiag_expires = EXPIRES_IN_MS(tp->timeout);
-       } else if (tp->pending == TCP_TIME_PROBE0) {
+               r->tcpdiag_retrans = icsk->icsk_retransmits;
+               r->tcpdiag_expires = EXPIRES_IN_MS(icsk->icsk_timeout);
+       } else if (icsk->icsk_pending == ICSK_TIME_PROBE0) {
                r->tcpdiag_timer = 4;
                r->tcpdiag_retrans = tp->probes_out;
-               r->tcpdiag_expires = EXPIRES_IN_MS(tp->timeout);
+               r->tcpdiag_expires = EXPIRES_IN_MS(icsk->icsk_timeout);
        } else if (timer_pending(&sk->sk_timer)) {
                r->tcpdiag_timer = 2;
                r->tcpdiag_retrans = tp->probes_out;
@@ -172,8 +175,6 @@ nlmsg_failure:
        return -1;
 }
 
-extern struct sock *tcp_v4_lookup(u32 saddr, u16 sport, u32 daddr, u16 dport,
-                                 int dif);
 #ifdef CONFIG_IP_TCPDIAG_IPV6
 extern struct sock *tcp_v6_lookup(struct in6_addr *saddr, u16 sport,
                                  struct in6_addr *daddr, u16 dport,
@@ -195,9 +196,9 @@ static int tcpdiag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh)
        struct sk_buff *rep;
 
        if (req->tcpdiag_family == AF_INET) {
-               sk = tcp_v4_lookup(req->id.tcpdiag_dst[0], req->id.tcpdiag_dport,
-                                  req->id.tcpdiag_src[0], req->id.tcpdiag_sport,
-                                  req->id.tcpdiag_if);
+               sk = inet_lookup(&tcp_hashinfo, req->id.tcpdiag_dst[0],
+                                req->id.tcpdiag_dport, req->id.tcpdiag_src[0],
+                                req->id.tcpdiag_sport, req->id.tcpdiag_if);
        }
 #ifdef CONFIG_IP_TCPDIAG_IPV6
        else if (req->tcpdiag_family == AF_INET6) {
@@ -239,7 +240,7 @@ static int tcpdiag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh)
 out:
        if (sk) {
                if (sk->sk_state == TCP_TIME_WAIT)
-                       tcp_tw_put((struct tcp_tw_bucket*)sk);
+                       inet_twsk_put((struct inet_timewait_sock *)sk);
                else
                        sock_put(sk);
        }
@@ -497,7 +498,7 @@ static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk,
 {
        struct tcpdiag_entry entry;
        struct tcpdiagreq *r = NLMSG_DATA(cb->nlh);
-       struct tcp_sock *tp = tcp_sk(sk);
+       struct inet_connection_sock *icsk = inet_csk(sk);
        struct listen_sock *lopt;
        struct rtattr *bc = NULL;
        struct inet_sock *inet = inet_sk(sk);
@@ -513,9 +514,9 @@ static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk,
 
        entry.family = sk->sk_family;
 
-       read_lock_bh(&tp->accept_queue.syn_wait_lock);
+       read_lock_bh(&icsk->icsk_accept_queue.syn_wait_lock);
 
-       lopt = tp->accept_queue.listen_opt;
+       lopt = icsk->icsk_accept_queue.listen_opt;
        if (!lopt || !lopt->qlen)
                goto out;
 
@@ -572,7 +573,7 @@ static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk,
        }
 
 out:
-       read_unlock_bh(&tp->accept_queue.syn_wait_lock);
+       read_unlock_bh(&icsk->icsk_accept_queue.syn_wait_lock);
 
        return err;
 }