diff options
-rw-r--r-- | include/linux/ipv6.h | 8 | ||||
-rw-r--r-- | include/net/inet6_hashtables.h | 17 | ||||
-rw-r--r-- | net/dccp/ipv6.c | 8 | ||||
-rw-r--r-- | net/ipv4/inet_diag.c | 2 | ||||
-rw-r--r-- | net/ipv6/inet6_hashtables.c | 25 | ||||
-rw-r--r-- | net/ipv6/tcp_ipv6.c | 19 |
6 files changed, 43 insertions, 36 deletions
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index c34786044a1b..4aaefc349a4b 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h | |||
@@ -457,16 +457,16 @@ static inline struct raw6_sock *raw6_sk(const struct sock *sk) | |||
457 | #define inet_v6_ipv6only(__sk) 0 | 457 | #define inet_v6_ipv6only(__sk) 0 |
458 | #endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ | 458 | #endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */ |
459 | 459 | ||
460 | #define INET6_MATCH(__sk, __hash, __saddr, __daddr, __ports, __dif)\ | 460 | #define INET6_MATCH(__sk, __net, __hash, __saddr, __daddr, __ports, __dif)\ |
461 | (((__sk)->sk_hash == (__hash)) && \ | 461 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ |
462 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ | 462 | ((*((__portpair *)&(inet_sk(__sk)->dport))) == (__ports)) && \ |
463 | ((__sk)->sk_family == AF_INET6) && \ | 463 | ((__sk)->sk_family == AF_INET6) && \ |
464 | ipv6_addr_equal(&inet6_sk(__sk)->daddr, (__saddr)) && \ | 464 | ipv6_addr_equal(&inet6_sk(__sk)->daddr, (__saddr)) && \ |
465 | ipv6_addr_equal(&inet6_sk(__sk)->rcv_saddr, (__daddr)) && \ | 465 | ipv6_addr_equal(&inet6_sk(__sk)->rcv_saddr, (__daddr)) && \ |
466 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | 466 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
467 | 467 | ||
468 | #define INET6_TW_MATCH(__sk, __hash, __saddr, __daddr, __ports, __dif) \ | 468 | #define INET6_TW_MATCH(__sk, __net, __hash, __saddr, __daddr, __ports, __dif) \ |
469 | (((__sk)->sk_hash == (__hash)) && \ | 469 | (((__sk)->sk_hash == (__hash)) && ((__sk)->sk_net == (__net)) && \ |
470 | (*((__portpair *)&(inet_twsk(__sk)->tw_dport)) == (__ports)) && \ | 470 | (*((__portpair *)&(inet_twsk(__sk)->tw_dport)) == (__ports)) && \ |
471 | ((__sk)->sk_family == PF_INET6) && \ | 471 | ((__sk)->sk_family == PF_INET6) && \ |
472 | (ipv6_addr_equal(&inet6_twsk(__sk)->tw_v6_daddr, (__saddr))) && \ | 472 | (ipv6_addr_equal(&inet6_twsk(__sk)->tw_v6_daddr, (__saddr))) && \ |
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h index 668056b4bb0b..fdff630708ce 100644 --- a/include/net/inet6_hashtables.h +++ b/include/net/inet6_hashtables.h | |||
@@ -57,34 +57,37 @@ extern void __inet6_hash(struct inet_hashinfo *hashinfo, struct sock *sk); | |||
57 | * | 57 | * |
58 | * The sockhash lock must be held as a reader here. | 58 | * The sockhash lock must be held as a reader here. |
59 | */ | 59 | */ |
60 | extern struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo, | 60 | extern struct sock *__inet6_lookup_established(struct net *net, |
61 | struct inet_hashinfo *hashinfo, | ||
61 | const struct in6_addr *saddr, | 62 | const struct in6_addr *saddr, |
62 | const __be16 sport, | 63 | const __be16 sport, |
63 | const struct in6_addr *daddr, | 64 | const struct in6_addr *daddr, |
64 | const u16 hnum, | 65 | const u16 hnum, |
65 | const int dif); | 66 | const int dif); |
66 | 67 | ||
67 | extern struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo, | 68 | extern struct sock *inet6_lookup_listener(struct net *net, |
69 | struct inet_hashinfo *hashinfo, | ||
68 | const struct in6_addr *daddr, | 70 | const struct in6_addr *daddr, |
69 | const unsigned short hnum, | 71 | const unsigned short hnum, |
70 | const int dif); | 72 | const int dif); |
71 | 73 | ||
72 | static inline struct sock *__inet6_lookup(struct inet_hashinfo *hashinfo, | 74 | static inline struct sock *__inet6_lookup(struct net *net, |
75 | struct inet_hashinfo *hashinfo, | ||
73 | const struct in6_addr *saddr, | 76 | const struct in6_addr *saddr, |
74 | const __be16 sport, | 77 | const __be16 sport, |
75 | const struct in6_addr *daddr, | 78 | const struct in6_addr *daddr, |
76 | const u16 hnum, | 79 | const u16 hnum, |
77 | const int dif) | 80 | const int dif) |
78 | { | 81 | { |
79 | struct sock *sk = __inet6_lookup_established(hashinfo, saddr, sport, | 82 | struct sock *sk = __inet6_lookup_established(net, hashinfo, saddr, |
80 | daddr, hnum, dif); | 83 | sport, daddr, hnum, dif); |
81 | if (sk) | 84 | if (sk) |
82 | return sk; | 85 | return sk; |
83 | 86 | ||
84 | return inet6_lookup_listener(hashinfo, daddr, hnum, dif); | 87 | return inet6_lookup_listener(net, hashinfo, daddr, hnum, dif); |
85 | } | 88 | } |
86 | 89 | ||
87 | extern struct sock *inet6_lookup(struct inet_hashinfo *hashinfo, | 90 | extern struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo, |
88 | const struct in6_addr *saddr, const __be16 sport, | 91 | const struct in6_addr *saddr, const __be16 sport, |
89 | const struct in6_addr *daddr, const __be16 dport, | 92 | const struct in6_addr *daddr, const __be16 dport, |
90 | const int dif); | 93 | const int dif); |
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index f42b75ce7f5c..ed0a0053a797 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c | |||
@@ -101,8 +101,8 @@ static void dccp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
101 | int err; | 101 | int err; |
102 | __u64 seq; | 102 | __u64 seq; |
103 | 103 | ||
104 | sk = inet6_lookup(&dccp_hashinfo, &hdr->daddr, dh->dccph_dport, | 104 | sk = inet6_lookup(&init_net, &dccp_hashinfo, &hdr->daddr, dh->dccph_dport, |
105 | &hdr->saddr, dh->dccph_sport, inet6_iif(skb)); | 105 | &hdr->saddr, dh->dccph_sport, inet6_iif(skb)); |
106 | 106 | ||
107 | if (sk == NULL) { | 107 | if (sk == NULL) { |
108 | ICMP6_INC_STATS_BH(__in6_dev_get(skb->dev), ICMP6_MIB_INERRORS); | 108 | ICMP6_INC_STATS_BH(__in6_dev_get(skb->dev), ICMP6_MIB_INERRORS); |
@@ -366,7 +366,7 @@ static struct sock *dccp_v6_hnd_req(struct sock *sk,struct sk_buff *skb) | |||
366 | if (req != NULL) | 366 | if (req != NULL) |
367 | return dccp_check_req(sk, skb, req, prev); | 367 | return dccp_check_req(sk, skb, req, prev); |
368 | 368 | ||
369 | nsk = __inet6_lookup_established(&dccp_hashinfo, | 369 | nsk = __inet6_lookup_established(&init_net, &dccp_hashinfo, |
370 | &iph->saddr, dh->dccph_sport, | 370 | &iph->saddr, dh->dccph_sport, |
371 | &iph->daddr, ntohs(dh->dccph_dport), | 371 | &iph->daddr, ntohs(dh->dccph_dport), |
372 | inet6_iif(skb)); | 372 | inet6_iif(skb)); |
@@ -797,7 +797,7 @@ static int dccp_v6_rcv(struct sk_buff *skb) | |||
797 | 797 | ||
798 | /* Step 2: | 798 | /* Step 2: |
799 | * Look up flow ID in table and get corresponding socket */ | 799 | * Look up flow ID in table and get corresponding socket */ |
800 | sk = __inet6_lookup(&dccp_hashinfo, &ipv6_hdr(skb)->saddr, | 800 | sk = __inet6_lookup(&init_net, &dccp_hashinfo, &ipv6_hdr(skb)->saddr, |
801 | dh->dccph_sport, | 801 | dh->dccph_sport, |
802 | &ipv6_hdr(skb)->daddr, ntohs(dh->dccph_dport), | 802 | &ipv6_hdr(skb)->daddr, ntohs(dh->dccph_dport), |
803 | inet6_iif(skb)); | 803 | inet6_iif(skb)); |
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index 95c9f1429228..da97695e7096 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c | |||
@@ -274,7 +274,7 @@ static int inet_diag_get_exact(struct sk_buff *in_skb, | |||
274 | } | 274 | } |
275 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 275 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
276 | else if (req->idiag_family == AF_INET6) { | 276 | else if (req->idiag_family == AF_INET6) { |
277 | sk = inet6_lookup(hashinfo, | 277 | sk = inet6_lookup(&init_net, hashinfo, |
278 | (struct in6_addr *)req->id.idiag_dst, | 278 | (struct in6_addr *)req->id.idiag_dst, |
279 | req->id.idiag_dport, | 279 | req->id.idiag_dport, |
280 | (struct in6_addr *)req->id.idiag_src, | 280 | (struct in6_addr *)req->id.idiag_src, |
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index ece6d0ee2da5..d325a9958909 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c | |||
@@ -54,7 +54,8 @@ EXPORT_SYMBOL(__inet6_hash); | |||
54 | * | 54 | * |
55 | * The sockhash lock must be held as a reader here. | 55 | * The sockhash lock must be held as a reader here. |
56 | */ | 56 | */ |
57 | struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo, | 57 | struct sock *__inet6_lookup_established(struct net *net, |
58 | struct inet_hashinfo *hashinfo, | ||
58 | const struct in6_addr *saddr, | 59 | const struct in6_addr *saddr, |
59 | const __be16 sport, | 60 | const __be16 sport, |
60 | const struct in6_addr *daddr, | 61 | const struct in6_addr *daddr, |
@@ -75,12 +76,12 @@ struct sock *__inet6_lookup_established(struct inet_hashinfo *hashinfo, | |||
75 | read_lock(lock); | 76 | read_lock(lock); |
76 | sk_for_each(sk, node, &head->chain) { | 77 | sk_for_each(sk, node, &head->chain) { |
77 | /* For IPV6 do the cheaper port and family tests first. */ | 78 | /* For IPV6 do the cheaper port and family tests first. */ |
78 | if (INET6_MATCH(sk, hash, saddr, daddr, ports, dif)) | 79 | if (INET6_MATCH(sk, net, hash, saddr, daddr, ports, dif)) |
79 | goto hit; /* You sunk my battleship! */ | 80 | goto hit; /* You sunk my battleship! */ |
80 | } | 81 | } |
81 | /* Must check for a TIME_WAIT'er before going to listener hash. */ | 82 | /* Must check for a TIME_WAIT'er before going to listener hash. */ |
82 | sk_for_each(sk, node, &head->twchain) { | 83 | sk_for_each(sk, node, &head->twchain) { |
83 | if (INET6_TW_MATCH(sk, hash, saddr, daddr, ports, dif)) | 84 | if (INET6_TW_MATCH(sk, net, hash, saddr, daddr, ports, dif)) |
84 | goto hit; | 85 | goto hit; |
85 | } | 86 | } |
86 | read_unlock(lock); | 87 | read_unlock(lock); |
@@ -93,9 +94,9 @@ hit: | |||
93 | } | 94 | } |
94 | EXPORT_SYMBOL(__inet6_lookup_established); | 95 | EXPORT_SYMBOL(__inet6_lookup_established); |
95 | 96 | ||
96 | struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo, | 97 | struct sock *inet6_lookup_listener(struct net *net, |
97 | const struct in6_addr *daddr, | 98 | struct inet_hashinfo *hashinfo, const struct in6_addr *daddr, |
98 | const unsigned short hnum, const int dif) | 99 | const unsigned short hnum, const int dif) |
99 | { | 100 | { |
100 | struct sock *sk; | 101 | struct sock *sk; |
101 | const struct hlist_node *node; | 102 | const struct hlist_node *node; |
@@ -104,7 +105,8 @@ struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo, | |||
104 | 105 | ||
105 | read_lock(&hashinfo->lhash_lock); | 106 | read_lock(&hashinfo->lhash_lock); |
106 | sk_for_each(sk, node, &hashinfo->listening_hash[inet_lhashfn(hnum)]) { | 107 | sk_for_each(sk, node, &hashinfo->listening_hash[inet_lhashfn(hnum)]) { |
107 | if (inet_sk(sk)->num == hnum && sk->sk_family == PF_INET6) { | 108 | if (sk->sk_net == net && inet_sk(sk)->num == hnum && |
109 | sk->sk_family == PF_INET6) { | ||
108 | const struct ipv6_pinfo *np = inet6_sk(sk); | 110 | const struct ipv6_pinfo *np = inet6_sk(sk); |
109 | 111 | ||
110 | score = 1; | 112 | score = 1; |
@@ -136,7 +138,7 @@ struct sock *inet6_lookup_listener(struct inet_hashinfo *hashinfo, | |||
136 | 138 | ||
137 | EXPORT_SYMBOL_GPL(inet6_lookup_listener); | 139 | EXPORT_SYMBOL_GPL(inet6_lookup_listener); |
138 | 140 | ||
139 | struct sock *inet6_lookup(struct inet_hashinfo *hashinfo, | 141 | struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo, |
140 | const struct in6_addr *saddr, const __be16 sport, | 142 | const struct in6_addr *saddr, const __be16 sport, |
141 | const struct in6_addr *daddr, const __be16 dport, | 143 | const struct in6_addr *daddr, const __be16 dport, |
142 | const int dif) | 144 | const int dif) |
@@ -144,7 +146,7 @@ struct sock *inet6_lookup(struct inet_hashinfo *hashinfo, | |||
144 | struct sock *sk; | 146 | struct sock *sk; |
145 | 147 | ||
146 | local_bh_disable(); | 148 | local_bh_disable(); |
147 | sk = __inet6_lookup(hashinfo, saddr, sport, daddr, ntohs(dport), dif); | 149 | sk = __inet6_lookup(net, hashinfo, saddr, sport, daddr, ntohs(dport), dif); |
148 | local_bh_enable(); | 150 | local_bh_enable(); |
149 | 151 | ||
150 | return sk; | 152 | return sk; |
@@ -170,6 +172,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row, | |||
170 | struct sock *sk2; | 172 | struct sock *sk2; |
171 | const struct hlist_node *node; | 173 | const struct hlist_node *node; |
172 | struct inet_timewait_sock *tw; | 174 | struct inet_timewait_sock *tw; |
175 | struct net *net = sk->sk_net; | ||
173 | 176 | ||
174 | prefetch(head->chain.first); | 177 | prefetch(head->chain.first); |
175 | write_lock(lock); | 178 | write_lock(lock); |
@@ -178,7 +181,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row, | |||
178 | sk_for_each(sk2, node, &head->twchain) { | 181 | sk_for_each(sk2, node, &head->twchain) { |
179 | tw = inet_twsk(sk2); | 182 | tw = inet_twsk(sk2); |
180 | 183 | ||
181 | if (INET6_TW_MATCH(sk2, hash, saddr, daddr, ports, dif)) { | 184 | if (INET6_TW_MATCH(sk2, net, hash, saddr, daddr, ports, dif)) { |
182 | if (twsk_unique(sk, sk2, twp)) | 185 | if (twsk_unique(sk, sk2, twp)) |
183 | goto unique; | 186 | goto unique; |
184 | else | 187 | else |
@@ -189,7 +192,7 @@ static int __inet6_check_established(struct inet_timewait_death_row *death_row, | |||
189 | 192 | ||
190 | /* And established part... */ | 193 | /* And established part... */ |
191 | sk_for_each(sk2, node, &head->chain) { | 194 | sk_for_each(sk2, node, &head->chain) { |
192 | if (INET6_MATCH(sk2, hash, saddr, daddr, ports, dif)) | 195 | if (INET6_MATCH(sk2, net, hash, saddr, daddr, ports, dif)) |
193 | goto not_unique; | 196 | goto not_unique; |
194 | } | 197 | } |
195 | 198 | ||
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 00c08399837d..59d0029e93a7 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -330,8 +330,8 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, | |||
330 | struct tcp_sock *tp; | 330 | struct tcp_sock *tp; |
331 | __u32 seq; | 331 | __u32 seq; |
332 | 332 | ||
333 | sk = inet6_lookup(&tcp_hashinfo, &hdr->daddr, th->dest, &hdr->saddr, | 333 | sk = inet6_lookup(skb->dev->nd_net, &tcp_hashinfo, &hdr->daddr, |
334 | th->source, skb->dev->ifindex); | 334 | th->dest, &hdr->saddr, th->source, skb->dev->ifindex); |
335 | 335 | ||
336 | if (sk == NULL) { | 336 | if (sk == NULL) { |
337 | ICMP6_INC_STATS_BH(__in6_dev_get(skb->dev), ICMP6_MIB_INERRORS); | 337 | ICMP6_INC_STATS_BH(__in6_dev_get(skb->dev), ICMP6_MIB_INERRORS); |
@@ -1208,9 +1208,9 @@ static struct sock *tcp_v6_hnd_req(struct sock *sk,struct sk_buff *skb) | |||
1208 | if (req) | 1208 | if (req) |
1209 | return tcp_check_req(sk, skb, req, prev); | 1209 | return tcp_check_req(sk, skb, req, prev); |
1210 | 1210 | ||
1211 | nsk = __inet6_lookup_established(&tcp_hashinfo, &ipv6_hdr(skb)->saddr, | 1211 | nsk = __inet6_lookup_established(sk->sk_net, &tcp_hashinfo, |
1212 | th->source, &ipv6_hdr(skb)->daddr, | 1212 | &ipv6_hdr(skb)->saddr, th->source, |
1213 | ntohs(th->dest), inet6_iif(skb)); | 1213 | &ipv6_hdr(skb)->daddr, ntohs(th->dest), inet6_iif(skb)); |
1214 | 1214 | ||
1215 | if (nsk) { | 1215 | if (nsk) { |
1216 | if (nsk->sk_state != TCP_TIME_WAIT) { | 1216 | if (nsk->sk_state != TCP_TIME_WAIT) { |
@@ -1710,9 +1710,10 @@ static int tcp_v6_rcv(struct sk_buff *skb) | |||
1710 | TCP_SKB_CB(skb)->flags = ipv6_get_dsfield(ipv6_hdr(skb)); | 1710 | TCP_SKB_CB(skb)->flags = ipv6_get_dsfield(ipv6_hdr(skb)); |
1711 | TCP_SKB_CB(skb)->sacked = 0; | 1711 | TCP_SKB_CB(skb)->sacked = 0; |
1712 | 1712 | ||
1713 | sk = __inet6_lookup(&tcp_hashinfo, &ipv6_hdr(skb)->saddr, th->source, | 1713 | sk = __inet6_lookup(skb->dev->nd_net, &tcp_hashinfo, |
1714 | &ipv6_hdr(skb)->daddr, ntohs(th->dest), | 1714 | &ipv6_hdr(skb)->saddr, th->source, |
1715 | inet6_iif(skb)); | 1715 | &ipv6_hdr(skb)->daddr, ntohs(th->dest), |
1716 | inet6_iif(skb)); | ||
1716 | 1717 | ||
1717 | if (!sk) | 1718 | if (!sk) |
1718 | goto no_tcp_socket; | 1719 | goto no_tcp_socket; |
@@ -1792,7 +1793,7 @@ do_time_wait: | |||
1792 | { | 1793 | { |
1793 | struct sock *sk2; | 1794 | struct sock *sk2; |
1794 | 1795 | ||
1795 | sk2 = inet6_lookup_listener(&tcp_hashinfo, | 1796 | sk2 = inet6_lookup_listener(skb->dev->nd_net, &tcp_hashinfo, |
1796 | &ipv6_hdr(skb)->daddr, | 1797 | &ipv6_hdr(skb)->daddr, |
1797 | ntohs(th->dest), inet6_iif(skb)); | 1798 | ntohs(th->dest), inet6_iif(skb)); |
1798 | if (sk2 != NULL) { | 1799 | if (sk2 != NULL) { |