* [PATCH v2 0/2] sctp: fix a problem with net_namespace
@ 2014-02-11 1:49 Wang Weidong
2014-02-11 1:49 ` [PATCH v2 1/2] sctp: fix a missed .data initialization Wang Weidong
2014-02-11 1:49 ` [PATCH v2 2/2] sctp: optimize the sctp_sysctl_net_register Wang Weidong
0 siblings, 2 replies; 5+ messages in thread
From: Wang Weidong @ 2014-02-11 1:49 UTC (permalink / raw)
To: nhorman, davem, vyasevich; +Cc: dborkman, netdev
fix a problem with net_namespace, and optimize
the sctp_sysctl_net_register.
v1 -> v2:
-patch1: add Neil's ACK.
Wang Weidong (2):
sctp: fix a missed .data initialization
sctp: optimize the sctp_sysctl_net_register
net/sctp/sysctl.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
--
1.7.12
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] sctp: fix a missed .data initialization
2014-02-11 1:49 [PATCH v2 0/2] sctp: fix a problem with net_namespace Wang Weidong
@ 2014-02-11 1:49 ` Wang Weidong
2014-02-11 1:49 ` [PATCH v2 2/2] sctp: optimize the sctp_sysctl_net_register Wang Weidong
1 sibling, 0 replies; 5+ messages in thread
From: Wang Weidong @ 2014-02-11 1:49 UTC (permalink / raw)
To: nhorman, davem, vyasevich; +Cc: dborkman, netdev
As commit 3c68198e75111a90("sctp: Make hmac algorithm selection for
cookie generation dynamic"), we miss the .data initialization.
If we don't use the net_namespace, the problem that parts of the
sysctl configuration won't be isolation and won't occur.
In sctp_sysctl_net_register(), we register the sysctl for each
net, in the for(), we use the 'table[i].data' as check condition, so
when the 'i' is the index of sctp_hmac_alg, the data is NULL, then
break. So add the .data initialization.
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Wang Weidong <wangweidong1@huawei.com>
---
net/sctp/sysctl.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index b0565af..2ddb401 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -152,6 +152,7 @@ static struct ctl_table sctp_net_table[] = {
},
{
.procname = "cookie_hmac_alg",
+ .data = &init_net.sctp.sctp_hmac_alg,
.maxlen = 8,
.mode = 0644,
.proc_handler = proc_sctp_do_hmac_alg,
--
1.7.12
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] sctp: optimize the sctp_sysctl_net_register
2014-02-11 1:49 [PATCH v2 0/2] sctp: fix a problem with net_namespace Wang Weidong
2014-02-11 1:49 ` [PATCH v2 1/2] sctp: fix a missed .data initialization Wang Weidong
@ 2014-02-11 1:49 ` Wang Weidong
2014-02-11 16:47 ` Sergei Shtylyov
1 sibling, 1 reply; 5+ messages in thread
From: Wang Weidong @ 2014-02-11 1:49 UTC (permalink / raw)
To: nhorman, davem, vyasevich; +Cc: dborkman, netdev
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>
---
net/sctp/sysctl.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index 2ddb401..b65396b 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -403,15 +403,17 @@ 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;
- table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
- if (!table)
- return -ENOMEM;
+ if (!net_eq(net, &init_net)) {
+ int i;
+ 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;
--
1.7.12
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] sctp: optimize the sctp_sysctl_net_register
2014-02-11 1:49 ` [PATCH v2 2/2] sctp: optimize the sctp_sysctl_net_register Wang Weidong
@ 2014-02-11 16:47 ` Sergei Shtylyov
2014-02-12 1:21 ` Wang Weidong
0 siblings, 1 reply; 5+ messages in thread
From: Sergei Shtylyov @ 2014-02-11 16:47 UTC (permalink / raw)
To: Wang Weidong, nhorman, davem, vyasevich; +Cc: dborkman, netdev
Hello.
On 02/11/2014 04:49 AM, Wang Weidong wrote:
> 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>
> ---
> net/sctp/sysctl.c | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
> diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
> index 2ddb401..b65396b 100644
> --- a/net/sctp/sysctl.c
> +++ b/net/sctp/sysctl.c
> @@ -403,15 +403,17 @@ 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;
>
> - table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
> - if (!table)
> - return -ENOMEM;
> + if (!net_eq(net, &init_net)) {
> + int i;
Empty line after declaration wouldn't hurt, just like above.
> + table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
> + if (!table)
> + return -ENOMEM;
WBR, Sergei
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/2] sctp: optimize the sctp_sysctl_net_register
2014-02-11 16:47 ` Sergei Shtylyov
@ 2014-02-12 1:21 ` Wang Weidong
0 siblings, 0 replies; 5+ messages in thread
From: Wang Weidong @ 2014-02-12 1:21 UTC (permalink / raw)
To: Sergei Shtylyov, nhorman, davem, vyasevich; +Cc: dborkman, netdev
On 2014/2/12 0:47, Sergei Shtylyov wrote:
> Hello.
>
> On 02/11/2014 04:49 AM, Wang Weidong wrote:
>
>> 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>
>> ---
>> net/sctp/sysctl.c | 16 +++++++++-------
>> 1 file changed, 9 insertions(+), 7 deletions(-)
>
>> diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
>> index 2ddb401..b65396b 100644
>> --- a/net/sctp/sysctl.c
>> +++ b/net/sctp/sysctl.c
>> @@ -403,15 +403,17 @@ 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;
>>
>> - table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
>> - if (!table)
>> - return -ENOMEM;
>> + if (!net_eq(net, &init_net)) {
>> + int i;
>
> Empty line after declaration wouldn't hurt, just like above.
>
Yeah. I will change it soon.
Thanks
Wang
>> + table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
>> + if (!table)
>> + return -ENOMEM;
>
> WBR, Sergei
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-02-12 1:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-11 1:49 [PATCH v2 0/2] sctp: fix a problem with net_namespace Wang Weidong
2014-02-11 1:49 ` [PATCH v2 1/2] sctp: fix a missed .data initialization Wang Weidong
2014-02-11 1:49 ` [PATCH v2 2/2] sctp: optimize the sctp_sysctl_net_register Wang Weidong
2014-02-11 16:47 ` Sergei Shtylyov
2014-02-12 1:21 ` Wang Weidong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).