]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: filters: Forward all filtered data at the end of http filtering
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 16 Nov 2020 09:10:38 +0000 (10:10 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 17 Nov 2020 08:59:35 +0000 (09:59 +0100)
When http filtering ends, if there are some filtered data not forwarded yet, we
forward them, in flt_http_end(). Most of time, this doesn't happen, except when
a tunnel is established using a CONNECT. In this case, there is not EOM on the
request and there is no body. Thus the headers are never forwarded, blocking the
stream.

This patch must be backported as far as 2.0. Prior versions don't suffer of this
bug because there is no HTX support. On the 2.0, the change is only applicable
on HTX streams. A special test must be performed to make sure.

src/filters.c

index 1b954d87d0e97e1f76769354f3890136f442d710..eddfb70d2c040cb66f38896c375c494e98fbfab7 100644 (file)
@@ -546,10 +546,15 @@ flt_set_stream_backend(struct stream *s, struct proxy *be)
 int
 flt_http_end(struct stream *s, struct http_msg *msg)
 {
+       unsigned long long *strm_off = &FLT_STRM_OFF(s, msg->chn);
+       unsigned int offset = 0;
        int ret = 1;
 
        DBG_TRACE_ENTER(STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA|STRM_EV_FLT_ANA, s, s->txn, msg);
        RESUME_FILTER_LOOP(s, msg->chn) {
+               unsigned long long flt_off = FLT_OFF(filter, msg->chn);
+               offset = flt_off - *strm_off;
+
                if (FLT_OPS(filter)->http_end) {
                        DBG_TRACE_DEVEL(FLT_ID(filter), STRM_EV_HTTP_ANA|STRM_EV_FLT_ANA, s);
                        ret = FLT_OPS(filter)->http_end(s, filter, msg);
@@ -557,6 +562,10 @@ flt_http_end(struct stream *s, struct http_msg *msg)
                                BREAK_EXECUTION(s, msg->chn, end);
                }
        } RESUME_FILTER_END;
+
+       c_adv(msg->chn, offset);
+       *strm_off += offset;
+
 end:
        DBG_TRACE_LEAVE(STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA|STRM_EV_FLT_ANA, s);
        return ret;