aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_diag.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/tcp_diag.c')
-rw-r--r--net/ipv4/tcp_diag.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c
index 8bf495c698f8..b812191b2f5c 100644
--- a/net/ipv4/tcp_diag.c
+++ b/net/ipv4/tcp_diag.c
@@ -24,6 +24,10 @@
24#include <net/tcp.h> 24#include <net/tcp.h>
25#include <net/ipv6.h> 25#include <net/ipv6.h>
26#include <net/inet_common.h> 26#include <net/inet_common.h>
27#include <net/inet_connection_sock.h>
28#include <net/inet_hashtables.h>
29#include <net/inet_timewait_sock.h>
30#include <net/inet6_hashtables.h>
27 31
28#include <linux/inet.h> 32#include <linux/inet.h>
29#include <linux/stddef.h> 33#include <linux/stddef.h>
@@ -102,7 +106,7 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
102 r->tcpdiag_wqueue = 0; 106 r->tcpdiag_wqueue = 0;
103 r->tcpdiag_uid = 0; 107 r->tcpdiag_uid = 0;
104 r->tcpdiag_inode = 0; 108 r->tcpdiag_inode = 0;
105#ifdef CONFIG_IP_TCPDIAG_IPV6 109#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
106 if (r->tcpdiag_family == AF_INET6) { 110 if (r->tcpdiag_family == AF_INET6) {
107 const struct tcp6_timewait_sock *tcp6tw = tcp6_twsk(sk); 111 const struct tcp6_timewait_sock *tcp6tw = tcp6_twsk(sk);
108 112
@@ -121,7 +125,7 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
121 r->id.tcpdiag_src[0] = inet->rcv_saddr; 125 r->id.tcpdiag_src[0] = inet->rcv_saddr;
122 r->id.tcpdiag_dst[0] = inet->daddr; 126 r->id.tcpdiag_dst[0] = inet->daddr;
123 127
124#ifdef CONFIG_IP_TCPDIAG_IPV6 128#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
125 if (r->tcpdiag_family == AF_INET6) { 129 if (r->tcpdiag_family == AF_INET6) {
126 struct ipv6_pinfo *np = inet6_sk(sk); 130 struct ipv6_pinfo *np = inet6_sk(sk);
127 131
@@ -196,19 +200,6 @@ nlmsg_failure:
196 return -1; 200 return -1;
197} 201}
198 202
199#ifdef CONFIG_IP_TCPDIAG_IPV6
200extern struct sock *tcp_v6_lookup(struct in6_addr *saddr, u16 sport,
201 struct in6_addr *daddr, u16 dport,
202 int dif);
203#else
204static inline struct sock *tcp_v6_lookup(struct in6_addr *saddr, u16 sport,
205 struct in6_addr *daddr, u16 dport,
206 int dif)
207{
208 return NULL;
209}
210#endif
211
212static int tcpdiag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh) 203static int tcpdiag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh)
213{ 204{
214 int err; 205 int err;
@@ -225,11 +216,14 @@ static int tcpdiag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh)
225 req->id.tcpdiag_dport, req->id.tcpdiag_src[0], 216 req->id.tcpdiag_dport, req->id.tcpdiag_src[0],
226 req->id.tcpdiag_sport, req->id.tcpdiag_if); 217 req->id.tcpdiag_sport, req->id.tcpdiag_if);
227 } 218 }
228#ifdef CONFIG_IP_TCPDIAG_IPV6 219#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
229 else if (req->tcpdiag_family == AF_INET6) { 220 else if (req->tcpdiag_family == AF_INET6) {
230 sk = tcp_v6_lookup((struct in6_addr*)req->id.tcpdiag_dst, req->id.tcpdiag_dport, 221 sk = inet6_lookup(hashinfo,
231 (struct in6_addr*)req->id.tcpdiag_src, req->id.tcpdiag_sport, 222 (struct in6_addr*)req->id.tcpdiag_dst,
232 req->id.tcpdiag_if); 223 req->id.tcpdiag_dport,
224 (struct in6_addr*)req->id.tcpdiag_src,
225 req->id.tcpdiag_sport,
226 req->id.tcpdiag_if);
233 } 227 }
234#endif 228#endif
235 else { 229 else {
@@ -440,7 +434,7 @@ static int tcpdiag_dump_sock(struct sk_buff *skb, struct sock *sk,
440 struct inet_sock *inet = inet_sk(sk); 434 struct inet_sock *inet = inet_sk(sk);
441 435
442 entry.family = sk->sk_family; 436 entry.family = sk->sk_family;
443#ifdef CONFIG_IP_TCPDIAG_IPV6 437#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
444 if (entry.family == AF_INET6) { 438 if (entry.family == AF_INET6) {
445 struct ipv6_pinfo *np = inet6_sk(sk); 439 struct ipv6_pinfo *np = inet6_sk(sk);
446 440
@@ -502,7 +496,7 @@ static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk,
502 r->tcpdiag_wqueue = 0; 496 r->tcpdiag_wqueue = 0;
503 r->tcpdiag_uid = sock_i_uid(sk); 497 r->tcpdiag_uid = sock_i_uid(sk);
504 r->tcpdiag_inode = 0; 498 r->tcpdiag_inode = 0;
505#ifdef CONFIG_IP_TCPDIAG_IPV6 499#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
506 if (r->tcpdiag_family == AF_INET6) { 500 if (r->tcpdiag_family == AF_INET6) {
507 ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src, 501 ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src,
508 &tcp6_rsk(req)->loc_addr); 502 &tcp6_rsk(req)->loc_addr);
@@ -567,13 +561,13 @@ static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk,
567 561
568 if (bc) { 562 if (bc) {
569 entry.saddr = 563 entry.saddr =
570#ifdef CONFIG_IP_TCPDIAG_IPV6 564#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
571 (entry.family == AF_INET6) ? 565 (entry.family == AF_INET6) ?
572 tcp6_rsk(req)->loc_addr.s6_addr32 : 566 tcp6_rsk(req)->loc_addr.s6_addr32 :
573#endif 567#endif
574 &ireq->loc_addr; 568 &ireq->loc_addr;
575 entry.daddr = 569 entry.daddr =
576#ifdef CONFIG_IP_TCPDIAG_IPV6 570#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
577 (entry.family == AF_INET6) ? 571 (entry.family == AF_INET6) ?
578 tcp6_rsk(req)->rmt_addr.s6_addr32 : 572 tcp6_rsk(req)->rmt_addr.s6_addr32 :
579#endif 573#endif