Hello Andriy,

On Sat, Jan 09, 2021 at 01:41:40AM +0200, Andriy Raketskiy wrote:
> Dear Sirs,
> 
> For example, is it possible to view only entries tracked via sc1 in
> table 'main_frontend' in the following sample configuration:
> 
> ...
> listen main_frontend
> ...
>   stick-table type ip size 10k expire 30m store
> conn_cur,conn_rate(60s),http_req_rate(60s),http_err_rate(60s)
>   tcp-request connection track-sc0 src
>   tcp-request connection track-sc1 src,ipmask(24)
> ...

I hadn't thought about this, and I understand how this could be useful.
The only solution I'm thinking about consists in filtering on the "use"
output value. I think it shouldn't be too difficult to add a "used"
extra keyword on "show table" to only dump these ones.

Are you interested in trying to implement it yourself, possibly with
some guidance ? It would be in stick-table.c, mostly the function
cli_io_handler_table(). In the STAT_ST_LIST state, I think a test
has to be inserted between the lock and the data_types test, to
basically do :

    if (filtering_on_ref_cnt && !skip_entry &&
        appctx->ctx.table.t->ref_cnt > 0)
         skip_entry = 1;

This new keyword would have to be added to cli_parse_table_req(), and
stored either into an existing field (we just need one bit to know we're
filtering on this) or in an extra field added to the CLI's context.

With this in mind, are you tempted to have a look ? :-)

Willy

Reply via email to