Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jul 2016 11:06:23 -0500
From:      Karl Denninger <karl@denninger.net>
To:        freebsd-net@freebsd.org
Subject:   Re: IPv6 -> IPv4 fallback broken in serf, kernel bug?
Message-ID:  <4b7e5fc9-7bc6-02e0-f147-3a5cb0e41788@denninger.net>
In-Reply-To: <201607261559.u6QFxF8a081339@gw.catspoiler.org>
References:  <201607261559.u6QFxF8a081339@gw.catspoiler.org>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
On 7/26/2016 10:59, Don Lewis wrote:
> Serf has some code to fall back from IPv4 if an IPv6 and more generally
> try different addresses on multi-homed servers if connection attempts
> fail, but it does not work properly on recent versions of FreeBSD. I've
> tested both recent FreeBSD 10.3-STABLE and HEAD.
>
> The way that it is supposed to work is that serf creates a socket, sets
> it non-blocking, calls connect(), and then passes the fd to poll(). When
> the connection attempt fails, it expects to see a POLLERR event.  The
> POLLERR event handler will then call getsockopt(fd, SOL_SOCKET,
> SO_ERROR, &error, ...).  If the returned error is ECONNREFUSED or one of
> a couple of other errors, then serf will move on to the next address.
>
> Instead what happens is that serf also(?) sees POLLIN set, which it
> processes first by calling read(), which returns an ECONNREFUSED error.
> That not a documented error return from read().
>
> An easy way to test this is to truss svn and attempt to do an http
> checkout from a host that has both IPv6 and IPv4 addresses, but is not
> listening on port 80.  The only connection attempt will be to the IPv6
> address.
>
> socket(PF_INET6,SOCK_STREAM|SOCK_CLOEXEC,6)	 = 4 (0x4)
> fcntl(4,F_GETFL,)				 = 2 (0x2)
> fcntl(4,F_SETFL,O_NONBLOCK|0x2)			 = 0 (0x0)
> setsockopt(0x4,0x6,0x1,0x7fffffffdda4,0x4)	 = 0 (0x0)
> gettimeofday({ 1469515046.979461 },0x0)		 = 0 (0x0)
> connect(4,{ AF_INET6 [xxxx:xxxx:xxxx:xxxx::xxxx]:80 },28) ERR#36 'Operation now in progress'
> gettimeofday({ 1469515046.979614 },0x0)		 = 0 (0x0)
> kevent(3,{ 4,EVFILT_READ,EV_ADD,0x0,0x0,0x805491300 },1,0x0,0,0x0) = 0 (0x0)
> kevent(3,{ 4,EVFILT_WRITE,EV_ADD,0x0,0x0,0x805491300 },1,0x0,0,0x0) = 0 (0x0)
> kevent(3,0x0,0,{ 4,EVFILT_READ,EV_EOF,NOTE_LOWAT|0x3c,0x0,0x805491300 4,EVFILT_WRITE,EV_EOF,NOTE_LOWAT|0x3c,0x8000,0x805491300 },32,{ 0.500000000 }) = 2 (0x2)
> read(4,0x80549c064,8000)			 ERR#61 'Connection refused'
> kevent(3,{ 4,EVFILT_READ,EV_DELETE,0x0,0x0,0x0 },1,0x0,0,0x0) = 0 (0x0)
> kevent(3,{ 4,EVFILT_WRITE,EV_DELETE,0x0,0x0,0x0 },1,0x0,0,0x0) = 0 (0x0)
> kevent(3,{ 4,EVFILT_READ,EV_DELETE,0x0,0x0,0x0 },1,0x0,0,0x0) ERR#2 'No such file or directory'
> kevent(3,{ 4,EVFILT_WRITE,EV_DELETE,0x0,0x0,0x0 },1,0x0,0,0x0) ERR#2 'No such file or directory'
> close(4)					 = 0 (0x0)
> close(3)					 = 0 (0x0)
> svn: E170013: Unable to connect to a repository at URL ...
>
>
> It looks like it should be possible to patch serf to handle this, but:
>   * Should POLLIN be set for this event?
>   
>   * What errno value should read() return in this case, if it is
>     ECONNREFUSED, then that should be documented.
>
>
This is kinda serious in that the above manifestation in svn effectively
disables it for those of us that are on IPv4 connections and have no
provider capability for IPv6 at the present time.   When I was running
10.2 this was not a problem but as soon as I rolled forward to 11.x it
showed up.

