Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit efb842c4 authored by wangweidong's avatar wangweidong Committed by David S. Miller
Browse files

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: default avatarWang Weidong <wangweidong1@huawei.com>
Acked-by: default avatarNeil Horman <nhorman@tuxdriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 22a1f514
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -402,7 +402,9 @@ 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;
	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);
@@ -411,6 +413,7 @@ int sctp_sysctl_net_register(struct net *net)

		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;