Linux 2.2.* SO_RCVBUF / SO_SNDBUF annoyance ?

Rob van Nieuwkerk (robn@verdi.et.tudelft.nl)
Wed, 14 Apr 1999 12:40:01 +0200 (CEST)


Hi,

I've been playing with Linux 2.2 TCP window scaling and noticed that
setsockopt() and getsockopt() handle RCVBUF/SNDBUF in a special way.

For example in ~linux/net/core/sock.c:

sock_setsockopt():

case SO_SNDBUF:
if (val > sysctl_wmem_max)
val = sysctl_wmem_max;
sk->sndbuf = max(val*2,2048);
^^^^^
^^^^^

sock_getsockopt():

case SO_SNDBUF:
v.val=sk->sndbuf;

Was there was a special reason for the val*2 ??

But anyway, it is annoying that you never get back the same value
with getsockopt() as you wrote with setsockopt() !
I have software that uses this to check if the setsockopt()
did succeed: the setsockopt() itself will *never* fail.

Of course you can check if you take in account the machanism
that Linux uses, but I think it is not right to pollute userspace
code with this kernel-internal knowledge.

Wouldn't it be better to just use "val" instead of "val*2" in
sock_setsockopt() ? After all
/proc/sys/net/core/{rmem_default,rmem_max,wmem_default,wmem_max}
correspond to the actual buffer size too (eg. without any factor).

Greetings,
Rob van Nieuwkerk

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/