xfrm_sysctl.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #include <linux/sysctl.h>
  2. #include <linux/slab.h>
  3. #include <net/net_namespace.h>
  4. #include <net/xfrm.h>
  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. #ifdef CONFIG_SYSCTL
  13. static struct ctl_table xfrm_table[] = {
  14. {
  15. .procname = "xfrm_aevent_etime",
  16. .maxlen = sizeof(u32),
  17. .mode = 0644,
  18. .proc_handler = proc_dointvec
  19. },
  20. {
  21. .procname = "xfrm_aevent_rseqth",
  22. .maxlen = sizeof(u32),
  23. .mode = 0644,
  24. .proc_handler = proc_dointvec
  25. },
  26. {
  27. .procname = "xfrm_larval_drop",
  28. .maxlen = sizeof(int),
  29. .mode = 0644,
  30. .proc_handler = proc_dointvec
  31. },
  32. {
  33. .procname = "xfrm_acq_expires",
  34. .maxlen = sizeof(int),
  35. .mode = 0644,
  36. .proc_handler = proc_dointvec
  37. },
  38. {}
  39. };
  40. int __net_init xfrm_sysctl_init(struct net *net)
  41. {
  42. struct ctl_table *table;
  43. __xfrm_sysctl_init(net);
  44. table = kmemdup(xfrm_table, sizeof(xfrm_table), GFP_KERNEL);
  45. if (!table)
  46. goto out_kmemdup;
  47. table[0].data = &net->xfrm.sysctl_aevent_etime;
  48. table[1].data = &net->xfrm.sysctl_aevent_rseqth;
  49. table[2].data = &net->xfrm.sysctl_larval_drop;
  50. table[3].data = &net->xfrm.sysctl_acq_expires;
  51. net->xfrm.sysctl_hdr = register_net_sysctl(net, "net/core", table);
  52. if (!net->xfrm.sysctl_hdr)
  53. goto out_register;
  54. return 0;
  55. out_register:
  56. kfree(table);
  57. out_kmemdup:
  58. return -ENOMEM;
  59. }
  60. void __net_exit xfrm_sysctl_fini(struct net *net)
  61. {
  62. struct ctl_table *table;
  63. table = net->xfrm.sysctl_hdr->ctl_table_arg;
  64. unregister_net_sysctl_table(net->xfrm.sysctl_hdr);
  65. kfree(table);
  66. }
  67. #else
  68. int __net_init xfrm_sysctl_init(struct net *net)
  69. {
  70. __xfrm_sysctl_init(net);
  71. return 0;
  72. }
  73. #endif