Skip to content

Commit

Permalink
[NET]: add SO_RCVBUF comment
Browse files Browse the repository at this point in the history
Put a comment in there explaining why we double the setsockopt()
caller's SO_RCVBUF.  People keep wondering.

Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Andrew Morton authored and David S. Miller committed Mar 31, 2006
1 parent 5607943 commit c08e496
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,21 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
val = sysctl_rmem_max;
set_rcvbuf:
sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
/* FIXME: is this lower bound the right one? */
/*
* 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.
*/
if ((val * 2) < SOCK_MIN_RCVBUF)
sk->sk_rcvbuf = SOCK_MIN_RCVBUF;
else
Expand Down

0 comments on commit c08e496

Please sign in to comment.