MINOR: map/acl: print the count of all the map/acl entries in "show map/acl"

The output of "show map/acl" now contains the 'entry_cnt' value that
represents the count of all the entries for each map/acl, not just the
active ones, which means that it also includes entries currently being
added.
This commit is contained in:
Dragan Dosen 2021-05-21 16:59:15 +02:00 committed by Willy Tarreau
parent acfd71b97a
commit a75eea78e2
4 changed files with 21 additions and 4 deletions

View File

@ -2220,7 +2220,9 @@ show acl [[@<ver>] <acl>]
versions will simply report no result. The dump format is the same as for the
maps even for the sample values. The data returned are not a list of
available ACL, but are the list of all patterns composing any ACL. Many of
these patterns can be shared with maps.
these patterns can be shared with maps. The 'entry_cnt' value represents the
count of all the ACL entries, not just the active ones, which means that it
also includes entries currently being added.
show backend
Dump the list of backends available in the running process
@ -2523,7 +2525,9 @@ show map [[@<ver>] <map>]
version currently being matched against and reported as 'curr_ver' in the map
list). It is possible to instead dump other versions by prepending '@<ver>'
before the map's identifier. The version works as a filter and non-existing
versions will simply report no result.
versions will simply report no result. The 'entry_cnt' value represents the
count of all the map entries, not just the active ones, which means that it
also includes entries currently being added.
In the output, the first column is a unique entry identifier, which is usable
as a reference for operations "del map" and "set map". The second column is

View File

@ -110,6 +110,7 @@ struct pat_ref {
unsigned int next_gen; /* next generation number (insertions use this one) */
int unique_id; /* Each pattern reference have unique id. */
unsigned long long revision; /* updated for each update */
unsigned long long entry_cnt; /* the total number of entries */
__decl_thread(HA_SPINLOCK_T lock); /* Lock used to protect pat ref elements */
};

View File

@ -439,9 +439,10 @@ static int cli_io_handler_pats_list(struct appctx *appctx)
/* Build messages. If the reference is used by another category than
* the listed categories, display the information in the message.
*/
chunk_appendf(&trash, "%d (%s) %s. curr_ver=%u next_ver=%u\n", appctx->ctx.map.ref->unique_id,
chunk_appendf(&trash, "%d (%s) %s. curr_ver=%u next_ver=%u entry_cnt=%llu\n", appctx->ctx.map.ref->unique_id,
appctx->ctx.map.ref->reference ? appctx->ctx.map.ref->reference : "",
appctx->ctx.map.ref->display, appctx->ctx.map.ref->curr_gen, appctx->ctx.map.ref->next_gen);
appctx->ctx.map.ref->display, appctx->ctx.map.ref->curr_gen, appctx->ctx.map.ref->next_gen,
appctx->ctx.map.ref->entry_cnt);
if (ci_putchk(si_ic(si), &trash) == -1) {
/* let's try again later from this stream. We add ourselves into

View File

@ -1177,6 +1177,7 @@ void pat_prune_gen(struct pattern_expr *expr)
free_pattern_tree(&expr->pattern_tree_2);
LIST_INIT(&expr->patterns);
expr->ref->revision = rdtsc();
expr->ref->entry_cnt = 0;
}
/*
@ -1205,6 +1206,7 @@ int pat_idx_list_val(struct pattern_expr *expr, struct pattern *pat, char **err)
patl->from_ref = pat->ref->list_head;
pat->ref->list_head = &patl->from_ref;
expr->ref->revision = rdtsc();
expr->ref->entry_cnt++;
/* that's ok */
return 1;
@ -1237,6 +1239,7 @@ int pat_idx_list_ptr(struct pattern_expr *expr, struct pattern *pat, char **err)
patl->from_ref = pat->ref->list_head;
pat->ref->list_head = &patl->from_ref;
expr->ref->revision = rdtsc();
expr->ref->entry_cnt++;
/* that's ok */
return 1;
@ -1270,6 +1273,7 @@ int pat_idx_list_str(struct pattern_expr *expr, struct pattern *pat, char **err)
patl->from_ref = pat->ref->list_head;
pat->ref->list_head = &patl->from_ref;
expr->ref->revision = rdtsc();
expr->ref->entry_cnt++;
/* that's ok */
return 1;
@ -1303,6 +1307,7 @@ int pat_idx_list_reg_cap(struct pattern_expr *expr, struct pattern *pat, int cap
patl->from_ref = pat->ref->list_head;
pat->ref->list_head = &patl->from_ref;
expr->ref->revision = rdtsc();
expr->ref->entry_cnt++;
/* that's ok */
return 1;
@ -1354,6 +1359,7 @@ int pat_idx_tree_ip(struct pattern_expr *expr, struct pattern *pat, char **err)
node->from_ref = pat->ref->tree_head;
pat->ref->tree_head = &node->from_ref;
expr->ref->revision = rdtsc();
expr->ref->entry_cnt++;
/* that's ok */
return 1;
@ -1384,6 +1390,7 @@ int pat_idx_tree_ip(struct pattern_expr *expr, struct pattern *pat, char **err)
node->from_ref = pat->ref->tree_head;
pat->ref->tree_head = &node->from_ref;
expr->ref->revision = rdtsc();
expr->ref->entry_cnt++;
/* that's ok */
return 1;
@ -1430,6 +1437,7 @@ int pat_idx_tree_str(struct pattern_expr *expr, struct pattern *pat, char **err)
node->from_ref = pat->ref->tree_head;
pat->ref->tree_head = &node->from_ref;
expr->ref->revision = rdtsc();
expr->ref->entry_cnt++;
/* that's ok */
return 1;
@ -1474,6 +1482,7 @@ int pat_idx_tree_pfx(struct pattern_expr *expr, struct pattern *pat, char **err)
node->from_ref = pat->ref->tree_head;
pat->ref->tree_head = &node->from_ref;
expr->ref->revision = rdtsc();
expr->ref->entry_cnt++;
/* that's ok */
return 1;
@ -1517,6 +1526,7 @@ void pat_delete_gen(struct pat_ref *ref, struct pat_ref_elt *elt)
/* update revision number to refresh the cache */
ref->revision = rdtsc();
ref->entry_cnt--;
elt->tree_head = NULL;
elt->list_head = NULL;
}
@ -1819,6 +1829,7 @@ struct pat_ref *pat_ref_new(const char *reference, const char *display, unsigned
ref->flags = flags;
ref->unique_id = -1;
ref->revision = 0;
ref->entry_cnt = 0;
LIST_INIT(&ref->head);
LIST_INIT(&ref->pat);