All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] sctp: fix a problem with net_namespace
@ 2014-02-12  1:44 Wang Weidong
  2014-02-12  1:44 ` [PATCH v3 1/2] sctp: fix a missed .data initialization Wang Weidong
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Wang Weidong @ 2014-02-12  1:44 UTC (permalink / raw)
  To: nhorman, davem, vyasevich; +Cc: dborkman, sergei.shtylyov, netdev

fix a problem with net_namespace, and optimize
the sctp_sysctl_net_register.

v2 -> v3:
  -patch2: add empty line after declaration as potined out by Sergei.

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 | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

-- 
1.7.12

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v3 1/2] sctp: fix a missed .data initialization
  2014-02-12  1:44 [PATCH v3 0/2] sctp: fix a problem with net_namespace Wang Weidong
@ 2014-02-12  1:44 ` Wang Weidong
  2014-02-12  1:44 ` [PATCH v3 2/2] sctp: optimize the sctp_sysctl_net_register Wang Weidong
  2014-02-13 22:13 ` [PATCH v3 0/2] sctp: fix a problem with net_namespace David Miller
  2 siblings, 0 replies; 8+ messages in thread
From: Wang Weidong @ 2014-02-12  1:44 UTC (permalink / raw)
  To: nhorman, davem, vyasevich; +Cc: dborkman, sergei.shtylyov, 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 7135e61..d354de5 100644
--- a/net/sctp/sysctl.c
+++ b/net/sctp/sysctl.c
@@ -151,6 +151,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] 8+ messages in thread

* [PATCH v3 2/2] sctp: optimize the sctp_sysctl_net_register
  2014-02-12  1:44 [PATCH v3 0/2] sctp: fix a problem with net_namespace Wang Weidong
  2014-02-12  1:44 ` [PATCH v3 1/2] sctp: fix a missed .data initialization Wang Weidong
@ 2014-02-12  1:44 ` Wang Weidong
  2014-02-12 11:53   ` Neil Horman
  2014-02-13 22:13 ` [PATCH v3 0/2] sctp: fix a problem with net_namespace David Miller
  2 siblings, 1 reply; 8+ messages in thread
From: Wang Weidong @ 2014-02-12  1:44 UTC (permalink / raw)
  To: nhorman, davem, vyasevich; +Cc: dborkman, sergei.shtylyov, 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 | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
index d354de5..35c8923 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;
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2] sctp: optimize the sctp_sysctl_net_register
  2014-02-12  1:44 ` [PATCH v3 2/2] sctp: optimize the sctp_sysctl_net_register Wang Weidong
@ 2014-02-12 11:53   ` Neil Horman
  2014-02-13  1:19     ` Wang Weidong
  0 siblings, 1 reply; 8+ messages in thread
From: Neil Horman @ 2014-02-12 11:53 UTC (permalink / raw)
  To: Wang Weidong; +Cc: davem, vyasevich, dborkman, sergei.shtylyov, netdev

On Wed, Feb 12, 2014 at 09:44:44AM +0800, 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 | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
> index d354de5..35c8923 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;
> +	}
>  
In the first version of this patch you complained about a lockdep issue.  Did
you figure out what that was, and if it related to these changes?

Neil

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2] sctp: optimize the sctp_sysctl_net_register
  2014-02-12 11:53   ` Neil Horman
@ 2014-02-13  1:19     ` Wang Weidong
  2014-02-13 12:44       ` Neil Horman
  0 siblings, 1 reply; 8+ messages in thread
From: Wang Weidong @ 2014-02-13  1:19 UTC (permalink / raw)
  To: Neil Horman; +Cc: davem, vyasevich, dborkman, sergei.shtylyov, netdev

On 2014/2/12 19:53, Neil Horman wrote:
> On Wed, Feb 12, 2014 at 09:44:44AM +0800, 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 | 17 ++++++++++-------
>>  1 file changed, 10 insertions(+), 7 deletions(-)
>>
>> diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
>> index d354de5..35c8923 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;
>> +	}
>>  
> In the first version of this patch you complained about a lockdep issue.  Did
> you figure out what that was, and if it related to these changes?
> 
> Neil
> 
> 
Hi Neil,

The lockdep issue doesn't relate to these changes. I should send it
by the another email. Sorry for confusing you.

Regards
Wang

