l->default_target = curpeers->peers_fe->default_target;
l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
global.maxsock++; /* for the listening socket */
- } /* neither "peer" nor "peers" */
+ }
+ else if (!strcmp(args[0], "table")) {
+ struct stktable *t, *other;
+ char *id;
+
+ /* Line number and peer ID are updated only if this peer is the local one. */
+ if (init_peers_frontend(file, -1, NULL, curpeers) != 0) {
+ err_code |= ERR_ALERT | ERR_ABORT;
+ goto out;
+ }
+
+ other = stktable_find_by_name(args[1]);
+ if (other) {
+ ha_alert("parsing [%s:%d] : stick-table name '%s' conflicts with table declared in %s '%s' at %s:%d.\n",
+ file, linenum, args[1],
+ other->proxy ? proxy_cap_str(other->proxy->cap) : "peers",
+ other->proxy ? other->id : other->peers.p->id,
+ other->conf.file, other->conf.line);
+ err_code |= ERR_ALERT | ERR_FATAL;
+ goto out;
+ }
+
+ t = calloc(1, sizeof *t);
+ id = strdup(args[1]);
+ if (!t || !id) {
+ ha_alert("parsing [%s:%d]: '%s %s' : memory allocation failed\n",
+ file, linenum, args[0], args[1]);
+ err_code |= ERR_ALERT | ERR_FATAL;
+ goto out;
+ }
+
+ err_code |= parse_stick_table(file, linenum, args, t, id, curpeers);
+ if (err_code & ERR_FATAL)
+ goto out;
+
+ stktable_store_name(t);
+ t->next = stktables_list;
+ stktables_list = t;
+ }
else if (!strcmp(args[0], "disabled")) { /* disables this peers section */
curpeers->state = PR_STSTOPPED;
}
{
int cfgerr = 0;
struct proxy *curproxy = NULL;
+ struct stktable *t;
struct server *newsrv = NULL;
int err_code = 0;
unsigned int next_pxid = 1;
if (curproxy->state == PR_STSTOPPED) {
/* ensure we don't keep listeners uselessly bound */
stop_proxy(curproxy);
- free((void *)curproxy->table.peers.name);
- curproxy->table.peers.p = NULL;
+ free((void *)curproxy->table->peers.name);
+ curproxy->table->peers.p = NULL;
continue;
}
/* find the target table for 'stick' rules */
list_for_each_entry(mrule, &curproxy->sticking_rules, list) {
- struct proxy *target;
+ struct stktable *target;
curproxy->be_req_ana |= AN_REQ_STICKING_RULES;
if (mrule->flags & STK_IS_STORE)
curproxy->be_rsp_ana |= AN_RES_STORE_RULES;
if (mrule->table.name)
- target = proxy_tbl_by_name(mrule->table.name);
+ target = stktable_find_by_name(mrule->table.name);
else
- target = curproxy;
+ target = curproxy->table;
if (!target) {
ha_alert("Proxy '%s': unable to find stick-table '%s'.\n",
curproxy->id, mrule->table.name);
cfgerr++;
}
- else if (target->table.size == 0) {
- ha_alert("Proxy '%s': stick-table '%s' used but not configured.\n",
- curproxy->id, mrule->table.name ? mrule->table.name : curproxy->id);
- cfgerr++;
- }
- else if (!stktable_compatible_sample(mrule->expr, target->table.type)) {
+ else if (!stktable_compatible_sample(mrule->expr, target->type)) {
ha_alert("Proxy '%s': type of fetch not usable with type of stick-table '%s'.\n",
curproxy->id, mrule->table.name ? mrule->table.name : curproxy->id);
cfgerr++;
}
- else if (curproxy->bind_proc & ~target->bind_proc) {
+ else if (target->proxy && curproxy->bind_proc & ~target->proxy->bind_proc) {
ha_alert("Proxy '%s': stick-table '%s' referenced 'stick-store' rule not present on all processes covered by proxy '%s'.\n",
curproxy->id, target->id, curproxy->id);
cfgerr++;
}
else {
free((void *)mrule->table.name);
- mrule->table.t = &(target->table);
- stktable_alloc_data_type(&target->table, STKTABLE_DT_SERVER_ID, NULL);
+ mrule->table.t = target;
+ stktable_alloc_data_type(target, STKTABLE_DT_SERVER_ID, NULL);
}
}
/* find the target table for 'store response' rules */
list_for_each_entry(mrule, &curproxy->storersp_rules, list) {
- struct proxy *target;
+ struct stktable *target;
curproxy->be_rsp_ana |= AN_RES_STORE_RULES;
if (mrule->table.name)
- target = proxy_tbl_by_name(mrule->table.name);
+ target = stktable_find_by_name(mrule->table.name);
else
- target = curproxy;
+ target = curproxy->table;
if (!target) {
ha_alert("Proxy '%s': unable to find store table '%s'.\n",
curproxy->id, mrule->table.name);
cfgerr++;
}
- else if (target->table.size == 0) {
- ha_alert("Proxy '%s': stick-table '%s' used but not configured.\n",
- curproxy->id, mrule->table.name ? mrule->table.name : curproxy->id);
- cfgerr++;
- }
- else if (!stktable_compatible_sample(mrule->expr, target->table.type)) {
+ else if (!stktable_compatible_sample(mrule->expr, target->type)) {
ha_alert("Proxy '%s': type of fetch not usable with type of stick-table '%s'.\n",
curproxy->id, mrule->table.name ? mrule->table.name : curproxy->id);
cfgerr++;
}
- else if (curproxy->bind_proc & ~target->bind_proc) {
+ else if (target->proxy && (curproxy->bind_proc & ~target->proxy->bind_proc)) {
ha_alert("Proxy '%s': stick-table '%s' referenced 'stick-store' rule not present on all processes covered by proxy '%s'.\n",
curproxy->id, target->id, curproxy->id);
cfgerr++;
}
else {
free((void *)mrule->table.name);
- mrule->table.t = &(target->table);
- stktable_alloc_data_type(&target->table, STKTABLE_DT_SERVER_ID, NULL);
+ mrule->table.t = target;
+ stktable_alloc_data_type(target, STKTABLE_DT_SERVER_ID, NULL);
}
}
LIST_INIT(&curproxy->block_rules);
}
- if (curproxy->table.peers.name) {
+ if (curproxy->table && curproxy->table->peers.name) {
struct peers *curpeers;
for (curpeers = cfg_peers; curpeers; curpeers = curpeers->next) {
- if (strcmp(curpeers->id, curproxy->table.peers.name) == 0) {
- free((void *)curproxy->table.peers.name);
- curproxy->table.peers.p = curpeers;
+ if (strcmp(curpeers->id, curproxy->table->peers.name) == 0) {
+ free((void *)curproxy->table->peers.name);
+ curproxy->table->peers.p = curpeers;
break;
}
}
if (!curpeers) {
ha_alert("Proxy '%s': unable to find sync peers '%s'.\n",
- curproxy->id, curproxy->table.peers.name);
- free((void *)curproxy->table.peers.name);
- curproxy->table.peers.p = NULL;
+ curproxy->id, curproxy->table->peers.name);
+ free((void *)curproxy->table->peers.name);
+ curproxy->table->peers.p = NULL;
cfgerr++;
}
else if (curpeers->state == PR_STSTOPPED) {
/* silently disable this peers section */
- curproxy->table.peers.p = NULL;
+ curproxy->table->peers.p = NULL;
}
else if (!curpeers->peers_fe) {
ha_alert("Proxy '%s': unable to find local peer '%s' in peers section '%s'.\n",
curproxy->id, localpeer, curpeers->id);
- curproxy->table.peers.p = NULL;
+ curproxy->table->peers.p = NULL;
cfgerr++;
}
}
/* compute the required process bindings for the peers */
for (curproxy = proxies_list; curproxy; curproxy = curproxy->next)
- if (curproxy->table.peers.p)
- curproxy->table.peers.p->peers_fe->bind_proc |= curproxy->bind_proc;
+ if (curproxy->table && curproxy->table->peers.p)
+ curproxy->table->peers.p->peers_fe->bind_proc |= curproxy->bind_proc;
if (cfg_peers) {
struct peers *curpeers = cfg_peers, **last;
}
}
+ for (t = stktables_list; t; t = t->next) {
+ if (t->proxy)
+ continue;
+ if (!stktable_init(t)) {
+ ha_alert("Proxy '%s': failed to initialize stick-table.\n", t->id);
+ cfgerr++;
+ }
+ }
+
/* initialize stick-tables on backend capable proxies. This must not
* be done earlier because the data size may be discovered while parsing
* other proxies.
*/
for (curproxy = proxies_list; curproxy; curproxy = curproxy->next) {
- if (curproxy->state == PR_STSTOPPED)
+ if (curproxy->state == PR_STSTOPPED || !curproxy->table)
continue;
- if (!stktable_init(&curproxy->table)) {
+ if (!stktable_init(curproxy->table)) {
ha_alert("Proxy '%s': failed to initialize stick-table.\n", curproxy->id);
cfgerr++;
}
/* structure used to return a table key built from a sample */
static THREAD_LOCAL struct stktable_key static_table_key;
+struct stktable *stktables_list;
+struct eb_root stktable_by_name = EB_ROOT;
+
#define round_ptr_size(i) (((i) + (sizeof(void *) - 1)) &~ (sizeof(void *) - 1))
+
+/* This function inserts stktable <t> into the tree of known stick-table.
+ * The stick-table ID is used as the storing key so it must already have
+ * been initialized.
+ */
+void stktable_store_name(struct stktable *t)
+{
+ t->name.key = t->id;
+ ebis_insert(&stktable_by_name, &t->name);
+}
+
+struct stktable *stktable_find_by_name(const char *name)
+{
+ struct ebpt_node *node;
+ struct stktable *t;
+
+ node = ebis_lookup(&stktable_by_name, name);
+ if (node) {
+ t = container_of(node, struct stktable, name);
+ if (!strcmp(t->id, name))
+ return t;
+ }
+
+ return NULL;
+}
+
/*
* Free an allocated sticky session <ts>, and decrease sticky sessions counter
* in table <t>.
struct stktable_key *key;
struct stksess *ts;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stksess *ts;
void *ptr;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
struct stktable_key *key;
struct stksess *ts;
- t = &arg_p[0].data.prx->table;
+ t = arg_p[0].data.t;
key = smp_to_stkey(smp, t);
if (!key)
{
smp->flags = SMP_F_VOL_TEST;
smp->data.type = SMP_T_SINT;
- smp->data.u.sint = args->data.prx->table.current;
+ smp->data.u.sint = args->data.t->current;
return 1;
}
static int
smp_fetch_table_avl(const struct arg *args, struct sample *smp, const char *kw, void *private)
{
- struct proxy *px;
+ struct stktable *t;
- px = args->data.prx;
+ t = args->data.t;
smp->flags = SMP_F_VOL_TEST;
smp->data.type = SMP_T_SINT;
- smp->data.u.sint = px->table.size - px->table.current;
+ smp->data.u.sint = t->size - t->current;
return 1;
}
return NULL;
/* Converts into key. */
- key = smp_to_stkey(&smp, &args->data.prx->table);
+ key = smp_to_stkey(&smp, args->data.t);
if (!key)
return NULL;
- stkctr->table = &args->data.prx->table;
+ stkctr->table = args->data.t;
stkctr_set_entry(stkctr, stktable_lookup_key(stkctr->table, key));
return stkctr;
}
if (unlikely(args[arg].type == ARGT_TAB)) {
/* an alternate table was specified, let's look up the same key there */
- stkctr->table = &args[arg].data.prx->table;
+ stkctr->table = args[arg].data.t;
stkctr_set_entry(stkctr, stktable_lookup(stkctr->table, stksess));
return stkctr;
}
return NULL;
/* Converts into key. */
- key = smp_to_stkey(&smp, &args->data.prx->table);
+ key = smp_to_stkey(&smp, args->data.t);
if (!key)
return NULL;
- stkctr->table = &args->data.prx->table;
+ stkctr->table = args->data.t;
stkctr_set_entry(stkctr, stktable_get_entry(stkctr->table, key));
return stkctr;
}
struct stksess *ts;
struct stktable_key *key;
void *ptr;
- struct proxy *px;
+ struct stktable *t;
if (!conn)
return 0;
return 0;
/* Converts into key. */
- key = smp_to_stkey(smp, &args->data.prx->table);
+ key = smp_to_stkey(smp, args->data.t);
if (!key)
return 0;
- px = args->data.prx;
+ t = args->data.t;
- if ((ts = stktable_get_entry(&px->table, key)) == NULL)
+ if ((ts = stktable_get_entry(t, key)) == NULL)
/* entry does not exist and could not be created */
return 0;
- ptr = stktable_data_ptr(&px->table, ts, STKTABLE_DT_CONN_CNT);
+ ptr = stktable_data_ptr(t, ts, STKTABLE_DT_CONN_CNT);
if (!ptr) {
return 0; /* parameter not stored in this table */
}
smp->flags = SMP_F_VOL_TEST;
- stktable_touch_local(&px->table, ts, 1);
+ stktable_touch_local(t, ts, 1);
/* Touch was previously performed by stktable_update_key */
return 1;
*/
static int table_dump_head_to_buffer(struct buffer *msg,
struct stream_interface *si,
- struct proxy *proxy, struct proxy *target)
+ struct stktable *t, struct stktable *target)
{
struct stream *s = si_strm(si);
chunk_appendf(msg, "# table: %s, type: %s, size:%d, used:%d\n",
- proxy->id, stktable_types[proxy->table.type].kw, proxy->table.size, proxy->table.current);
+ t->id, stktable_types[t->type].kw, t->size, t->current);
/* any other information should be dumped here */
*/
static int table_dump_entry_to_buffer(struct buffer *msg,
struct stream_interface *si,
- struct proxy *proxy, struct stksess *entry)
+ struct stktable *t, struct stksess *entry)
{
int dt;
chunk_appendf(msg, "%p:", entry);
- if (proxy->table.type == SMP_T_IPV4) {
+ if (t->type == SMP_T_IPV4) {
char addr[INET_ADDRSTRLEN];
inet_ntop(AF_INET, (const void *)&entry->key.key, addr, sizeof(addr));
chunk_appendf(msg, " key=%s", addr);
}
- else if (proxy->table.type == SMP_T_IPV6) {
+ else if (t->type == SMP_T_IPV6) {
char addr[INET6_ADDRSTRLEN];
inet_ntop(AF_INET6, (const void *)&entry->key.key, addr, sizeof(addr));
chunk_appendf(msg, " key=%s", addr);
}
- else if (proxy->table.type == SMP_T_SINT) {
+ else if (t->type == SMP_T_SINT) {
chunk_appendf(msg, " key=%u", *(unsigned int *)entry->key.key);
}
- else if (proxy->table.type == SMP_T_STR) {
+ else if (t->type == SMP_T_STR) {
chunk_appendf(msg, " key=");
- dump_text(msg, (const char *)entry->key.key, proxy->table.key_size);
+ dump_text(msg, (const char *)entry->key.key, t->key_size);
}
else {
chunk_appendf(msg, " key=");
- dump_binary(msg, (const char *)entry->key.key, proxy->table.key_size);
+ dump_binary(msg, (const char *)entry->key.key, t->key_size);
}
chunk_appendf(msg, " use=%d exp=%d", entry->ref_cnt - 1, tick_remain(now_ms, entry->expire));
for (dt = 0; dt < STKTABLE_DATA_TYPES; dt++) {
void *ptr;
- if (proxy->table.data_ofs[dt] == 0)
+ if (t->data_ofs[dt] == 0)
continue;
if (stktable_data_types[dt].arg_type == ARG_T_DELAY)
- chunk_appendf(msg, " %s(%d)=", stktable_data_types[dt].name, proxy->table.data_arg[dt].u);
+ chunk_appendf(msg, " %s(%d)=", stktable_data_types[dt].name, t->data_arg[dt].u);
else
chunk_appendf(msg, " %s=", stktable_data_types[dt].name);
- ptr = stktable_data_ptr(&proxy->table, entry, dt);
+ ptr = stktable_data_ptr(t, entry, dt);
switch (stktable_data_types[dt].std_type) {
case STD_T_SINT:
chunk_appendf(msg, "%d", stktable_data_cast(ptr, std_t_sint));
case STD_T_FRQP:
chunk_appendf(msg, "%d",
read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
- proxy->table.data_arg[dt].u));
+ t->data_arg[dt].u));
break;
}
}
static int table_process_entry_per_key(struct appctx *appctx, char **args)
{
struct stream_interface *si = appctx->owner;
- struct proxy *px = appctx->ctx.table.target;
+ struct stktable *t = appctx->ctx.table.target;
struct stksess *ts;
uint32_t uint32_key;
unsigned char ip6_key[sizeof(struct in6_addr)];
return 1;
}
- switch (px->table.type) {
+ switch (t->type) {
case SMP_T_IPV4:
uint32_key = htonl(inetaddr_host(args[4]));
static_table_key.key = &uint32_key;
switch (appctx->ctx.table.action) {
case STK_CLI_ACT_SHOW:
- ts = stktable_lookup_key(&px->table, &static_table_key);
+ ts = stktable_lookup_key(t, &static_table_key);
if (!ts)
return 1;
chunk_reset(&trash);
- if (!table_dump_head_to_buffer(&trash, si, px, px)) {
- stktable_release(&px->table, ts);
+ if (!table_dump_head_to_buffer(&trash, si, t, t)) {
+ stktable_release(t, ts);
return 0;
}
HA_RWLOCK_RDLOCK(STK_SESS_LOCK, &ts->lock);
- if (!table_dump_entry_to_buffer(&trash, si, px, ts)) {
+ if (!table_dump_entry_to_buffer(&trash, si, t, ts)) {
HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- stktable_release(&px->table, ts);
+ stktable_release(t, ts);
return 0;
}
HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
- stktable_release(&px->table, ts);
+ stktable_release(t, ts);
break;
case STK_CLI_ACT_CLR:
- ts = stktable_lookup_key(&px->table, &static_table_key);
+ ts = stktable_lookup_key(t, &static_table_key);
if (!ts)
return 1;
- if (!stksess_kill(&px->table, ts, 1)) {
+ if (!stksess_kill(t, ts, 1)) {
/* don't delete an entry which is currently referenced */
appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Entry currently in use, cannot remove\n";
break;
case STK_CLI_ACT_SET:
- ts = stktable_get_entry(&px->table, &static_table_key);
+ ts = stktable_get_entry(t, &static_table_key);
if (!ts) {
/* don't delete an entry which is currently referenced */
appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "\"data.<type>\" followed by a value expected\n";
appctx->st0 = CLI_ST_PRINT;
HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
- stktable_touch_local(&px->table, ts, 1);
+ stktable_touch_local(t, ts, 1);
return 1;
}
appctx->ctx.cli.msg = "Unknown data type\n";
appctx->st0 = CLI_ST_PRINT;
HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
- stktable_touch_local(&px->table, ts, 1);
+ stktable_touch_local(t, ts, 1);
return 1;
}
- if (!px->table.data_ofs[data_type]) {
+ if (!t->data_ofs[data_type]) {
appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Data type not stored in this table\n";
appctx->st0 = CLI_ST_PRINT;
HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
- stktable_touch_local(&px->table, ts, 1);
+ stktable_touch_local(t, ts, 1);
return 1;
}
appctx->ctx.cli.msg = "Require a valid integer value to store\n";
appctx->st0 = CLI_ST_PRINT;
HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
- stktable_touch_local(&px->table, ts, 1);
+ stktable_touch_local(t, ts, 1);
return 1;
}
- ptr = stktable_data_ptr(&px->table, ts, data_type);
+ ptr = stktable_data_ptr(t, ts, data_type);
switch (stktable_data_types[data_type].std_type) {
case STD_T_SINT:
}
}
HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
- stktable_touch_local(&px->table, ts, 1);
+ stktable_touch_local(t, ts, 1);
break;
default:
return 1;
}
- if (!((struct proxy *)appctx->ctx.table.target)->table.data_ofs[appctx->ctx.table.data_type]) {
+ if (!((struct proxy *)appctx->ctx.table.target)->table->data_ofs[appctx->ctx.table.data_type]) {
appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "Data type not stored in this table\n";
appctx->st0 = CLI_ST_PRINT;
{
appctx->ctx.table.data_type = -1;
appctx->ctx.table.target = NULL;
- appctx->ctx.table.proxy = NULL;
appctx->ctx.table.entry = NULL;
appctx->ctx.table.action = (long)private; // keyword argument, one of STK_CLI_ACT_*
if (*args[2]) {
- appctx->ctx.table.target = proxy_tbl_by_name(args[2]);
+ appctx->ctx.table.target = stktable_find_by_name(args[2]);
if (!appctx->ctx.table.target) {
appctx->ctx.cli.severity = LOG_ERR;
appctx->ctx.cli.msg = "No such table\n";
if (unlikely(si_ic(si)->flags & (CF_WRITE_ERROR|CF_SHUTW))) {
/* in case of abort, remove any refcount we might have set on an entry */
if (appctx->st2 == STAT_ST_LIST) {
- stksess_kill_if_expired(&appctx->ctx.table.proxy->table, appctx->ctx.table.entry, 1);
+ stksess_kill_if_expired(appctx->ctx.table.t, appctx->ctx.table.entry, 1);
}
return 1;
}
while (appctx->st2 != STAT_ST_FIN) {
switch (appctx->st2) {
case STAT_ST_INIT:
- appctx->ctx.table.proxy = appctx->ctx.table.target;
- if (!appctx->ctx.table.proxy)
- appctx->ctx.table.proxy = proxies_list;
+ appctx->ctx.table.t = appctx->ctx.table.target;
+ if (!appctx->ctx.table.t)
+ appctx->ctx.table.t = stktables_list;
appctx->ctx.table.entry = NULL;
appctx->st2 = STAT_ST_INFO;
break;
case STAT_ST_INFO:
- if (!appctx->ctx.table.proxy ||
+ if (!appctx->ctx.table.t ||
(appctx->ctx.table.target &&
- appctx->ctx.table.proxy != appctx->ctx.table.target)) {
+ appctx->ctx.table.t != appctx->ctx.table.target)) {
appctx->st2 = STAT_ST_END;
break;
}
- if (appctx->ctx.table.proxy->table.size) {
- if (show && !table_dump_head_to_buffer(&trash, si, appctx->ctx.table.proxy, appctx->ctx.table.target))
+ if (appctx->ctx.table.t->size) {
+ if (show && !table_dump_head_to_buffer(&trash, si, appctx->ctx.table.t, appctx->ctx.table.target))
return 0;
if (appctx->ctx.table.target &&
(strm_li(s)->bind_conf->level & ACCESS_LVL_MASK) >= ACCESS_LVL_OPER) {
/* dump entries only if table explicitly requested */
- HA_SPIN_LOCK(STK_TABLE_LOCK, &appctx->ctx.table.proxy->table.lock);
- eb = ebmb_first(&appctx->ctx.table.proxy->table.keys);
+ HA_SPIN_LOCK(STK_TABLE_LOCK, &appctx->ctx.table.t->lock);
+ eb = ebmb_first(&appctx->ctx.table.t->keys);
if (eb) {
appctx->ctx.table.entry = ebmb_entry(eb, struct stksess, key);
appctx->ctx.table.entry->ref_cnt++;
appctx->st2 = STAT_ST_LIST;
- HA_SPIN_UNLOCK(STK_TABLE_LOCK, &appctx->ctx.table.proxy->table.lock);
+ HA_SPIN_UNLOCK(STK_TABLE_LOCK, &appctx->ctx.table.t->lock);
break;
}
- HA_SPIN_UNLOCK(STK_TABLE_LOCK, &appctx->ctx.table.proxy->table.lock);
+ HA_SPIN_UNLOCK(STK_TABLE_LOCK, &appctx->ctx.table.t->lock);
}
}
- appctx->ctx.table.proxy = appctx->ctx.table.proxy->next;
+ appctx->ctx.table.t = appctx->ctx.table.t->next;
break;
case STAT_ST_LIST:
dt = appctx->ctx.table.data_type;
- ptr = stktable_data_ptr(&appctx->ctx.table.proxy->table,
+ ptr = stktable_data_ptr(appctx->ctx.table.t,
appctx->ctx.table.entry,
dt);
break;
case STD_T_FRQP:
data = read_freq_ctr_period(&stktable_data_cast(ptr, std_t_frqp),
- appctx->ctx.table.proxy->table.data_arg[dt].u);
+ appctx->ctx.table.t->data_arg[dt].u);
break;
}
}
if (show && !skip_entry &&
- !table_dump_entry_to_buffer(&trash, si, appctx->ctx.table.proxy, appctx->ctx.table.entry)) {
+ !table_dump_entry_to_buffer(&trash, si, appctx->ctx.table.t, appctx->ctx.table.entry)) {
HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &appctx->ctx.table.entry->lock);
return 0;
}
HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &appctx->ctx.table.entry->lock);
- HA_SPIN_LOCK(STK_TABLE_LOCK, &appctx->ctx.table.proxy->table.lock);
+ HA_SPIN_LOCK(STK_TABLE_LOCK, &appctx->ctx.table.t->lock);
appctx->ctx.table.entry->ref_cnt--;
eb = ebmb_next(&appctx->ctx.table.entry->key);
struct stksess *old = appctx->ctx.table.entry;
appctx->ctx.table.entry = ebmb_entry(eb, struct stksess, key);
if (show)
- __stksess_kill_if_expired(&appctx->ctx.table.proxy->table, old);
+ __stksess_kill_if_expired(appctx->ctx.table.t, old);
else if (!skip_entry && !appctx->ctx.table.entry->ref_cnt)
- __stksess_kill(&appctx->ctx.table.proxy->table, old);
+ __stksess_kill(appctx->ctx.table.t, old);
appctx->ctx.table.entry->ref_cnt++;
- HA_SPIN_UNLOCK(STK_TABLE_LOCK, &appctx->ctx.table.proxy->table.lock);
+ HA_SPIN_UNLOCK(STK_TABLE_LOCK, &appctx->ctx.table.t->lock);
break;
}
if (show)
- __stksess_kill_if_expired(&appctx->ctx.table.proxy->table, appctx->ctx.table.entry);
+ __stksess_kill_if_expired(appctx->ctx.table.t, appctx->ctx.table.entry);
else if (!skip_entry && !appctx->ctx.table.entry->ref_cnt)
- __stksess_kill(&appctx->ctx.table.proxy->table, appctx->ctx.table.entry);
+ __stksess_kill(appctx->ctx.table.t, appctx->ctx.table.entry);
- HA_SPIN_UNLOCK(STK_TABLE_LOCK, &appctx->ctx.table.proxy->table.lock);
+ HA_SPIN_UNLOCK(STK_TABLE_LOCK, &appctx->ctx.table.t->lock);
- appctx->ctx.table.proxy = appctx->ctx.table.proxy->next;
+ appctx->ctx.table.t = appctx->ctx.table.t->next;
appctx->st2 = STAT_ST_INFO;
break;
static void cli_release_show_table(struct appctx *appctx)
{
if (appctx->st2 == STAT_ST_LIST) {
- stksess_kill_if_expired(&appctx->ctx.table.proxy->table, appctx->ctx.table.entry, 1);
+ stksess_kill_if_expired(appctx->ctx.table.t, appctx->ctx.table.entry, 1);
}
}