cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: [PATCH v2] Add "Happy Eyeballs" for IPv4/IPv6.

From: Paul Marks <paul_at_pmarks.net>
Date: Sun, 27 Oct 2013 13:35:25 -0700

On Sun, Oct 27, 2013 at 12:53 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Sun, 27 Oct 2013, Paul Marks wrote:
>
>> As an Internet Lorax, I beg you to reconsider this algorithm.
>
> I think you're thinking about this a slightly wrong way. It is not
> reconsidering the algorithm that we need, it is polishing and improving the
> algorithm.
>
> We welcome all contributions that make libcurl better and that includes
> Happy Eyeballs.

Yes, I'm a fan of Happy Eyeballs in general, provided that the
implementation is consistent with the spirit of the RFC.

I tested the current git code, and this request returned an IPv4
address on every attempt:

$ src/curl -v http://ds.test-ipv6.com/ip/
* About to connect() to ds.test-ipv6.com port 80 (#0)
* Trying 216.218.228.119...
* Trying 2001:470:1:18::119...
* Adding handle: conn: 0x13268e0
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x13268e0) send_pipe: 1, recv_pipe: 0
* Connected to ds.test-ipv6.com (216.218.228.119) port 80 (#0)
...
callback({"ip":"98.248.32.xx","type":"ipv4","subtype":"","via":"","padding":""})
* Connection #0 to host ds.test-ipv6.com left intact

I then ran this on my router:
$ iptables -I FORWARD -i eth1 -s 216.218.228.119 -j DROP

And curl hangs waiting for the IPv4 response:
$ src/curl -v http://ds.test-ipv6.com/ip/
* About to connect() to ds.test-ipv6.com port 80 (#0)
* Trying 216.218.228.119...
* Trying 2001:470:1:18::119...
* Adding handle: conn: 0x15548e0
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x15548e0) send_pipe: 1, recv_pipe: 0
// -- At this point, it hangs for a couple minutes --
* Whut?
* Failed connect to ds.test-ipv6.com:80; Connection timed out
* Failed connect to ds.test-ipv6.com:80; Broken pipe
* Closing connection 0
curl: (7) Failed connect to ds.test-ipv6.com:80; Connection timed out

But IPv6-only mode works fine:
$ src/curl -v -6 http://ds.test-ipv6.com/ip/
* About to connect() to ds.test-ipv6.com port 80 (#0)
* Trying 2001:470:1:18::119...
* Adding handle: conn: 0x21228e0
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x21228e0) send_pipe: 1, recv_pipe: 0
* Connected to ds.test-ipv6.com (2001:470:1:18::119) port 80 (#0)
...
callback({"ip":"2601:9:xxxx:xxx::f61","type":"ipv6","subtype":"","via":"","padding":""})
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-10-27