public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] sctp: enlarge SO_RCVBUF option value
@ 2013-11-04  5:28 Simon Xu
  2013-11-04  8:18 ` Jan Stancek
  2013-11-04  8:25 ` Wanlong Gao
  0 siblings, 2 replies; 3+ messages in thread
From: Simon Xu @ 2013-11-04  5:28 UTC (permalink / raw)
  To: ltp-list

When using setsockopt() with recent Linux kernels, it doesn't make sense to
use a value smaller than SOCK_MIN_RCVBUF/2 for SO_RCVBUF and expect getting
a SO_RCVBUF value by getsockopt() which is doubled.  See the following code
in linux/net/core/sock.c:

	if ((val * 2) < SOCK_MIN_RCVBUF)
		sk->sk_rcvbuf = SOCK_MIN_RCVBUF;
	else
		sk->sk_rcvbuf = val * 2;
	break;

SOCK_MIN_RCVBUF is defined as (2048 + sizeof(struct sk_buff)) which is 2240.
---
 testcases/network/sctp/func_tests/test_1_to_1_sockopt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/network/sctp/func_tests/test_1_to_1_sockopt.c b/testcases/network/sctp/func_tests/test_1_to_1_sockopt.c
index b12313b..c36f502 100644
--- a/testcases/network/sctp/func_tests/test_1_to_1_sockopt.c
+++ b/testcases/network/sctp/func_tests/test_1_to_1_sockopt.c
@@ -299,9 +299,9 @@ int main(void)
 	tst_resm(TPASS, "getsockopt() SCTP_STATUS - SUCCESS");
 
 	/* Reducing the SO_RCVBUF value using setsockopt() */
-	/*Minimum value is 128 and hence I am using it */
 	len = sizeof(int);
-	rcvbuf_val_set = 128;
+	/* (rcvbuf len)*2 should be no less than SOCK_MIN_RCVBUF in kernel */
+	rcvbuf_val_set = 1500;
 	/* TEST16: Test case for setsockopt SO_RCVBUF */
 	error = setsockopt(sk2, SOL_SOCKET, SO_RCVBUF, &rcvbuf_val_set, len);
 	if (error < 0)
-- 
1.8.1.2


------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] sctp: enlarge SO_RCVBUF option value
  2013-11-04  5:28 [LTP] [PATCH] sctp: enlarge SO_RCVBUF option value Simon Xu
@ 2013-11-04  8:18 ` Jan Stancek
  2013-11-04  8:25 ` Wanlong Gao
  1 sibling, 0 replies; 3+ messages in thread
From: Jan Stancek @ 2013-11-04  8:18 UTC (permalink / raw)
  To: Simon Xu; +Cc: ltp-list



----- Original Message -----
> From: "Simon Xu" <xu.simon@oracle.com>
> To: ltp-list@lists.sourceforge.net
> Sent: Monday, 4 November, 2013 6:28:15 AM
> Subject: [LTP] [PATCH] sctp: enlarge SO_RCVBUF option value
> 
> When using setsockopt() with recent Linux kernels, it doesn't make sense to
> use a value smaller than SOCK_MIN_RCVBUF/2 for SO_RCVBUF and expect getting
> a SO_RCVBUF value by getsockopt() which is doubled.  See the following code
> in linux/net/core/sock.c:
> 
> 	if ((val * 2) < SOCK_MIN_RCVBUF)
> 		sk->sk_rcvbuf = SOCK_MIN_RCVBUF;
> 	else
> 		sk->sk_rcvbuf = val * 2;
> 	break;
> 
> SOCK_MIN_RCVBUF is defined as (2048 + sizeof(struct sk_buff)) which is 2240.
> ---

You are missing 'Signed-off-by', but patch looks good to me.

Reviewed-by: Jan Stancek <jstancek@redhat.com>

Regards,
Jan

>  testcases/network/sctp/func_tests/test_1_to_1_sockopt.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/testcases/network/sctp/func_tests/test_1_to_1_sockopt.c
> b/testcases/network/sctp/func_tests/test_1_to_1_sockopt.c
> index b12313b..c36f502 100644
> --- a/testcases/network/sctp/func_tests/test_1_to_1_sockopt.c
> +++ b/testcases/network/sctp/func_tests/test_1_to_1_sockopt.c
> @@ -299,9 +299,9 @@ int main(void)
>  	tst_resm(TPASS, "getsockopt() SCTP_STATUS - SUCCESS");
>  
>  	/* Reducing the SO_RCVBUF value using setsockopt() */
> -	/*Minimum value is 128 and hence I am using it */
>  	len = sizeof(int);
> -	rcvbuf_val_set = 128;
> +	/* (rcvbuf len)*2 should be no less than SOCK_MIN_RCVBUF in kernel */
> +	rcvbuf_val_set = 1500;
>  	/* TEST16: Test case for setsockopt SO_RCVBUF */
>  	error = setsockopt(sk2, SOL_SOCKET, SO_RCVBUF, &rcvbuf_val_set, len);
>  	if (error < 0)
> --
> 1.8.1.2
> 
> 
> ------------------------------------------------------------------------------
> Android is increasing in popularity, but the open development platform that
> developers love is also attractive to malware creators. Download this white
> paper to learn more about secure code signing practices that can help keep
> Android apps secure.
> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list
> 

------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] sctp: enlarge SO_RCVBUF option value
  2013-11-04  5:28 [LTP] [PATCH] sctp: enlarge SO_RCVBUF option value Simon Xu
  2013-11-04  8:18 ` Jan Stancek
@ 2013-11-04  8:25 ` Wanlong Gao
  1 sibling, 0 replies; 3+ messages in thread
From: Wanlong Gao @ 2013-11-04  8:25 UTC (permalink / raw)
  To: Simon Xu; +Cc: ltp-list

On 11/04/2013 01:28 PM, Simon Xu wrote:
> When using setsockopt() with recent Linux kernels, it doesn't make sense to
> use a value smaller than SOCK_MIN_RCVBUF/2 for SO_RCVBUF and expect getting
> a SO_RCVBUF value by getsockopt() which is doubled.  See the following code
> in linux/net/core/sock.c:
> 
> 	if ((val * 2) < SOCK_MIN_RCVBUF)
> 		sk->sk_rcvbuf = SOCK_MIN_RCVBUF;
> 	else
> 		sk->sk_rcvbuf = val * 2;
> 	break;
> 
> SOCK_MIN_RCVBUF is defined as (2048 + sizeof(struct sk_buff)) which is 2240.
> ---
>  testcases/network/sctp/func_tests/test_1_to_1_sockopt.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thank you. Please add your Signed-off-by next time as Jan pointed out.

Wanlong Gao


------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2013-11-04  8:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-04  5:28 [LTP] [PATCH] sctp: enlarge SO_RCVBUF option value Simon Xu
2013-11-04  8:18 ` Jan Stancek
2013-11-04  8:25 ` Wanlong Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox