[master] 966b586 Add "Proxy" VSL tag for information learned through proxy protocol.

Poul-Henning Kamp phk at FreeBSD.org
Wed Apr 8 11:05:32 CEST 2015


commit 966b586f490d38c952d28898f7934a4053e0e62a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Apr 8 09:04:57 2015 +0000

    Add "Proxy" VSL tag for information learned through proxy protocol.
    
    Clarify which addresses are in ReqStart and SessOpen

diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c
index c7ae516..299777f 100644
--- a/bin/varnishd/proxy/cache_proxy_proto.c
+++ b/bin/varnishd/proxy/cache_proxy_proto.c
@@ -150,6 +150,8 @@ vpx_proto1(const struct worker *wrk, struct req *req)
 	AN(VSA_Build(sa, res->ai_addr, res->ai_addrlen));
 	freeaddrinfo(res);
 
+	VSLb(req->vsl, SLT_Proxy, "1 %s %s %s %s",
+	    fld[1], fld[2], fld[3], fld[4]);
 	req->htc->pipeline_b = q;
 	return (0);
 }
@@ -172,6 +174,8 @@ vpx_proto2(const struct worker *wrk, struct req *req)
 	struct sockaddr_in sin4;
 	struct sockaddr_in6 sin6;
 	struct suckaddr *sa = NULL;
+	char ha[VTCP_ADDRBUFSIZE];
+	char pa[VTCP_PORTBUFSIZE];
 	char hb[VTCP_ADDRBUFSIZE];
 	char pb[VTCP_PORTBUFSIZE];
 
@@ -247,6 +251,7 @@ vpx_proto2(const struct worker *wrk, struct req *req)
 		memcpy(&sin4.sin_port, p + 26, 2);
 		SES_Reserve_server_addr(req->sp, &sa);
 		AN(VSA_Build(sa, &sin4, sizeof sin4));
+		VTCP_name(sa, ha, sizeof ha, pa, sizeof pa);
 
 		/* src/client */
 		memcpy(&sin4.sin_addr, p + 16, 4);
@@ -263,6 +268,7 @@ vpx_proto2(const struct worker *wrk, struct req *req)
 		memcpy(&sin6.sin6_port, p + 50, 2);
 		SES_Reserve_server_addr(req->sp, &sa);
 		AN(VSA_Build(sa, &sin6, sizeof sin6));
+		VTCP_name(sa, ha, sizeof ha, pa, sizeof pa);
 
 		/* src/client */
 		memcpy(&sin6.sin6_addr, p + 16, 16);
@@ -278,8 +284,8 @@ vpx_proto2(const struct worker *wrk, struct req *req)
 	VTCP_name(sa, hb, sizeof hb, pb, sizeof pb);
 	SES_Set_String_Attr(req->sp, SA_CLIENT_IP, hb);
 	SES_Set_String_Attr(req->sp, SA_CLIENT_PORT, pb);
-	VSLb(req->vsl, SLT_Debug, "PROXY2 %s %s", hb, pb);
 
+	VSLb(req->vsl, SLT_Proxy, "2 %s %s %s %s", hb, pb, ha, pa);
 	return (0);
 }
 
diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h
index 94d0910..ecb2683 100644
--- a/include/tbl/vsl_tags.h
+++ b/include/tbl/vsl_tags.h
@@ -70,9 +70,9 @@ SLTM(SessOpen, 0, "Client connection opened",
 	"\t|  |  |  |  |  +- File descriptor number\n"
 	"\t|  |  |  |  +---- Local TCP port ('-' if !$log_local_addr)\n"
 	"\t|  |  |  +------- Local IPv4/6 address ('-' if !$log_local_addr)\n"
-	"\t|  |  +---------- Listen socket\n"
-	"\t|  +------------- Client TCP socket\n"
-	"\t+---------------- Client IPv4/6 address\n"
+	"\t|  |  +---------- Listen socket (-a argument)\n"
+	"\t|  +------------- Remote TCP port\n"
+	"\t+---------------- Remote IPv4/6 address\n"
 	"\n"
 )
 
@@ -138,6 +138,19 @@ SLTM(HttpGarbage, SLT_F_BINARY, "Unparseable HTTP request",
 	"Logs the content of unparseable HTTP requests.\n\n"
 )
 
+SLTM(Proxy, 0, "PROXY protocol information",
+	"PROXY protocol information.\n\n"
+	"The format is::\n\n"
+	"\t%d %s %d %s %d [key value]...\n"
+	"\t|  |  |  |  |  |\n"
+	"\t|  |  |  |  |  +- optional information\n"
+	"\t|  |  |  |  +- server port\n"
+	"\t|  |  |  +- server ip\n"
+	"\t|  |  +- client port\n"
+	"\t|  +- client ip\n"
+	"\t+---- PROXY protocol version\n"
+)
+
 SLTM(ProxyGarbage, 0, "Unparseable PROXY request",
 	"A PROXY protocol header was unparseable.\n\n"
 )
@@ -263,8 +276,8 @@ SLTM(ReqStart, 0, "Client request start",
 	"The format is::\n\n"
 	"\t%s %s\n"
 	"\t|  |\n"
-	"\t|  +- Port number\n"
-	"\t+---- IP address\n"
+	"\t|  +- Client Port number\n"
+	"\t+---- Client IP4/6 address\n"
 	"\n"
 )
 



More information about the varnish-commit mailing list