diff options
| author | Alexey Dobriyan <adobriyan@sw.ru> | 2008-04-14 03:56:02 -0400 |
|---|---|---|
| committer | Patrick McHardy <kaber@trash.net> | 2008-04-14 03:56:02 -0400 |
| commit | 666953df353194bef76086fa3f126241cbac3e3a (patch) | |
| tree | bd69afed2996b0a521361efcd29e32ea7606e9ff /include/linux | |
| parent | 36e2a1b0f7f2598e38952494b91490f58aa221c8 (diff) | |
[NETFILTER]: ip_tables: per-netns FILTER/MANGLE/RAW tables for real
Commit 9335f047fe61587ec82ff12fbb1220bcfdd32006 aka
"[NETFILTER]: ip_tables: per-netns FILTER, MANGLE, RAW"
added per-netns _view_ of iptables rules. They were shown to user, but
ignored by filtering code. Now that it's possible to at least ping loopback,
per-netns tables can affect filtering decisions.
netns is taken in case of
PRE_ROUTING, LOCAL_IN -- from in device,
POST_ROUTING, LOCAL_OUT -- from out device,
FORWARD -- from in device which should be equal to out device's netns.
This code is relatively new, so BUG_ON was plugged.
Wrappers were added to a) keep code the same from CONFIG_NET_NS=n users
(overwhelming majority), b) consolidate code in one place -- similar
changes will be done in ipv6 and arp netfilter code.
Signed-off-by: Alexey Dobriyan <adobriyan@sw.ru>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/netfilter.h | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h index 89e6c72ad295..66bc52060fd6 100644 --- a/include/linux/netfilter.h +++ b/include/linux/netfilter.h | |||
| @@ -6,11 +6,13 @@ | |||
| 6 | #include <linux/types.h> | 6 | #include <linux/types.h> |
| 7 | #include <linux/skbuff.h> | 7 | #include <linux/skbuff.h> |
| 8 | #include <linux/net.h> | 8 | #include <linux/net.h> |
| 9 | #include <linux/netdevice.h> | ||
| 9 | #include <linux/if.h> | 10 | #include <linux/if.h> |
| 10 | #include <linux/in.h> | 11 | #include <linux/in.h> |
| 11 | #include <linux/in6.h> | 12 | #include <linux/in6.h> |
| 12 | #include <linux/wait.h> | 13 | #include <linux/wait.h> |
| 13 | #include <linux/list.h> | 14 | #include <linux/list.h> |
| 15 | #include <net/net_namespace.h> | ||
| 14 | #endif | 16 | #endif |
| 15 | #include <linux/compiler.h> | 17 | #include <linux/compiler.h> |
| 16 | 18 | ||
| @@ -76,7 +78,6 @@ extern void netfilter_init(void); | |||
| 76 | #define NF_MAX_HOOKS 8 | 78 | #define NF_MAX_HOOKS 8 |
| 77 | 79 | ||
| 78 | struct sk_buff; | 80 | struct sk_buff; |
| 79 | struct net_device; | ||
| 80 | 81 | ||
| 81 | typedef unsigned int nf_hookfn(unsigned int hooknum, | 82 | typedef unsigned int nf_hookfn(unsigned int hooknum, |
| 82 | struct sk_buff *skb, | 83 | struct sk_buff *skb, |
| @@ -320,5 +321,56 @@ extern void (*nf_ct_destroy)(struct nf_conntrack *); | |||
| 320 | static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {} | 321 | static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {} |
| 321 | #endif | 322 | #endif |
| 322 | 323 | ||
| 324 | static inline struct net *nf_pre_routing_net(const struct net_device *in, | ||
| 325 | const struct net_device *out) | ||
| 326 | { | ||
| 327 | #ifdef CONFIG_NET_NS | ||
| 328 | return in->nd_net; | ||
| 329 | #else | ||
| 330 | return &init_net; | ||
| 331 | #endif | ||
| 332 | } | ||
| 333 | |||
| 334 | static inline struct net *nf_local_in_net(const struct net_device *in, | ||
| 335 | const struct net_device *out) | ||
| 336 | { | ||
| 337 | #ifdef CONFIG_NET_NS | ||
| 338 | return in->nd_net; | ||
| 339 | #else | ||
| 340 | return &init_net; | ||
| 341 | #endif | ||
| 342 | } | ||
| 343 | |||
| 344 | static inline struct net *nf_forward_net(const struct net_device *in, | ||
| 345 | const struct net_device *out) | ||
| 346 | { | ||
| 347 | #ifdef CONFIG_NET_NS | ||
| 348 | BUG_ON(in->nd_net != out->nd_net); | ||
| 349 | return in->nd_net; | ||
| 350 | #else | ||
| 351 | return &init_net; | ||
| 352 | #endif | ||
| 353 | } | ||
| 354 | |||
| 355 | static inline struct net *nf_local_out_net(const struct net_device *in, | ||
| 356 | const struct net_device *out) | ||
| 357 | { | ||
| 358 | #ifdef CONFIG_NET_NS | ||
| 359 | return out->nd_net; | ||
| 360 | #else | ||
| 361 | return &init_net; | ||
| 362 | #endif | ||
| 363 | } | ||
| 364 | |||
| 365 | static inline struct net *nf_post_routing_net(const struct net_device *in, | ||
| 366 | const struct net_device *out) | ||
| 367 | { | ||
| 368 | #ifdef CONFIG_NET_NS | ||
| 369 | return out->nd_net; | ||
| 370 | #else | ||
| 371 | return &init_net; | ||
| 372 | #endif | ||
| 373 | } | ||
| 374 | |||
| 323 | #endif /*__KERNEL__*/ | 375 | #endif /*__KERNEL__*/ |
| 324 | #endif /*__LINUX_NETFILTER_H*/ | 376 | #endif /*__LINUX_NETFILTER_H*/ |
