[master] 5764e6c53 be more specific about the reason for a failed PROXYv2 session

Nils Goroll nils.goroll at uplex.de
Mon Dec 28 18:03:06 UTC 2020


commit 5764e6c5353880fee9968b10f34653672e41a63f
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Dec 28 18:20:42 2020 +0100

    be more specific about the reason for a failed PROXYv2 session
    
    We reported any PROXY connection failure as JUNK. Now we report the same
    reasons as for failing HTTP1 connections.
    
    Implmentation:
    
    SES_DeleteHS() asserts that the hs argument be negative (one of
    JUNK, CLOSE, TIMEOUT, OVERFLOW, EOF).
    
    HTC_RxStuff() may return OVERFLOW, JUNK, COMPLETE, EOF or TIMEOUT (or,
    instead of TIMEOUT, IDLE if the callback returned EMPTY).
    
    Because vpx_complete() only returns JUNK, OVERFLOW or MORE, using
    the HTC_RxStuff() return value for SES_DeleteHS() is safe if different
    from COMPLETE.

diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c
index e9a2ce164..c31fb6131 100644
--- a/bin/varnishd/proxy/cache_proxy_proto.c
+++ b/bin/varnishd/proxy/cache_proxy_proto.c
@@ -537,7 +537,7 @@ vpx_new_session(struct worker *wrk, void *arg)
 	    1024);			// XXX ?
 	if (hs != HTC_S_COMPLETE) {
 		Req_Release(req);
-		SES_Delete(sp, SC_RX_JUNK, NAN);
+		SES_DeleteHS(sp, hs, NAN);
 		return;
 	}
 	p = req->htc->rxbuf_b;
diff --git a/bin/varnishtest/tests/o00001.vtc b/bin/varnishtest/tests/o00001.vtc
index ef78b2d95..bc07ac3e4 100644
--- a/bin/varnishtest/tests/o00001.vtc
+++ b/bin/varnishtest/tests/o00001.vtc
@@ -73,6 +73,8 @@ logexpect l1 -v v1 -g raw {
 	expect * 1013	ProxyGarbage	"PROXY2: Ignoring short IPv6 addresses \\(35\\)"
 	expect * 1016	Proxy		"2 1.2.3.4 2314 5.6.7.8 2828"
 	expect * 1019	Proxy		"2 102:304:506::d0e:f10 2314 8182:8384:8586::8d8e:8f80 2828"
+	expect * 1022	Begin		"^sess 0 PROXY"
+	expect 1 1022	SessClose	"^RX_OVERFLOW"
 } -start
 
 client c1 {
@@ -197,4 +199,17 @@ client c1 \
 
 delay .1
 
+client c2 {
+	# max length with garbage
+	sendhex "0d 0a 0d 0a 00 0d 0a 51 55 49 54 0a"
+	# annouce 1025 bytes
+	sendhex "20 00 04 01"
+	# 1024 bytes implicit proxy hdr limit
+	send_n 64 "0123456789abcdef"
+	timeout 8
+	expect_close
+} -run
+
+delay .1
+
 logexpect l1 -wait


More information about the varnish-commit mailing list