blob: 05a6e3d9c258c0815e870db6660fda8e4802d31f [file] [log] [blame]
Alexey Dobriyanb27aead2008-11-25 18:00:48 -08001#include <linux/sysctl.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +09002#include <linux/slab.h>
Alexey Dobriyanb27aead2008-11-25 18:00:48 -08003#include <net/net_namespace.h>
4#include <net/xfrm.h>
5
Alexey Dobriyan2c8c1e72010-01-17 03:35:32 +00006static void __net_init __xfrm_sysctl_init(struct net *net)
Alexey Dobriyanb27aead2008-11-25 18:00:48 -08007{
8 net->xfrm.sysctl_aevent_etime = XFRM_AE_ETIME;
9 net->xfrm.sysctl_aevent_rseqth = XFRM_AE_SEQT_SIZE;
10 net->xfrm.sysctl_larval_drop = 1;
11 net->xfrm.sysctl_acq_expires = 30;
12}
13
14#ifdef CONFIG_SYSCTL
15static struct ctl_table xfrm_table[] = {
16 {
Alexey Dobriyanb27aead2008-11-25 18:00:48 -080017 .procname = "xfrm_aevent_etime",
18 .maxlen = sizeof(u32),
19 .mode = 0644,
20 .proc_handler = proc_dointvec
21 },
22 {
Alexey Dobriyanb27aead2008-11-25 18:00:48 -080023 .procname = "xfrm_aevent_rseqth",
24 .maxlen = sizeof(u32),
25 .mode = 0644,
26 .proc_handler = proc_dointvec
27 },
28 {
Alexey Dobriyanb27aead2008-11-25 18:00:48 -080029 .procname = "xfrm_larval_drop",
30 .maxlen = sizeof(int),
31 .mode = 0644,
32 .proc_handler = proc_dointvec
33 },
34 {
Alexey Dobriyanb27aead2008-11-25 18:00:48 -080035 .procname = "xfrm_acq_expires",
36 .maxlen = sizeof(int),
37 .mode = 0644,
38 .proc_handler = proc_dointvec
39 },
40 {}
41};
42
43int __net_init xfrm_sysctl_init(struct net *net)
44{
45 struct ctl_table *table;
46
47 __xfrm_sysctl_init(net);
48
49 table = kmemdup(xfrm_table, sizeof(xfrm_table), GFP_KERNEL);
50 if (!table)
51 goto out_kmemdup;
52 table[0].data = &net->xfrm.sysctl_aevent_etime;
53 table[1].data = &net->xfrm.sysctl_aevent_rseqth;
54 table[2].data = &net->xfrm.sysctl_larval_drop;
55 table[3].data = &net->xfrm.sysctl_acq_expires;
56
Eric W. Biederman464dc802012-11-16 03:02:59 +000057 /* Don't export sysctls to unprivileged users */
58 if (net->user_ns != &init_user_ns)
59 table[0].procname = NULL;
60
Eric W. Biedermanec8f23c2012-04-19 13:44:49 +000061 net->xfrm.sysctl_hdr = register_net_sysctl(net, "net/core", table);
Alexey Dobriyanb27aead2008-11-25 18:00:48 -080062 if (!net->xfrm.sysctl_hdr)
63 goto out_register;
64 return 0;
65
66out_register:
67 kfree(table);
68out_kmemdup:
69 return -ENOMEM;
70}
71
Alexey Dobriyan2c8c1e72010-01-17 03:35:32 +000072void __net_exit xfrm_sysctl_fini(struct net *net)
Alexey Dobriyanb27aead2008-11-25 18:00:48 -080073{
74 struct ctl_table *table;
75
76 table = net->xfrm.sysctl_hdr->ctl_table_arg;
77 unregister_net_sysctl_table(net->xfrm.sysctl_hdr);
78 kfree(table);
79}
80#else
81int __net_init xfrm_sysctl_init(struct net *net)
82{
83 __xfrm_sysctl_init(net);
84 return 0;
85}
86#endif