netfilter: netns nf_conntrack: add netns boilerplate
One comment: #ifdefs around #include is necessary to overcome amazing compile breakages in NOTRACK-in-netns patch (see below). Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: Patrick McHardy <kaber@trash.net>
This commit is contained in:
parent
e10aad9998
commit
dfdb8d7918
@ -16,6 +16,9 @@
|
|||||||
#include <net/netns/ipv6.h>
|
#include <net/netns/ipv6.h>
|
||||||
#include <net/netns/dccp.h>
|
#include <net/netns/dccp.h>
|
||||||
#include <net/netns/x_tables.h>
|
#include <net/netns/x_tables.h>
|
||||||
|
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
|
||||||
|
#include <net/netns/conntrack.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
struct proc_dir_entry;
|
struct proc_dir_entry;
|
||||||
struct net_device;
|
struct net_device;
|
||||||
@ -67,6 +70,9 @@ struct net {
|
|||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_NETFILTER
|
#ifdef CONFIG_NETFILTER
|
||||||
struct netns_xt xt;
|
struct netns_xt xt;
|
||||||
|
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
|
||||||
|
struct netns_ct ct;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
struct net_generic *gen;
|
struct net_generic *gen;
|
||||||
};
|
};
|
||||||
|
@ -24,8 +24,8 @@ extern unsigned int nf_conntrack_in(u_int8_t pf,
|
|||||||
unsigned int hooknum,
|
unsigned int hooknum,
|
||||||
struct sk_buff *skb);
|
struct sk_buff *skb);
|
||||||
|
|
||||||
extern int nf_conntrack_init(void);
|
extern int nf_conntrack_init(struct net *net);
|
||||||
extern void nf_conntrack_cleanup(void);
|
extern void nf_conntrack_cleanup(struct net *net);
|
||||||
|
|
||||||
extern int nf_conntrack_proto_init(void);
|
extern int nf_conntrack_proto_init(void);
|
||||||
extern void nf_conntrack_proto_fini(void);
|
extern void nf_conntrack_proto_fini(void);
|
||||||
|
6
include/net/netns/conntrack.h
Normal file
6
include/net/netns/conntrack.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef __NETNS_CONNTRACK_H
|
||||||
|
#define __NETNS_CONNTRACK_H
|
||||||
|
|
||||||
|
struct netns_ct {
|
||||||
|
};
|
||||||
|
#endif
|
@ -1006,7 +1006,7 @@ EXPORT_SYMBOL_GPL(nf_conntrack_flush);
|
|||||||
|
|
||||||
/* Mishearing the voices in his head, our hero wonders how he's
|
/* Mishearing the voices in his head, our hero wonders how he's
|
||||||
supposed to kill the mall. */
|
supposed to kill the mall. */
|
||||||
void nf_conntrack_cleanup(void)
|
void nf_conntrack_cleanup(struct net *net)
|
||||||
{
|
{
|
||||||
rcu_assign_pointer(ip_ct_attach, NULL);
|
rcu_assign_pointer(ip_ct_attach, NULL);
|
||||||
|
|
||||||
@ -1120,7 +1120,7 @@ EXPORT_SYMBOL_GPL(nf_conntrack_set_hashsize);
|
|||||||
module_param_call(hashsize, nf_conntrack_set_hashsize, param_get_uint,
|
module_param_call(hashsize, nf_conntrack_set_hashsize, param_get_uint,
|
||||||
&nf_conntrack_htable_size, 0600);
|
&nf_conntrack_htable_size, 0600);
|
||||||
|
|
||||||
int __init nf_conntrack_init(void)
|
int nf_conntrack_init(struct net *net)
|
||||||
{
|
{
|
||||||
int max_factor = 8;
|
int max_factor = 8;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -537,7 +537,7 @@ static const struct file_operations exp_file_ops = {
|
|||||||
};
|
};
|
||||||
#endif /* CONFIG_PROC_FS */
|
#endif /* CONFIG_PROC_FS */
|
||||||
|
|
||||||
static int __init exp_proc_init(void)
|
static int exp_proc_init(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_PROC_FS
|
#ifdef CONFIG_PROC_FS
|
||||||
struct proc_dir_entry *proc;
|
struct proc_dir_entry *proc;
|
||||||
@ -558,7 +558,7 @@ static void exp_proc_remove(void)
|
|||||||
|
|
||||||
module_param_named(expect_hashsize, nf_ct_expect_hsize, uint, 0600);
|
module_param_named(expect_hashsize, nf_ct_expect_hsize, uint, 0600);
|
||||||
|
|
||||||
int __init nf_conntrack_expect_init(void)
|
int nf_conntrack_expect_init(void)
|
||||||
{
|
{
|
||||||
int err = -ENOMEM;
|
int err = -ENOMEM;
|
||||||
|
|
||||||
|
@ -440,11 +440,26 @@ static void nf_conntrack_standalone_fini_sysctl(void)
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_SYSCTL */
|
#endif /* CONFIG_SYSCTL */
|
||||||
|
|
||||||
|
static int nf_conntrack_net_init(struct net *net)
|
||||||
|
{
|
||||||
|
return nf_conntrack_init(net);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void nf_conntrack_net_exit(struct net *net)
|
||||||
|
{
|
||||||
|
nf_conntrack_cleanup(net);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct pernet_operations nf_conntrack_net_ops = {
|
||||||
|
.init = nf_conntrack_net_init,
|
||||||
|
.exit = nf_conntrack_net_exit,
|
||||||
|
};
|
||||||
|
|
||||||
static int __init nf_conntrack_standalone_init(void)
|
static int __init nf_conntrack_standalone_init(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = nf_conntrack_init();
|
ret = register_pernet_subsys(&nf_conntrack_net_ops);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out;
|
goto out;
|
||||||
ret = nf_conntrack_standalone_init_proc();
|
ret = nf_conntrack_standalone_init_proc();
|
||||||
@ -458,7 +473,7 @@ static int __init nf_conntrack_standalone_init(void)
|
|||||||
out_sysctl:
|
out_sysctl:
|
||||||
nf_conntrack_standalone_fini_proc();
|
nf_conntrack_standalone_fini_proc();
|
||||||
out_proc:
|
out_proc:
|
||||||
nf_conntrack_cleanup();
|
unregister_pernet_subsys(&nf_conntrack_net_ops);
|
||||||
out:
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -467,7 +482,7 @@ static void __exit nf_conntrack_standalone_fini(void)
|
|||||||
{
|
{
|
||||||
nf_conntrack_standalone_fini_sysctl();
|
nf_conntrack_standalone_fini_sysctl();
|
||||||
nf_conntrack_standalone_fini_proc();
|
nf_conntrack_standalone_fini_proc();
|
||||||
nf_conntrack_cleanup();
|
unregister_pernet_subsys(&nf_conntrack_net_ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(nf_conntrack_standalone_init);
|
module_init(nf_conntrack_standalone_init);
|
||||||
|
Loading…
Reference in New Issue
Block a user