All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] sctp/test_1_to_1_sockopt.c: set SO_SNDBUF above the defined minimum
@ 2015-03-10 11:18 Alexey Kodanev
  2015-03-11 10:30 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Kodanev @ 2015-03-10 11:18 UTC (permalink / raw)
  To: ltp-list; +Cc: vasily.isaenko

SO_SNDBUF have the following minimum value:
TCP_SKB_MIN_TRUESIZE (2048 + sizeof(struct sk_buff))
SOCK_MIN_SNDBUF (TCP_SKB_MIN_TRUESIZE * 2)

The test set 'SO_SNDBUF' to 2048, then it gets the value back
with getsockopt(). But the value was defaulted in the kernel
to the SOCK_MIN_SNDBUF.

Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
---
 utils/sctp/func_tests/test_1_to_1_sockopt.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/utils/sctp/func_tests/test_1_to_1_sockopt.c b/utils/sctp/func_tests/test_1_to_1_sockopt.c
index 4cd84da..436b344 100644
--- a/utils/sctp/func_tests/test_1_to_1_sockopt.c
+++ b/utils/sctp/func_tests/test_1_to_1_sockopt.c
@@ -340,7 +340,7 @@ main(void)
 			 "got value differs Set Value=%d Get Value=%d",
 			 (2*rcvbuf_val_set), rcvbuf_val_get);
 
-	sndbuf_val_set = 2048;
+	sndbuf_val_set = 5000;
 	/* TEST17: Test case for setsockopt SO_SNDBUF */
 	error = setsockopt(sk2, SOL_SOCKET, SO_SNDBUF, &sndbuf_val_set, len);
 	if (error < 0)
-- 
1.7.1


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
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/test_1_to_1_sockopt.c: set SO_SNDBUF above the defined minimum
  2015-03-10 11:18 [LTP] [PATCH] sctp/test_1_to_1_sockopt.c: set SO_SNDBUF above the defined minimum Alexey Kodanev
@ 2015-03-11 10:30 ` Cyril Hrubis
       [not found]   ` <55002A64.6040108@oracle.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2015-03-11 10:30 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: vasily.isaenko, ltp-list

Hi!
> SO_SNDBUF have the following minimum value:
> TCP_SKB_MIN_TRUESIZE (2048 + sizeof(struct sk_buff))
> SOCK_MIN_SNDBUF (TCP_SKB_MIN_TRUESIZE * 2)
> 
> The test set 'SO_SNDBUF' to 2048, then it gets the value back
> with getsockopt(). But the value was defaulted in the kernel
> to the SOCK_MIN_SNDBUF.

I guess that the setsockopt() does that without failing and then
the comparsion of the value you get with getsockopt() fails, right?

I still do not get why the code does:

if ((2 * sndbuf_val_set) != sndbuf_val_get)

Shouldn't the sndbuf_val_set == sndbuf_val_get once the value is changed
to 5000?

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
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/test_1_to_1_sockopt.c: set SO_SNDBUF above the defined minimum
       [not found]   ` <55002A64.6040108@oracle.com>
@ 2015-03-11 11:48     ` Cyril Hrubis
  0 siblings, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2015-03-11 11:48 UTC (permalink / raw)
  To: Alexey Kodanev; +Cc: vasily.isaenko, ltp-list

Hi!
> This is what is written in kernel source (net/core/sock.c):
> 
> sk->sk_sndbuf = max_t(u32, val * 2, SOCK_MIN_SNDBUF);
> ...
> /*
>   * We double it on the way in to account for
>   * "struct sk_buff" etc. overhead.   Applications
>   * assume that the SO_RCVBUF setting they make will
>   * allow that much actual data to be received on that
>   * socket.
>   *
>   * Applications are unaware that "struct sk_buff" and
>   * other overheads allocate from the receive buffer
>   * during socket buffer allocation.
>   *
>   * And after considering the possible alternatives,
>   * returning the value we actually used in getsockopt
>   * is the most desirable behavior.
>   */
> 
> sk->sk_rcvbuf = max_t(u32, val * 2, SOCK_MIN_RCVBUF);
> 
> I'm not sure why it is not just 'val', because it chooses the maximum 
> value in any case and we have defined minimum.

Ok.

The patch is fine then.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
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:[~2015-03-11 11:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-10 11:18 [LTP] [PATCH] sctp/test_1_to_1_sockopt.c: set SO_SNDBUF above the defined minimum Alexey Kodanev
2015-03-11 10:30 ` Cyril Hrubis
     [not found]   ` <55002A64.6040108@oracle.com>
2015-03-11 11:48     ` Cyril Hrubis

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.