xfrm: SA lookups with mark
[linux-2.6.git] / net / xfrm / xfrm_sysctl.c
1 #include <linux/sysctl.h>
2 #include <net/net_namespace.h>
3 #include <net/xfrm.h>
4
5 static void __net_init __xfrm_sysctl_init(struct net *net)
6 {
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
14 static struct ctl_table xfrm_table[] = {
15         {
16                 .procname       = "xfrm_aevent_etime",
17                 .maxlen         = sizeof(u32),
18                 .mode           = 0644,
19                 .proc_handler   = proc_dointvec
20         },
21         {
22                 .procname       = "xfrm_aevent_rseqth",
23                 .maxlen         = sizeof(u32),
24                 .mode           = 0644,
25                 .proc_handler   = proc_dointvec
26         },
27         {
28                 .procname       = "xfrm_larval_drop",
29                 .maxlen         = sizeof(int),
30                 .mode           = 0644,
31                 .proc_handler   = proc_dointvec
32         },
33         {
34                 .procname       = "xfrm_acq_expires",
35                 .maxlen         = sizeof(int),
36                 .mode           = 0644,
37                 .proc_handler   = proc_dointvec
38         },
39         {}
40 };
41
42 int __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
61 out_register:
62         kfree(table);
63 out_kmemdup:
64         return -ENOMEM;
65 }
66
67 void __net_exit xfrm_sysctl_fini(struct net *net)
68 {
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
76 int __net_init xfrm_sysctl_init(struct net *net)
77 {
78         __xfrm_sysctl_init(net);
79         return 0;
80 }
81 #endif