diff options
-rw-r--r-- | include/linux/netfilter.h | 53 | ||||
-rw-r--r-- | net/ipv4/netfilter/iptable_filter.c | 6 | ||||
-rw-r--r-- | net/ipv4/netfilter/iptable_mangle.c | 10 | ||||
-rw-r--r-- | net/ipv4/netfilter/iptable_raw.c | 4 | ||||
-rw-r--r-- | net/ipv4/netfilter/iptable_security.c | 6 | ||||
-rw-r--r-- | net/ipv6/netfilter/ip6table_filter.c | 6 | ||||
-rw-r--r-- | net/ipv6/netfilter/ip6table_security.c | 6 |
7 files changed, 19 insertions, 72 deletions
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h index bf3afb0844f7..48cfe51bfddc 100644 --- a/include/linux/netfilter.h +++ b/include/linux/netfilter.h | |||
@@ -5,13 +5,11 @@ | |||
5 | #include <linux/init.h> | 5 | #include <linux/init.h> |
6 | #include <linux/skbuff.h> | 6 | #include <linux/skbuff.h> |
7 | #include <linux/net.h> | 7 | #include <linux/net.h> |
8 | #include <linux/netdevice.h> | ||
9 | #include <linux/if.h> | 8 | #include <linux/if.h> |
10 | #include <linux/in.h> | 9 | #include <linux/in.h> |
11 | #include <linux/in6.h> | 10 | #include <linux/in6.h> |
12 | #include <linux/wait.h> | 11 | #include <linux/wait.h> |
13 | #include <linux/list.h> | 12 | #include <linux/list.h> |
14 | #include <net/net_namespace.h> | ||
15 | #endif | 13 | #endif |
16 | #include <linux/types.h> | 14 | #include <linux/types.h> |
17 | #include <linux/compiler.h> | 15 | #include <linux/compiler.h> |
@@ -355,56 +353,5 @@ extern void (*nf_ct_destroy)(struct nf_conntrack *); | |||
355 | static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {} | 353 | static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {} |
356 | #endif | 354 | #endif |
357 | 355 | ||
358 | static inline struct net *nf_pre_routing_net(const struct net_device *in, | ||
359 | const struct net_device *out) | ||
360 | { | ||
361 | #ifdef CONFIG_NET_NS | ||
362 | return in->nd_net; | ||
363 | #else | ||
364 | return &init_net; | ||
365 | #endif | ||
366 | } | ||
367 | |||
368 | static inline struct net *nf_local_in_net(const struct net_device *in, | ||
369 | const struct net_device *out) | ||
370 | { | ||
371 | #ifdef CONFIG_NET_NS | ||
372 | return in->nd_net; | ||
373 | #else | ||
374 | return &init_net; | ||
375 | #endif | ||
376 | } | ||
377 | |||
378 | static inline struct net *nf_forward_net(const struct net_device *in, | ||
379 | const struct net_device *out) | ||
380 | { | ||
381 | #ifdef CONFIG_NET_NS | ||
382 | BUG_ON(in->nd_net != out->nd_net); | ||
383 | return in->nd_net; | ||
384 | #else | ||
385 | return &init_net; | ||
386 | #endif | ||
387 | } | ||
388 | |||
389 | static inline struct net *nf_local_out_net(const struct net_device *in, | ||
390 | const struct net_device *out) | ||
391 | { | ||
392 | #ifdef CONFIG_NET_NS | ||
393 | return out->nd_net; | ||
394 | #else | ||
395 | return &init_net; | ||
396 | #endif | ||
397 | } | ||
398 | |||
399 | static inline struct net *nf_post_routing_net(const struct net_device *in, | ||
400 | const struct net_device *out) | ||
401 | { | ||
402 | #ifdef CONFIG_NET_NS | ||
403 | return out->nd_net; | ||
404 | #else | ||
405 | return &init_net; | ||
406 | #endif | ||
407 | } | ||
408 | |||
409 | #endif /*__KERNEL__*/ | 356 | #endif /*__KERNEL__*/ |
410 | #endif /*__LINUX_NETFILTER_H*/ | 357 | #endif /*__LINUX_NETFILTER_H*/ |
diff --git a/net/ipv4/netfilter/iptable_filter.c b/net/ipv4/netfilter/iptable_filter.c index 1ea677dcf845..c9224310ebae 100644 --- a/net/ipv4/netfilter/iptable_filter.c +++ b/net/ipv4/netfilter/iptable_filter.c | |||
@@ -70,7 +70,7 @@ ipt_local_in_hook(unsigned int hook, | |||
70 | int (*okfn)(struct sk_buff *)) | 70 | int (*okfn)(struct sk_buff *)) |
71 | { | 71 | { |
72 | return ipt_do_table(skb, hook, in, out, | 72 | return ipt_do_table(skb, hook, in, out, |
73 | nf_local_in_net(in, out)->ipv4.iptable_filter); | 73 | dev_net(in)->ipv4.iptable_filter); |
74 | } | 74 | } |
75 | 75 | ||
76 | static unsigned int | 76 | static unsigned int |
@@ -81,7 +81,7 @@ ipt_hook(unsigned int hook, | |||
81 | int (*okfn)(struct sk_buff *)) | 81 | int (*okfn)(struct sk_buff *)) |
82 | { | 82 | { |
83 | return ipt_do_table(skb, hook, in, out, | 83 | return ipt_do_table(skb, hook, in, out, |
84 | nf_forward_net(in, out)->ipv4.iptable_filter); | 84 | dev_net(in)->ipv4.iptable_filter); |
85 | } | 85 | } |
86 | 86 | ||
87 | static unsigned int | 87 | static unsigned int |
@@ -101,7 +101,7 @@ ipt_local_out_hook(unsigned int hook, | |||
101 | } | 101 | } |
102 | 102 | ||
103 | return ipt_do_table(skb, hook, in, out, | 103 | return ipt_do_table(skb, hook, in, out, |
104 | nf_local_out_net(in, out)->ipv4.iptable_filter); | 104 | dev_net(out)->ipv4.iptable_filter); |
105 | } | 105 | } |
106 | 106 | ||
107 | static struct nf_hook_ops ipt_ops[] __read_mostly = { | 107 | static struct nf_hook_ops ipt_ops[] __read_mostly = { |
diff --git a/net/ipv4/netfilter/iptable_mangle.c b/net/ipv4/netfilter/iptable_mangle.c index da59182f2226..69f2c4287146 100644 --- a/net/ipv4/netfilter/iptable_mangle.c +++ b/net/ipv4/netfilter/iptable_mangle.c | |||
@@ -81,7 +81,7 @@ ipt_pre_routing_hook(unsigned int hook, | |||
81 | int (*okfn)(struct sk_buff *)) | 81 | int (*okfn)(struct sk_buff *)) |
82 | { | 82 | { |
83 | return ipt_do_table(skb, hook, in, out, | 83 | return ipt_do_table(skb, hook, in, out, |
84 | nf_pre_routing_net(in, out)->ipv4.iptable_mangle); | 84 | dev_net(in)->ipv4.iptable_mangle); |
85 | } | 85 | } |
86 | 86 | ||
87 | static unsigned int | 87 | static unsigned int |
@@ -92,7 +92,7 @@ ipt_post_routing_hook(unsigned int hook, | |||
92 | int (*okfn)(struct sk_buff *)) | 92 | int (*okfn)(struct sk_buff *)) |
93 | { | 93 | { |
94 | return ipt_do_table(skb, hook, in, out, | 94 | return ipt_do_table(skb, hook, in, out, |
95 | nf_post_routing_net(in, out)->ipv4.iptable_mangle); | 95 | dev_net(out)->ipv4.iptable_mangle); |
96 | } | 96 | } |
97 | 97 | ||
98 | static unsigned int | 98 | static unsigned int |
@@ -103,7 +103,7 @@ ipt_local_in_hook(unsigned int hook, | |||
103 | int (*okfn)(struct sk_buff *)) | 103 | int (*okfn)(struct sk_buff *)) |
104 | { | 104 | { |
105 | return ipt_do_table(skb, hook, in, out, | 105 | return ipt_do_table(skb, hook, in, out, |
106 | nf_local_in_net(in, out)->ipv4.iptable_mangle); | 106 | dev_net(in)->ipv4.iptable_mangle); |
107 | } | 107 | } |
108 | 108 | ||
109 | static unsigned int | 109 | static unsigned int |
@@ -114,7 +114,7 @@ ipt_forward_hook(unsigned int hook, | |||
114 | int (*okfn)(struct sk_buff *)) | 114 | int (*okfn)(struct sk_buff *)) |
115 | { | 115 | { |
116 | return ipt_do_table(skb, hook, in, out, | 116 | return ipt_do_table(skb, hook, in, out, |
117 | nf_forward_net(in, out)->ipv4.iptable_mangle); | 117 | dev_net(in)->ipv4.iptable_mangle); |
118 | } | 118 | } |
119 | 119 | ||
120 | static unsigned int | 120 | static unsigned int |
@@ -147,7 +147,7 @@ ipt_local_hook(unsigned int hook, | |||
147 | tos = iph->tos; | 147 | tos = iph->tos; |
148 | 148 | ||
149 | ret = ipt_do_table(skb, hook, in, out, | 149 | ret = ipt_do_table(skb, hook, in, out, |
150 | nf_local_out_net(in, out)->ipv4.iptable_mangle); | 150 | dev_net(out)->ipv4.iptable_mangle); |
151 | /* Reroute for ANY change. */ | 151 | /* Reroute for ANY change. */ |
152 | if (ret != NF_DROP && ret != NF_STOLEN && ret != NF_QUEUE) { | 152 | if (ret != NF_DROP && ret != NF_STOLEN && ret != NF_QUEUE) { |
153 | iph = ip_hdr(skb); | 153 | iph = ip_hdr(skb); |
diff --git a/net/ipv4/netfilter/iptable_raw.c b/net/ipv4/netfilter/iptable_raw.c index fddce7754b72..8faebfe638f1 100644 --- a/net/ipv4/netfilter/iptable_raw.c +++ b/net/ipv4/netfilter/iptable_raw.c | |||
@@ -53,7 +53,7 @@ ipt_hook(unsigned int hook, | |||
53 | int (*okfn)(struct sk_buff *)) | 53 | int (*okfn)(struct sk_buff *)) |
54 | { | 54 | { |
55 | return ipt_do_table(skb, hook, in, out, | 55 | return ipt_do_table(skb, hook, in, out, |
56 | nf_pre_routing_net(in, out)->ipv4.iptable_raw); | 56 | dev_net(in)->ipv4.iptable_raw); |
57 | } | 57 | } |
58 | 58 | ||
59 | static unsigned int | 59 | static unsigned int |
@@ -72,7 +72,7 @@ ipt_local_hook(unsigned int hook, | |||
72 | return NF_ACCEPT; | 72 | return NF_ACCEPT; |
73 | } | 73 | } |
74 | return ipt_do_table(skb, hook, in, out, | 74 | return ipt_do_table(skb, hook, in, out, |
75 | nf_local_out_net(in, out)->ipv4.iptable_raw); | 75 | dev_net(out)->ipv4.iptable_raw); |
76 | } | 76 | } |
77 | 77 | ||
78 | /* 'raw' is the very first table. */ | 78 | /* 'raw' is the very first table. */ |
diff --git a/net/ipv4/netfilter/iptable_security.c b/net/ipv4/netfilter/iptable_security.c index db6d312128e1..36f3be3cc428 100644 --- a/net/ipv4/netfilter/iptable_security.c +++ b/net/ipv4/netfilter/iptable_security.c | |||
@@ -73,7 +73,7 @@ ipt_local_in_hook(unsigned int hook, | |||
73 | int (*okfn)(struct sk_buff *)) | 73 | int (*okfn)(struct sk_buff *)) |
74 | { | 74 | { |
75 | return ipt_do_table(skb, hook, in, out, | 75 | return ipt_do_table(skb, hook, in, out, |
76 | nf_local_in_net(in, out)->ipv4.iptable_security); | 76 | dev_net(in)->ipv4.iptable_security); |
77 | } | 77 | } |
78 | 78 | ||
79 | static unsigned int | 79 | static unsigned int |
@@ -84,7 +84,7 @@ ipt_forward_hook(unsigned int hook, | |||
84 | int (*okfn)(struct sk_buff *)) | 84 | int (*okfn)(struct sk_buff *)) |
85 | { | 85 | { |
86 | return ipt_do_table(skb, hook, in, out, | 86 | return ipt_do_table(skb, hook, in, out, |
87 | nf_forward_net(in, out)->ipv4.iptable_security); | 87 | dev_net(in)->ipv4.iptable_security); |
88 | } | 88 | } |
89 | 89 | ||
90 | static unsigned int | 90 | static unsigned int |
@@ -103,7 +103,7 @@ ipt_local_out_hook(unsigned int hook, | |||
103 | return NF_ACCEPT; | 103 | return NF_ACCEPT; |
104 | } | 104 | } |
105 | return ipt_do_table(skb, hook, in, out, | 105 | return ipt_do_table(skb, hook, in, out, |
106 | nf_local_out_net(in, out)->ipv4.iptable_security); | 106 | dev_net(out)->ipv4.iptable_security); |
107 | } | 107 | } |
108 | 108 | ||
109 | static struct nf_hook_ops ipt_ops[] __read_mostly = { | 109 | static struct nf_hook_ops ipt_ops[] __read_mostly = { |
diff --git a/net/ipv6/netfilter/ip6table_filter.c b/net/ipv6/netfilter/ip6table_filter.c index 55a2c290bad4..b110a8a85a14 100644 --- a/net/ipv6/netfilter/ip6table_filter.c +++ b/net/ipv6/netfilter/ip6table_filter.c | |||
@@ -68,7 +68,7 @@ ip6t_local_in_hook(unsigned int hook, | |||
68 | int (*okfn)(struct sk_buff *)) | 68 | int (*okfn)(struct sk_buff *)) |
69 | { | 69 | { |
70 | return ip6t_do_table(skb, hook, in, out, | 70 | return ip6t_do_table(skb, hook, in, out, |
71 | nf_local_in_net(in, out)->ipv6.ip6table_filter); | 71 | dev_net(in)->ipv6.ip6table_filter); |
72 | } | 72 | } |
73 | 73 | ||
74 | static unsigned int | 74 | static unsigned int |
@@ -79,7 +79,7 @@ ip6t_forward_hook(unsigned int hook, | |||
79 | int (*okfn)(struct sk_buff *)) | 79 | int (*okfn)(struct sk_buff *)) |
80 | { | 80 | { |
81 | return ip6t_do_table(skb, hook, in, out, | 81 | return ip6t_do_table(skb, hook, in, out, |
82 | nf_forward_net(in, out)->ipv6.ip6table_filter); | 82 | dev_net(in)->ipv6.ip6table_filter); |
83 | } | 83 | } |
84 | 84 | ||
85 | static unsigned int | 85 | static unsigned int |
@@ -100,7 +100,7 @@ ip6t_local_out_hook(unsigned int hook, | |||
100 | #endif | 100 | #endif |
101 | 101 | ||
102 | return ip6t_do_table(skb, hook, in, out, | 102 | return ip6t_do_table(skb, hook, in, out, |
103 | nf_local_out_net(in, out)->ipv6.ip6table_filter); | 103 | dev_net(out)->ipv6.ip6table_filter); |
104 | } | 104 | } |
105 | 105 | ||
106 | static struct nf_hook_ops ip6t_ops[] __read_mostly = { | 106 | static struct nf_hook_ops ip6t_ops[] __read_mostly = { |
diff --git a/net/ipv6/netfilter/ip6table_security.c b/net/ipv6/netfilter/ip6table_security.c index 6e7131036bc6..20bc52f13e43 100644 --- a/net/ipv6/netfilter/ip6table_security.c +++ b/net/ipv6/netfilter/ip6table_security.c | |||
@@ -72,7 +72,7 @@ ip6t_local_in_hook(unsigned int hook, | |||
72 | int (*okfn)(struct sk_buff *)) | 72 | int (*okfn)(struct sk_buff *)) |
73 | { | 73 | { |
74 | return ip6t_do_table(skb, hook, in, out, | 74 | return ip6t_do_table(skb, hook, in, out, |
75 | nf_local_in_net(in, out)->ipv6.ip6table_security); | 75 | dev_net(in)->ipv6.ip6table_security); |
76 | } | 76 | } |
77 | 77 | ||
78 | static unsigned int | 78 | static unsigned int |
@@ -83,7 +83,7 @@ ip6t_forward_hook(unsigned int hook, | |||
83 | int (*okfn)(struct sk_buff *)) | 83 | int (*okfn)(struct sk_buff *)) |
84 | { | 84 | { |
85 | return ip6t_do_table(skb, hook, in, out, | 85 | return ip6t_do_table(skb, hook, in, out, |
86 | nf_forward_net(in, out)->ipv6.ip6table_security); | 86 | dev_net(in)->ipv6.ip6table_security); |
87 | } | 87 | } |
88 | 88 | ||
89 | static unsigned int | 89 | static unsigned int |
@@ -95,7 +95,7 @@ ip6t_local_out_hook(unsigned int hook, | |||
95 | { | 95 | { |
96 | /* TBD: handle short packets via raw socket */ | 96 | /* TBD: handle short packets via raw socket */ |
97 | return ip6t_do_table(skb, hook, in, out, | 97 | return ip6t_do_table(skb, hook, in, out, |
98 | nf_local_out_net(in, out)->ipv6.ip6table_security); | 98 | dev_net(out)->ipv6.ip6table_security); |
99 | } | 99 | } |
100 | 100 | ||
101 | static struct nf_hook_ops ip6t_ops[] __read_mostly = { | 101 | static struct nf_hook_ops ip6t_ops[] __read_mostly = { |