aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2008-10-08 05:35:04 -0400
committerPatrick McHardy <kaber@trash.net>2008-10-08 05:35:04 -0400
commita702a65fc1376fc1f6757ec2a6960348af3f1876 (patch)
tree4d44e147a76b35228a4535c9cc446c1d1bf0dddd
parent63c9a26264be108b52de087724673f8664570e34 (diff)
netfilter: netns nf_conntrack: pass netns pointer to nf_conntrack_in()
It's deducible from skb->dev or skb->dst->dev, but we know netns at the moment of call, so pass it down and use for finding and creating conntracks. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Patrick McHardy <kaber@trash.net>
-rw-r--r--include/net/netfilter/nf_conntrack_core.h3
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c4
-rw-r--r--net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c24
-rw-r--r--net/netfilter/nf_conntrack_core.c15
4 files changed, 28 insertions, 18 deletions
diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
index b4b45c541da6..e78afe7f28e3 100644
--- a/include/net/netfilter/nf_conntrack_core.h
+++ b/include/net/netfilter/nf_conntrack_core.h
@@ -20,7 +20,8 @@
20/* This header is used to share core functionality between the 20/* This header is used to share core functionality between the
21 standalone connection tracking module, and the compatibility layer's use 21 standalone connection tracking module, and the compatibility layer's use
22 of connection tracking. */ 22 of connection tracking. */
23extern unsigned int nf_conntrack_in(u_int8_t pf, 23extern unsigned int nf_conntrack_in(struct net *net,
24 u_int8_t pf,
24 unsigned int hooknum, 25 unsigned int hooknum,
25 struct sk_buff *skb); 26 struct sk_buff *skb);
26 27
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index 03dd108015c2..2e4dd3fb0022 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -172,7 +172,7 @@ static unsigned int ipv4_conntrack_in(unsigned int hooknum,
172 const struct net_device *out, 172 const struct net_device *out,
173 int (*okfn)(struct sk_buff *)) 173 int (*okfn)(struct sk_buff *))
174{ 174{
175 return nf_conntrack_in(PF_INET, hooknum, skb); 175 return nf_conntrack_in(dev_net(in), PF_INET, hooknum, skb);
176} 176}
177 177
178static unsigned int ipv4_conntrack_local(unsigned int hooknum, 178static unsigned int ipv4_conntrack_local(unsigned int hooknum,
@@ -188,7 +188,7 @@ static unsigned int ipv4_conntrack_local(unsigned int hooknum,
188 printk("ipt_hook: happy cracking.\n"); 188 printk("ipt_hook: happy cracking.\n");
189 return NF_ACCEPT; 189 return NF_ACCEPT;
190 } 190 }
191 return nf_conntrack_in(PF_INET, hooknum, skb); 191 return nf_conntrack_in(dev_net(out), PF_INET, hooknum, skb);
192} 192}
193 193
194/* Connection tracking may drop packets, but never alters them, so 194/* Connection tracking may drop packets, but never alters them, so
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index 85050c072abd..e91db16611d9 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -211,11 +211,10 @@ static unsigned int ipv6_defrag(unsigned int hooknum,
211 return NF_STOLEN; 211 return NF_STOLEN;
212} 212}
213 213
214static unsigned int ipv6_conntrack_in(unsigned int hooknum, 214static unsigned int __ipv6_conntrack_in(struct net *net,
215 struct sk_buff *skb, 215 unsigned int hooknum,
216 const struct net_device *in, 216 struct sk_buff *skb,
217 const struct net_device *out, 217 int (*okfn)(struct sk_buff *))
218 int (*okfn)(struct sk_buff *))
219{ 218{
220 struct sk_buff *reasm = skb->nfct_reasm; 219 struct sk_buff *reasm = skb->nfct_reasm;
221 220
@@ -225,7 +224,7 @@ static unsigned int ipv6_conntrack_in(unsigned int hooknum,
225 if (!reasm->nfct) { 224 if (!reasm->nfct) {
226 unsigned int ret; 225 unsigned int ret;
227 226
228 ret = nf_conntrack_in(PF_INET6, hooknum, reasm); 227 ret = nf_conntrack_in(net, PF_INET6, hooknum, reasm);
229 if (ret != NF_ACCEPT) 228 if (ret != NF_ACCEPT)
230 return ret; 229 return ret;
231 } 230 }
@@ -235,7 +234,16 @@ static unsigned int ipv6_conntrack_in(unsigned int hooknum,
235 return NF_ACCEPT; 234 return NF_ACCEPT;
236 } 235 }
237 236
238 return nf_conntrack_in(PF_INET6, hooknum, skb); 237 return nf_conntrack_in(net, PF_INET6, hooknum, skb);
238}
239
240static unsigned int ipv6_conntrack_in(unsigned int hooknum,
241 struct sk_buff *skb,
242 const struct net_device *in,
243 const struct net_device *out,
244 int (*okfn)(struct sk_buff *))
245{
246 return __ipv6_conntrack_in(dev_net(in), hooknum, skb, okfn);
239} 247}
240 248
241static unsigned int ipv6_conntrack_local(unsigned int hooknum, 249static unsigned int ipv6_conntrack_local(unsigned int hooknum,
@@ -250,7 +258,7 @@ static unsigned int ipv6_conntrack_local(unsigned int hooknum,
250 printk("ipv6_conntrack_local: packet too short\n"); 258 printk("ipv6_conntrack_local: packet too short\n");
251 return NF_ACCEPT; 259 return NF_ACCEPT;
252 } 260 }
253 return ipv6_conntrack_in(hooknum, skb, in, out, okfn); 261 return __ipv6_conntrack_in(dev_net(out), hooknum, skb, okfn);
254} 262}
255 263
256static struct nf_hook_ops ipv6_conntrack_ops[] __read_mostly = { 264static struct nf_hook_ops ipv6_conntrack_ops[] __read_mostly = {
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 2a105db13307..5c96d9732c7b 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -611,7 +611,8 @@ init_conntrack(struct net *net,
611 611
612/* On success, returns conntrack ptr, sets skb->nfct and ctinfo */ 612/* On success, returns conntrack ptr, sets skb->nfct and ctinfo */
613static inline struct nf_conn * 613static inline struct nf_conn *
614resolve_normal_ct(struct sk_buff *skb, 614resolve_normal_ct(struct net *net,
615 struct sk_buff *skb,
615 unsigned int dataoff, 616 unsigned int dataoff,
616 u_int16_t l3num, 617 u_int16_t l3num,
617 u_int8_t protonum, 618 u_int8_t protonum,
@@ -632,10 +633,9 @@ resolve_normal_ct(struct sk_buff *skb,
632 } 633 }
633 634
634 /* look for tuple match */ 635 /* look for tuple match */
635 h = nf_conntrack_find_get(&init_net, &tuple); 636 h = nf_conntrack_find_get(net, &tuple);
636 if (!h) { 637 if (!h) {
637 h = init_conntrack(&init_net, &tuple, l3proto, l4proto, skb, 638 h = init_conntrack(net, &tuple, l3proto, l4proto, skb, dataoff);
638 dataoff);
639 if (!h) 639 if (!h)
640 return NULL; 640 return NULL;
641 if (IS_ERR(h)) 641 if (IS_ERR(h))
@@ -669,7 +669,8 @@ resolve_normal_ct(struct sk_buff *skb,
669} 669}
670 670
671unsigned int 671unsigned int
672nf_conntrack_in(u_int8_t pf, unsigned int hooknum, struct sk_buff *skb) 672nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,
673 struct sk_buff *skb)
673{ 674{
674 struct nf_conn *ct; 675 struct nf_conn *ct;
675 enum ip_conntrack_info ctinfo; 676 enum ip_conntrack_info ctinfo;
@@ -709,8 +710,8 @@ nf_conntrack_in(u_int8_t pf, unsigned int hooknum, struct sk_buff *skb)
709 return -ret; 710 return -ret;
710 } 711 }
711 712
712 ct = resolve_normal_ct(skb, dataoff, pf, protonum, l3proto, l4proto, 713 ct = resolve_normal_ct(net, skb, dataoff, pf, protonum,
713 &set_reply, &ctinfo); 714 l3proto, l4proto, &set_reply, &ctinfo);
714 if (!ct) { 715 if (!ct) {
715 /* Not valid part of a connection */ 716 /* Not valid part of a connection */
716 NF_CT_STAT_INC_ATOMIC(invalid); 717 NF_CT_STAT_INC_ATOMIC(invalid);