Date: Wed, 28 Mar 2012 00:53:03 GMT From: Sean Bruno <sbruno@FreeBSD.org> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/166458: bind() incorrectly interprets SO_REUSEADDR option as also implying SO_REUSEPORT on FreeBSD Message-ID: <201203280053.q2S0r3LR070049@red.freebsd.org> Resent-Message-ID: <201203280100.q2S10PEY063414@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 166458 >Category: kern >Synopsis: bind() incorrectly interprets SO_REUSEADDR option as also implying SO_REUSEPORT on FreeBSD >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Mar 28 01:00:25 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Sean Bruno >Release: 9.0 >Organization: Yahoo! Inc >Environment: FreeBSD xxxxxxxxxxxxx 9.0-RELEASE FreeBSD 9.0-RELEASE #3: Tue Dec 27 14:14:29 PST 2011 root@build9x64.pcbsd.org:/usr/obj/builds/amd64/pcbsd-build90/fbsd-source/9.0/sys/GENERIC amd64 >Description: <attempting to duplicate internal bug and loop in submitter> <There> ... seems to be a bug in FreeBSD when specifying port number 0 in the socket address passed to the bind system call in order to let the kernel select a free port number. The semantics of SO_REUSEADDR is inconsistently implemented on FreeBSD. FreeBSD 4 jail environment (on a FreeBSD 4 host): dev-tegge:~$ ./bindbug serversock addr is 10.76.250.174:40328 dup bind: Address already in use This error was expected, tried to bind to used addr/port dup2 bind: Address already in use This error was expected, tried to bind to used port without SO_REUSEPORT autosock addr is 10.76.250.174:40328 bug triggered, port number conflict on sockets without SO_REUSEPORT listen succeded after implicitly overlapping port bind FreeBSD 6 host enironment: tegge-store1:~:$ ./bindbug serversock addr is 127.0.0.1:59073 dup bind: Address already in use This error was expected, tried to bind to used addr/port BUG: binding duplicate socket to server port succeeded dup2sock addr is 0.0.0.0:59073 overlapping explicit bind to same port number succeeded without SO_REUSEPORT listen succeeded after explicitly overlapping port bind autosock addr is 0.0.0.0:59073 bug triggered, port number conflict on sockets without SO_REUSEPORT listen succeded after implicitly overlapping port bind RHEL4 host environment: [tegge@dell-bl1s3 ~]$ time ./bindbug serversock addr is 127.0.0.1:43270 dup bind: Address already in use This error was expected, tried to bind to used addr/port dup2 bind: Address already in use This error was expected, tried to bind to used port without SO_REUSEPORT bug not triggered after 16777216 iterations real 1m12.753s user 0m4.695s sys 1m8.037s >How-To-Repeat: Use test code that is attached, compile and run on a fbsd box vs a linux box. test case is at http://people.freebsd.org/~sbruno/bind_test.c >Fix: >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203280053.q2S0r3LR070049>