]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: map: list-based matching potential ordering regression
authorAurelien DARRAGON <adarragon@haproxy.com>
Wed, 3 Jan 2024 10:54:03 +0000 (11:54 +0100)
committerAurelien DARRAGON <adarragon@haproxy.com>
Wed, 10 Jan 2024 17:02:13 +0000 (18:02 +0100)
commitb546bb6d67145db0ebd14c79d72199064208dc2f
treec6f3cafdf7fee6a92437c1f1a06de827b4a61540
parent37d5a26cc5a5ebe1abeb2836f89424e33408a186
BUG/MINOR: map: list-based matching potential ordering regression

An unexpected side-effect was introduced by 5fea597 ("MEDIUM: map/acl:
Accelerate several functions using pat_ref_elt struct ->head list")

The above commit tried to use eb tree API to manipulate elements as much
as possible in the hope to accelerate some functions.

Prior to 5fea597, pattern_read_from_file() used to iterate over all
elements from the map file in the same order they were seen in the file
(using list_for_each_entry) to push them in the pattern expression.

Now, since eb api is used to iterate over elements, the ordering is lost
very early.

This is known to cause behavior changes with existing setups (same conf
and map file) when compared with previous versions for some list-based
matching methods as described in GH #2400. For instance, the map_dom()
converter may return a different matching key from the one that was
returned by older haproxy versions.

For IP or STR matching, matching is based on tree lookups for better
efficiency, so in this case the ordering is lost at the name of
performance. The order in which they are loaded doesn't matter because
tree ordering is based on the content, it is not positional.

But with some other types, matching is based on list lookups (e.g.: dom),
and the order in which elements are pushed into the list can affect the
matching element that will be returned (in case of multiple matches, since
only the first matching element in the list will be returned).

Despite the documentation not officially stating that the file ordering
should be preserved for list-based matching methods, it's probably best
to be conservative here and stick to historical behavior. Moreover, there
was no performance benefit from using the eb tree api to iterate over
elements in pattern_read_from_file() since all elements are visited
anyway.

This should be backported to 2.9.
src/pattern.c