netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net:sysctl fix the confusing corner of tcp_mem
@ 2015-12-09  2:01 Wang Yufen
  2015-12-09 13:47 ` Sergei Shtylyov
  2015-12-09 16:38 ` Eric W. Biederman
  0 siblings, 2 replies; 4+ messages in thread
From: Wang Yufen @ 2015-12-09  2:01 UTC (permalink / raw)
  To: davem, netdev
  Cc: guohanjun, zhangdianfang, dingtianhong, huxinwei, Yufen Wang,
	Eric Dumazet, Eric W. Biederman

From: Yufen Wang <wangyufen@huawei.com>

I tried on linux-4.1:
    linux:~# cat /proc/sys/net/ipv4/tcp_mem 
    8388608	12582912	16777216
    linux:~# echo 1234 >/proc/sys/net/ipv4/tcp_mem 
    -bash: echo: write error: Invalid argument
    linux:~# cat /proc/sys/net/ipv4/tcp_mem 
    1234	12582912	16777216

the echo operation got error, but value already written to tcp_mem.
If a write() returns an error like EINVAL, we expect no change occurred.
This patch fix the confusing corner and makes __do_proc_doulongvec_minmax 
works the same as __do_proc_dointvec

Signed-off-by: Yufen Wang <wangyufen@huawei.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
---
 kernel/sysctl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index c3eee4c..e3ee4be 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2318,6 +2318,8 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
 			bool neg;
 
 			left -= proc_skip_spaces(&kbuf);
