r5119 - in trunk/varnish-cache: bin/varnishd bin/varnishtest bin/varnishtest/tests doc/sphinx/phk lib/libvarnish
phk at varnish-cache.org
phk at varnish-cache.org
Tue Aug 24 17:56:49 CEST 2010
Author: phk
Date: 2010-08-24 17:56:49 +0200 (Tue, 24 Aug 2010)
New Revision: 5119
Added:
trunk/varnish-cache/doc/sphinx/phk/ipv6suckage.rst
Modified:
trunk/varnish-cache/bin/varnishd/cache_panic.c
trunk/varnish-cache/bin/varnishd/cache_vrt.c
trunk/varnish-cache/bin/varnishd/mgt_cli.c
trunk/varnish-cache/bin/varnishtest/tests/v00010.vtc
trunk/varnish-cache/bin/varnishtest/vtc_server.c
trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
trunk/varnish-cache/doc/sphinx/phk/index.rst
trunk/varnish-cache/lib/libvarnish/vss.c
Log:
Always report sockaddr's as
IP# <space> PORT#
Explain why.
Modified: trunk/varnish-cache/bin/varnishd/cache_panic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_panic.c 2010-08-24 15:49:52 UTC (rev 5118)
+++ trunk/varnish-cache/bin/varnishd/cache_panic.c 2010-08-24 15:56:49 UTC (rev 5119)
@@ -215,7 +215,7 @@
vsb_printf(vsp, "sp = %p {\n", sp);
vsb_printf(vsp,
" fd = %d, id = %d, xid = %u,\n", sp->fd, sp->id, sp->xid);
- vsb_printf(vsp, " client = %s:%s,\n",
+ vsb_printf(vsp, " client = %s %s,\n",
sp->addr ? sp->addr : "?.?.?.?",
sp->port ? sp->port : "?");
switch (sp->step) {
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2010-08-24 15:49:52 UTC (rev 5118)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2010-08-24 15:56:49 UTC (rev 5119)
@@ -752,6 +752,10 @@
return (vrt_hostname);
}
+/*--------------------------------------------------------------------
+ * XXX: This is pessimistically silly
+ */
+
int
VRT_r_server_port(struct sess *sp)
{
Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-08-24 15:49:52 UTC (rev 5118)
+++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-08-24 15:56:49 UTC (rev 5119)
@@ -444,7 +444,7 @@
AN(vsb);
TCP_myname(fd, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1);
TCP_hisname(fd, abuf2, sizeof abuf2, pbuf2, sizeof pbuf2);
- vsb_printf(vsb, "%s %s:%s %s:%s", pfx, abuf2, pbuf2, abuf1, pbuf1);
+ vsb_printf(vsb, "%s %s %s %s %s", pfx, abuf2, pbuf2, abuf1, pbuf1);
vsb_finish(vsb);
AZ(vsb_overflowed(vsb));
return (vsb);
Modified: trunk/varnish-cache/bin/varnishtest/tests/v00010.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/v00010.vtc 2010-08-24 15:49:52 UTC (rev 5118)
+++ trunk/varnish-cache/bin/varnishtest/tests/v00010.vtc 2010-08-24 15:56:49 UTC (rev 5119)
@@ -25,7 +25,7 @@
varnish v1 -cliok "param.set diag_bitmap 0x00001000"
# Force the (random) port selected to be used again after restart.
-varnish v1 -cliok "param.set listen_address ${v1_sock}"
+varnish v1 -cliok "param.set listen_address ${v1_addr}:${v1_port}"
# varnishtest defaults to auto_restart off, to avoid masking bugs.
varnish v1 -cliok "param.set auto_restart on"
Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2010-08-24 15:49:52 UTC (rev 5118)
+++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2010-08-24 15:56:49 UTC (rev 5119)
@@ -95,7 +95,7 @@
vl = vtc_logopen(s->name);
- vtc_log(vl, 2, "Started on %s:%s", s->aaddr, s->aport);
+ vtc_log(vl, 2, "Started on %s %s", s->aaddr, s->aport);
for (i = 0; i < s->repeat; i++) {
if (s->repeat > 1)
vtc_log(vl, 3, "Iteration %d", i);
@@ -185,12 +185,12 @@
s->aport, sizeof s->aport);
macro_def(s->vl, s->name, "addr", "%s", s->aaddr);
macro_def(s->vl, s->name, "port", "%s", s->aport);
- macro_def(s->vl, s->name, "sock", "%s:%s", s->aaddr, s->aport);
+ macro_def(s->vl, s->name, "sock", "%s %s", s->aaddr, s->aport);
/* Record the actual port, and reuse it on subsequent starts */
if (!strcmp(s->port, "0"))
REPLACE(s->port, s->aport);
}
- vtc_log(s->vl, 1, "Listen on %s:%s", s->addr, s->port);
+ vtc_log(s->vl, 1, "Listen on %s %s", s->addr, s->port);
s->run = 1;
AZ(pthread_create(&s->tp, NULL, server_thread, s));
}
Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2010-08-24 15:49:52 UTC (rev 5118)
+++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2010-08-24 15:56:49 UTC (rev 5119)
@@ -281,7 +281,7 @@
vsb_printf(vsb, " -p syslog_cli_traffic=off");
vsb_printf(vsb, " -a '%s'", "127.0.0.1:0");
vsb_printf(vsb, " -S %s/_S", v->workdir);
- vsb_printf(vsb, " -M %s:%s", abuf, pbuf);
+ vsb_printf(vsb, " -M '%s %s'", abuf, pbuf);
vsb_printf(vsb, " -P %s/varnishd.pid", v->workdir);
vsb_printf(vsb, " %s", vsb_data(v->storage));
vsb_printf(vsb, " %s", vsb_data(v->args));
@@ -410,7 +410,7 @@
vtc_log(v->vl, 2, "Listen on %s %s", h, p);
macro_def(v->vl, v->name, "addr", "%s", h);
macro_def(v->vl, v->name, "port", "%s", p);
- macro_def(v->vl, v->name, "sock", "%s:%s", h, p);
+ macro_def(v->vl, v->name, "sock", "%s %s", h, p);
}
/**********************************************************************
Modified: trunk/varnish-cache/doc/sphinx/phk/index.rst
===================================================================
--- trunk/varnish-cache/doc/sphinx/phk/index.rst 2010-08-24 15:49:52 UTC (rev 5118)
+++ trunk/varnish-cache/doc/sphinx/phk/index.rst 2010-08-24 15:56:49 UTC (rev 5119)
@@ -8,6 +8,7 @@
.. toctree::
+ ipv6suckage.rst
backends.rst
platforms.rst
barriers.rst
Added: trunk/varnish-cache/doc/sphinx/phk/ipv6suckage.rst
===================================================================
--- trunk/varnish-cache/doc/sphinx/phk/ipv6suckage.rst (rev 0)
+++ trunk/varnish-cache/doc/sphinx/phk/ipv6suckage.rst 2010-08-24 15:56:49 UTC (rev 5119)
@@ -0,0 +1,66 @@
+.. _phk_ipv6suckage:
+
+============
+IPv6 Suckage
+============
+
+In my drawer full of cassette tapes, is a 6 tape collection published
+by Carl Malamuds "Internet Talk Radio", the first and by far the
+geekiest radio station on the internet.
+
+The tapes are from 1994 and the topic is "IPng", the IPv4 replacement
+that eventually became IPv6. To say that I am a bit jaded about
+IPv6 by now, is accusing the pope of being religious.
+
+IPv4 addresses in numeric form, are written as 192.168.0.1 and to
+not confuse IPv6 with IPv4, it was decided in RFC1884 that IPv6
+would use colons and groups of 16 bits, and because 128 bits are a
+lot of bits, the secret '::' trick was introduced, to supress all
+the zero bits that we may not ever need anyway: 1080::8:800:200C:417A
+
+Colon was chosen because it was already used in MAC/ethernet addresses
+and did no damage there and it is not a troublesome metacharacter
+in shells. No worries.
+
+Most protocols have a Well Known Service number, TELNET is 23, SSH
+is 22 and HTTP is 80 so usually people will only have to care about
+the IP number.
+
+Except when they don't, for instance when they run more than one
+webserver on the same machine.
+
+No worries, says the power that controls what URLs look like, we
+will just stick the port number after the IP# with a colon:
+
+ http://192.168.0.1:8080/...
+
+That obviously does not work with IPv6, so RFC3986 comes around and
+says "darn, we didn't think of that" and puts the IPV6 address in
+[...] giving us:
+
+ http://[1080::8:800:200C:417A]:8080/
+
+Remember that "harmless in shells" detail ? Yeah, sorry about that.
+
+Now, there are also a RFC sanctioned API for translating a socket
+address into an ascii string, getnameinfo(), and if you tell it that
+you want a numeric return, you get a numeric return, and you don't
+even need to know if it is a IPv4 or IPv6 address in the first place.
+
+But it returns the IP# in one buffer and the port number in another,
+so if you want to format the sockaddr in the by RFC5952 recommended
+way (the same as RFC3986), you need to inspect the version field
+in the sockaddr to see if you should do
+
+ "%s:%s", host, port
+or
+ "[%s]:%s", host, port
+
+Careless standardization costs code, have I mentioned this before ?
+
+Varnish reports socket addresses as two fields: IP space PORT,
+now you know why.
+
+Until next time,
+
+Poul-Henning, 2010-08-24
Modified: trunk/varnish-cache/lib/libvarnish/vss.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/vss.c 2010-08-24 15:49:52 UTC (rev 5118)
+++ trunk/varnish-cache/lib/libvarnish/vss.c 2010-08-24 15:56:49 UTC (rev 5119)
@@ -105,6 +105,8 @@
} else {
/* IPv4 address of the form 127.0.0.1:80, or non-numeric */
p = strchr(str, ':');
+ if (p == NULL)
+ p = strchr(str, ' ');
if (p == NULL) {
*addr = strdup(str);
XXXAN(*addr);
More information about the varnish-commit
mailing list