netns xfrm: add netns boilerplate
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c95839693d
commit
d62ddc21b6
|
@ -19,6 +19,7 @@
|
||||||
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
|
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
|
||||||
#include <net/netns/conntrack.h>
|
#include <net/netns/conntrack.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <net/netns/xfrm.h>
|
||||||
|
|
||||||
struct proc_dir_entry;
|
struct proc_dir_entry;
|
||||||
struct net_device;
|
struct net_device;
|
||||||
|
@ -73,6 +74,9 @@ struct net {
|
||||||
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
|
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
|
||||||
struct netns_ct ct;
|
struct netns_ct ct;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifdef CONFIG_XFRM
|
||||||
|
struct netns_xfrm xfrm;
|
||||||
#endif
|
#endif
|
||||||
struct net_generic *gen;
|
struct net_generic *gen;
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef __NETNS_XFRM_H
|
||||||
|
#define __NETNS_XFRM_H
|
||||||
|
|
||||||
|
struct netns_xfrm {
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1269,7 +1269,8 @@ struct xfrm6_tunnel {
|
||||||
|
|
||||||
extern void xfrm_init(void);
|
extern void xfrm_init(void);
|
||||||
extern void xfrm4_init(void);
|
extern void xfrm4_init(void);
|
||||||
extern void xfrm_state_init(void);
|
extern int xfrm_state_init(struct net *net);
|
||||||
|
extern void xfrm_state_fini(struct net *net);
|
||||||
extern void xfrm4_state_init(void);
|
extern void xfrm4_state_init(void);
|
||||||
#ifdef CONFIG_XFRM
|
#ifdef CONFIG_XFRM
|
||||||
extern int xfrm6_init(void);
|
extern int xfrm6_init(void);
|
||||||
|
|
|
@ -2394,12 +2394,13 @@ static int __init xfrm_statistics_init(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void __init xfrm_policy_init(void)
|
static int __net_init xfrm_policy_init(struct net *net)
|
||||||
{
|
{
|
||||||
unsigned int hmask, sz;
|
unsigned int hmask, sz;
|
||||||
int dir;
|
int dir;
|
||||||
|
|
||||||
xfrm_dst_cache = kmem_cache_create("xfrm_dst_cache",
|
if (net_eq(net, &init_net))
|
||||||
|
xfrm_dst_cache = kmem_cache_create("xfrm_dst_cache",
|
||||||
sizeof(struct xfrm_dst),
|
sizeof(struct xfrm_dst),
|
||||||
0, SLAB_HWCACHE_ALIGN|SLAB_PANIC,
|
0, SLAB_HWCACHE_ALIGN|SLAB_PANIC,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -2425,16 +2426,50 @@ static void __init xfrm_policy_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
INIT_LIST_HEAD(&xfrm_policy_all);
|
INIT_LIST_HEAD(&xfrm_policy_all);
|
||||||
register_netdevice_notifier(&xfrm_dev_notifier);
|
if (net_eq(net, &init_net))
|
||||||
|
register_netdevice_notifier(&xfrm_dev_notifier);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void xfrm_policy_fini(struct net *net)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __net_init xfrm_net_init(struct net *net)
|
||||||
|
{
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
rv = xfrm_state_init(net);
|
||||||
|
if (rv < 0)
|
||||||
|
goto out_state;
|
||||||
|
rv = xfrm_policy_init(net);
|
||||||
|
if (rv < 0)
|
||||||
|
goto out_policy;
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
out_policy:
|
||||||
|
xfrm_state_fini(net);
|
||||||
|
out_state:
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __net_exit xfrm_net_exit(struct net *net)
|
||||||
|
{
|
||||||
|
xfrm_policy_fini(net);
|
||||||
|
xfrm_state_fini(net);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct pernet_operations __net_initdata xfrm_net_ops = {
|
||||||
|
.init = xfrm_net_init,
|
||||||
|
.exit = xfrm_net_exit,
|
||||||
|
};
|
||||||
|
|
||||||
void __init xfrm_init(void)
|
void __init xfrm_init(void)
|
||||||
{
|
{
|
||||||
|
register_pernet_subsys(&xfrm_net_ops);
|
||||||
#ifdef CONFIG_XFRM_STATISTICS
|
#ifdef CONFIG_XFRM_STATISTICS
|
||||||
xfrm_statistics_init();
|
xfrm_statistics_init();
|
||||||
#endif
|
#endif
|
||||||
xfrm_state_init();
|
|
||||||
xfrm_policy_init();
|
|
||||||
xfrm_input_init();
|
xfrm_input_init();
|
||||||
#ifdef CONFIG_XFRM_STATISTICS
|
#ifdef CONFIG_XFRM_STATISTICS
|
||||||
xfrm_proc_init();
|
xfrm_proc_init();
|
||||||
|
|
|
@ -2080,7 +2080,7 @@ error:
|
||||||
|
|
||||||
EXPORT_SYMBOL(xfrm_init_state);
|
EXPORT_SYMBOL(xfrm_init_state);
|
||||||
|
|
||||||
void __init xfrm_state_init(void)
|
int __net_init xfrm_state_init(struct net *net)
|
||||||
{
|
{
|
||||||
unsigned int sz;
|
unsigned int sz;
|
||||||
|
|
||||||
|
@ -2094,6 +2094,11 @@ void __init xfrm_state_init(void)
|
||||||
xfrm_state_hmask = ((sz / sizeof(struct hlist_head)) - 1);
|
xfrm_state_hmask = ((sz / sizeof(struct hlist_head)) - 1);
|
||||||
|
|
||||||
INIT_WORK(&xfrm_state_gc_work, xfrm_state_gc_task);
|
INIT_WORK(&xfrm_state_gc_work, xfrm_state_gc_task);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void xfrm_state_fini(struct net *net)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_AUDITSYSCALL
|
#ifdef CONFIG_AUDITSYSCALL
|
||||||
|
|
Loading…
Reference in New Issue