]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: pattern: Properly flag virtual maps as using samples
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 25 Sep 2025 08:03:41 +0000 (10:03 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 25 Sep 2025 08:16:53 +0000 (10:16 +0200)
When a map file is load, internally, the pattern reference is flagged as
based on a sample. However it is not performed for virtual maps. This flag
is only used during startup to check the map compatibility when it used at
different places. At runtime this does not change anything. But errors can
be triggered during configuration parsing. For instance, the following valid
config will trigger an error:

    http-request set-map(virt@test) foo bar if !{ str(foo),map(virt@test) -m found }
    http-request set-var(txn.foo) str(foo),map(virt@test)

The fix is quite obvious. PAT_REF_SMP flag must be set for virtual map as
any other map.

A workaround is to use optional map (opt@...) by checking the map id cannot
reference an existing file.

This patch must be backported as far as 3.0.

src/pattern.c

index 04a76d207efedf76204e35702d6ab727d04f0c2f..f01e693a586aa6e79d8537ab6b677ce2dcbcd01e 100644 (file)
@@ -2506,6 +2506,8 @@ int pattern_read_from_file(struct pattern_head *head, unsigned int refflags,
                                        return 0;
                        }
                }
+               else if ((ref->flags & PAT_REF_ID) && load_smp)
+                       ref->flags |= PAT_REF_SMP;
        }
        else {
                /* The reference already exists, check the map compatibility. */