> .
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2] sctp: optimize the sctp_sysctl_net_register
  2014-02-13  1:19     ` Wang Weidong
@ 2014-02-13 12:44       ` Neil Horman
  2014-02-14  2:18         ` Wang Weidong
  0 siblings, 1 reply; 8+ messages in thread
From: Neil Horman @ 2014-02-13 12:44 UTC (permalink / raw)
  To: Wang Weidong; +Cc: davem, vyasevich, dborkman, sergei.shtylyov, netdev

On Thu, Feb 13, 2014 at 09:19:25AM +0800, Wang Weidong wrote:
> On 2014/2/12 19:53, Neil Horman wrote:
> > On Wed, Feb 12, 2014 at 09:44:44AM +0800, 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 | 17 ++++++++++-------
> >>  1 file changed, 10 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
> >> index d354de5..35c8923 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;
> >> +	}
> >>  
> > In the first version of this patch you complained about a lockdep issue.  Did
> > you figure out what that was, and if it related to these changes?
> > 
> > Neil
> > 
> > 
> Hi Neil,
> 
> The lockdep issue doesn't relate to these changes. I should send it
> by the another email. Sorry for confusing you.
> 
> Regards
> Wang
> 
Then you probably don't need to mention it in the same note that you're
proposing changes.

Acked-by: Neil Horman <nhorman@tuxdriver.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 0/2] sctp: fix a problem with net_namespace
  2014-02-12  1:44 [PATCH v3 0/2] sctp: fix a problem with net_namespace Wang Weidong
  2014-02-12  1:44 ` [PATCH v3 1/2] sctp: fix a missed .data initialization Wang Weidong
  2014-02-12  1:44 ` [PATCH v3 2/2] sctp: optimize the sctp_sysctl_net_register Wang Weidong
@ 2014-02-13 22:13 ` David Miller
  2 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2014-02-13 22:13 UTC (permalink / raw)
  To: wangweidong1; +Cc: nhorman, vyasevich, dborkman, sergei.shtylyov, netdev

From: Wang Weidong <wangweidong1@huawei.com>
Date: Wed, 12 Feb 2014 09:44:42 +0800

> fix a problem with net_namespace, and optimize
> the sctp_sysctl_net_register.
> 
> v2 -> v3:
>   -patch2: add empty line after declaration as potined out by Sergei.
> 
> v1 -> v2:
>   -patch1: add Neil's ACK.
> 
> Wang Weidong (2):
>   sctp: fix a missed .data initialization
>   sctp: optimize the sctp_sysctl_net_register

Series applied, thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2] sctp: optimize the sctp_sysctl_net_register
  2014-02-13 12:44       ` Neil Horman
@ 2014-02-14  2:18         ` Wang Weidong
  0 siblings, 0 replies; 8+ messages in thread
From: Wang Weidong @ 2014-02-14  2:18 UTC (permalink / raw)
  To: Neil Horman; +Cc: davem, vyasevich, dborkman, sergei.shtylyov, netdev

On 2014/2/13 20:44, Neil Horman wrote:
> On Thu, Feb 13, 2014 at 09:19:25AM +0800, Wang Weidong wrote:
>> On 2014/2/12 19:53, Neil Horman wrote:
>>> On Wed, Feb 12, 2014 at 09:44:44AM +0800, 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 | 17 ++++++++++-------
>>>>  1 file changed, 10 insertions(+), 7 deletions(-)
>>>>
>>>> diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
>>>> index d354de5..35c8923 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;
>>>> +	}
>>>>  
>>> In the first version of this patch you complained about a lockdep issue.  Did
>>> you figure out what that was, and if it related to these changes?
>>>
>>> Neil
>>>
>>>
>> Hi Neil,
>>
>> The lockdep issue doesn't relate to these changes. I should send it
>> by the another email. Sorry for confusing you.
>>
>> Regards
>> Wang
>>
> Then you probably don't need to mention it in the same note that you're
> proposing changes.
> 
Ok. Got it!

Thanks
Wang

> Acked-by: Neil Horman <nhorman@tuxdriver.com>
> 
> 
> .
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-02-14  2:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-12  1:44 [PATCH v3 0/2] sctp: fix a problem with net_namespace Wang Weidong
2014-02-12  1:44 ` [PATCH v3 1/2] sctp: fix a missed .data initialization Wang Weidong
2014-02-12  1:44 ` [PATCH v3 2/2] sctp: optimize the sctp_sysctl_net_register Wang Weidong
2014-02-12 11:53   ` Neil Horman
2014-02-13  1:19     ` Wang Weidong
2014-02-13 12:44       ` Neil Horman
2014-02-14  2:18         ` Wang Weidong
2014-02-13 22:13 ` [PATCH v3 0/2] sctp: fix a problem with net_namespace David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.