]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http-ana: Apply stop to the current section for http-response rules
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 9 Nov 2021 15:33:25 +0000 (16:33 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 9 Nov 2021 17:02:36 +0000 (18:02 +0100)
A TCP/HTTP action can stop the rules evaluation. However, it should be
applied on the current section only. For instance, for http-requests rules,
an "allow" on a frontend must stop evaluation of rules defined in this
frontend. But the backend rules, if any, must still be evaluated.

For http-response rulesets, according the configuration manual, the same
must be true. Only "allow" action is concerned. However, since the
beginning, this action stops evaluation of all remaining rules, not only
those of the current section.

This patch may be backported to all supported versions. But it is not so
critical because the bug exists since a while. I doubt it will break any
existing configuration because the current behavior is
counterintuitive.

reg-tests/http-rules/h1or2_to_h1c.vtc
src/http_ana.c

index 182013b59af3f0e9e9e3139731b847fb48695e3d..4263a2ae8e50343b48fb90e4103d7704f264264f 100644 (file)
@@ -160,6 +160,8 @@ haproxy h1 -conf {
        http-response set-header     sl1-crc "%[res.fhdr(sl1),crc32]"
        http-response set-header     sl2-crc "%[res.fhdr(sl2),crc32]"
        http-response set-header     hdr-crc "%[res.fhdr(hdr),crc32]"
+       http-response allow
+       http-response deny # must not be evaluated
 
        server s1 ${s1_addr}:${s1_port}
 } -start
index c037261cf67591b79bc11cb6671b01c9e89007eb..341a9f87008c6eda8aba4c3065dc80eae697ae4d 100644 (file)
@@ -1815,7 +1815,7 @@ int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, s
 
        while (1) {
                /* evaluate http-response rules */
-               if (ret == HTTP_RULE_RES_CONT) {
+               if (ret == HTTP_RULE_RES_CONT || ret == HTTP_RULE_RES_STOP) {
                        struct list *def_rules, *rules;
 
                        def_rules = ((cur_proxy->defpx && (cur_proxy == s->be || cur_proxy->defpx != s->be->defpx)) ? &cur_proxy->defpx->http_res_rules : NULL);