Skip to content

Commit ee1c7b9

Browse files
committed
vcc_acl: Add +silent acl option to omit +fold warnings
With a lot of folding going on, the warnings can easily bury more relevant CLI output.
1 parent 4b1e115 commit ee1c7b9

File tree

3 files changed

+45
-14
lines changed

3 files changed

+45
-14
lines changed

bin/varnishtest/tests/c00005.vtc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,3 +375,24 @@ client c1 {
375375
} -run
376376

377377
logexpect l1 -wait
378+
379+
# test +silent
380+
varnish v1 -cliexpect "^$" {vcl.inline silent << EOF
381+
vcl 4.1;
382+
383+
backend dummy None;
384+
385+
acl acl1 +log +pedantic +fold +silent {
386+
# all contained in 1.3.0.0/21 and 1.4.4.0/22
387+
"1.2.0.0"/23;
388+
"1.2.2.0"/24;
389+
"1.2.3.0"/24;
390+
}
391+
392+
sub vcl_recv {
393+
if (client.ip ~ acl1) {
394+
return (synth(403));
395+
}
396+
}
397+
EOF
398+
}

doc/sphinx/reference/vcl.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ individually:
354354

355355
Skip and fold operations on VCL entries are output as warnings
356356
during VCL compilation as entries from the VCL are processed in
357-
order.
357+
order unless the `+silent` flag is also given.
358358

359359
Logging under the ``VCL_acl`` tag can change with this parameter
360360
enabled: Matches on skipped subnet entries are now logged as matches
@@ -365,6 +365,8 @@ individually:
365365

366366
Negated ACL entries are never folded.
367367

368+
* `+silent` - Do not emit warnings about folding
369+
368370
VCL objects
369371
-----------
370372

lib/libvcc/vcc_acl.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct acl {
5454

5555
int flag_log;
5656
int flag_fold;
57+
int flag_silent;
5758
int flag_pedantic;
5859
int flag_table;
5960

@@ -263,26 +264,30 @@ vcl_acl_fold(struct vcc *tl, struct acl_e **l, struct acl_e **r)
263264
do {
264265
switch (cmp) {
265266
case ACL_CONTAINED:
266-
VSB_cat(tl->sb, "ACL entry:\n");
267-
vcc_ErrWhere(tl, (*r)->t_addr);
268-
VSB_cat(tl->sb, "supersedes / removes:\n");
269-
vcc_ErrWhere(tl, (*l)->t_addr);
270-
vcc_Warn(tl);
267+
if (tl->acl->flag_silent == 0) {
268+
VSB_cat(tl->sb, "ACL entry:\n");
269+
vcc_ErrWhere(tl, (*r)->t_addr);
270+
VSB_cat(tl->sb, "supersedes / removes:\n");
271+
vcc_ErrWhere(tl, (*l)->t_addr);
272+
vcc_Warn(tl);
273+
}
271274
VRBT_REMOVE(acl_tree, &tl->acl->acl_tree, *l);
272275
FREE_OBJ(*l);
273276
*l = VRBT_PREV(acl_tree, &tl->acl->acl_tree, *r);
274277
break;
275278
case ACL_LEFT:
276279
(*l)->mask--;
277280
(*l)->fixed = "folded";
278-
VSB_cat(tl->sb, "ACL entry:\n");
279-
vcc_ErrWhere(tl, (*l)->t_addr);
280-
VSB_cat(tl->sb, "left of:\n");
281-
vcc_ErrWhere(tl, (*r)->t_addr);
282-
VSB_printf(tl->sb, "removing the latter and expanding "
283-
"mask of the former by one to /%u\n",
284-
(*l)->mask - 8);
285-
vcc_Warn(tl);
281+
if (tl->acl->flag_silent == 0) {
282+
VSB_cat(tl->sb, "ACL entry:\n");
283+
vcc_ErrWhere(tl, (*l)->t_addr);
284+
VSB_cat(tl->sb, "left of:\n");
285+
vcc_ErrWhere(tl, (*r)->t_addr);
286+
VSB_printf(tl->sb, "removing the latter and "
287+
"expanding mask of the former by one to "
288+
"/%u\n", (*l)->mask - 8);
289+
vcc_Warn(tl);
290+
}
286291
VRBT_REMOVE(acl_tree, &tl->acl->acl_tree, *r);
287292
FREE_OBJ(*r);
288293
VRBT_REMOVE(acl_tree, &tl->acl->acl_tree, *l);
@@ -838,6 +843,9 @@ vcc_ParseAcl(struct vcc *tl)
838843
} else if (vcc_IdIs(tl->t, "fold")) {
839844
acl->flag_fold = sign;
840845
vcc_NextToken(tl);
846+
} else if (vcc_IdIs(tl->t, "silent")) {
847+
acl->flag_silent = sign;
848+
vcc_NextToken(tl);
841849
} else if (vcc_IdIs(tl->t, "pedantic")) {
842850
acl->flag_pedantic = sign;
843851
vcc_NextToken(tl);

0 commit comments

Comments
 (0)