blob: 2c4d6cdcba492cd2f70ac32a3e71b5b0abd17691 [file] [log] [blame]
Alexey Dobriyanb27aead2008-11-25 18:00:48 -08001#include <linux/sysctl.h>
2#include <net/net_namespace.h>
3#include <net/xfrm.h>
4
Alexey Dobriyan2c8c1e72010-01-17 03:35:32 +00005static void __net_init __xfrm_sysctl_init(struct net *net)
Alexey Dobriyanb27aead2008-11-25 18:00:48 -08006{
7 net->xfrm.sysctl_aevent_etime = XFRM_AE_ETIME;
8 net->xfrm.sysctl_aevent_rseqth = XFRM_AE_SEQT_SIZE;
9 net->xfrm.sysctl_larval_drop = 1;
10 net->xfrm.sysctl_acq_expires = 30;
11}
12
13#ifdef CONFIG_SYSCTL
14static struct ctl_table xfrm_table[] = {
15 {
Alexey Dobriyanb27aead2008-11-25 18:00:48 -080016 .procname = "xfrm_aevent_etime",
17 .maxlen = sizeof(u32),
18 .mode = 0644,
19 .proc_handler = proc_dointvec
20 },
21 {
Alexey Dobriyanb27aead2008-11-25 18:00:48 -080022 .procname = "xfrm_aevent_rseqth",
23 .maxlen = sizeof(u32),
24 .mode = 0644,
25 .proc_handler = proc_dointvec
26 },
27 {
Alexey Dobriyanb27aead2008-11-25 18:00:48 -080028 .procname = "xfrm_larval_drop",
29 .maxlen = sizeof(int),
30 .mode = 0644,
31 .proc_handler = proc_dointvec
32 },
33 {
Alexey Dobriyanb27aead2008-11-25 18:00:48 -080034 .procname = "xfrm_acq_expires",
35 .maxlen = sizeof(int),
36 .mode = 0644,
37 .proc_handler = proc_dointvec
38 },
39 {}
40};
41
42int __net_init xfrm_sysctl_init(struct net *net)
43{
44 struct ctl_table *table;
45
46 __xfrm_sysctl_init(net);
47
48 table = kmemdup(xfrm_table, sizeof(xfrm_table), GFP_KERNEL);
49 if (!table)
50 goto out_kmemdup;
51 table[0].data = &net->xfrm.sysctl_aevent_etime;
52 table[1].data = &net->xfrm.sysctl_aevent_rseqth;
53 table[2].data = &net->xfrm.sysctl_larval_drop;
54 table[3].data = &net->xfrm.sysctl_acq_expires;
55
56 net->xfrm.sysctl_hdr = register_net_sysctl_table(net, net_core_path, table);
57 if (!net->xfrm.sysctl_hdr)
58 goto out_register;
59 return 0;
60
61out_register:
62 kfree(table);
63out_kmemdup:
64 return -ENOMEM;
65}
66
Alexey Dobriyan2c8c1e72010-01-17 03:35:32 +000067void __net_exit xfrm_sysctl_fini(struct net *net)
Alexey Dobriyanb27aead2008-11-25 18:00:48 -080068{
69 struct ctl_table *table;
70
71 table = net->xfrm.sysctl_hdr->ctl_table_arg;
72 unregister_net_sysctl_table(net->xfrm.sysctl_hdr);
73 kfree(table);
74}
75#else
76int __net_init xfrm_sysctl_init(struct net *net)
77{
78 __xfrm_sysctl_init(net);
79 return 0;
80}
81#endif