sysctl_net_unix.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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/sysctl.h>
  13. #include <net/af_unix.h>
  14. static ctl_table unix_table[] = {
  15. {
  16. .procname = "max_dgram_qlen",
  17. .data = &init_net.unx.sysctl_max_dgram_qlen,
  18. .maxlen = sizeof(int),
  19. .mode = 0644,
  20. .proc_handler = proc_dointvec
  21. },
  22. { }
  23. };
  24. static struct ctl_path unix_path[] = {
  25. { .procname = "net", },
  26. { .procname = "unix", },
  27. { },
  28. };
  29. int __net_init unix_sysctl_register(struct net *net)
  30. {
  31. struct ctl_table *table;
  32. table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
  33. if (table == NULL)
  34. goto err_alloc;
  35. table[0].data = &net->unx.sysctl_max_dgram_qlen;
  36. net->unx.ctl = register_net_sysctl_table(net, unix_path, table);
  37. if (net->unx.ctl == NULL)
  38. goto err_reg;
  39. return 0;
  40. err_reg:
  41. kfree(table);
  42. err_alloc:
  43. return -ENOMEM;
  44. }
  45. void unix_sysctl_unregister(struct net *net)
  46. {
  47. struct ctl_table *table;
  48. table = net->unx.ctl->ctl_table_arg;
  49. unregister_sysctl_table(net->unx.ctl);
  50. kfree(table);
  51. }