0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/mm.h>
0009 #include <linux/slab.h>
0010 #include <linux/sysctl.h>
0011
0012 #include <net/af_unix.h>
0013
0014 static struct ctl_table unix_table[] = {
0015 {
0016 .procname = "max_dgram_qlen",
0017 .data = &init_net.unx.sysctl_max_dgram_qlen,
0018 .maxlen = sizeof(int),
0019 .mode = 0644,
0020 .proc_handler = proc_dointvec
0021 },
0022 { }
0023 };
0024
0025 int __net_init unix_sysctl_register(struct net *net)
0026 {
0027 struct ctl_table *table;
0028
0029 if (net_eq(net, &init_net)) {
0030 table = unix_table;
0031 } else {
0032 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
0033 if (!table)
0034 goto err_alloc;
0035
0036 table[0].data = &net->unx.sysctl_max_dgram_qlen;
0037 }
0038
0039 net->unx.ctl = register_net_sysctl(net, "net/unix", table);
0040 if (net->unx.ctl == NULL)
0041 goto err_reg;
0042
0043 return 0;
0044
0045 err_reg:
0046 if (!net_eq(net, &init_net))
0047 kfree(table);
0048 err_alloc:
0049 return -ENOMEM;
0050 }
0051
0052 void unix_sysctl_unregister(struct net *net)
0053 {
0054 struct ctl_table *table;
0055
0056 table = net->unx.ctl->ctl_table_arg;
0057 unregister_net_sysctl_table(net->unx.ctl);
0058 if (!net_eq(net, &init_net))
0059 kfree(table);
0060 }