Skip to content

vcl: Make 'none' a reserved keyword and use it for probes #4309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/varnishtest/tests/m00000.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ varnish v1 -errvcl {Symbol not found: 'obj'} {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the commit message:
As with other versioning questions, I think we should only increase the major version for silent breaking changes. In this case a VCL compilation failure ensures that VCL authors become aware of the change, so we do not need a VCL version bump.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case I think we should consider it a bug fix, we should never have authorized none to persist as a usable symbol name once we gave it a special meaning.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

varnish v1 -errvcl {rot13: VFP already registered (per-vcl)} {
import debug;
backend none none;
backend be none;
sub vcl_init {
debug.rot104();
}
Expand All @@ -167,7 +167,7 @@ varnish v1 -errvcl {Failed from VCL} {

varnish v1 -errvcl {Failed initialization} {
import debug;
backend none none;
backend be none;
sub vcl_init {
new fails = debug.obj("fail");
}
Expand All @@ -177,7 +177,7 @@ shell {
cat >${tmpdir}/f1 <<-EOF
vcl 4.1;
import debug;
backend none none;
backend be none;
sub vcl_init {
new fails = debug.obj("fail");
}
Expand Down
2 changes: 1 addition & 1 deletion bin/varnishtest/tests/m00048.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ client c1 -repeat 2 {

varnish v1 -vcl {
import debug;
backend none none;
backend be none;

sub vcl_recv {
return (synth(200));
Expand Down
4 changes: 2 additions & 2 deletions bin/varnishtest/tests/r03940.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ varnishtest "test startup_timeout vs. stevedore init / open"
# startup_timeout used, delay in stevedore init
varnish v1 -arg "-sdebug=debug,dinit=5s -pstartup_timeout=3s -pcli_timeout=2s" \
-arg "-p feature=+no_coredump" \
-vcl "backend none none;" \
-vcl "backend be none;" \
-expectexit 0x40
varnish v1 -cliexpect \
"Child failed on launch within startup_timeout=3.00s" \
Expand All @@ -31,7 +31,7 @@ shell {grep -q "Child failed on launch within startup_timeout=3.00s" ${p1_out}}

varnish v2 -arg "-sdebug=debug,dopen=5s -pstartup_timeout=2s -pcli_timeout=3s" \
-arg "-p feature=+no_coredump" \
-vcl "backend none none;" \
-vcl "backend be none;" \
-expectexit 0x40
varnish v2 -cliexpect \
"launch within cli_timeout=3.00s .tip: set startup_" \
Expand Down
2 changes: 1 addition & 1 deletion bin/varnishtest/tests/t02027.vtc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
varnishtest "H2 RxStuff conditions"

varnish v1 -arg "-p feature=+http2" -arg "-p debug=+syncvsl" -vcl {
backend none none;
backend be none;
sub vcl_recv {
return (synth(200));
}
Expand Down
4 changes: 2 additions & 2 deletions bin/varnishtest/tests/u00002.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ server s1 -repeat 4 {
} -start

varnish v1 -vcl+backend {
backend none none;
backend be none;

sub vcl_backend_fetch {
# XXX would like to do everything in v_b_e, but
# return(pass(x)) is not supported
if (bereq.url == "/hitpass") {
set bereq.backend = s1;
} else {
set bereq.backend = none;
set bereq.backend = be;
}
}

Expand Down
13 changes: 5 additions & 8 deletions bin/varnishtest/tests/v00021.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,6 @@ varnish v1 -errvcl {Unused sub foo, defined:} {
}
}

# deliberately testing for name "none"
varnish v1 -errvcl {Unused sub none, defined:} {
backend b { .host = "${localhost}"; }

sub none {
}
}

varnish v1 -errvcl {Invalid return "deliver"} {
backend b { .host = "${localhost}"; }

Expand Down Expand Up @@ -177,6 +169,11 @@ varnish v1 -errvcl {Symbol 'default' is a reserved word.} {
sub vcl_init { new default = debug.obj(); }
}

varnish v1 -errvcl {Symbol 'none' is a reserved word.} {
import debug;
sub vcl_init { new none = debug.obj(); }
}

varnish v1 -syntax 4.1 -errvcl {(Only available when VCL syntax <= 4.0)} {
sub vcl_recv {
set req.esi = false;
Expand Down
22 changes: 19 additions & 3 deletions lib/libvcc/vcc_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1599,10 +1599,8 @@ static void v_matchproto_(sym_expr_t)
vcc_Eval_Default(struct vcc *tl, struct expr **e, struct token *t,
struct symbol *sym, vcc_type_t fmt)
{
(void)e;
(void)fmt;

(void)sym;
(void)t;

if (fmt->default_sym == NULL) {
VSB_cat(tl->sb, "Symbol 'default' is a reserved word.\n");
Expand All @@ -1613,6 +1611,19 @@ vcc_Eval_Default(struct vcc *tl, struct expr **e, struct token *t,
*e = vcc_mk_expr(fmt, "%s", fmt->default_sym->rname);
}

static void v_matchproto_(sym_expr_t)
vcc_Eval_None(struct vcc *tl, struct expr **e, struct token *t,
struct symbol *sym, vcc_type_t fmt)
{

(void)e;
(void)fmt;
(void)sym;

VSB_cat(tl->sb, "'none' is a reserved word.\n");
vcc_ErrWhere(tl, t);
}

/*--------------------------------------------------------------------
*/

Expand Down Expand Up @@ -1649,4 +1660,9 @@ vcc_Expr_Init(struct vcc *tl)
AN(sym);
sym->type = DEFAULT;
sym->eval = vcc_Eval_Default;

sym = VCC_MkSym(tl, "none", SYM_MAIN, SYM_FUNC, VCL_LOW, VCL_HIGH);
AN(sym);
sym->type = DEFAULT;
sym->eval = vcc_Eval_None;
}