Fortunately svnlite does work, but if this same breakage manages to
migrate there as well.......

-- 
Karl Denninger
karl@denninger.net <mailto:karl@denninger.net>
/The Market Ticker/
/[S/MIME encrypted email preferred]/

[-- Attachment #2 --]
0	*H
010
	`He0	*H
_0[0C)0
	*H
010	UUS10UFlorida10U	Niceville10U
Cuda Systems LLC10UCuda Systems LLC CA1"0 	*H
	Cuda Systems LLC CA0
150421022159Z
200419022159Z0Z10	UUS10UFlorida10U
Cuda Systems LLC10UKarl Denninger (OCSP)0"0
	*H
0
X@vkY
Tq/vE]5#֯MX\8LJ/V?5Da+
sJc*/r{ȼnS+w")ąZ^DtdCOZ ~7Q '@a#ijc۴oZdB&!Ӝ-<	?HN5y
5}F|ef゘"Vلio74zn">a1qWuɖbFeGE&3(KhixG3!#e_XƬϜ/,$+;4y'Bz<qT9_?rRUpn5
Jn&Rx/p Jyel*pN8/#9u/YPEC)TY>~/˘N[vyiDKˉ,^" ?$T8v&K%z8C @?K{9f`+@,|Mbia007++0)0'+0http://cudasystems.net:88880	U00	`HB0U0,	`HB
OpenSSL Generated Certificate0U-h\Ff Y0U#0$q}ݽʒm50U0karl@denninger.net0
	*H
Owbabɺx&Uk[(Oj!%pMQ0I!#QH}.>~2&D}<wm_>V6v]f>=Nn+8;q wfΰ/RLyUG#b}n!Dր_up|_ǰc/%ۥ
nN8:d;-UJd/m1~VނיnN I˾$tF1&}|?q?\đXԑ&\4V<lKۮ3%Am_(q-(cAeGX)f}-˥6cv~Kg8m~v;|9:-iAPқ6ېn-.)<[$KJtt/L4ᖣ^Cmu4vb{+BG$M0c\[MR|0FԸP&78"4p#}DZ9;V9#>Sw"[UP7100010	UUS10UFlorida10U	Niceville10U
Cuda Systems LLC10UCuda Systems LLC CA1"0 	*H
	Cuda Systems LLC CA)0
	`HeM0	*H
	1	*H
0	*H
	1
160726160623Z0O	*H
	1B@rR_:n8aMݸTD:~.^me&zcRn1	$?ͧ0l	*H
	1_0]0	`He*0	`He0
*H
0*H
0
*H
@0+0
*H
(0	+710010	UUS10UFlorida10U	Niceville10U
Cuda Systems LLC10UCuda Systems LLC CA1"0 	*H
	Cuda Systems LLC CA)0*H
	1010	UUS10UFlorida10U	Niceville10U
Cuda Systems LLC10UCuda Systems LLC CA1"0 	*H
	Cuda Systems LLC CA)0
	*H
;sX+*jx
5pZ@Qbݝ@Q\4&w_|Kb(k>}Uj9+t-BUX6y[+[]}B}uDn!Ӳ\Vr9.O`Go5\0j)+
>830M=:SfN*:Y^
hSՍẁiC4y	`(i;]K{֜pzFxܨk:n8ύ}jse.тu\
4`G^f
Gáȏ9悝sIb{b]S?l'sT.>43VBR	I
Ѝ_lM2;^nҝΖgh%7qY|7lP_gYXlZ
<EX7+odsuۮ>Do|	'q2cGңM]Nas/",@s@
ؗ*O޼OfX
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4b7e5fc9-7bc6-02e0-f147-3a5cb0e41788>