0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <linux/init.h>
0014 #include <linux/sysctl.h>
0015 #include <net/net_namespace.h>
0016
0017 #include "smc.h"
0018 #include "smc_core.h"
0019 #include "smc_sysctl.h"
0020
0021 static struct ctl_table smc_table[] = {
0022 {
0023 .procname = "autocorking_size",
0024 .data = &init_net.smc.sysctl_autocorking_size,
0025 .maxlen = sizeof(unsigned int),
0026 .mode = 0644,
0027 .proc_handler = proc_douintvec,
0028 },
0029 {
0030 .procname = "smcr_buf_type",
0031 .data = &init_net.smc.sysctl_smcr_buf_type,
0032 .maxlen = sizeof(unsigned int),
0033 .mode = 0644,
0034 .proc_handler = proc_douintvec_minmax,
0035 .extra1 = SYSCTL_ZERO,
0036 .extra2 = SYSCTL_TWO,
0037 },
0038 { }
0039 };
0040
0041 int __net_init smc_sysctl_net_init(struct net *net)
0042 {
0043 struct ctl_table *table;
0044
0045 table = smc_table;
0046 if (!net_eq(net, &init_net)) {
0047 int i;
0048
0049 table = kmemdup(table, sizeof(smc_table), GFP_KERNEL);
0050 if (!table)
0051 goto err_alloc;
0052
0053 for (i = 0; i < ARRAY_SIZE(smc_table) - 1; i++)
0054 table[i].data += (void *)net - (void *)&init_net;
0055 }
0056
0057 net->smc.smc_hdr = register_net_sysctl(net, "net/smc", table);
0058 if (!net->smc.smc_hdr)
0059 goto err_reg;
0060
0061 net->smc.sysctl_autocorking_size = SMC_AUTOCORKING_DEFAULT_SIZE;
0062 net->smc.sysctl_smcr_buf_type = SMCR_PHYS_CONT_BUFS;
0063
0064 return 0;
0065
0066 err_reg:
0067 if (!net_eq(net, &init_net))
0068 kfree(table);
0069 err_alloc:
0070 return -ENOMEM;
0071 }
0072
0073 void __net_exit smc_sysctl_net_exit(struct net *net)
0074 {
0075 struct ctl_table *table;
0076
0077 table = net->smc.smc_hdr->ctl_table_arg;
0078 unregister_net_sysctl_table(net->smc.smc_hdr);
0079 if (!net_eq(net, &init_net))
0080 kfree(table);
0081 }