]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: map/acl: print the count of all the map/acl entries in "show map/acl"
authorDragan Dosen <ddosen@haproxy.com>
Fri, 21 May 2021 14:59:15 +0000 (16:59 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 25 May 2021 06:44:45 +0000 (08:44 +0200)
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.

doc/management.txt
include/haproxy/pattern-t.h
src/map.c
src/pattern.c

index ab122fc89eceae05b93e7c1d460048afcc6b8d07..b1ef55ec23d70920e1386e010a734aca527817ea 100644 (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
index 0cd9af0ae95bf37f441d2b962ba0059711a8b238..27305b2d17ca27f0125d3e88c64b7c85f527cf7d 100644 (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 */
 };
 
index f1b2be90c815467ad312c0d3381c157d970fc324..00297022da064de64976a01e36ccd7ab376400b6 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -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
index 265b05f4866e75de95382eeaab47db683eff2624..afc0ad0d081604a029eb22f89d9a133ab9b43f41 100644 (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);