+                        if (!left)
+                                break;
 
 			err = proc_get_long(&kbuf, &left, &val, &neg,
 					     proc_wspace_sep,
-- 
2.5.0

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

* Re: [PATCH net] net:sysctl fix the confusing corner of tcp_mem
  2015-12-09  2:01 [PATCH net] net:sysctl fix the confusing corner of tcp_mem Wang Yufen
@ 2015-12-09 13:47 ` Sergei Shtylyov
  2015-12-09 16:38 ` Eric W. Biederman
  1 sibling, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2015-12-09 13:47 UTC (permalink / raw)
  To: Wang Yufen, davem, netdev
  Cc: guohanjun, zhangdianfang, dingtianhong, huxinwei, Eric Dumazet,
	Eric W. Biederman

Hello.

On 12/9/2015 5:01 AM, Wang Yufen wrote:

> From: Yufen Wang <wangyufen@huawei.com>
>
> I tried on linux-4.1:
>      linux:~# cat /proc/sys/net/ipv4/tcp_mem
>      8388608	12582912	16777216
>      linux:~# echo 1234 >/proc/sys/net/ipv4/tcp_mem
>      -bash: echo: write error: Invalid argument
>      linux:~# cat /proc/sys/net/ipv4/tcp_mem
>      1234	12582912	16777216
>
> the echo operation got error, but value already written to tcp_mem.
> If a write() returns an error like EINVAL, we expect no change occurred.
> This patch fix the confusing corner and makes __do_proc_doulongvec_minmax
> works the same as __do_proc_dointvec
>
> Signed-off-by: Yufen Wang <wangyufen@huawei.com>
> Cc: Eric Dumazet <eric.dumazet@gmail.com>
> Cc: "Eric W. Biederman" <ebiederm@xmission.com>
> ---
>   kernel/sysctl.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index c3eee4c..e3ee4be 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -2318,6 +2318,8 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
>   			bool neg;
>
>   			left -= proc_skip_spaces(&kbuf);
> +                        if (!left)
> +                                break;

     Please use tabs for indentation, not spaces.

[...]

MBR, Sergei

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

* Re: [PATCH net] net:sysctl fix the confusing corner of tcp_mem
  2015-12-09  2:01 [PATCH net] net:sysctl fix the confusing corner of tcp_mem Wang Yufen
  2015-12-09 13:47 ` Sergei Shtylyov
@ 2015-12-09 16:38 ` Eric W. Biederman
  2015-12-21  1:02   ` Hanjun Guo
  1 sibling, 1 reply; 4+ messages in thread
From: Eric W. Biederman @ 2015-12-09 16:38 UTC (permalink / raw)
  To: Wang Yufen
  Cc: davem, netdev, guohanjun, zhangdianfang, dingtianhong, huxinwei,
	Eric Dumazet

Wang Yufen <wangyufen@huawei.com> writes:

> From: Yufen Wang <wangyufen@huawei.com>
>
> I tried on linux-4.1:
>     linux:~# cat /proc/sys/net/ipv4/tcp_mem 
>     8388608	12582912	16777216
>     linux:~# echo 1234 >/proc/sys/net/ipv4/tcp_mem 
>     -bash: echo: write error: Invalid argument
>     linux:~# cat /proc/sys/net/ipv4/tcp_mem 
>     1234	12582912	16777216
>
> the echo operation got error, but value already written to tcp_mem.
> If a write() returns an error like EINVAL, we expect no change occurred.
> This patch fix the confusing corner and makes __do_proc_doulongvec_minmax 
> works the same as __do_proc_dointvec

Nacked-by: "Eric W. Biederman" <ebiederm@xmission.com>

Except for possibly breaking your muscle memory this does not explain
why this is a problem.

Further you are changing a whole lot more than tcp_mem, without a word
of justification in your description.

I do not think changing every integer use of sysctl for some unknown
reason.  Is justified in this case.

Eric



> Signed-off-by: Yufen Wang <wangyufen@huawei.com>
> Cc: Eric Dumazet <eric.dumazet@gmail.com>
> Cc: "Eric W. Biederman" <ebiederm@xmission.com>
> ---
>  kernel/sysctl.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index c3eee4c..e3ee4be 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -2318,6 +2318,8 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
>  			bool neg;
>  
>  			left -= proc_skip_spaces(&kbuf);
> +                        if (!left)
> +                                break;
>  
>  			err = proc_get_long(&kbuf, &left, &val, &neg,
>  					     proc_wspace_sep,

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

* Re: [PATCH net] net:sysctl fix the confusing corner of tcp_mem
  2015-12-09 16:38 ` Eric W. Biederman
@ 2015-12-21  1:02   ` Hanjun Guo
  0 siblings, 0 replies; 4+ messages in thread
From: Hanjun Guo @ 2015-12-21  1:02 UTC (permalink / raw)
  To: Eric W. Biederman, Wang Yufen
  Cc: davem, netdev, zhangdianfang, dingtianhong, huxinwei, Eric Dumazet

Hi Eric,

On 2015/12/10 0:38, Eric W. Biederman wrote:
> Wang Yufen <wangyufen@huawei.com> writes:
>
>> From: Yufen Wang <wangyufen@huawei.com>
>>
>> I tried on linux-4.1:
>>     linux:~# cat /proc/sys/net/ipv4/tcp_mem 
>>     8388608	12582912	16777216
>>     linux:~# echo 1234 >/proc/sys/net/ipv4/tcp_mem 
>>     -bash: echo: write error: Invalid argument
>>     linux:~# cat /proc/sys/net/ipv4/tcp_mem 
>>     1234	12582912	16777216
>>
>> the echo operation got error, but value already written to tcp_mem.
>> If a write() returns an error like EINVAL, we expect no change occurred.
>> This patch fix the confusing corner and makes __do_proc_doulongvec_minmax 
>> works the same as __do_proc_dointvec
> Nacked-by: "Eric W. Biederman" <ebiederm@xmission.com>
>
> Except for possibly breaking your muscle memory this does not explain
> why this is a problem.

I think it's really confusing that we got write error but actually the
value echoed is written properly, at least we need to fix it and make
the result match the behavior, right?

>
> Further you are changing a whole lot more than tcp_mem, without a word
> of justification in your description.

I agree, we can update the change log.

Thanks
Hanjun

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

end of thread, other threads:[~2015-12-21  1:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-09  2:01 [PATCH net] net:sysctl fix the confusing corner of tcp_mem Wang Yufen
2015-12-09 13:47 ` Sergei Shtylyov
2015-12-09 16:38 ` Eric W. Biederman
2015-12-21  1:02   ` Hanjun Guo

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).