]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: stick-table: Wrong stick-table backends parsing.
authorFrédéric Lécaille <flecaille@haproxy.com>
Wed, 7 Aug 2019 07:28:39 +0000 (09:28 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Aug 2019 08:32:31 +0000 (10:32 +0200)
When parsing references to stick-tables declared as backends, they are added to
a list of proxies (they are proxies!) which refer to this stick-tables.
Before this patch we added them to these list without checking they were already
present, making the silly hypothesis the actions/sample were checked/resolved in the same
order the proxies are parsed.

This patch implement a simple inline function to in_proxies_list() to test
the presence of a proxy in a list of proxies. We use this function when resolving
/checking samples/actions.

This bug was introduced by 015e4d7 commit.

Must be backported to 2.0.

include/proto/proxy.h
src/action.c
src/sample.c

index c75c0da21e1405c4b44e97576ee1e278af9f796e..558718ba237ed6ac8eb2cd75be0efdfa65de064e 100644 (file)
@@ -184,6 +184,21 @@ static inline int l7_status_match(struct proxy *p, int status)
        }
        return 0;
 }
+
+/* Return 1 if <p> proxy is in <list> list of proxies which are also stick-tables,
+ * 0 if not.
+ */
+static inline int in_proxies_list(struct proxy *list, struct proxy *proxy)
+{
+       struct proxy *p;
+
+       for (p = list; p; p = p->next_stkt_ref)
+               if (proxy == p)
+                       return 1;
+
+       return 0;
+}
+
 #endif /* _PROTO_PROXY_H */
 
 /*
index 54542420cf5f10f0469cd719984d86ac14a7fa3c..76842022c8af04cf71ae225e7c4ddd77e7ab629e 100644 (file)
@@ -56,7 +56,7 @@ int check_trk_action(struct act_rule *rule, struct proxy *px, char **err)
                return 0;
        }
        else {
-               if (target->proxies_list != px) {
+               if (!in_proxies_list(target->proxies_list, px)) {
                        px->next_stkt_ref = target->proxies_list;
                        target->proxies_list = px;
                }
index 94c605f9279b02754a5c534cf7c219cef66c731a..6327b6b08dc3f8db88c8c68ef5db500882df77d7 100644 (file)
@@ -1274,7 +1274,7 @@ int smp_resolve_args(struct proxy *p)
                                break;
                        }
 
-                       if (t->proxies_list != p) {
+                       if (!in_proxies_list(t->proxies_list, p)) {
                                p->next_stkt_ref = t->proxies_list;
                                t->proxies_list = p;
                        }