Commit 5c803768 authored by David S. Miller's avatar David S. Miller

[TCP]: Fix tcp_diag build with ipv6 completely disabled.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ba599be9
...@@ -103,12 +103,14 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk, ...@@ -103,12 +103,14 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
r->tcpdiag_wqueue = 0; r->tcpdiag_wqueue = 0;
r->tcpdiag_uid = 0; r->tcpdiag_uid = 0;
r->tcpdiag_inode = 0; r->tcpdiag_inode = 0;
#ifdef CONFIG_IP_TCPDIAG_IPV6
if (r->tcpdiag_family == AF_INET6) { if (r->tcpdiag_family == AF_INET6) {
ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src, ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src,
&tw->tw_v6_rcv_saddr); &tw->tw_v6_rcv_saddr);
ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst, ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst,
&tw->tw_v6_daddr); &tw->tw_v6_daddr);
} }
#endif
nlh->nlmsg_len = skb->tail - b; nlh->nlmsg_len = skb->tail - b;
return skb->len; return skb->len;
} }
...@@ -118,6 +120,7 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk, ...@@ -118,6 +120,7 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
r->id.tcpdiag_src[0] = inet->rcv_saddr; r->id.tcpdiag_src[0] = inet->rcv_saddr;
r->id.tcpdiag_dst[0] = inet->daddr; r->id.tcpdiag_dst[0] = inet->daddr;
#ifdef CONFIG_IP_TCPDIAG_IPV6
if (r->tcpdiag_family == AF_INET6) { if (r->tcpdiag_family == AF_INET6) {
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
...@@ -126,6 +129,7 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk, ...@@ -126,6 +129,7 @@ static int tcpdiag_fill(struct sk_buff *skb, struct sock *sk,
ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst, ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst,
&np->daddr); &np->daddr);
} }
#endif
#define EXPIRES_IN_MS(tmo) ((tmo-jiffies)*1000+HZ-1)/HZ #define EXPIRES_IN_MS(tmo) ((tmo-jiffies)*1000+HZ-1)/HZ
...@@ -211,11 +215,13 @@ static int tcpdiag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh) ...@@ -211,11 +215,13 @@ static int tcpdiag_get_exact(struct sk_buff *in_skb, const struct nlmsghdr *nlh)
req->id.tcpdiag_src[0], req->id.tcpdiag_sport, req->id.tcpdiag_src[0], req->id.tcpdiag_sport,
req->id.tcpdiag_if); req->id.tcpdiag_if);
} }
#ifdef CONFIG_IP_TCPDIAG_IPV6
else if (req->tcpdiag_family == AF_INET6) { else if (req->tcpdiag_family == AF_INET6) {
sk = tcp_v6_lookup((struct in6_addr*)req->id.tcpdiag_dst, req->id.tcpdiag_dport, sk = tcp_v6_lookup((struct in6_addr*)req->id.tcpdiag_dst, req->id.tcpdiag_dport,
(struct in6_addr*)req->id.tcpdiag_src, req->id.tcpdiag_sport, (struct in6_addr*)req->id.tcpdiag_src, req->id.tcpdiag_sport,
req->id.tcpdiag_if); req->id.tcpdiag_if);
} }
#endif
else { else {
return -EINVAL; return -EINVAL;
} }
...@@ -424,12 +430,14 @@ static int tcpdiag_dump_sock(struct sk_buff *skb, struct sock *sk, ...@@ -424,12 +430,14 @@ static int tcpdiag_dump_sock(struct sk_buff *skb, struct sock *sk,
struct inet_opt *inet = inet_sk(sk); struct inet_opt *inet = inet_sk(sk);
entry.family = sk->sk_family; entry.family = sk->sk_family;
#ifdef CONFIG_IP_TCPDIAG_IPV6
if (entry.family == AF_INET6) { if (entry.family == AF_INET6) {
struct ipv6_pinfo *np = inet6_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk);
entry.saddr = np->rcv_saddr.s6_addr32; entry.saddr = np->rcv_saddr.s6_addr32;
entry.daddr = np->daddr.s6_addr32; entry.daddr = np->daddr.s6_addr32;
} else } else
#endif
{ {
entry.saddr = &inet->rcv_saddr; entry.saddr = &inet->rcv_saddr;
entry.daddr = &inet->daddr; entry.daddr = &inet->daddr;
...@@ -482,12 +490,14 @@ static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk, ...@@ -482,12 +490,14 @@ static int tcpdiag_fill_req(struct sk_buff *skb, struct sock *sk,
r->tcpdiag_wqueue = 0; r->tcpdiag_wqueue = 0;
r->tcpdiag_uid = sock_i_uid(sk); r->tcpdiag_uid = sock_i_uid(sk);
r->tcpdiag_inode = 0; r->tcpdiag_inode = 0;
#ifdef CONFIG_IP_TCPDIAG_IPV6
if (r->tcpdiag_family == AF_INET6) { if (r->tcpdiag_family == AF_INET6) {
ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src, ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_src,
&req->af.v6_req.loc_addr); &req->af.v6_req.loc_addr);
ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst, ipv6_addr_copy((struct in6_addr *)r->id.tcpdiag_dst,
&req->af.v6_req.rmt_addr); &req->af.v6_req.rmt_addr);
} }
#endif
nlh->nlmsg_len = skb->tail - b; nlh->nlmsg_len = skb->tail - b;
return skb->len; return skb->len;
...@@ -543,12 +553,16 @@ static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk, ...@@ -543,12 +553,16 @@ static int tcpdiag_dump_reqs(struct sk_buff *skb, struct sock *sk,
if (bc) { if (bc) {
entry.saddr = entry.saddr =
#ifdef CONFIG_IP_TCPDIAG_IPV6
(entry.family == AF_INET6) ? (entry.family == AF_INET6) ?
req->af.v6_req.loc_addr.s6_addr32 : req->af.v6_req.loc_addr.s6_addr32 :
#endif
&req->af.v4_req.loc_addr; &req->af.v4_req.loc_addr;
entry.daddr = entry.daddr =
#ifdef CONFIG_IP_TCPDIAG_IPV6
(entry.family == AF_INET6) ? (entry.family == AF_INET6) ?
req->af.v6_req.rmt_addr.s6_addr32 : req->af.v6_req.rmt_addr.s6_addr32 :
#endif
&req->af.v4_req.rmt_addr; &req->af.v4_req.rmt_addr;
entry.dport = ntohs(req->rmt_port); entry.dport = ntohs(req->rmt_port);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment