]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: filters: Fix a typo when a filter is attached blocking the release
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 4 Oct 2021 05:50:13 +0000 (07:50 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 4 Oct 2021 06:28:44 +0000 (08:28 +0200)
When a filter is attached to a stream, the wrong FLT_END analyzer is added
on the request channel. AN_REQ_FLT_END must be added instead of
AN_RES_FLT_END. Because of this bug, the stream may hang on the filter
release stage.

It seems to be ok for HTTP filters (cache & compression) in HTTP mode. But
when enabled on a TCP proxy, the stream is blocked until the client or the
server timeout expire because data forwarding is blocked. The stream is then
prematurely aborted.

This bug was introduced by commit 26eb5ea35 ("BUG/MINOR: filters: Always set
FLT_END analyser when CF_FLT_ANALYZE flag is set"). The patch must be
backported in all stable versions.

reg-tests/filters/random-forwarding.vtc
src/filters.c

index 07dd2b85ce796cfcceb83b3bac254851c340d170..650d207e155510fcc1702fd768d0d95eb26b00b3 100644 (file)
@@ -37,6 +37,16 @@ server s1 {
         rxreq
         expect req.url == "/"
         txresp -nolen
+        close
+
+        accept
+        rxreq
+        expect req.url == "/"
+        expect req.bodylen == 20480
+        txresp -nolen \
+          -hdr "Content-Type: text/plain" \
+          -bodylen 20480
+
 } -start
 
 haproxy h1 -conf {
@@ -60,6 +70,14 @@ haproxy h1 -conf {
     backend be1
         server www ${s1_addr}:${s1_port}
 
+    listen li1
+        mode tcp
+        bind "fd@${li1}"
+        # Validate nothing is blocked in TCP mode
+        filter compression
+        server www ${s1_addr}:${s1_port}
+
+
 } -start
 
 client c1 -connect ${h1_fe1_sock} {
@@ -105,3 +123,17 @@ client c3 -connect ${h1_fe1_sock} {
         expect resp.http.content-length == "<undef>"
         expect resp.bodylen == 0
 } -run
+
+client c4 -connect ${h1_li1_sock} {
+        txreq -url "/" \
+          -hdr "Accept-Encoding: gzip" \
+          -hdr "Content-Type: text/plain" \
+          -bodylen 20480
+        rxresp
+        expect resp.status == 200
+        expect resp.http.content-encoding == "<undef>"
+        expect resp.http.transfer-encoding == "<undef>"
+        expect resp.http.content-length == "<undef>"
+        expect resp.bodylen == 20480
+        expect_close
+} -run
index 136a3e80b38758da87d5fd15e1437210e7fdcb4d..f64c192bdbead6e90f82772865cb6c24ee2c240b 100644 (file)
@@ -475,7 +475,7 @@ flt_stream_start(struct stream *s)
        }
        if (strm_li(s) && (strm_li(s)->analysers & AN_REQ_FLT_START_FE)) {
                s->req.flags |= CF_FLT_ANALYZE;
-               s->req.analysers |= AN_RES_FLT_END;
+               s->req.analysers |= AN_REQ_FLT_END;
        }
        return 0;
 }