Commit a2dbc597 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Renovate ban related statistics, add long descriptions etc.

parent 0fe28b30
......@@ -376,7 +376,6 @@ void
BAN_Insert(struct ban *b)
{
struct ban *bi, *be;
unsigned pcount;
ssize_t ln;
double t0;
......@@ -402,8 +401,10 @@ BAN_Insert(struct ban *b)
Lck_Lock(&ban_mtx);
VTAILQ_INSERT_HEAD(&ban_head, b, list);
ban_start = b;
VSC_C_main->n_ban++;
VSC_C_main->n_ban_add++;
VSC_C_main->bans++;
VSC_C_main->bans_added++;
if (b->flags & BAN_F_REQ)
VSC_C_main->bans_req++;
be = VTAILQ_LAST(&ban_head, banhead_s);
if (params->ban_dups && be != b)
......@@ -419,7 +420,6 @@ BAN_Insert(struct ban *b)
/* Hunt down duplicates, and mark them as gone */
bi = b;
pcount = 0;
Lck_Lock(&ban_mtx);
while(bi != be) {
bi = VTAILQ_NEXT(bi, list);
......@@ -429,11 +429,10 @@ BAN_Insert(struct ban *b)
if (memcmp(b->spec + 8, bi->spec + 8, ln - 8))
continue;
bi->flags |= BAN_F_GONE;
VSC_C_main->n_ban_gone++;
pcount++;
VSC_C_main->bans_gone++;
VSC_C_main->bans_dups++;
}
be->refcount--;
VSC_C_main->n_ban_dups += pcount;
Lck_Unlock(&ban_mtx);
}
......@@ -520,20 +519,28 @@ BAN_Reload(const uint8_t *ban, unsigned len)
t0 = ban_time(ban);
assert(len == ban_len(ban));
Lck_Lock(&ban_mtx);
VTAILQ_FOREACH(b, &ban_head, list) {
t1 = ban_time(b->spec);
assert (t1 < t2);
t2 = t1;
if (t1 == t0)
if (t1 == t0) {
Lck_Unlock(&ban_mtx);
return;
}
if (t1 < t0)
break;
if (!memcmp(b->spec + 8, ban + 8, len - 8))
if (!memcmp(b->spec + 8, ban + 8, len - 8)) {
gone |= BAN_F_GONE;
VSC_C_main->bans_dups++;
VSC_C_main->bans_gone++;
}
}
VSC_C_main->n_ban++;
VSC_C_main->n_ban_add++;
VSC_C_main->bans++;
VSC_C_main->bans_added++;
b2 = BAN_New();
AN(b2);
......@@ -552,9 +559,13 @@ BAN_Reload(const uint8_t *ban, unsigned len)
for (b = VTAILQ_NEXT(b2, list); b != NULL; b = VTAILQ_NEXT(b, list)) {
if (b->flags & BAN_F_GONE)
continue;
if (!memcmp(b->spec + 8, ban + 8, len - 8))
if (!memcmp(b->spec + 8, ban + 8, len - 8)) {
b->flags |= BAN_F_GONE;
VSC_C_main->bans_dups++;
VSC_C_main->bans_gone++;
}
}
Lck_Unlock(&ban_mtx);
}
/*--------------------------------------------------------------------
......@@ -705,8 +716,8 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req)
}
Lck_Lock(&ban_mtx);
VSC_C_main->n_ban_obj_test++;
VSC_C_main->n_ban_re_test += tests;
VSC_C_main->bans_tested++;
VSC_C_main->bans_tests_tested += tests;
if (b == oc->ban && skipped > 0) {
AZ(has_req);
......@@ -758,9 +769,11 @@ ban_CheckLast(void)
b = VTAILQ_LAST(&ban_head, banhead_s);
if (b != VTAILQ_FIRST(&ban_head) && b->refcount == 0) {
if (b->flags & BAN_F_GONE)
VSC_C_main->n_ban_gone--;
VSC_C_main->n_ban--;
VSC_C_main->n_ban_retire++;
VSC_C_main->bans_gone--;
if (b->flags & BAN_F_REQ)
VSC_C_main->bans_req--;
VSC_C_main->bans--;
VSC_C_main->bans_deleted++;
VTAILQ_REMOVE(&ban_head, b, list);
} else {
b = NULL;
......@@ -888,7 +901,7 @@ ban_lurker_work(const struct sess *sp, unsigned pass)
if (!(b->flags & BAN_F_REQ)) {
if (!(b->flags & BAN_F_GONE)) {
b->flags |= BAN_F_GONE;
VSC_C_main->n_ban_gone++;
VSC_C_main->bans_gone++;
}
if (params->diag_bitmap & 0x80000)
VSL(SLT_Debug, 0, "lurker BAN %f now gone",
......@@ -1090,6 +1103,6 @@ BAN_Init(void)
ban_magic = BAN_New();
AN(ban_magic);
ban_magic->flags |= BAN_F_GONE;
VSC_C_main->n_ban_gone++;
VSC_C_main->bans_gone++;
BAN_Insert(ban_magic);
}
......@@ -16,7 +16,7 @@ varnish v1 -vcl+backend {} -start
varnish v1 -cliok "ban.url FOO"
# There is one "magic" ban from boot
varnish v1 -expect n_ban_add == 2
varnish v1 -expect bans_added == 2
varnish v1 -cliok "ban.list"
# Our fetch is not affected by the ban
......@@ -31,12 +31,12 @@ client c1 {
} -run
varnish v1 -cliok "ban.list"
varnish v1 -expect n_ban_obj_test == 0
varnish v1 -expect n_ban_re_test == 0
varnish v1 -expect bans_tested == 0
varnish v1 -expect bans_tests_tested == 0
# Add another ban
varnish v1 -cliok "ban.url FOO"
varnish v1 -expect n_ban_add == 3
varnish v1 -expect bans_added == 3
varnish v1 -cliok "ban.list"
# The cached object will be band, and a new
......@@ -47,8 +47,8 @@ client c1 {
expect resp.http.foo == 2
} -run
varnish v1 -expect n_ban_obj_test == 1
varnish v1 -expect n_ban_re_test == 1
varnish v1 -expect bans_tested == 1
varnish v1 -expect bans_tests_tested == 1
varnish v1 -cliok "ban.list"
# Fetch the cached copy, just for grins
......@@ -62,15 +62,15 @@ client c1 {
# Now add another two bans, Kilroy should not be hit
varnish v1 -cliok "ban.url KILROY"
varnish v1 -cliok "ban.url FOO"
varnish v1 -expect n_ban_add == 5
varnish v1 -expect bans_added == 5
# Enable dup removal of bans
varnish v1 -cliok "param.set ban_dups on"
# This should incapacitate the two previous FOO bans.
varnish v1 -cliok "ban.url FOO"
varnish v1 -expect n_ban_add == 6
varnish v1 -expect n_ban_dups == 3
varnish v1 -expect bans_added == 6
varnish v1 -expect bans_dups == 3
varnish v1 -cliok "ban.list"
# And we should get a fresh object from backend
......@@ -81,8 +81,8 @@ client c1 {
} -run
# With only two objects having ever been compared
varnish v1 -expect n_ban_obj_test == 2
varnish v1 -expect n_ban_re_test == 2
varnish v1 -expect bans_tested == 2
varnish v1 -expect bans_tests_tested == 2
varnish v1 -cliok "ban.list"
# Test a bogus regexp
......
......@@ -49,8 +49,8 @@ client c1 {
delay 0.1
varnish v1 -cliok "ban req.url == /alpha"
varnish v1 -cliok "ban.list"
varnish v1 -expect n_ban == 2
varnish v1 -expect n_ban_gone == 1
varnish v1 -expect bans == 2
varnish v1 -expect bans_gone == 1
client c1 {
txreq -url "/beta"
......@@ -61,7 +61,7 @@ client c1 {
delay 0.1
varnish v1 -cliok "ban obj.http.foo == /beta"
varnish v1 -cliok "ban.list"
varnish v1 -expect n_ban == 3
varnish v1 -expect bans == 3
client c1 {
txreq -url "/gamma"
......@@ -72,7 +72,7 @@ client c1 {
delay 0.1
varnish v1 -cliok "ban obj.http.foo == /gamma"
varnish v1 -cliok "ban.list"
varnish v1 -expect n_ban == 4
varnish v1 -expect bans == 4
client c1 {
txreq -url "/delta"
......@@ -83,22 +83,22 @@ client c1 {
delay 0.1
varnish v1 -cliok "ban req.url == /delta"
varnish v1 -expect n_ban_gone == 1
varnish v1 -expect bans_gone == 1
varnish v1 -cliok "ban obj.http.foo == /gamma"
# Dup-check should have added one
varnish v1 -expect n_ban_gone == 2
varnish v1 -expect bans_gone == 2
varnish v1 -cliok "ban req.url == /epsilon"
varnish v1 -cliok "ban.list"
varnish v1 -expect n_ban == 7
varnish v1 -expect n_ban_gone == 2
varnish v1 -expect bans == 7
varnish v1 -expect bans_gone == 2
varnish v1 -cliok "param.set ban_lurker_sleep .01"
delay 1
varnish v1 -cliok "param.set ban_lurker_sleep .00"
varnish v1 -cliok "ban.list"
varnish v1 -expect n_ban == 7
varnish v1 -expect n_ban_gone == 4
varnish v1 -expect bans == 7
varnish v1 -expect bans_gone == 4
client c1 {
txreq -url "/alpha"
......@@ -108,7 +108,7 @@ client c1 {
delay 1
varnish v1 -cliok "ban.list"
varnish v1 -expect n_ban == 4
varnish v1 -expect bans == 4
client c1 {
txreq -url "/beta"
......@@ -127,5 +127,7 @@ client c1 {
delay 1
varnish v1 -cliok "ban.list"
varnish v1 -expect n_ban == 1
varnish v1 -expect n_ban_gone == 0
varnish v1 -expect bans == 1
varnish v1 -expect bans_gone == 0
varnish v1 -expect bans_added == 7
varnish v1 -expect bans_deleted == 6
......@@ -36,4 +36,4 @@ varnish v1 -start
varnish v1 -cliok ban.list
# Count of 3 here, because two "magic" bans are also there"
varnish v1 -expect n_ban == 3
varnish v1 -expect bans == 3
......@@ -21,4 +21,4 @@ foo
varnish v1 -cliok ban.list
varnish v1 -expect n_ban_add == 2
varnish v1 -expect bans_added == 2
......@@ -26,7 +26,7 @@ varnish v1 -vcl+backend {
} -start
varnish v1 -cliok "param.set ban_lurker_sleep 0.01"
varnish v1 -expect n_ban_obj_test == 0
varnish v1 -expect bans_tests_tested == 0
delay 0.01
client c1 {
......@@ -40,10 +40,10 @@ client c1 {
} -run
delay 0.1
varnish v1 -expect n_ban_obj_test == 0
varnish v1 -expect bans_tests_tested == 0
delay 1.0
varnish v1 -expect n_ban_obj_test == 1
varnish v1 -expect bans_tests_tested == 1
varnish v1 -cliok "param.set ban_lurker_sleep 5.01"
......@@ -58,7 +58,7 @@ client c2 {
} -run
delay 0.1
varnish v1 -expect n_ban_obj_test == 1
varnish v1 -expect bans_tests_tested == 1
delay 1.1
varnish v1 -expect n_ban_obj_test == 2
varnish v1 -expect bans_tests_tested == 2
......@@ -41,6 +41,10 @@
* e - Explantion: Short explanation of field (for screen use)
* d - Description: Long explanation of field (for doc use)
*
* Please describe Gauge variables as "Number of..." to indicate that
* this is a snapshot, and Counter variables as "Count of" to indicate
* accumulative count.
*
* -----------------------
* NB: Cleanup in progress
* -----------------------
......@@ -297,13 +301,49 @@ VSC_F(n_vcl, uint64_t, 0, 'a', "N vcl total", "")
VSC_F(n_vcl_avail, uint64_t, 0, 'a', "N vcl available", "")
VSC_F(n_vcl_discard, uint64_t, 0, 'a', "N vcl discarded", "")
VSC_F(n_ban, uint64_t, 0, 'i', "N total active bans", "")
VSC_F(n_ban_gone, uint64_t, 0, 'i', "N total gone bans", "")
VSC_F(n_ban_add, uint64_t, 0, 'a', "N new bans added", "")
VSC_F(n_ban_retire, uint64_t, 0, 'a', "N old bans deleted", "")
VSC_F(n_ban_obj_test, uint64_t, 0, 'a', "N objects tested", "")
VSC_F(n_ban_re_test, uint64_t, 0, 'a', "N regexps tested against", "")
VSC_F(n_ban_dups, uint64_t, 0, 'a', "N duplicate bans removed", "")
/**********************************************************************/
VSC_F(bans, uint64_t, 0, 'g',
"Count of bans",
"Number of all bans in system, including bans superseded"
" by newer bans and bans already checked by the ban-lurker."
)
VSC_F(bans_gone, uint64_t, 0, 'g',
"Number of bans marked 'gone'",
"Number of bans which are no longer active, either because they"
" got checked by the ban-lurker or superseded by newer identical bans."
)
VSC_F(bans_req, uint64_t, 0, 'g',
"Number of bans using req.*",
"Number of bans which use req.* variables. These bans can not"
" be washed by the ban-lurker."
)
VSC_F(bans_added, uint64_t, 0, 'c',
"Bans added",
"Counter of bans added to ban list."
)
VSC_F(bans_deleted, uint64_t, 0, 'c',
"Bans deleted",
"Counter of bans deleted from ban list."
)
VSC_F(bans_tested, uint64_t, 0, 'c',
"Bans tested against objects",
"Count of how many bans and objects have been tested against"
" each other."
)
VSC_F(bans_tests_tested, uint64_t, 0, 'c',
"Ban tests tested against objects",
"Count of how many tests and objects have been tested against"
" each other. 'ban req.url == foo && req.http.host == bar'"
" counts as one in 'bans_tested' and as two in 'bans_tests_tested'"
)
VSC_F(bans_dups, uint64_t, 0, 'c',
"Bans superseded by other bans",
"Count of bans replaced by later identical bans."
)
/**********************************************************************/
VSC_F(hcb_nolock, uint64_t, 0, 'a', "HCB Lookups without lock", "")
VSC_F(hcb_lock, uint64_t, 0, 'a', "HCB Lookups with lock", "")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment