sysctl_net_unix.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * NET4: Sysctl interface to net af_unix subsystem.
  3. *
  4. * Authors: Mike Shaver.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/mm.h>
  12. #include <linux/slab.h>
  13. #include <linux/sysctl.h>
  14. #include <net/af_unix.h>
  15. static ctl_table unix_table[] = {
  16. {
  17. .procname = "max_dgram_qlen",
  18. .data = &init_net.unx.sysctl_max_dgram_qlen,
  19. .maxlen = sizeof(int),
  20. .mode = 0644,
  21. .proc_handler = proc_dointvec
  22. },
  23. { }
  24. };
  25. static struct ctl_path unix_path[] = {
  26. { .procname = "net", },
  27. { .procname = "unix", },
  28. { },
  29. };
  30. int __net_init unix_sysctl_register(struct net *net)
  31. {
  32. struct ctl_table *table;
  33. table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
  34. if (table == NULL)
  35. goto err_alloc;
  36. table[0].data = &net->unx.sysctl_max_dgram_qlen;
  37. net->unx.ctl = register_net_sysctl_table(net, unix_path, table);
  38. if (net->unx.ctl == NULL)
  39. goto err_reg;
  40. return 0;
  41. err_reg:
  42. kfree(table);
  43. err_alloc:
  44. return -ENOMEM;
  45. }
  46. void unix_sysctl_unregister(struct net *net)
  47. {
  48. struct ctl_table *table;
  49. table = net->unx.ctl->ctl_table_arg;
  50. unregister_sysctl_table(net->unx.ctl);
  51. kfree(table);
  52. }