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.
This commit is contained in:
Frdric Lcaille 2019-03-19 14:55:01 +01:00 committed by Willy Tarreau
parent 1b8e68e89a
commit 015e4d7d93
6 changed files with 30 additions and 0 deletions

View File

@ -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 */

View File

@ -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];

View File

@ -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

View File

@ -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;

View File

@ -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 <stktables_list>
* 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;

View File

@ -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;