IPv[46] parsing

Federico Schwindt fgsch at lodoss.net
Tue Oct 27 21:14:38 CET 2015


Hi,

Here's a resume of the current situation and the proposed plan to address
it.

While moving from 4.0.x to 4.1 I noticed that std.ip(..., "::1") doesn't
work anymore.
It errors out with:

IP constant '"::1"' could not be resolved to an IP address:
Servname not supported for ai_socktype
(Sorry if that error message is gibberish.)

Using [::1] works though.
This changed when Resolve_Sockaddr() was modified to use VSS_Resolver(), in
commit d86639568e660bbf272492659f85e271145903c6.

I've opened a ticket to deal with this,
https://www.varnish-cache.org/trac/ticket/1801.

My first problem with this is the now mandatory [].
They do make sense when you need to use a port with an IPv6, in fact that's
the only way, but we do accept 1.2.3.4 as literal, so why not ::1?
Using the [] notation for specifying an IPv6 address without a port is
non-standard and something you won't find on the wild. It feels pretty much
arbitrary too.

Moving on, if you were to pass [::1] as the first argument to std.ip() it
won't work, since getaddrinfo() doesn't know how to parse it.
This is not consistent.

First, I'd like to restore the pre 4.1 behaviour with a 2 lines patch (see
attached).
The patch is fairly small and if we parse it incorrectly it will fail down
the line when we call getaddrinfo().

The other thing that I mentioned on Monday is modifying std.ip() to accept
[::1] and [::1]:80 as well.
The former might be needed when dealing with forward like headers (rfc
7239) for example and should be trivial.

Before I proceed I'd like some consensus, time is scarce after all.

So let the bike shedding begin.

f.-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20151027/28cb2247/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: r01801.patch
Type: text/x-diff
Size: 504 bytes
Desc: not available
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-dev/attachments/20151027/28cb2247/attachment.patch>


More information about the varnish-dev mailing list