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.-
diff --git a/lib/libvarnish/vss.c b/lib/libvarnish/vss.c
index 6d1b809..3d40473 100644
--- a/lib/libvarnish/vss.c
+++ b/lib/libvarnish/vss.c
@@ -56,6 +56,7 @@
  * "0.0.0.0" - "0.0.0.0:80"
  * "[::1]" - "[::1]:80"
  * "[::]" - "[::]:80"
+ * "::1"
  *
  * See also RFC5952
  */
@@ -86,6 +87,8 @@ vss_parse(char *str, char **addr, char **port)
 			p = strchr(str, ':');
 		if (p == NULL)
 			return (NULL);
+		if (p[0] == ':' && strchr(&p[1], ':'))
+			return (NULL);
 		if (p == str)
 			*addr = NULL;
 	}
_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to