From 015e4d7d93a2a34e79bd08e832046708e5d37f1e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Tue, 19 Mar 2019 14:55:01 +0100 Subject: [PATCH] MINOR: stick-tables: Add peers process binding computing. Add a list of proxies for all the stick-tables (->proxies_list struct stktable member) so that to be able to compute the process bindings of the peers after having parsed the configuration file. The proxies are added to the stick-tables they reference when parsing stick-tables lines in proxy sections, when checking the actions in check_trk_action() and when resolving samples args for stick-tables without checking is they are duplicates. We check only there is no loop. Then, after having parsed everything, we add the proxy bindings to the peers frontend bindings with stick-tables they reference. --- include/types/proxy.h | 1 + include/types/stick_table.h | 1 + src/action.c | 4 ++++ src/cfgparse-listen.c | 6 ++++++ src/cfgparse.c | 13 +++++++++++++ src/sample.c | 5 +++++ 6 files changed, 30 insertions(+) diff --git a/include/types/proxy.h b/include/types/proxy.h index f6d2634f6e..45ef2c824a 100644 --- a/include/types/proxy.h +++ b/include/types/proxy.h @@ -395,6 +395,7 @@ struct proxy { struct conn_src conn_src; /* connection source settings */ enum obj_type *default_target; /* default target to use for accepted streams or NULL */ struct proxy *next; + struct proxy *next_stkt_ref; /* Link to the list of proxies which refer to the same stick-table. */ struct list logsrvs; struct list logformat; /* log_format linked list */ diff --git a/include/types/stick_table.h b/include/types/stick_table.h index ff9546cd50..a4baeb37ee 100644 --- a/include/types/stick_table.h +++ b/include/types/stick_table.h @@ -185,6 +185,7 @@ struct stktable { void *p; } data_arg[STKTABLE_DATA_TYPES]; /* optional argument of each data type */ struct proxy *proxy; /* The proxy this stick-table is attached to, if any.*/ + struct proxy *proxies_list; /* The list of proxies which reference this stick-table. */ }; extern struct stktable_data_type stktable_data_types[STKTABLE_DATA_TYPES]; diff --git a/src/action.c b/src/action.c index 4cce7a4181..54542420cf 100644 --- a/src/action.c +++ b/src/action.c @@ -56,6 +56,10 @@ int check_trk_action(struct act_rule *rule, struct proxy *px, char **err) return 0; } else { + if (target->proxies_list != px) { + px->next_stkt_ref = target->proxies_list; + target->proxies_list = px; + } free(rule->arg.trk_ctr.table.n); rule->arg.trk_ctr.table.t = target; /* Note: if we decide to enhance the track-sc syntax, we may be diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index 2b2785a553..7537bc2eca 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -1749,6 +1749,12 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) stktable_store_name(curproxy->table); curproxy->table->next = stktables_list; stktables_list = curproxy->table; + + /* Add this proxy to the list of proxies which refer to its stick-table. */ + if (curproxy->table->proxies_list != curproxy) { + curproxy->next_stkt_ref = curproxy->table->proxies_list; + curproxy->table->proxies_list = curproxy; + } } else if (!strcmp(args[0], "stick")) { struct sticking_rule *rule; diff --git a/src/cfgparse.c b/src/cfgparse.c index 3e326330fb..c7db11068e 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -3861,6 +3861,19 @@ out_uri_auth_compat: if (curproxy->table && curproxy->table->peers.p) curproxy->table->peers.p->peers_fe->bind_proc |= curproxy->bind_proc; + /* compute the required process bindings for the peers from + * for all the stick-tables, the ones coming with "peers" sections included. + */ + for (t = stktables_list; t; t = t->next) { + struct proxy *p; + + for (p = t->proxies_list; p; p = p->next_stkt_ref) { + if (t->peers.p && t->peers.p->peers_fe) { + t->peers.p->peers_fe->bind_proc |= p->bind_proc; + } + } + } + if (cfg_peers) { struct peers *curpeers = cfg_peers, **last; struct peer *p, *pb; diff --git a/src/sample.c b/src/sample.c index aa20d35d1e..2a1ce8d5e3 100644 --- a/src/sample.c +++ b/src/sample.c @@ -1278,6 +1278,11 @@ int smp_resolve_args(struct proxy *p) break; } + if (t->proxies_list != p) { + p->next_stkt_ref = t->proxies_list; + t->proxies_list = p; + } + free(arg->data.str.area); arg->data.str.area = NULL; arg->unresolved = 0; -- 2.39.5