| Alexey Dobriyan | b27aead | 2008-11-25 18:00:48 -0800 | [diff] [blame] | 1 | #include <linux/sysctl.h> | 
|  | 2 | #include <net/net_namespace.h> | 
|  | 3 | #include <net/xfrm.h> | 
|  | 4 |  | 
|  | 5 | static void __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 | .ctl_name	= NET_CORE_AEVENT_ETIME, | 
|  | 17 | .procname	= "xfrm_aevent_etime", | 
|  | 18 | .maxlen		= sizeof(u32), | 
|  | 19 | .mode		= 0644, | 
|  | 20 | .proc_handler	= proc_dointvec | 
|  | 21 | }, | 
|  | 22 | { | 
|  | 23 | .ctl_name	= NET_CORE_AEVENT_RSEQTH, | 
|  | 24 | .procname	= "xfrm_aevent_rseqth", | 
|  | 25 | .maxlen		= sizeof(u32), | 
|  | 26 | .mode		= 0644, | 
|  | 27 | .proc_handler	= proc_dointvec | 
|  | 28 | }, | 
|  | 29 | { | 
|  | 30 | .ctl_name	= CTL_UNNUMBERED, | 
|  | 31 | .procname	= "xfrm_larval_drop", | 
|  | 32 | .maxlen		= sizeof(int), | 
|  | 33 | .mode		= 0644, | 
|  | 34 | .proc_handler	= proc_dointvec | 
|  | 35 | }, | 
|  | 36 | { | 
|  | 37 | .ctl_name	= CTL_UNNUMBERED, | 
|  | 38 | .procname	= "xfrm_acq_expires", | 
|  | 39 | .maxlen		= sizeof(int), | 
|  | 40 | .mode		= 0644, | 
|  | 41 | .proc_handler	= proc_dointvec | 
|  | 42 | }, | 
|  | 43 | {} | 
|  | 44 | }; | 
|  | 45 |  | 
|  | 46 | int __net_init xfrm_sysctl_init(struct net *net) | 
|  | 47 | { | 
|  | 48 | struct ctl_table *table; | 
|  | 49 |  | 
|  | 50 | __xfrm_sysctl_init(net); | 
|  | 51 |  | 
|  | 52 | table = kmemdup(xfrm_table, sizeof(xfrm_table), GFP_KERNEL); | 
|  | 53 | if (!table) | 
|  | 54 | goto out_kmemdup; | 
|  | 55 | table[0].data = &net->xfrm.sysctl_aevent_etime; | 
|  | 56 | table[1].data = &net->xfrm.sysctl_aevent_rseqth; | 
|  | 57 | table[2].data = &net->xfrm.sysctl_larval_drop; | 
|  | 58 | table[3].data = &net->xfrm.sysctl_acq_expires; | 
|  | 59 |  | 
|  | 60 | net->xfrm.sysctl_hdr = register_net_sysctl_table(net, net_core_path, table); | 
|  | 61 | if (!net->xfrm.sysctl_hdr) | 
|  | 62 | goto out_register; | 
|  | 63 | return 0; | 
|  | 64 |  | 
|  | 65 | out_register: | 
|  | 66 | kfree(table); | 
|  | 67 | out_kmemdup: | 
|  | 68 | return -ENOMEM; | 
|  | 69 | } | 
|  | 70 |  | 
|  | 71 | void xfrm_sysctl_fini(struct net *net) | 
|  | 72 | { | 
|  | 73 | struct ctl_table *table; | 
|  | 74 |  | 
|  | 75 | table = net->xfrm.sysctl_hdr->ctl_table_arg; | 
|  | 76 | unregister_net_sysctl_table(net->xfrm.sysctl_hdr); | 
|  | 77 | kfree(table); | 
|  | 78 | } | 
|  | 79 | #else | 
|  | 80 | int __net_init xfrm_sysctl_init(struct net *net) | 
|  | 81 | { | 
|  | 82 | __xfrm_sysctl_init(net); | 
|  | 83 | return 0; | 
|  | 84 | } | 
|  | 85 | #endif |