[Bug 206716] HPN-SSH: getsockopt(SO_SNDBUF) returns high watermark, not setsockopt(SO_SNDBUF)

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Wed Mar 2 18:43:09 UTC 2016


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=206716

timon at timon.net.nz changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon at timon.net.nz

--- Comment #4 from timon at timon.net.nz ---
Maybe I miss something, but looks like there is no bug in FreeBSD.
Yes, on FreeBSD getsockopt(..., SO_SNDBUF, ...) returns "high watermark", but
setsockopt(..., SO_SNDBUF, ...) attempts to resize the buffer and, on success,
sets "high watermark" to the new buffer size. So getsockopt() returns the value
set by getsockopt().

I have written a simple test and run it on the 10.1-RELEASE and 10.2-RELEASE:
-----8<-----
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <err.h>
#include <stdio.h>

int main () {
        int s, size;
        socklen_t sizelen;

        s = socket(AF_INET6, SOCK_RAW, IPPROTO_IP);

        sizelen = sizeof size;
        getsockopt(s, SOL_SOCKET, SO_SNDBUF, &size, &sizelen);
        printf("Current socket send buffer size: %i\n", size);
        size /= 2;
        setsockopt(s, SOL_SOCKET, SO_SNDBUF, &size, sizelen);
        getsockopt(s, SOL_SOCKET, SO_SNDBUF, &size, &sizelen);
        printf("New socket send buffer size: %i\n", size);
}
-----8<-----
$ cc test.so_sndbuf.c
$ sudo ./a.out 
Current socket send buffer size: 9216
New socket send buffer size: 4608

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the freebsd-amd64 mailing list