diff options
author | wangweidong <wangweidong1@huawei.com> | 2014-02-12 09:44:44 +0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-02-13 17:08:29 -0500 |
commit | efb842c45e667332774196bd5a1d539d048159cc (patch) | |
tree | 6b4d1df5479cc9b9fe7c45f65bf4ff7f3a48d06e /net/sctp | |
parent | 22a1f5140ed69baa5906ce9b2b9143478f5a4da0 (diff) | |
download | linux-efb842c45e667332774196bd5a1d539d048159cc.tar.bz2 |
sctp: optimize the sctp_sysctl_net_register
Here, when the net is init_net, we needn't to kmemdup the ctl_table
again. So add a check for net. Also we can save some memory.
Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp')
-rw-r--r-- | net/sctp/sysctl.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c index d354de5a6fe0..35c8923b5554 100644 --- a/net/sctp/sysctl.c +++ b/net/sctp/sysctl.c @@ -402,15 +402,18 @@ static int proc_sctp_do_rto_max(struct ctl_table *ctl, int write, int sctp_sysctl_net_register(struct net *net) { - struct ctl_table *table; - int i; + struct ctl_table *table = sctp_net_table; + + if (!net_eq(net, &init_net)) { + int i; - table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); - if (!table) - return -ENOMEM; + table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL); + if (!table) + return -ENOMEM; - for (i = 0; table[i].data; i++) - table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; + for (i = 0; table[i].data; i++) + table[i].data += (char *)(&net->sctp) - (char *)&init_net.sctp; + } net->sctp.sysctl_header = register_net_sysctl(net, "net/sctp", table); return 0; |