From phk at FreeBSD.org Mon Jun 3 07:23:11 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 3 Jun 2019 07:23:11 +0000 (UTC) Subject: [master] c3610d36e Monday morning flexelinting Message-ID: <20190603072311.B22E210153A@lists.varnish-cache.org> commit c3610d36ef906c869e8e94f3a54b09d1e859d3b6 Author: Poul-Henning Kamp Date: Mon Jun 3 06:00:18 2019 +0000 Monday morning flexelinting diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c index 2d7f7f03f..4d0453807 100644 --- a/bin/varnishd/cache/cache_ban_lurker.c +++ b/bin/varnishd/cache/cache_ban_lurker.c @@ -105,6 +105,7 @@ ban_cleantail(struct banhead_s *obans) bt = NULL; if (bt != NULL) { + AN(obans); VTAILQ_FOREACH(b, &freelist, list) { if (b != bt) continue; diff --git a/bin/varnishd/mgt/mgt_symtab.c b/bin/varnishd/mgt/mgt_symtab.c index be80ec593..b8ef07d3a 100644 --- a/bin/varnishd/mgt/mgt_symtab.c +++ b/bin/varnishd/mgt/mgt_symtab.c @@ -41,7 +41,6 @@ #include "mgt/mgt_vcl.h" #include "vcli_serve.h" -#include "libvcc.h" #include "vjsn.h" /*--------------------------------------------------------------------*/ From phk at FreeBSD.org Mon Jun 3 07:23:11 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 3 Jun 2019 07:23:11 +0000 (UTC) Subject: [master] a80f4ef9a Unify bespoke error messages to "Symbol not found" before things get too confusing. Message-ID: <20190603072311.D22F910153D@lists.varnish-cache.org> commit a80f4ef9a1763f78eea6acf106e03cb12bdf89b1 Author: Poul-Henning Kamp Date: Mon Jun 3 06:36:20 2019 +0000 Unify bespoke error messages to "Symbol not found" before things get too confusing. diff --git a/bin/varnishtest/tests/r01837.vtc b/bin/varnishtest/tests/r01837.vtc index fbfd797c0..e96a44cf7 100644 --- a/bin/varnishtest/tests/r01837.vtc +++ b/bin/varnishtest/tests/r01837.vtc @@ -1,6 +1,6 @@ varnishtest "Test VCC errors out if probe is used before it is defined" -varnish v1 -errvcl "Probe not found: 'p'" { +varnish v1 -errvcl "Symbol not found: 'p'" { backend b { .host = "127.0.0.1"; .probe = p; diff --git a/bin/varnishtest/tests/v00018.vtc b/bin/varnishtest/tests/v00018.vtc index d0a21eb1d..fd519c981 100644 --- a/bin/varnishtest/tests/v00018.vtc +++ b/bin/varnishtest/tests/v00018.vtc @@ -133,7 +133,7 @@ varnish v1 -errvcl {Symbol 'vcl_recv' has wrong type (sub):} { } } -varnish v1 -syntax 4.0 -errvcl {Not a VCL label:} { +varnish v1 -syntax 4.0 -errvcl {Symbol not found:} { sub vcl_recv { return (vcl(vcl_recv)); } diff --git a/bin/varnishtest/tests/v00019.vtc b/bin/varnishtest/tests/v00019.vtc index f579b024a..d81455a15 100644 --- a/bin/varnishtest/tests/v00019.vtc +++ b/bin/varnishtest/tests/v00019.vtc @@ -64,7 +64,7 @@ varnish v1 -errvcl {Comparison of different types: STRING '==' INT} { } } -varnish v1 -errvcl {Unknown variable: 'req.http.req.http.foo'} { +varnish v1 -errvcl {Symbol not found: 'req.http.req.http.foo'} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.req.http.foo = "bar"; diff --git a/bin/varnishtest/tests/v00021.vtc b/bin/varnishtest/tests/v00021.vtc index 44c4c0f3d..80ef0a93e 100644 --- a/bin/varnishtest/tests/v00021.vtc +++ b/bin/varnishtest/tests/v00021.vtc @@ -91,7 +91,7 @@ varnish v1 -vcl { } } -varnish v1 -errvcl {Unknown variable: 'req.foobar'} { +varnish v1 -errvcl {Symbol not found: 'req.foobar'} { backend foo { .host = "127.0.0.1"; } sub vcl_recv { set req.foobar = 3; } } diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 4e547a2ab..1e218cb4f 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -94,7 +94,7 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym) (void)t; ExpectErr(tl, ID); t = tl->t; - sym = VCC_SymbolGet(tl, SYM_VAR, "Unknown variable", XREF_NONE); + sym = VCC_SymbolGet(tl, SYM_VAR, SYMTAB_EXISTING, XREF_NONE); ERRCHK(tl); AN(sym); if (sym->w_methods == 0) { @@ -146,7 +146,7 @@ vcc_act_unset(struct vcc *tl, struct token *t, struct symbol *sym) /* XXX: Wrong, should use VCC_Expr(HEADER) */ ExpectErr(tl, ID); t = tl->t; - sym = VCC_SymbolGet(tl, SYM_VAR, "Unknown variable", XREF_NONE); + sym = VCC_SymbolGet(tl, SYM_VAR, SYMTAB_EXISTING, XREF_NONE); ERRCHK(tl); AN(sym); if (sym->u_methods == 0) { @@ -269,7 +269,7 @@ vcc_act_return_vcl(struct vcc *tl) ExpectErr(tl, '('); vcc_NextToken(tl); ExpectErr(tl, ID); - sym = VCC_SymbolGet(tl, SYM_VCL, "Not a VCL label", XREF_NONE); + sym = VCC_SymbolGet(tl, SYM_VCL, SYMTAB_EXISTING, XREF_NONE); ERRCHK(tl); AN(sym); if (sym->eval_priv == NULL) { diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c index 4243b9da6..3200b1f84 100644 --- a/lib/libvcc/vcc_backend.c +++ b/lib/libvcc/vcc_backend.c @@ -432,7 +432,7 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname) (void)vcc_default_probe(tl); } else { pb = VCC_SymbolGet(tl, SYM_PROBE, - "Probe not found", XREF_REF); + SYMTAB_EXISTING, XREF_REF); ERRCHK(tl); AN(pb); Fb(tl, 0, "\t.probe = %s,\n", pb->rname); @@ -540,6 +540,7 @@ vcc_ParseBackend(struct vcc *tl) } else { sym = VCC_HandleSymbol(tl, BACKEND, "vgc_backend"); ERRCHK(tl); + AN(sym); dn = sym->rname; if (tl->default_director == NULL) { tl->first_director = sym; diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index 3a2116a9f..4d0fb0574 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -350,13 +350,19 @@ void vcc_stevedore(struct vcc *vcc, const char *stv_name); /* vcc_symb.c */ void VCC_PrintCName(struct vsb *vsb, const char *b, const char *e); struct symbol *VCC_MkSym(struct vcc *tl, const char *b, vcc_kind_t, int, int); -extern const char XREF_NONE[]; -extern const char XREF_DEF[]; -extern const char XREF_REF[]; -extern const char SYMTAB_NOERR[]; -extern const char SYMTAB_CREATE[]; -struct symbol *VCC_SymbolGet(struct vcc *, vcc_kind_t, const char *, - const char *); + +struct symxref { const char *name; }; +extern const struct symxref XREF_NONE[1]; +extern const struct symxref XREF_DEF[1]; +extern const struct symxref XREF_REF[1]; + +struct symmode { const char *name; }; +extern const struct symmode SYMTAB_NOERR[1]; +extern const struct symmode SYMTAB_CREATE[1]; +extern const struct symmode SYMTAB_EXISTING[1]; + +struct symbol *VCC_SymbolGet(struct vcc *, vcc_kind_t, + const struct symmode *, const struct symxref *); typedef void symwalk_f(struct vcc *tl, const struct symbol *s); void VCC_WalkSymbols(struct vcc *tl, symwalk_f *func, vcc_kind_t); diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index dae6fe2f2..9c263e0b7 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -688,8 +688,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt) switch (tl->t->tok) { case ID: t = tl->t; - sym = VCC_SymbolGet(tl, SYM_NONE, "Symbol not found", - XREF_REF); + sym = VCC_SymbolGet(tl, SYM_NONE, SYMTAB_EXISTING, XREF_REF); ERRCHK(tl); AN(sym); if (sym->kind == SYM_FUNC && sym->type == VOID) { diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c index 9883dede4..18bfbe6b3 100644 --- a/lib/libvcc/vcc_symb.c +++ b/lib/libvcc/vcc_symb.c @@ -226,19 +226,25 @@ vcc_sym_in_tab(struct vcc *tl, struct symtab *st, } -const char XREF_NONE[] = "xref_none"; -const char XREF_DEF[] = "xref_def"; -const char XREF_REF[] = "xref_ref"; -const char SYMTAB_NOERR[] = "sym_noerror"; -const char SYMTAB_CREATE[] = "sym_create"; +const struct symxref XREF_NONE[1] = {{"xref_none"}}; +const struct symxref XREF_DEF[1] = {{"xref_def"}}; +const struct symxref XREF_REF[1] = {{"xref_ref"}}; +const struct symmode SYMTAB_NOERR[1] = {{"sym_noerror"}}; +const struct symmode SYMTAB_CREATE[1] = {{"sym_create"}}; +const struct symmode SYMTAB_EXISTING[1] = {{"Symbol not found"}}; struct symbol * -VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind, const char *e, const char *x) +VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind, + const struct symmode *e, const struct symxref *x) { struct symtab *st; struct symbol *sym; struct token *t0, *tn, *tn1; + AN(tl); + AN(e); + AN(x); + AN(x->name); if (tl->syntax >= VCL_41 && e == SYMTAB_CREATE && kind != SYM_SUB && (tl->t->b[0] == 'v'|| tl->t->b[0] == 'V') && (tl->t->b[1] == 'c'|| tl->t->b[1] == 'C') && @@ -270,7 +276,7 @@ VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind, const char *e, const char *x) return (sym); tl->t = VTAILQ_NEXT(tn, list); if (sym == NULL) { - VSB_printf(tl->sb, "%s: '", e); + VSB_printf(tl->sb, "%s: '", e->name); for (tn1 = t0; tn1 != tl->t; tn1 = VTAILQ_NEXT(tn1, list)) VSB_printf(tl->sb, "%.*s", PF(tn1)); VSB_printf(tl->sb, "'"); diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index c98e261f0..1a5c13453 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -402,7 +402,7 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) ExpectErr(tl, ID); t = tl->t; - sy2 = VCC_SymbolGet(tl, SYM_OBJECT, "Symbol not found", XREF_NONE); + sy2 = VCC_SymbolGet(tl, SYM_OBJECT, SYMTAB_EXISTING, XREF_NONE); ERRCHK(tl); AN(sy2); if (sy2->eval_priv == NULL) { From phk at FreeBSD.org Mon Jun 3 07:23:11 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 3 Jun 2019 07:23:11 +0000 (UTC) Subject: [master] ddb1358cb Introduce partial symbol lookups (ie: finding foo.bar in foo.bar.barf) Message-ID: <20190603072311.EAFCE101540@lists.varnish-cache.org> commit ddb1358cb55357700f55cb61cb961d32267b8b12 Author: Poul-Henning Kamp Date: Mon Jun 3 06:47:44 2019 +0000 Introduce partial symbol lookups (ie: finding foo.bar in foo.bar.barf) diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index 4d0fb0574..74871e421 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -360,6 +360,7 @@ struct symmode { const char *name; }; extern const struct symmode SYMTAB_NOERR[1]; extern const struct symmode SYMTAB_CREATE[1]; extern const struct symmode SYMTAB_EXISTING[1]; +extern const struct symmode SYMTAB_PARTIAL[1]; struct symbol *VCC_SymbolGet(struct vcc *, vcc_kind_t, const struct symmode *, const struct symxref *); diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c index 18bfbe6b3..d33a2a564 100644 --- a/lib/libvcc/vcc_symb.c +++ b/lib/libvcc/vcc_symb.c @@ -232,14 +232,15 @@ const struct symxref XREF_REF[1] = {{"xref_ref"}}; const struct symmode SYMTAB_NOERR[1] = {{"sym_noerror"}}; const struct symmode SYMTAB_CREATE[1] = {{"sym_create"}}; const struct symmode SYMTAB_EXISTING[1] = {{"Symbol not found"}}; +const struct symmode SYMTAB_PARTIAL[1] = {{"Symbol not found"}}; struct symbol * VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind, const struct symmode *e, const struct symxref *x) { - struct symtab *st; - struct symbol *sym; - struct token *t0, *tn, *tn1; + struct symtab *st, *st2; + struct symbol *sym = NULL, *sym2 = NULL; + struct token *t0, *tn, *tn1, *tn2 = NULL; AN(tl); AN(e); @@ -261,6 +262,12 @@ VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind, tn = tl->t; while (1) { st = vcc_symtab_str(st, tn->b, tn->e); + sym2 = vcc_sym_in_tab(tl, st, kind, tl->syntax, tl->syntax); + if (sym2 != NULL) { + sym = sym2; + st2 = st; + tn2 = tn; + } tn1 = VTAILQ_NEXT(tn, list); if (tn1->tok != '.') break; @@ -269,11 +276,18 @@ VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind, break; tn = tn1; } - sym = vcc_sym_in_tab(tl, st, kind, tl->syntax, tl->syntax); - if (sym == NULL && e == SYMTAB_CREATE) - sym = vcc_new_symbol(tl, st, kind, tl->syntax, tl->syntax); + if (sym != NULL && e == SYMTAB_PARTIAL) { + st = st2; + tn = tn2; + } else if (st != st2) { + sym = NULL; + } if (sym == NULL && e == SYMTAB_NOERR) return (sym); + AN(st); + AN(tn); + if (sym == NULL && e == SYMTAB_CREATE) + sym = vcc_new_symbol(tl, st, kind, tl->syntax, tl->syntax); tl->t = VTAILQ_NEXT(tn, list); if (sym == NULL) { VSB_printf(tl->sb, "%s: '", e->name); From phk at FreeBSD.org Mon Jun 3 07:23:12 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 3 Jun 2019 07:23:12 +0000 (UTC) Subject: [master] 513bd412f Insert a no-op level in expression parser to make diffs more readable Message-ID: <20190603072312.116ED101545@lists.varnish-cache.org> commit 513bd412f05904720579dccf3082ce8cf3f308d5 Author: Poul-Henning Kamp Date: Mon Jun 3 06:48:20 2019 +0000 Insert a no-op level in expression parser to make diffs more readable diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 9c263e0b7..49970f2bc 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -655,7 +655,7 @@ vcc_Eval_SymFunc(struct vcc *tl, struct expr **e, struct token *t, /*-------------------------------------------------------------------- * SYNTAX: - * Expr4: + * Expr5: * '(' ExprCor ')' * symbol * CNUM @@ -664,7 +664,7 @@ vcc_Eval_SymFunc(struct vcc *tl, struct expr **e, struct token *t, */ static void -vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt) +vcc_expr5(struct vcc *tl, struct expr **e, vcc_type_t fmt) { struct expr *e1, *e2; const char *ip, *sign; @@ -799,6 +799,21 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt) vcc_ErrWhere(tl, tl->t); } +/*-------------------------------------------------------------------- + * SYNTAX: + * Expr4: + * Expr5 + */ + +static void +vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt) +{ + + *e = NULL; + vcc_expr5(tl, e, fmt); + return; +} + /*-------------------------------------------------------------------- * SYNTAX: * ExprMul: From phk at FreeBSD.org Mon Jun 3 07:23:12 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 3 Jun 2019 07:23:12 +0000 (UTC) Subject: [master] 340abd045 Recognize type-based methods and fix error messages accordingly. Message-ID: <20190603072312.2D7C6101548@lists.varnish-cache.org> commit 340abd0456e4d018fd1589f406287057ab6740ff Author: Poul-Henning Kamp Date: Mon Jun 3 07:22:10 2019 +0000 Recognize type-based methods and fix error messages accordingly. No methods are implemented yet. diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc index 0b8b7b474..7da6152ea 100644 --- a/bin/varnishtest/tests/v00016.vtc +++ b/bin/varnishtest/tests/v00016.vtc @@ -41,7 +41,7 @@ varnish v1 -errvcl {Operator > not possible on BACKEND} { sub vcl_recv { if (a > b) { } } } -varnish v1 -errvcl {Symbol not found: 'req.foo'} { +varnish v1 -errvcl {Unknown property 'foo' for type HTTP} { backend b { .host = "127.0.0.1"; } sub vcl_hash { if (req.foo != "bar") { } } } diff --git a/bin/varnishtest/tests/v00018.vtc b/bin/varnishtest/tests/v00018.vtc index fd519c981..3ce6bd051 100644 --- a/bin/varnishtest/tests/v00018.vtc +++ b/bin/varnishtest/tests/v00018.vtc @@ -38,7 +38,7 @@ varnish v1 -errvcl {Expected ';' got 'if'} { sub vcl_recv { set req.url = "foo" if "bar"; } } -varnish v1 -errvcl {Symbol not found: 'req.foo'} { +varnish v1 -errvcl {Unknown property 'foo' for type HTTP} { backend b { .host = "127.0.0.1"; } sub vcl_hash { hash_data(req.foo); } } diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 49970f2bc..9517bcca1 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -688,7 +688,7 @@ vcc_expr5(struct vcc *tl, struct expr **e, vcc_type_t fmt) switch (tl->t->tok) { case ID: t = tl->t; - sym = VCC_SymbolGet(tl, SYM_NONE, SYMTAB_EXISTING, XREF_REF); + sym = VCC_SymbolGet(tl, SYM_NONE, SYMTAB_PARTIAL, XREF_REF); ERRCHK(tl); AN(sym); if (sym->kind == SYM_FUNC && sym->type == VOID) { @@ -811,7 +811,16 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt) *e = NULL; vcc_expr5(tl, e, fmt); - return; + while (tl->t->tok == '.') { + vcc_NextToken(tl); + ExpectErr(tl, ID); + VSB_printf(tl->sb, "Unknown property "); + vcc_ErrToken(tl, tl->t); + VSB_printf(tl->sb, + " for type %s\n", (*e)->fmt->name); + vcc_ErrWhere(tl, tl->t); + return; + } } /*-------------------------------------------------------------------- diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c index d33a2a564..6da0505e8 100644 --- a/lib/libvcc/vcc_symb.c +++ b/lib/libvcc/vcc_symb.c @@ -238,7 +238,7 @@ struct symbol * VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind, const struct symmode *e, const struct symxref *x) { - struct symtab *st, *st2; + struct symtab *st, *st2 = NULL; struct symbol *sym = NULL, *sym2 = NULL; struct token *t0, *tn, *tn1, *tn2 = NULL; From phk at FreeBSD.org Mon Jun 3 13:01:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 3 Jun 2019 13:01:09 +0000 (UTC) Subject: [master] f8bc0ea37 Add an empty lookup table for type based methods, while I find out how vcc_expr actually works... Message-ID: <20190603130109.7843C107BA9@lists.varnish-cache.org> commit f8bc0ea370fe2fcbb9912531a1dd08f8ff1ad6da Author: Poul-Henning Kamp Date: Mon Jun 3 10:38:30 2019 +0000 Add an empty lookup table for type based methods, while I find out how vcc_expr actually works... diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 9517bcca1..1221c4e9e 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -802,24 +802,50 @@ vcc_expr5(struct vcc *tl, struct expr **e, vcc_type_t fmt) /*-------------------------------------------------------------------- * SYNTAX: * Expr4: - * Expr5 + * Expr5 */ +static const struct vcc_methods { + vcc_type_t type_from; + vcc_type_t type_to; + const char *method; + const char *impl; +} vcc_methods[] = { + //{ BACKEND, BOOL, "healthy", "VRT_Healthy(ctx, \v1, 0)" }, + { NULL, NULL, NULL, NULL}, // XXX: For Flexelint + { NULL, NULL, NULL, NULL}, +}; + static void vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt) { + const struct vcc_methods *vm; *e = NULL; vcc_expr5(tl, e, fmt); + ERRCHK(tl); + AN(*e); while (tl->t->tok == '.') { vcc_NextToken(tl); ExpectErr(tl, ID); - VSB_printf(tl->sb, "Unknown property "); - vcc_ErrToken(tl, tl->t); - VSB_printf(tl->sb, - " for type %s\n", (*e)->fmt->name); - vcc_ErrWhere(tl, tl->t); - return; + + for(vm = vcc_methods; vm->type_from != NULL; vm++) { + + if (vm->type_from == (*e)->fmt && + vcc_IdIs(tl->t, vm->method)) + break; + } + + if (vm->type_from == NULL) { + VSB_printf(tl->sb, "Unknown property "); + vcc_ErrToken(tl, tl->t); + VSB_printf(tl->sb, + " for type %s\n", (*e)->fmt->name); + vcc_ErrWhere(tl, tl->t); + return; + } + vcc_NextToken(tl); + *e = vcc_expr_edit(tl, vm->type_to, vm->impl, *e, NULL); } } From phk at FreeBSD.org Mon Jun 3 13:01:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 3 Jun 2019 13:01:09 +0000 (UTC) Subject: [master] c878d750f Move the layout of compiled ACLs to VPI space Message-ID: <20190603130109.8CE20107BAC@lists.varnish-cache.org> commit c878d750fa31310e71df7b1590e60e9148545ee0 Author: Poul-Henning Kamp Date: Mon Jun 3 12:05:47 2019 +0000 Move the layout of compiled ACLs to VPI space diff --git a/include/vcc_interface.h b/include/vcc_interface.h index 347c20077..10df9d49a 100644 --- a/include/vcc_interface.h +++ b/include/vcc_interface.h @@ -55,3 +55,11 @@ int VPI_Vmod_Init(VRT_CTX, struct vmod **hdl, unsigned nbr, void *ptr, int len, const char *nm, const char *path, const char *file_id, const char *backup); void VPI_Vmod_Unload(VRT_CTX, struct vmod **hdl); +typedef int acl_match_f(VRT_CTX, const VCL_IP); + +struct vrt_acl { + unsigned magic; +#define VRT_ACL_MAGIC 0x78329d96 + acl_match_f *match; +}; + diff --git a/include/vrt.h b/include/vrt.h index 7a227ebc9..4cb78e002 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -387,14 +387,6 @@ struct vrt_backend_probe { * Implementation details of ACLs */ -typedef int acl_match_f(VRT_CTX, const VCL_IP); - -struct vrt_acl { - unsigned magic; -#define VRT_ACL_MAGIC 0x78329d96 - acl_match_f *match; -}; - void VRT_acl_log(VRT_CTX, const char *); int VRT_acl_match(VRT_CTX, VCL_ACL, VCL_IP); diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 9e1463101..8ded76669 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -513,7 +513,7 @@ xyzzy_match_acl(VRT_CTX, VCL_ACL acl, VCL_IP ip) { CHECK_OBJ_ORNULL(ctx, VRT_CTX_MAGIC); - CHECK_OBJ_ORNULL(acl, VRT_ACL_MAGIC); + AN(acl); assert(VSA_Sane(ip)); return (VRT_acl_match(ctx, acl, ip)); From phk at FreeBSD.org Mon Jun 3 13:01:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 3 Jun 2019 13:01:09 +0000 (UTC) Subject: [master] c1990ad9f Necessary #include for previous commit. Message-ID: <20190603130109.A6A44107BAF@lists.varnish-cache.org> commit c1990ad9f9bee5a8532ddd88765fb823ebf3f439 Author: Poul-Henning Kamp Date: Mon Jun 3 12:06:18 2019 +0000 Necessary #include for previous commit. diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 10da99437..854a690f2 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -40,6 +40,7 @@ #include "vsa.h" #include "vtcp.h" #include "vtim.h" +#include "vcc_interface.h" #include "common/heritage.h" #include "common/vsmw.h" From phk at FreeBSD.org Mon Jun 3 13:01:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 3 Jun 2019 13:01:09 +0000 (UTC) Subject: [master] 3ea061c99 Teach ACLs their name Message-ID: <20190603130109.BED8A107BB4@lists.varnish-cache.org> commit 3ea061c9955d5a9875eb2686090689ed86820878 Author: Poul-Henning Kamp Date: Mon Jun 3 13:00:14 2019 +0000 Teach ACLs their name diff --git a/include/vcc_interface.h b/include/vcc_interface.h index 10df9d49a..682767265 100644 --- a/include/vcc_interface.h +++ b/include/vcc_interface.h @@ -61,5 +61,6 @@ struct vrt_acl { unsigned magic; #define VRT_ACL_MAGIC 0x78329d96 acl_match_f *match; + const char *name; }; diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index 43a5b43a1..023a73d52 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -454,6 +454,7 @@ vcc_acl_emit(struct vcc *tl, const char *name, const char *rname, int anon) Fh(tl, 0, "\nconst struct vrt_acl %s[] = {{\n", rname); Fh(tl, 0, "\t.magic = VRT_ACL_MAGIC,\n"); Fh(tl, 0, "\t.match = &%s,\n", VSB_data(func)); + Fh(tl, 0, "\t.name = \"%s\",\n", name); Fh(tl, 0, "}};\n\n"); } VSB_destroy(&func); From phk at FreeBSD.org Mon Jun 3 18:08:10 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 3 Jun 2019 18:08:10 +0000 (UTC) Subject: [master] f72c22352 Do not preemptively convert handles to STRING if we can do so later Message-ID: <20190603180810.A0D6110E9F1@lists.varnish-cache.org> commit f72c22352467512dca79a8f53f484f1f93f21213 Author: Poul-Henning Kamp Date: Mon Jun 3 13:55:37 2019 +0000 Do not preemptively convert handles to STRING if we can do so later diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 1221c4e9e..13931d13c 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -315,7 +315,8 @@ vcc_Eval_Handle(struct vcc *tl, struct expr **e, struct token *t, AN(sym->rname); AZ(type->stringform); - if (sym->type != STRING && type == STRINGS) { + if (sym->type->tostring == NULL && + sym->type != STRING && type == STRINGS) { *e = vcc_mk_expr(STRINGS, "\"%s\"", sym->name); (*e)->nstr = 1; (*e)->constant |= EXPR_CONST | EXPR_STR_CONST; From phk at FreeBSD.org Mon Jun 3 18:08:10 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 3 Jun 2019 18:08:10 +0000 (UTC) Subject: [master] 4515993f4 Teach ACL's how to find their own name. Message-ID: <20190603180810.BC90D10E9F4@lists.varnish-cache.org> commit 4515993f430c6dd4f7343e8b88ec58771ac7ddee Author: Poul-Henning Kamp Date: Mon Jun 3 13:56:46 2019 +0000 Teach ACL's how to find their own name. diff --git a/lib/libvcc/vcc_types.c b/lib/libvcc/vcc_types.c index 3611dcef5..196efa539 100644 --- a/lib/libvcc/vcc_types.c +++ b/lib/libvcc/vcc_types.c @@ -37,6 +37,7 @@ const struct type ACL[1] = {{ .magic = TYPE_MAGIC, .name = "ACL", + .tostring = "((\v1)->name)", }}; const struct type BACKEND[1] = {{ From phk at FreeBSD.org Tue Jun 4 06:39:10 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 4 Jun 2019 06:39:10 +0000 (UTC) Subject: [master] 2962375b4 Reimplement the storage.*.* properties as type driven properties Message-ID: <20190604063910.7118A11B89A@lists.varnish-cache.org> commit 2962375b4ed80e2197a318f92f2fb9f6cfcd12f8 Author: Poul-Henning Kamp Date: Tue Jun 4 06:37:28 2019 +0000 Reimplement the storage.*.* properties as type driven properties diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 49835eba4..0f33bd656 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -41,7 +41,6 @@ #include "storage/storage.h" #include "vrt_obj.h" - static pthread_mutex_t stv_mtx; /*-------------------------------------------------------------------- @@ -214,18 +213,13 @@ VRT_stevedore(const char *nm) return (stv_find(nm)); } -#define VRTSTVVAR(nm, vtype, ctype, dval) \ -ctype \ -VRT_Stv_##nm(const char *nm) \ -{ \ - const struct stevedore *stv; \ - \ - stv = stv_find(nm); \ - if (stv == NULL) \ - return (dval); \ - if (stv->var_##nm == NULL) \ - return (dval); \ - return (stv->var_##nm(stv)); \ +#define VRTSTVVAR(nm, vtype, ctype, dval) \ +ctype \ +VRT_stevedore_##nm(VCL_STEVEDORE stv) \ +{ \ + if (stv == NULL) \ + return (0); \ + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); \ + return (stv->var_##nm(stv)); \ } - #include "tbl/vrt_stv_var.h" diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 892dfff5b..fb464bc39 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -731,12 +731,11 @@ vcc_Var_Init(struct vcc *tl) struct symbol *sym; """) - parse_var_doc(join(srcroot, "doc/sphinx/reference/vcl_var.rst")) fo.write("}\n") for i in stv_variables: - fh.write(vcltypes[i[1]].c + " VRT_Stv_" + i[0] + "(const char *);\n") + fh.write(vcltypes[i[1]].c + " VRT_stevedore_" + i[0] + "(VCL_STEVEDORE);\n") fo.write("\n/* VCL type identifiers */\n") diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 13931d13c..6301cb722 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -813,7 +813,11 @@ static const struct vcc_methods { const char *impl; } vcc_methods[] = { //{ BACKEND, BOOL, "healthy", "VRT_Healthy(ctx, \v1, 0)" }, - { NULL, NULL, NULL, NULL}, // XXX: For Flexelint + +#define VRTSTVVAR(nm, vtype, ctype, dval) \ + { STEVEDORE, vtype, #nm, "VRT_stevedore_" #nm "(\v1)"}, +#include "tbl/vrt_stv_var.h" + { NULL, NULL, NULL, NULL}, }; diff --git a/lib/libvcc/vcc_storage.c b/lib/libvcc/vcc_storage.c index aa83a32dc..ac4fbeb7d 100644 --- a/lib/libvcc/vcc_storage.c +++ b/lib/libvcc/vcc_storage.c @@ -59,27 +59,11 @@ #include #include "vcc_compile.h" -#include "libvcc.h" // VCC_Stevedore() proto - -/*-------------------------------------------------------------------- - * - */ - -static struct stvars { - const char *name; - vcc_type_t type; -} stvars[] = { -#define VRTSTVVAR(nm, vtype, ctype, dval) { #nm, vtype }, -#include "tbl/vrt_stv_var.h" -#undef VRTSTVVAR - { NULL, BOOL } -}; void vcc_stevedore(struct vcc *vcc, const char *stv_name) { struct symbol *sym; - struct stvars *sv; char buf[1024]; CHECK_OBJ_NOTNULL(vcc, VCC_MAGIC); @@ -91,15 +75,4 @@ vcc_stevedore(struct vcc *vcc, const char *stv_name) bprintf(buf, "VRT_stevedore(\"%s\")", stv_name); sym->rname = TlDup(vcc, buf); sym->r_methods = ~0; - - for (sv = stvars; sv->name != NULL; sv++) { - bprintf(buf, "storage.%s.%s", stv_name, sv->name); - sym = VCC_MkSym(vcc, buf, SYM_VAR, VCL_LOW, VCL_41); - AN(sym); - sym->type = sv->type; - sym->eval = vcc_Eval_Var; - bprintf(buf, "VRT_Stv_%s(\"%s\")", sv->name, stv_name); - sym->rname = TlDup(vcc, buf); - sym->r_methods = ~0; - } } From dridi.boukelmoune at gmail.com Wed Jun 12 04:58:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 12 Jun 2019 04:58:10 +0000 (UTC) Subject: [master] 21efe76d2 Appropriate VSL group checking Message-ID: <20190612045810.BB744AE051@lists.varnish-cache.org> commit 21efe76d23ed81e5423c59055e55c2c5a7f29dbd Author: Dridi Boukelmoune Date: Thu May 16 15:02:54 2019 +0200 Appropriate VSL group checking We have a dedicated enum entry for that, and nothing prevents the caller from passing a negative value. diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index fb284a58a..b27646113 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -1088,7 +1088,7 @@ VSLQ_New(struct VSL_data *vsl, struct VSL_cursor **cp, struct VSLQ *vslq; CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC); - if (grouping > VSL_g_session) { + if (grouping < 0 || grouping >= VSL_g__MAX) { (void)vsl_diag(vsl, "Illegal query grouping"); return (NULL); } From dridi.boukelmoune at gmail.com Wed Jun 12 04:58:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 12 Jun 2019 04:58:10 +0000 (UTC) Subject: [master] 5ce86e76b Align columns Message-ID: <20190612045810.D0E9BAE054@lists.varnish-cache.org> commit 5ce86e76bbf73040ade4cea380f03e2d8ba438bf Author: Dridi Boukelmoune Date: Thu May 16 16:40:00 2019 +0200 Align columns diff --git a/lib/libvarnishapi/generate.py b/lib/libvarnishapi/generate.py index ea4ebd02a..e411957d6 100755 --- a/lib/libvarnishapi/generate.py +++ b/lib/libvarnishapi/generate.py @@ -45,33 +45,33 @@ if len(sys.argv) == 3: tokens = { # Numerical comparisons - "T_EQ": "==", - "T_NEQ": "!=", - "T_LEQ": "<=", - "T_GEQ": ">=", + "T_EQ": "==", + "T_NEQ": "!=", + "T_LEQ": "<=", + "T_GEQ": ">=", # String comparisons - "T_SEQ": "eq", + "T_SEQ": "eq", "T_SNEQ": "ne", # Regular expression matching "T_NOMATCH": "!~", # Boolean operators - "T_AND": "and", - "T_OR": "or", - "T_NOT": "not", + "T_AND": "and", + "T_OR": "or", + "T_NOT": "not", # Miscellaneous - None: "<>~[]{}():,", + None: "<>~[]{}():,", # These have handwritten recognizers - "VAL": None, - "EOI": None, + "VAL": None, + "EOI": None, # Special "T_TRUE": None, - "VXID": "vxid", + "VXID": "vxid", } ####################################################################### From dridi.boukelmoune at gmail.com Wed Jun 12 04:58:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 12 Jun 2019 04:58:10 +0000 (UTC) Subject: [master] 406ec859a Turn newline into the end of a VSL query Message-ID: <20190612045810.ED56FAE058@lists.varnish-cache.org> commit 406ec859a6275086166a8f4dd4ad0028a062f2ca Author: Dridi Boukelmoune Date: Thu May 16 16:40:47 2019 +0200 Turn newline into the end of a VSL query Instead of treating it as a mere whitespace separator. As a result the lexer output looks like this: TOK_1, ..., TOK_N, EOI[, TOK_1, ..., TOK_N, EOI[...]] At this point though, only the first series of tokens is considered, in a single query mode that was already what we've had so far. It will also be the parser's job to ignore consecutive EOI tokens for "empty" queries. diff --git a/lib/libvarnishapi/vxp_lexer.c b/lib/libvarnishapi/vxp_lexer.c index b004c55f8..ff5221e41 100644 --- a/lib/libvarnishapi/vxp_lexer.c +++ b/lib/libvarnishapi/vxp_lexer.c @@ -103,8 +103,8 @@ vxp_Lexer(struct vxp *vxp) for (p = vxp->b; p < vxp->e; ) { - /* Skip any whitespace */ - if (isspace(*p)) { + /* Skip any space or tab */ + if (isblank(*p)) { p++; continue; } @@ -126,6 +126,8 @@ vxp_Lexer(struct vxp *vxp) q++; if (q == vxp->e) break; + } else if (*q == '\n') { + break; } else if (*q == quote) { q++; quote = '\0'; @@ -157,6 +159,13 @@ vxp_Lexer(struct vxp *vxp) continue; } + /* On to the next query */ + if (*p == '\n') { + vxp_add_token(vxp, EOI, p, p + 1); + p++; + continue; + } + /* Error */ vxp_add_token(vxp, EOI, p, p + 1); VSB_printf(vxp->sb, "Syntax error "); From dridi.boukelmoune at gmail.com Wed Jun 12 04:58:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 12 Jun 2019 04:58:11 +0000 (UTC) Subject: [master] 94ca452d7 Allow comments in a VSL query Message-ID: <20190612045811.154C1AE05D@lists.varnish-cache.org> commit 94ca452d73cd09b4e8fb858797224281c12c1978 Author: Dridi Boukelmoune Date: Fri May 17 09:16:31 2019 +0200 Allow comments in a VSL query Now that we can have multiple lines in a query, it may come in handy to add a description of a query or its purpose. diff --git a/lib/libvarnishapi/vxp_lexer.c b/lib/libvarnishapi/vxp_lexer.c index ff5221e41..e6ce575aa 100644 --- a/lib/libvarnishapi/vxp_lexer.c +++ b/lib/libvarnishapi/vxp_lexer.c @@ -109,6 +109,13 @@ vxp_Lexer(struct vxp *vxp) continue; } + /* Skip comments */ + if (*p == '#') { + while (p < vxp->e && *p != '\n') + p++; + continue; + } + /* Match for the fixed tokens */ u = vxp_fixed_token(p, &q); if (u != 0) { From dridi.boukelmoune at gmail.com Wed Jun 12 04:58:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 12 Jun 2019 04:58:11 +0000 (UTC) Subject: [master] a3ab11ec7 Rename vxp_add_token to vxp_append_token Message-ID: <20190612045811.34983AE060@lists.varnish-cache.org> commit a3ab11ec72ce8bef27c5fa0405585b4f353854ce Author: Dridi Boukelmoune Date: Fri May 17 09:24:38 2019 +0200 Rename vxp_add_token to vxp_append_token We always add tokens in order, we don't need to check whether there was one present in the first place. diff --git a/lib/libvarnishapi/vxp_lexer.c b/lib/libvarnishapi/vxp_lexer.c index e6ce575aa..57f0c971f 100644 --- a/lib/libvarnishapi/vxp_lexer.c +++ b/lib/libvarnishapi/vxp_lexer.c @@ -45,7 +45,7 @@ #include "vxp.h" static void -vxp_add_token(struct vxp *vxp, unsigned tok, const char *b, const char *e) +vxp_append_token(struct vxp *vxp, unsigned tok, const char *b, const char *e) { struct token *t; @@ -54,10 +54,7 @@ vxp_add_token(struct vxp *vxp, unsigned tok, const char *b, const char *e) t->tok = tok; t->b = b; t->e = e; - if (vxp->t != NULL) - VTAILQ_INSERT_AFTER(&vxp->tokens, vxp->t, t, list); - else - VTAILQ_INSERT_TAIL(&vxp->tokens, t, list); + VTAILQ_INSERT_TAIL(&vxp->tokens, t, list); vxp->t = t; } @@ -120,7 +117,7 @@ vxp_Lexer(struct vxp *vxp) u = vxp_fixed_token(p, &q); if (u != 0) { AN(q); - vxp_add_token(vxp, u, p, q); + vxp_append_token(vxp, u, p, q); p = q; continue; } @@ -141,7 +138,7 @@ vxp_Lexer(struct vxp *vxp) break; } } - vxp_add_token(vxp, VAL, p, q); + vxp_append_token(vxp, VAL, p, q); if (quote != '\0') { VSB_printf(vxp->sb, "Unterminated string "); vxp_ErrWhere(vxp, vxp->t, q - p); @@ -157,7 +154,7 @@ vxp_Lexer(struct vxp *vxp) for (q = p; q < vxp->e; q++) if (!isword(*q)) break; - vxp_add_token(vxp, VAL, p, q); + vxp_append_token(vxp, VAL, p, q); vxp->t->dec = vxp_Alloc(vxp, (q - p) + 1); AN(vxp->t->dec); memcpy(vxp->t->dec, p, q - p); @@ -168,20 +165,20 @@ vxp_Lexer(struct vxp *vxp) /* On to the next query */ if (*p == '\n') { - vxp_add_token(vxp, EOI, p, p + 1); + vxp_append_token(vxp, EOI, p, p + 1); p++; continue; } /* Error */ - vxp_add_token(vxp, EOI, p, p + 1); + vxp_append_token(vxp, EOI, p, p + 1); VSB_printf(vxp->sb, "Syntax error "); vxp_ErrWhere(vxp, vxp->t, q - p); return; } /* Finished */ - vxp_add_token(vxp, EOI, vxp->e, vxp->e); + vxp_append_token(vxp, EOI, vxp->e, vxp->e); } #ifdef VXP_DEBUG From dridi.boukelmoune at gmail.com Wed Jun 12 04:58:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 12 Jun 2019 04:58:11 +0000 (UTC) Subject: [master] c061b8eb3 Treat multiline VSL queries as if they were OR'ed Message-ID: <20190612045811.58B88AE065@lists.varnish-cache.org> commit c061b8eb3f70017d343dd680a9886188b22890b9 Author: Dridi Boukelmoune Date: Fri May 17 10:06:05 2019 +0200 Treat multiline VSL queries as if they were OR'ed The two following queries now become equivalent: vut -g request -q ' # catch varnish errors *Error # catch backend errors BerespStatus >= 500 ' vut -g request -q '(*Error) or (BerespStatus >= 500)' It becomes interesting when we wish to capture transactions for different scenarios but would like to decompose them cleanly. Especially when the query of an individual scenario is rather complex and OR'ing everything manually would become cumbersome. This diff is better viewed with the --ignore-all-space flag. diff --git a/bin/varnishtest/tests/u00014.vtc b/bin/varnishtest/tests/u00014.vtc new file mode 100644 index 000000000..648bc45e6 --- /dev/null +++ b/bin/varnishtest/tests/u00014.vtc @@ -0,0 +1,91 @@ +varnishtest "VSL compound queries" + +# This test case compares individual query scenarios to their +# compounded queries counterparts. + +server s1 { + rxreq + txresp -status 500 + + rxreq + txresp -status 503 +} -start + +varnish v1 -vcl+backend "" -start + +client c1 { + txreq + rxresp + expect resp.status == 500 + + txreq + rxresp + expect resp.status == 503 +} -run + +# Let's fist create a script to reduce in all the variants below. + +shell { + cat >ncsa.sh <<-EOF + #!/bin/sh + + varnishncsa -d -n ${v1_name} -F '%s' "\$@" | + tr '\n' ' ' + # ' + EOF + chmod +x ncsa.sh +} + +shell -match "^500 503 $" { + # no query + ./ncsa.sh +} + +shell -err -expect "Query expression error" { + # empty query + varnishncsa -d -n ${v1_name} -q '' +} + +shell -err -expect "Query expression error" { + varnishncsa -d -n ${v1_name} -q ' + # empty multiline query + ' +} + +shell -err -expect "Query expression error" { + varnishncsa -d -n ${v1_name} -q ' + * ~ "Incomplete quoted string + ' +} + +shell -match "^500 $" { + # single query 1 + ./ncsa.sh -q 'RespStatus == 500' +} + +shell -match "^503 $" { + # single query 2 + ./ncsa.sh -q 'RespStatus == 503' +} + +shell -match "^500 503 $" { + # query 1 OR query 2 + ./ncsa.sh -q '(RespStatus == 500) or (RespStatus == 503)' +} + +shell -match "^500 503 $" { + ./ncsa.sh -q ' + # query 1 + RespStatus == 500 + + # query 2 + RespStatus == 503 + ' +} + +shell -match "^500 503 $" { + ./ncsa.sh -q ' + RespStatus == 500 # query 1 + RespStatus == 503 # query 2 + ' +} diff --git a/doc/sphinx/reference/vsl-query.rst b/doc/sphinx/reference/vsl-query.rst index 92b97c9e7..67cf2f02d 100644 --- a/doc/sphinx/reference/vsl-query.rst +++ b/doc/sphinx/reference/vsl-query.rst @@ -131,6 +131,26 @@ whose id can be obtained from an ``X-Varnish`` HTTP header, the default "guru meditation" error page, or ``Begin`` and ``Link`` log records. +A query must fit on a single line, but it is possible to pass multiple +queries at once, one query per line. Empty lines are ignored, and the +list of queries is treated as if the 'or' operator was used to combine +them. + +For example this list of queries:: + + # catch varnish errors + *Error + + # catch backend errors + BerespStatus >= 500 + +is identical to this query:: + + (*Error) or (BerespStatus >= 500) + +Comments can be used and will be ignored, they start with the ``'#'`` +character. + Record selection criteria ------------------------- diff --git a/lib/libvarnishapi/vxp_parse.c b/lib/libvarnishapi/vxp_parse.c index e6db240c5..16f65f42f 100644 --- a/lib/libvarnishapi/vxp_parse.c +++ b/lib/libvarnishapi/vxp_parse.c @@ -503,15 +503,30 @@ vxp_expr_or(struct vxp *vxp, struct vex **pvex) /* * SYNTAX: * expr: - * expr_or EOI + * expr_or EOI { 'or' expr_or EOI }? */ static void vxp_expr(struct vxp *vxp, struct vex **pvex) { - vxp_expr_or(vxp, pvex); + struct vex *a = NULL, *or; + + if (*pvex == NULL) { + vxp_expr_or(vxp, pvex); + ERRCHK(vxp); + ExpectErr(vxp, EOI); + return; + } + + vxp_expr(vxp, &a); ERRCHK(vxp); - ExpectErr(vxp, EOI); + + or = vex_alloc(vxp); + AN(or); + or->tok = T_OR; + or->b = *pvex; + or->a = a; + *pvex = or; } /* @@ -523,17 +538,27 @@ vxp_Parse(struct vxp *vxp) { struct vex *vex = NULL; + AZ(vxp->err); vxp->t = VTAILQ_FIRST(&vxp->tokens); - if (vxp->t == NULL) - return (NULL); - vxp_expr(vxp, &vex); + while (vxp->t != NULL) { + /* Ignore empty queries */ + while (vxp->t != NULL && vxp->t->tok == EOI) + vxp->t = VTAILQ_NEXT(vxp->t, list); + + if (vxp->t == NULL) + break; + + vxp_expr(vxp, &vex); + + if (vxp->err) { + if (vex) + vex_Free(&vex); + AZ(vex); + return (NULL); + } - if (vxp->err) { - if (vex) - vex_Free(&vex); - AZ(vex); - return (NULL); + vxp->t = VTAILQ_NEXT(vxp->t, list); } return (vex); From dridi.boukelmoune at gmail.com Wed Jun 12 04:58:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 12 Jun 2019 04:58:11 +0000 (UTC) Subject: [master] b7de3a9da Allow multiple -q options for VUTs Message-ID: <20190612045811.78B87AE069@lists.varnish-cache.org> commit b7de3a9da43bb45bb93c71a02b912ef627bfd7fa Author: Dridi Boukelmoune Date: Fri May 17 12:05:56 2019 +0200 Allow multiple -q options for VUTs This makes the following queries equivalent: vut -g request -q '*Error' -q 'BerespStatus >= 500' vut -g request -q ' *Error BerespStatus >= 500 ' vut -g request -q '(*Error) or (BerespStatus >= 500)' We now have two ways to express "compound" VSL queries, although this ultimately relies on multiline queries. diff --git a/bin/varnishtest/tests/u00014.vtc b/bin/varnishtest/tests/u00014.vtc index 648bc45e6..244dcc08f 100644 --- a/bin/varnishtest/tests/u00014.vtc +++ b/bin/varnishtest/tests/u00014.vtc @@ -89,3 +89,8 @@ shell -match "^500 503 $" { RespStatus == 503 # query 2 ' } + +shell -match "^500 503 $" { + # multiple -q options + ./ncsa.sh -q 'RespStatus == 500' -q 'RespStatus == 503' +} diff --git a/include/vut_options.h b/include/vut_options.h index d6941e1fe..f2c47deb1 100644 --- a/include/vut_options.h +++ b/include/vut_options.h @@ -75,7 +75,9 @@ #define VUT_OPT_q \ VOPT("q:", "[-q ]", "VSL query", \ - "Specifies the VSL query to use." \ + "Specifies the VSL query to use. When multiple -q" \ + " options are specified, all queries are considered" \ + " as if the 'or' operator was used to combine them." \ ) #define VUT_OPT_r \ diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 91be51925..bb46128a9 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -50,6 +50,7 @@ #include "vas.h" #include "miniobj.h" #include "vcs.h" +#include "vsb.h" #include "vut.h" @@ -126,6 +127,30 @@ VUT_Error(struct VUT *vut, int status, const char *fmt, ...) exit(status); } +static void +vut_arg_q(struct VUT *vut, const char *arg) +{ + struct vsb *vsb; + char *s; + + AN(arg); + if (vut->q_arg == NULL) { + REPLACE(vut->q_arg, arg); + return; + } + + vsb = VSB_new_auto(); + AN(vsb); + AZ(VSB_printf(vsb, "%s\n%s", vut->q_arg, arg)); + AZ(VSB_finish(vsb)); + + s = strdup(VSB_data(vsb)); + REPLACE(vut->q_arg, s); + + VSB_clear(vsb); + VSB_destroy(&vsb); +} + int VUT_Arg(struct VUT *vut, int opt, const char *arg) { @@ -169,8 +194,7 @@ VUT_Arg(struct VUT *vut, int opt, const char *arg) return (1); case 'q': /* Query to use */ - AN(arg); - REPLACE(vut->q_arg, arg); + vut_arg_q(vut, arg); return (1); case 'r': /* Binary file input */ From dridi.boukelmoune at gmail.com Wed Jun 12 04:58:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 12 Jun 2019 04:58:11 +0000 (UTC) Subject: [master] 69976ebfa Assert Message-ID: <20190612045811.9BC89AE06E@lists.varnish-cache.org> commit 69976ebfa0e32abc1ff430d0debcc999bcdd27e4 Author: Dridi Boukelmoune Date: Fri May 17 13:37:42 2019 +0200 Assert diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index bb46128a9..0fdce6634 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -157,6 +157,9 @@ VUT_Arg(struct VUT *vut, int opt, const char *arg) int i; char *p; + CHECK_OBJ_NOTNULL(vut, VUT_MAGIC); + AN(opt); + switch (opt) { case 'd': /* Head */ From dridi.boukelmoune at gmail.com Wed Jun 12 04:58:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 12 Jun 2019 04:58:11 +0000 (UTC) Subject: [master] d704203e1 Whitespace OCD Message-ID: <20190612045811.BE0D8AE072@lists.varnish-cache.org> commit d704203e121eb4cf52bd9829fc0e3b96a28d0c2f Author: Dridi Boukelmoune Date: Fri May 17 13:38:19 2019 +0200 Whitespace OCD diff --git a/include/vut_options.h b/include/vut_options.h index f2c47deb1..6b4675c18 100644 --- a/include/vut_options.h +++ b/include/vut_options.h @@ -36,7 +36,7 @@ #define VUT_GLOBAL_OPT_P \ VOPT("P:", "[-P ]", "PID file", \ - "Write the process' PID to the specified file." \ + "Write the process' PID to the specified file." \ ) #define VUT_GLOBAL_OPT_V \ From dridi.boukelmoune at gmail.com Wed Jun 12 04:58:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 12 Jun 2019 04:58:11 +0000 (UTC) Subject: [master] 8fd8366fd Add VUT_OPT_Q to get a VSL query from a file Message-ID: <20190612045812.06B9BAE079@lists.varnish-cache.org> commit 8fd8366fd55a7818fd66bff09bca3340de2b28c4 Author: Dridi Boukelmoune Date: Fri May 17 13:55:43 2019 +0200 Add VUT_OPT_Q to get a VSL query from a file diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h index 1bf1de7c7..44d710da4 100644 --- a/bin/varnishhist/varnishhist_options.h +++ b/bin/varnishhist/varnishhist_options.h @@ -91,6 +91,7 @@ HIS_OPT_p #undef HIS_CLIENT #undef HIS_PROF HIS_OPT_P +VUT_OPT_Q VUT_OPT_q VUT_OPT_r VUT_OPT_t diff --git a/bin/varnishlog/varnishlog_options.h b/bin/varnishlog/varnishlog_options.h index ea0b4c698..8c9fd1db7 100644 --- a/bin/varnishlog/varnishlog_options.h +++ b/bin/varnishlog/varnishlog_options.h @@ -68,6 +68,7 @@ VUT_OPT_k VSL_OPT_L VUT_OPT_n VUT_GLOBAL_OPT_P +VUT_OPT_Q VUT_OPT_q VUT_OPT_r VSL_OPT_R diff --git a/bin/varnishncsa/varnishncsa_options.h b/bin/varnishncsa/varnishncsa_options.h index 73765083f..8987a9615 100644 --- a/bin/varnishncsa/varnishncsa_options.h +++ b/bin/varnishncsa/varnishncsa_options.h @@ -86,6 +86,7 @@ VUT_OPT_h VSL_OPT_L VUT_OPT_n VUT_GLOBAL_OPT_P +VUT_OPT_Q VUT_OPT_q VUT_OPT_r VSL_OPT_R diff --git a/bin/varnishtest/tests/u00014.vtc b/bin/varnishtest/tests/u00014.vtc index 244dcc08f..dc3138ae3 100644 --- a/bin/varnishtest/tests/u00014.vtc +++ b/bin/varnishtest/tests/u00014.vtc @@ -58,6 +58,15 @@ shell -err -expect "Query expression error" { ' } +shell -err -expect "Query expression error" { + echo '# empty query file' >empty.vslq + varnishncsa -d -n ${v1_name} -Q empty.vslq +} + +shell -err -expect "-Q missing.vslq: No such file or directory" { + varnishncsa -d -n ${v1_name} -Q missing.vslq +} + shell -match "^500 $" { # single query 1 ./ncsa.sh -q 'RespStatus == 500' @@ -90,7 +99,40 @@ shell -match "^500 503 $" { ' } +shell -match "^500 503 $" { + cat >query.vslq <<-EOF + # query 1 + RespStatus == 500 + + # query 2 + RespStatus == 503 + EOF + ./ncsa.sh -Q query.vslq +} + shell -match "^500 503 $" { # multiple -q options ./ncsa.sh -q 'RespStatus == 500' -q 'RespStatus == 503' } + +shell -match "^500 503 $" { + # multiple -Q options + + cat >query1.vslq <<-EOF + # query 1 + RespStatus == 500 + EOF + + cat >query2.vslq <<-EOF + # query 2 + RespStatus == 503 + EOF + + ./ncsa.sh -Q query1.vslq -Q query2.vslq +} + +shell -match "^500 503 $" { + # mix -Q and -q options + + ./ncsa.sh -Q query1.vslq -q 'RespStatus == 503' +} diff --git a/bin/varnishtop/varnishtop_options.h b/bin/varnishtop/varnishtop_options.h index 6605d463a..2a6c312e7 100644 --- a/bin/varnishtop/varnishtop_options.h +++ b/bin/varnishtop/varnishtop_options.h @@ -73,6 +73,7 @@ VSL_OPT_I VSL_OPT_L VUT_OPT_n TOP_OPT_p +VUT_OPT_Q VUT_OPT_q VUT_OPT_r VUT_OPT_t diff --git a/doc/sphinx/reference/vsl-query.rst b/doc/sphinx/reference/vsl-query.rst index 67cf2f02d..072747f4c 100644 --- a/doc/sphinx/reference/vsl-query.rst +++ b/doc/sphinx/reference/vsl-query.rst @@ -149,7 +149,7 @@ is identical to this query:: (*Error) or (BerespStatus >= 500) Comments can be used and will be ignored, they start with the ``'#'`` -character. +character, which may be more useful when the query is read from a file. Record selection criteria ------------------------- diff --git a/include/vut_options.h b/include/vut_options.h index 6b4675c18..7aacaaaec 100644 --- a/include/vut_options.h +++ b/include/vut_options.h @@ -73,10 +73,18 @@ " the host name is used." \ ) +#define VUT_OPT_Q \ + VOPT("Q:", "[-Q ]", "VSL query file", \ + "Specifies the file containing the VSL query to use." \ + " When multiple -Q or -q options are specified, all" \ + " queries are considered as if the 'or' operator was" \ + " used to combine them." \ + ) + #define VUT_OPT_q \ VOPT("q:", "[-q ]", "VSL query", \ - "Specifies the VSL query to use. When multiple -q" \ - " options are specified, all queries are considered" \ + "Specifies the VSL query to use. When multiple -q or" \ + " -Q options are specified, all queries are considered" \ " as if the 'or' operator was used to combine them." \ ) diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 0fdce6634..db7f97116 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -51,6 +51,7 @@ #include "miniobj.h" #include "vcs.h" #include "vsb.h" +#include "vfil.h" #include "vut.h" @@ -195,8 +196,19 @@ VUT_Arg(struct VUT *vut, int opt, const char *arg) AN(arg); REPLACE(vut->P_arg, arg); return (1); + case 'Q': + AN(arg); + p = VFIL_readfile(NULL, arg, NULL); + if (p == NULL) { + VUT_Error(vut, 1, "-Q %s: %s", arg, strerror(errno)); + return (-1); + } + vut_arg_q(vut, p); + free(p); + return (1); case 'q': /* Query to use */ + AN(arg); vut_arg_q(vut, arg); return (1); case 'r': From dridi.boukelmoune at gmail.com Wed Jun 12 04:58:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 12 Jun 2019 04:58:12 +0000 (UTC) Subject: [master] de44cc3c2 Test coverage for a query on a multiline VSL record Message-ID: <20190612045812.3032CAE089@lists.varnish-cache.org> commit de44cc3c23a1cbf3dc95da7f274461ed8f2223fd Author: Dridi Boukelmoune Date: Mon May 27 16:29:43 2019 +0200 Test coverage for a query on a multiline VSL record Not a multiline VSL query, it's the record containing multiple lines. diff --git a/bin/varnishtest/tests/u00014.vtc b/bin/varnishtest/tests/u00014.vtc index dc3138ae3..9667d85c6 100644 --- a/bin/varnishtest/tests/u00014.vtc +++ b/bin/varnishtest/tests/u00014.vtc @@ -136,3 +136,13 @@ shell -match "^500 503 $" { ./ncsa.sh -Q query1.vslq -q 'RespStatus == 503' } + +# Make v1 log a multiline VSL record and query it + +logexpect l1 -v v1 -g raw -q {CLI ~ "\\nvcl1.s1"} { + expect 0 0 CLI "vcl1.s1 +healthy" +} -start + +varnish v1 -cliok backend.list + +logexpect l1 -wait From dridi.boukelmoune at gmail.com Wed Jun 12 04:58:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 12 Jun 2019 04:58:12 +0000 (UTC) Subject: [master] 11b8a7ebd Reinstitute multi-line VSL queries Message-ID: <20190612045812.61408AE091@lists.varnish-cache.org> commit 11b8a7ebdb30516b4181c8ae61e9b0ce150f08de Author: Dridi Boukelmoune Date: Wed Jun 5 14:12:39 2019 +0200 Reinstitute multi-line VSL queries Forcing one line per query can lead to very long lines for cases where we can't decompose OR-able individual queries. Where newline previously acted as a mere space between tokens, the backslash-newline sequence now fills that void. diff --git a/bin/varnishtest/tests/u00014.vtc b/bin/varnishtest/tests/u00014.vtc index 9667d85c6..488357e1b 100644 --- a/bin/varnishtest/tests/u00014.vtc +++ b/bin/varnishtest/tests/u00014.vtc @@ -54,7 +54,8 @@ shell -err -expect "Query expression error" { shell -err -expect "Query expression error" { varnishncsa -d -n ${v1_name} -q ' - * ~ "Incomplete quoted string + * ~ "Incomplete quoted + string" ' } @@ -137,7 +138,32 @@ shell -match "^500 503 $" { ./ncsa.sh -Q query1.vslq -q 'RespStatus == 503' } -# Make v1 log a multiline VSL record and query it +shell -match "^500 $" { + set -e + + tee query1_cont.vslq <<-EOF | wc -l | grep -q 4 # ensure 4 lines + # line continuation + RespStatus \\ + == \\ + 500 + EOF + + ./ncsa.sh -Q query1_cont.vslq +} + +shell -err -expect "Query expression error" { + set -e + + tee string_cont.vslq <<-EOF | wc -l | grep -q 3 # ensure 3 lines + # quoted string continuation + * ~ "very long \\ + string" + EOF + + varnishncsa -d -n ${v1_name} -Q string_cont.vslq +} + +# Make v1 log a multiline VSL record and query it (hardly useful) logexpect l1 -v v1 -g raw -q {CLI ~ "\\nvcl1.s1"} { expect 0 0 CLI "vcl1.s1 +healthy" diff --git a/doc/sphinx/reference/vsl-query.rst b/doc/sphinx/reference/vsl-query.rst index 072747f4c..71534a4b0 100644 --- a/doc/sphinx/reference/vsl-query.rst +++ b/doc/sphinx/reference/vsl-query.rst @@ -151,6 +151,23 @@ is identical to this query:: Comments can be used and will be ignored, they start with the ``'#'`` character, which may be more useful when the query is read from a file. +For very long queries that couldn't easily be split into multiple queries +it is possible to break them into multiple lines with a backslash preceding +an end of line. + +For example this query:: + + BerespStatus >= 500 + +is identical to this query:: + + BerespStatus \ + >= \ + 500 + +A backslash-newline sequence doesn't continue a comment on the next line +and isn't allowed in a quoted string. + Record selection criteria ------------------------- diff --git a/lib/libvarnishapi/vxp_lexer.c b/lib/libvarnishapi/vxp_lexer.c index 57f0c971f..b1e952a12 100644 --- a/lib/libvarnishapi/vxp_lexer.c +++ b/lib/libvarnishapi/vxp_lexer.c @@ -106,6 +106,11 @@ vxp_Lexer(struct vxp *vxp) continue; } + if (*p == '\\' && p[1] == '\n') { + p += 2; + continue; + } + /* Skip comments */ if (*p == '#') { while (p < vxp->e && *p != '\n') @@ -128,7 +133,7 @@ vxp_Lexer(struct vxp *vxp) for (q = p + 1; q < vxp->e; q++) { if (*q == '\\') { q++; - if (q == vxp->e) + if (q == vxp->e || *q == '\n') break; } else if (*q == '\n') { break; From dridi.boukelmoune at gmail.com Wed Jun 12 04:58:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 12 Jun 2019 04:58:12 +0000 (UTC) Subject: [master] 9689c5399 Start skeleton release notes for the next version. Message-ID: <20190612045812.87C62AE09C@lists.varnish-cache.org> commit 9689c5399e87f487b7da9b413942f3dc091d9729 Author: Geoff Simmons Date: Tue Sep 25 16:31:17 2018 +0200 Start skeleton release notes for the next version. Restructured so that: * 'Upgrading' is limited to work that has to be done to upgrade from a current deployment to the new version. * 'Changes' is a comprehensive, user-level description of changes and new features. Conflicts: doc/sphinx/whats-new/index.rst diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst new file mode 100644 index 000000000..fbda9d6b9 --- /dev/null +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -0,0 +1,73 @@ +**Note: This is a working document for a future release, with running +updates for changes in the development branch. For changes in the +released versions of Varnish, see:** :ref:`whats-new-index` + +.. _whatsnew_changes_CURRENT: + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Changes in Varnish **$NEXT_RELEASE** +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +For information about updating your current Varnish deployment to the +new version, see :ref:`whatsnew_upgrading_CURRENT`. + +A more detailed and technical account of changes in Varnish, with +links to issues that have been fixed and pull requests that have been +merged, may be found in the `change log`_. + +.. _change log: https://github.com/varnishcache/varnish-cache/blob/master/doc/changes.rst + +varnishd +======== + +Parameters +~~~~~~~~~~ + +**XXX changes in -p parameters** + +Other changes in varnishd +~~~~~~~~~~~~~~~~~~~~~~~~~ + +Changes to VCL +============== + +VCL variables +~~~~~~~~~~~~~ + +**XXX new, deprecated or removed variables, or changed semantics** + +Other changes to VCL +~~~~~~~~~~~~~~~~~~~~ + +VMODs +===== + +**XXX changes in the bundled VMODs** + +varnishlog +========== + +**XXX changes concerning varnishlog(1) and/or vsl(7)** + +varnishadm +========== + +**XXX changes concerning varnishadm(1) and/or varnish-cli(7)** + +varnishstat +=========== + +**XXX changes concerning varnishstat(1) and/or varnish-counters(7)** + +varnishtest +=========== + +**XXX changes concerning varnishtest(1) and/or vtc(7)** + +Changes for developers and VMOD authors +======================================= + +**XXX changes concerning VRT, the public APIs, source code organization, +builds etc.** + +*eof* diff --git a/doc/sphinx/whats-new/index.rst b/doc/sphinx/whats-new/index.rst index 424c6685d..510027c08 100644 --- a/doc/sphinx/whats-new/index.rst +++ b/doc/sphinx/whats-new/index.rst @@ -8,6 +8,20 @@ This section describes the changes and improvements between different versions of Varnish, and what upgrading between the different versions entail. +Varnish **$NEXT_RELEASE** +------------------------- + +**Note: These are working documents for a future release, with running +updates for changes in the development branch. For changes in the +released versions of Varnish, see the chapters listed below.** + + +.. toctree:: + :maxdepth: 2 + + changes-trunk + upgrading-trunk + Varnish 6.2 ----------- diff --git a/doc/sphinx/whats-new/upgrading-trunk.rst b/doc/sphinx/whats-new/upgrading-trunk.rst new file mode 100644 index 000000000..6143fde99 --- /dev/null +++ b/doc/sphinx/whats-new/upgrading-trunk.rst @@ -0,0 +1,33 @@ +**Note: This is a working document for a future release, with running +updates for changes in the development branch. For changes in the +released versions of Varnish, see:** :ref:`whats-new-index` + +.. _whatsnew_upgrading_CURRENT: + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Upgrading to Varnish **$NEXT_RELEASE** +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +**XXX: how to upgrade from previous deployments to this +version. Limited to work that has to be done for an upgrade, new +features are listed in "Changes". Explicitly mention what does *not* +have to be changed, especially in VCL. May include, but is not limited +to:** + +* Elements of VCL that have been removed or are deprecated, or whose + semantics have changed. + +* -p parameters that have been removed or are deprecated, or whose + semantics have changed. + +* Changes in the CLI. + +* Changes in the output or interpretation of stats or the log, including + changes affecting varnishncsa/-hist/-top. + +* Changes that may be necessary in VTCs or in the use of varnishtest. + +* Changes in public APIs that may require changes in VMODs or VAPI/VUT + clients. + +*eof* From dridi.boukelmoune at gmail.com Wed Jun 12 04:58:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 12 Jun 2019 04:58:12 +0000 (UTC) Subject: [master] 316dfbc84 Mention VSL query syntax in 2019-09 release notes Message-ID: <20190612045812.AD1B2AE0A6@lists.varnish-cache.org> commit 316dfbc84d0cf294848a20d059af09833c5d74db Author: Dridi Boukelmoune Date: Thu Jun 6 13:49:23 2019 +0200 Mention VSL query syntax in 2019-09 release notes diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index fbda9d6b9..224b81b9f 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -44,10 +44,81 @@ VMODs **XXX changes in the bundled VMODs** -varnishlog -========== +vsl-query(7) +============ + +The syntax for VSL queries, mainly available via the ``-q`` option with +:ref:`varnishlog(1)` and similar tools, has slightly changed. Previously +and end of line in a query would be treated as a simple token separator +so in a script you could for example write this:: + + varnishlog -q ' + tag operator operand or + tag operator operand or + tag operator operand + ' -g request ... + +From now on, a query ends at the end of the line, but multiple queries +can be specified in which case it acts as if the ``or`` operator was used +to join all the queries. + +With this change in the syntax, the following query:: + + varnishlog -q ' + query1 + query2 + ' + +is equivalent to:: + + varnishlog -q '(query1) or (query2)' + +In other words, if you are using a Varnish utility to process transactions +for several independent reasons, you can decompose complex queries into +simpler ones by breaking them into separate lines, and for the most complex +queries possibly getting rid of parenthesis you would have needed in a +single query. + +If your query is complex and long, but cannot appropriately be broken down +into multiple queries, you can still break it down into multiple lines by +using a backslash-newline sequence:: + + tag operator operand and \ + tag operator operand and \ + tag operator operand + +See :ref:`vsl-query(7)` for more information about this change. + +With this new meaning for an end of line in a query it is now possible to +add comments in a query. If you run into the situation where again you need +to capture transactions for multiple reasons, you may document it directly +in the query:: + + varnishlog -q ' + # catch varnish errors + *Error + + # catch client errors + BerespStatus >= 400 and BerespStatus < 500 + + # catch backend errors + BerespStatus >= 500 + ' -g request + +This way when you later revisit a complex query, comments may help you +maintain an understanding of each individual query. This can become even +more convenient when the query is stored in a file. + +varnishlog(1), varnishncsa(1) and others +======================================== + +Our collection of log-processing tools gained the ability to specify +multiple ``-q`` options. While previously only the last ``-q`` option +would prevail you may now pass multiple individual queries and filtering +will operate as if the ``or`` operator was used to join all the queries. -**XXX changes concerning varnishlog(1) and/or vsl(7)** +A new ``-Q`` option allows you to read the query from a file instead. It +can also be used multiple times and adds up to any ``-q`` option specified. varnishadm ========== From dridi.boukelmoune at gmail.com Wed Jun 12 12:21:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 12 Jun 2019 12:21:09 +0000 (UTC) Subject: [master] f1584fd8d Partial revert of "Appropriate VSL group checking" Message-ID: <20190612122109.376B49A6A@lists.varnish-cache.org> commit f1584fd8d8e28308ef0c37af7b33aad947fcf50f Author: Dridi Boukelmoune Date: Wed Jun 12 14:17:14 2019 +0200 Partial revert of "Appropriate VSL group checking" This would trigger the tautological-compare warning on a recent-enough Clang, and SunCC appears to complain as well. Reported by @daghf. diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index b27646113..4bef6b233 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -1088,7 +1088,7 @@ VSLQ_New(struct VSL_data *vsl, struct VSL_cursor **cp, struct VSLQ *vslq; CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC); - if (grouping < 0 || grouping >= VSL_g__MAX) { + if (grouping >= VSL_g__MAX) { (void)vsl_diag(vsl, "Illegal query grouping"); return (NULL); } From dridi.boukelmoune at gmail.com Thu Jun 13 05:49:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 13 Jun 2019 05:49:07 +0000 (UTC) Subject: [master] e4efa422c Kill dead statement Message-ID: <20190613054907.811DBA3D4F@lists.varnish-cache.org> commit e4efa422cec26bf285deab9ebc4f024186e27c88 Author: Dridi Boukelmoune Date: Thu Jun 13 07:47:37 2019 +0200 Kill dead statement Spotted by VTEST. diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index db7f97116..fe4f22cc7 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -199,10 +199,8 @@ VUT_Arg(struct VUT *vut, int opt, const char *arg) case 'Q': AN(arg); p = VFIL_readfile(NULL, arg, NULL); - if (p == NULL) { + if (p == NULL) VUT_Error(vut, 1, "-Q %s: %s", arg, strerror(errno)); - return (-1); - } vut_arg_q(vut, p); free(p); return (1); From dridi.boukelmoune at gmail.com Thu Jun 13 08:13:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 13 Jun 2019 08:13:08 +0000 (UTC) Subject: [master] 2e5807745 Give up on one u14 test Message-ID: <20190613081308.1458CA6BAF@lists.varnish-cache.org> commit 2e5807745cde363f45600116477c417fcf5d91cc Author: Dridi Boukelmoune Date: Thu Jun 13 10:12:00 2019 +0200 Give up on one u14 test That libtool bug on SunOS... diff --git a/bin/varnishtest/tests/u00014.vtc b/bin/varnishtest/tests/u00014.vtc index 488357e1b..05f458798 100644 --- a/bin/varnishtest/tests/u00014.vtc +++ b/bin/varnishtest/tests/u00014.vtc @@ -41,11 +41,6 @@ shell -match "^500 503 $" { ./ncsa.sh } -shell -err -expect "Query expression error" { - # empty query - varnishncsa -d -n ${v1_name} -q '' -} - shell -err -expect "Query expression error" { varnishncsa -d -n ${v1_name} -q ' # empty multiline query From fgsch at lodoss.net Thu Jun 13 17:34:08 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 13 Jun 2019 17:34:08 +0000 (UTC) Subject: [master] 96e81ce2e Plug minor leak and cleanup Message-ID: <20190613173408.F0F0C65B4@lists.varnish-cache.org> commit 96e81ce2e2248e4e1c5918544f425e75b36fda40 Author: Federico G. Schwindt Date: Thu Jun 13 18:20:16 2019 +0100 Plug minor leak and cleanup diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index fe4f22cc7..5c9d6a509 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -132,7 +132,6 @@ static void vut_arg_q(struct VUT *vut, const char *arg) { struct vsb *vsb; - char *s; AN(arg); if (vut->q_arg == NULL) { @@ -145,10 +144,8 @@ vut_arg_q(struct VUT *vut, const char *arg) AZ(VSB_printf(vsb, "%s\n%s", vut->q_arg, arg)); AZ(VSB_finish(vsb)); - s = strdup(VSB_data(vsb)); - REPLACE(vut->q_arg, s); + REPLACE(vut->q_arg, VSB_data(vsb)); - VSB_clear(vsb); VSB_destroy(&vsb); } From phk at FreeBSD.org Mon Jun 17 07:00:16 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 17 Jun 2019 07:00:16 +0000 (UTC) Subject: [master] 4600cf986 Simplify vtc_record() Message-ID: <20190617070016.C468CA33A1@lists.varnish-cache.org> commit 4600cf986c4645feb18e939ae6a40bbe211cb350 Author: Poul-Henning Kamp Date: Mon Jun 17 06:03:08 2019 +0000 Simplify vtc_record() diff --git a/bin/varnishtest/vtc_subr.c b/bin/varnishtest/vtc_subr.c index ffcc51ef7..3cf36d586 100644 --- a/bin/varnishtest/vtc_subr.c +++ b/bin/varnishtest/vtc_subr.c @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include #include @@ -42,7 +42,6 @@ #include "vct.h" #include "vnum.h" #include "vre.h" -#include "vtcp.h" struct vsb * vtc_hex_to_bin(struct vtclog *vl, const char *arg) @@ -188,29 +187,24 @@ vtc_wait4(struct vtclog *vl, long pid, void * vtc_record(struct vtclog *vl, int fd, struct vsb *vsb) { - char buf[65536]; - struct pollfd fds[1]; + char buf[BUFSIZ]; int i; - VTCP_nonblocking(fd); while (1) { - memset(fds, 0, sizeof fds); - fds->fd = fd; - fds->events = POLLIN; - i = poll(fds, 1, 10000); - if (i == 0) - continue; - if (fds->revents & POLLIN) { - i = read(fd, buf, sizeof buf - 1); - if (i > 0) { - if (vsb != NULL) - VSB_bcat(vsb, buf, i); - buf[i] = '\0'; - vtc_dump(vl, 3, "debug", buf, -2); - } - } - if (fds->revents & (POLLERR|POLLHUP)) { - vtc_log(vl, 4, "STDOUT poll 0x%x", fds->revents); + errno = 0; + i = read(fd, buf, sizeof buf - 1); + if (i > 0) { + if (vsb != NULL) + VSB_bcat(vsb, buf, i); + buf[i] = '\0'; + vtc_dump(vl, 3, "debug", buf, -2); + } else if (i == 0 && errno == 0) { + vtc_log(vl, 4, "STDOUT EOF"); + break; + } else { + vtc_log(vl, 4, + "STDOUT read failed with %d - %s.", + errno, strerror(errno)); break; } } From phk at FreeBSD.org Mon Jun 17 07:00:17 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 17 Jun 2019 07:00:17 +0000 (UTC) Subject: [master] 18f63d489 Add "error" state to backend fetch and response Message-ID: <20190617070017.15E9BA33AF@lists.varnish-cache.org> commit 18f63d489704db53d6b3f25ab13858f1762c37fd Author: Andrew Wiik Date: Tue Jun 4 11:01:04 2019 -0400 Add "error" state to backend fetch and response diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a6ade1d39..a204200c1 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -412,6 +412,9 @@ struct busyobj { struct http_conn *htc; + uint16_t err_code; + const char *err_reason; + struct pool_task fetch_task; #define BO_FLAG(l, r, w, d) unsigned l:1; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 88ee91cd8..c01de9387 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -277,7 +277,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL) return (F_STP_FAIL); - assert (wrk->handling == VCL_RET_FETCH); + assert (wrk->handling == VCL_RET_FETCH || wrk->handling == VCL_RET_ERROR); HTTP_Setup(bo->beresp, bo->ws, bo->vsl, SLT_BerespMethod); @@ -290,6 +290,9 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) bo->vfc->resp = bo->beresp; bo->vfc->req = bo->bereq; + if (wrk->handling == VCL_RET_ERROR) + return (F_STP_ERROR); + i = VDI_GetHdr(bo); now = W_TIM_real(wrk); @@ -384,10 +387,14 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) VCL_backend_response_method(bo->vcl, wrk, NULL, bo, NULL); - if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL) { + if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL || + wrk->handling == VCL_RET_ERROR) { bo->htc->doclose = SC_RESP_CLOSE; VDI_Finish(bo); - return (F_STP_FAIL); + if (wrk->handling == VCL_RET_ERROR) + return (F_STP_ERROR); + else + return (F_STP_FAIL); } if (wrk->handling == VCL_RET_RETRY) { @@ -705,7 +712,8 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) AN(bo->fetch_objcore->flags & OC_F_BUSY); assert(bo->director_state == DIR_S_NULL); - wrk->stats->fetch_failed++; + if (wrk->handling != VCL_RET_ERROR) + wrk->stats->fetch_failed++; now = W_TIM_real(wrk); VSLb_ts_busyobj(bo, "Error", now); @@ -719,7 +727,11 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) // XXX: reset all beresp flags ? HTTP_Setup(bo->beresp, bo->ws, bo->vsl, SLT_BerespMethod); - http_PutResponse(bo->beresp, "HTTP/1.1", 503, "Backend fetch failed"); + if (bo->err_code > 0) + http_PutResponse(bo->beresp, "HTTP/1.1", bo->err_code, bo->err_reason); + else + http_PutResponse(bo->beresp, "HTTP/1.1", 503, "Backend fetch failed"); + http_TimeHeader(bo->beresp, "Date: ", now); http_SetHeader(bo->beresp, "Server: Varnish"); diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 854a690f2..81cc12b09 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -55,9 +55,18 @@ VRT_synth(VRT_CTX, VCL_INT code, VCL_STRING reason) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + assert(ctx->req != NULL || ctx->bo != NULL); if (code < 100 || code > 65535) code = 503; + + if (ctx->req == NULL) { + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + ctx->bo->err_code = (uint16_t)code; + ctx->bo->err_reason = reason ? reason + : http_Status2Reason(ctx->bo->err_code % 1000, NULL); + return; + } + ctx->req->err_code = (uint16_t)code; ctx->req->err_reason = reason ? reason : http_Status2Reason(ctx->req->err_code % 1000, NULL); diff --git a/bin/varnishtest/tests/v00062.vtc b/bin/varnishtest/tests/v00062.vtc new file mode 100644 index 000000000..365b949d6 --- /dev/null +++ b/bin/varnishtest/tests/v00062.vtc @@ -0,0 +1,78 @@ +varnishtest "backend_(fetch|response) error state with custom status/reason" + +server s1 -repeat 3 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_fetch { + if (bereq.url == "/errorsynth") { + return (error(403)); + } + + if (bereq.url == "/errorsynthbody") { + return (error(403, "Steven has no cookies")); + } + + if (bereq.url == "/error") { + return (error); + } + } + + sub vcl_backend_response { + if (bereq.url == "/resperrorsynth") { + return (error(403)); + } + + if (bereq.url == "/resperrorsynthbody") { + return (error(403, "Steven has no cookies")); + } + + if (bereq.url == "/resperror") { + return (error); + } + } + + sub vcl_backend_error { + set beresp.http.error = "visited"; + } +} -start + +client c1 { + txreq -url /error + rxresp + expect resp.status == 503 + expect resp.http.error == visited + + txreq -url /errorsynth + rxresp + expect resp.status == 403 + expect resp.http.error == visited + + txreq -url /errorsynthbody + rxresp + expect resp.status == 403 + expect resp.reason == "Steven has no cookies" + expect resp.http.error == visited + + txreq -url /resperror + rxresp + expect resp.status == 503 + expect resp.http.error == visited + + txreq -url /resperrorsynth + rxresp + expect resp.status == 403 + expect resp.http.error == visited + + txreq -url /resperrorsynthbody + rxresp + expect resp.status == 403 + expect resp.reason == "Steven has no cookies" + expect resp.http.error == visited +} -run + +# Make sure we don't increment the failed fetch counter + +varnish v1 -expect fetch_failed == 0 diff --git a/doc/graphviz/cache_fetch.dot b/doc/graphviz/cache_fetch.dot index eb68f72a3..96c0967a0 100644 --- a/doc/graphviz/cache_fetch.dot +++ b/doc/graphviz/cache_fetch.dot @@ -39,16 +39,18 @@ digraph cache_fetch { /* vbf_stp_startfetch() */ v_b_f [ shape=record - label="{vbf_stp_startfetch:|{vcl_backend_fetch\{\}|bereq.*}|{fail|abandon|fetch}}" + label="{vbf_stp_startfetch:|{vcl_backend_fetch\{\}|bereq.*}|{error|fail|abandon|fetch}}" ] + v_b_f:error:s -> v_b_e v_b_f:fetch:s -> v_b_hdrs [style=bold] v_b_hdrs [ label="send bereq,\nread beresp (headers)"] v_b_hdrs -> v_b_r [style=bold] v_b_hdrs -> v_b_e v_b_r [ shape=record - label="{vbf_stp_startfetch:|{vcl_backend_response\{\}|{bereq.*|beresp.*}}|{fail|{retry|{max?|ok?}}|abandon|{deliver or pass|{304?|other?}}}}" + label="{vbf_stp_startfetch:|{vcl_backend_response\{\}|{bereq.*|beresp.*}}|{error|fail|{retry|{max?|ok?}}|abandon|{deliver or pass|{304?|other?}}}}" ] + v_b_r:error:s -> v_b_e v_b_r:retry -> v_b_r_retry [color=purple] v_b_r:max -> v_b_e v_b_r:fetch_304:s -> vbf_stp_condfetch @@ -90,8 +92,8 @@ digraph cache_fetch { ] vbf_stp_condfetch:ok:s -> vbf_stp_fetchend - error [shape=plaintext] - error -> FETCH_FAIL + fail [shape=plaintext] + fail -> FETCH_FAIL /* vbf_stp_error */ v_b_e [ diff --git a/doc/graphviz/cache_fetch.svg b/doc/graphviz/cache_fetch.svg index aeb38a95b..fa09e056e 100644 --- a/doc/graphviz/cache_fetch.svg +++ b/doc/graphviz/cache_fetch.svg @@ -1,283 +1,338 @@ - - - + + cache_fetch - -cluster_backend - + + +cluster_backend + -RETRY -RETRY + +RETRY +RETRY -v_b_f - -vbf_stp_startfetch: - -vcl_backend_fetch{} - -bereq.* - -fail - -abandon - -fetch + +v_b_f + +vbf_stp_startfetch: + +vcl_backend_fetch{} + +bereq.* + +error + +fail + +abandon + +fetch -RETRY->v_b_f - - + +RETRY->v_b_f + + -v_b_f_BGFETCH - -BGFETCH + +v_b_f_BGFETCH + +BGFETCH -v_b_f_BGFETCH->v_b_f - - + +v_b_f_BGFETCH->v_b_f + + -v_b_f_FETCH - -FETCH + +v_b_f_FETCH + +FETCH -v_b_f_FETCH->v_b_f - - + +v_b_f_FETCH->v_b_f + + -v_b_f_FETCH->v_b_f - - + +v_b_f_FETCH->v_b_f + + + + + +v_b_e + +vbf_stp_error: + +vcl_backend_error{} + +bereq.* + +beresp.* + +retry + +fail + +max? + +ok? + +abandon + +deliver + + + +v_b_f:s->v_b_e + + -v_b_hdrs - -send bereq, -read beresp (headers) + +v_b_hdrs + +send bereq, +read beresp (headers) -v_b_f:fetch:s->v_b_hdrs - - + +v_b_f:s->v_b_hdrs + + - -v_b_r - -vbf_stp_startfetch: - -vcl_backend_response{} - -bereq.* - -beresp.* - -fail - -retry - -max? - -ok? - -abandon - -deliver or pass - -304? - -other? + + +FETCH_DONE + +FETCH_DONE - -v_b_hdrs->v_b_r - - + + +v_b_e:deliver->FETCH_DONE + + +"backend synth" - -v_b_e - -vbf_stp_error: - -vcl_backend_error{} - -bereq.* - -beresp.* - -retry - -fail - -max? - -ok? - -abandon - -deliver + + +FETCH_FAIL + +FETCH_FAIL + + + +v_b_e:s->FETCH_FAIL + + + + + +v_b_e_retry +RETRY + + + +v_b_e:retry->v_b_e_retry + + -v_b_hdrs->v_b_e - - + +v_b_hdrs->v_b_e + + + + + +v_b_r + +vbf_stp_startfetch: + +vcl_backend_response{} + +bereq.* + +beresp.* + +error + +fail + +retry + +max? + +ok? + +abandon + +deliver or pass + +304? + +other? + + + +v_b_hdrs->v_b_r + + + + + +v_b_r:s->v_b_e + + -v_b_r:max->v_b_e - - + +v_b_r:max->v_b_e + + -v_b_r_retry -RETRY + +v_b_r_retry +RETRY -v_b_r:retry->v_b_r_retry - - + +v_b_r:retry->v_b_r_retry + + -vbf_stp_condfetch - -vbf_stp_condfetch: - -copy obj attr - -steal body - -fetch_fail? - -ok? + +vbf_stp_condfetch + +vbf_stp_condfetch: + +copy obj attr + +steal body + +fetch_fail? + +ok? -v_b_r:fetch_304:s->vbf_stp_condfetch - - + +v_b_r:s->vbf_stp_condfetch + + -vbf_stp_fetch - -vbf_stp_fetch: - -setup VFPs - -get object - -error? - -body? + +vbf_stp_fetch + +vbf_stp_fetch: + +setup VFPs + +get object + +error? + +body? -v_b_r:non_304:s->vbf_stp_fetch - - - - -FETCH_DONE - -FETCH_DONE - - -v_b_e:deliver->FETCH_DONE - - -"backend synth" - - -FETCH_FAIL - -FETCH_FAIL - - -v_b_e:max:s->FETCH_FAIL - - - - -v_b_e_retry -RETRY - - -v_b_e:retry->v_b_e_retry - - + +v_b_r:s->vbf_stp_fetch + + -vbf_stp_fetchend - -vbf_stp_fetchend: - -finalize object and director - -done + +vbf_stp_fetchend + +vbf_stp_fetchend: + +finalize object and director + +done -vbf_stp_condfetch:ok:s->vbf_stp_fetchend - - + +vbf_stp_condfetch:s->vbf_stp_fetchend + + -vbf_stp_fetchbody - -vbf_stp_fetchbody: - -get storage - -read body, run VFPs - -fetch_fail? - -error? - -ok? + +vbf_stp_fetchbody + +vbf_stp_fetchbody: + +get storage + +read body, run VFPs + +fetch_fail? + +error? + +ok? -vbf_stp_fetch:body:s->vbf_stp_fetchbody - - + +vbf_stp_fetch:s->vbf_stp_fetchbody + + -vbf_stp_fetch:body:s->vbf_stp_fetchend - - + +vbf_stp_fetch:s->vbf_stp_fetchend + + -vbf_stp_fetchbody:ok:s->vbf_stp_fetchend - - + +vbf_stp_fetchbody:s->vbf_stp_fetchend + + -vbf_stp_fetchend:done:s->FETCH_DONE - - - - -error -error - - -error->FETCH_FAIL - - + +vbf_stp_fetchend:s->FETCH_DONE + + + + + +fail +fail + + + +fail->FETCH_FAIL + + -abandon -abandon + +abandon +abandon -abandon->FETCH_FAIL - - + +abandon->FETCH_FAIL + + diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index 0315b4838..fd5a58104 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -356,6 +356,11 @@ The `vcl_backend_fetch` subroutine may terminate with calling ``fetch`` Fetch the object from the backend. + ``error(status code, reason)`` + Transition to :ref:`vcl_backend_error` with ``beresp.status`` and + ``beresp.reason`` being preset to the arguments of ``error()`` if + arguments are provided. + Before calling `vcl_backend_fetch`, Varnish core prepares the `bereq` backend request as follows: @@ -417,6 +422,11 @@ The `vcl_backend_response` subroutine may terminate with calling lookups hitting this object will be turned into passed transactions, as if ``vcl_recv`` had returned ``pass``. + ``error(status code, reason)`` + Transition to :ref:`vcl_backend_error` with ``beresp.status`` and + ``beresp.reason`` being preset to the arguments of ``error()`` if + arguments are provided. + 304 handling ~~~~~~~~~~~~ diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index fb464bc39..d662375fd 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -129,11 +129,11 @@ returns = ( ('backend_fetch', "B", - ('fail', 'fetch', 'abandon') + ('fail', 'fetch', 'abandon', 'error') ), ('backend_response', "B", - ('fail', 'deliver', 'retry', 'abandon', 'pass') + ('fail', 'deliver', 'retry', 'abandon', 'pass', 'error') ), ('backend_error', "B", diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 1e218cb4f..9ce0e6312 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -335,7 +335,7 @@ vcc_act_return(struct vcc *tl, struct token *t, struct symbol *sym) vcc_ProcAction(tl->curproc, hand, tl->t); vcc_NextToken(tl); if (tl->t->tok == '(') { - if (hand == VCL_RET_SYNTH) + if (hand == VCL_RET_SYNTH || hand == VCL_RET_ERROR) vcc_act_return_synth(tl); else if (hand == VCL_RET_VCL) vcc_act_return_vcl(tl); From dridi.boukelmoune at gmail.com Mon Jun 17 07:18:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 17 Jun 2019 07:18:09 +0000 (UTC) Subject: [master] d0a66fa48 Whitespace OCD Message-ID: <20190617071809.09827A3CA8@lists.varnish-cache.org> commit d0a66fa48a209955dcb3dd6bd0eb613b48f15405 Author: Dridi Boukelmoune Date: Mon Jun 17 09:12:48 2019 +0200 Whitespace OCD diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index c01de9387..f9cab4055 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -712,7 +712,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) AN(bo->fetch_objcore->flags & OC_F_BUSY); assert(bo->director_state == DIR_S_NULL); - if (wrk->handling != VCL_RET_ERROR) + if (wrk->handling != VCL_RET_ERROR) wrk->stats->fetch_failed++; now = W_TIM_real(wrk); @@ -728,9 +728,11 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) HTTP_Setup(bo->beresp, bo->ws, bo->vsl, SLT_BerespMethod); if (bo->err_code > 0) - http_PutResponse(bo->beresp, "HTTP/1.1", bo->err_code, bo->err_reason); + http_PutResponse(bo->beresp, "HTTP/1.1", bo->err_code, + bo->err_reason); else - http_PutResponse(bo->beresp, "HTTP/1.1", 503, "Backend fetch failed"); + http_PutResponse(bo->beresp, "HTTP/1.1", 503, + "Backend fetch failed"); http_TimeHeader(bo->beresp, "Date: ", now); http_SetHeader(bo->beresp, "Server: Varnish"); From phk at FreeBSD.org Mon Jun 17 07:32:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 17 Jun 2019 07:32:07 +0000 (UTC) Subject: [master] c4860b99d This is an ugly but relevant optimization of VSL timestamp production, so we apply it only where it makes most difference. Message-ID: <20190617073208.053DEA42E8@lists.varnish-cache.org> commit c4860b99d96990df3d13d24c7a4c96c898a910f0 Author: Poul-Henning Kamp Date: Mon Jun 17 07:30:28 2019 +0000 This is an ugly but relevant optimization of VSL timestamp production, so we apply it only where it makes most difference. The hard work done by: slink Closes: 2792 diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 3465bd2de..836b53966 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -371,19 +371,26 @@ VSLb(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, ...) va_end(ap); } +#define Tf6 "%ju.%06u" +#define Ta6(t) (uintmax_t)floor((t)), (uint32_t)floor((t) * 1e6) % 1000000U + void VSLb_ts(struct vsl_log *vsl, const char *event, vtim_real first, vtim_real *pprev, vtim_real now) { - /* XXX: Make an option to turn off some unnecessary timestamp - logging. This must be done carefully because some functions - (e.g. V1L_Open) takes the last timestamp as its initial - value for timeout calculation. */ + /* + * XXX: Make an option to turn off some unnecessary timestamp + * logging. This must be done carefully because some functions + * (e.g. V1L_Open) takes the last timestamp as its initial + * value for timeout calculation. + */ vsl_sanity(vsl); + AN(event); + AN(pprev); assert(!isnan(now) && now != 0.); - VSLb(vsl, SLT_Timestamp, "%s: %.6f %.6f %.6f", - event, now, now - first, now - *pprev); + VSLb(vsl, SLT_Timestamp, "%s: " Tf6 " " Tf6 " " Tf6, + event, Ta6(now), Ta6(now - first), Ta6(now - *pprev)); *pprev = now; } From phk at FreeBSD.org Mon Jun 17 13:08:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 17 Jun 2019 13:08:08 +0000 (UTC) Subject: [master] 76fb1eedd Change the output format of varnishtest. Message-ID: <20190617130809.00DF2AC93C@lists.varnish-cache.org> commit 76fb1eeddf36d06d5df52a5c58ca1bba317911b4 Author: Poul-Henning Kamp Date: Mon Jun 17 13:06:25 2019 +0000 Change the output format of varnishtest. Instead of a timestamp per line, which makes diff(1) really hard to use, emit millisecond timestamps on separate "dT" lines, whenever time has changed since last timestamp. diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index e9b540ee6..76935d6a8 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -28,6 +28,7 @@ #include "config.h" +#include #include #include #include @@ -48,7 +49,6 @@ struct vtclog { struct vsb *vsb; pthread_mutex_t mtx; int act; - double tx; }; static pthread_key_t log_key; @@ -59,7 +59,6 @@ static double t0; #define GET_VL(vl) \ do { \ CHECK_OBJ_NOTNULL(vl, VTCLOG_MAGIC); \ - vl->tx = VTIM_mono() - t0; \ AZ(pthread_mutex_lock(&vl->mtx)); \ vl->act = 1; \ VSB_clear(vl->vsb); \ @@ -129,8 +128,8 @@ vtc_leadinv(const struct vtclog *vl, int lvl, const char *fmt, va_list ap) assert(lvl < (int)NLEAD); assert(lvl >= 0); - VSB_printf(vl->vsb, "%s %-4s %4.1f ", - lead[lvl < 0 ? 1: lvl], vl->id, vl->tx); + VSB_printf(vl->vsb, "%s %-4s ", + lead[lvl < 0 ? 1: lvl], vl->id); if (fmt != NULL) (void)VSB_vprintf(vl->vsb, fmt, ap); } @@ -149,11 +148,23 @@ static void vtc_log_emit(const struct vtclog *vl) { unsigned l; + int i; + int t_this; + static int t_last = -1; l = VSB_len(vl->vsb); if (l == 0) return; + t_this = (int)round((VTIM_mono() - t0) * 1000); AZ(pthread_mutex_lock(&vtclog_mtx)); + if (t_last != t_this) { + assert(vtclog_left > 25); + i = snprintf(vtclog_buf, vtclog_left, + "**** dT %d.%03d\n", t_this / 1000, t_this % 1000); + t_last = t_this; + vtclog_buf += i; + vtclog_left -= i; + } assert(vtclog_left > l); memcpy(vtclog_buf, VSB_data(vl->vsb), l); vtclog_buf += l; @@ -211,8 +222,8 @@ vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len) if (str == NULL) vtc_leadin(vl, lvl, "%s(null)\n", pfx); else { - bprintf(buf, "%s %-4s %4.1f %s|", - lead[lvl < 0 ? 1: lvl], vl->id, vl->tx, pfx); + bprintf(buf, "%s %-4s %s|", + lead[lvl < 0 ? 1: lvl], vl->id, pfx); if (len < 0) len = strlen(str); VSB_quote_pfx(vl->vsb, buf, str, From phk at FreeBSD.org Tue Jun 18 05:43:10 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 18 Jun 2019 05:43:10 +0000 (UTC) Subject: [master] 0cddee5ed Use sufficiently wide type. Message-ID: <20190618054310.81C0D920F7@lists.varnish-cache.org> commit 0cddee5ed8a26a2ab09b672793c27d3f760b49c2 Author: Poul-Henning Kamp Date: Tue Jun 18 05:36:35 2019 +0000 Use sufficiently wide type. Spotted by: fgs & ubsan diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 836b53966..f3765ff70 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -371,8 +371,8 @@ VSLb(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, ...) va_end(ap); } -#define Tf6 "%ju.%06u" -#define Ta6(t) (uintmax_t)floor((t)), (uint32_t)floor((t) * 1e6) % 1000000U +#define Tf6 "%ju.%06ju" +#define Ta6(t) (uintmax_t)floor((t)), (uintmax_t)floor((t) * 1e6) % 1000000U void VSLb_ts(struct vsl_log *vsl, const char *event, vtim_real first, From phk at FreeBSD.org Tue Jun 18 07:26:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 18 Jun 2019 07:26:09 +0000 (UTC) Subject: [master] 7e14355f7 Convert std.toupper() and std.tolower() from STRING_LIST to STRANDS Message-ID: <20190618072609.BEB3C943BF@lists.varnish-cache.org> commit 7e14355f76dba7fe77043085bf7a08bbe20f8852 Author: Poul-Henning Kamp Date: Tue Jun 18 06:59:30 2019 +0000 Convert std.toupper() and std.tolower() from STRING_LIST to STRANDS diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index fafc8ae29..ee56f584e 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -84,7 +84,7 @@ Example:: set req.url = std.querysort(req.url); -$Function STRING toupper(STRING_LIST s) +$Function STRING toupper(STRANDS s) Converts the string *s* to uppercase. @@ -92,7 +92,7 @@ Example:: set beresp.http.scream = std.toupper("yes!"); -$Function STRING tolower(STRING_LIST s) +$Function STRING tolower(STRANDS s) Converts the string *s* to lowercase. diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 11e5f8667..7d2871e57 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -65,26 +65,25 @@ vmod_set_ip_tos(VRT_CTX, VCL_INT tos) } static const char * -vmod_updown(VRT_CTX, int up, const char *s, va_list ap) +vmod_updown(VRT_CTX, int up, VCL_STRANDS s) { unsigned u; char *b, *e; const char *p; + int i; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); u = WS_ReserveAll(ctx->ws); e = b = ctx->ws->f; e += u; - p = s; - while (p != vrt_magic_string_end && b < e) { - if (p != NULL) { - for (; b < e && *p != '\0'; p++) - if (up) - *b++ = (char)toupper(*p); - else - *b++ = (char)tolower(*p); + for (i = 0; i < s->n && b < e; i++) { + p = s->p[i]; + while (p != NULL && *p != '\0' && b < e) { + if (up) + *b++ = (char)toupper(*p++); + else + *b++ = (char)tolower(*p++); } - p = va_arg(ap, const char *); } if (b < e) *b = '\0'; @@ -102,29 +101,19 @@ vmod_updown(VRT_CTX, int up, const char *s, va_list ap) } VCL_STRING v_matchproto_(td_std_toupper) -vmod_toupper(VRT_CTX, const char *s, ...) +vmod_toupper(VRT_CTX, VCL_STRANDS s) { - const char *p; - va_list ap; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - va_start(ap, s); - p = vmod_updown(ctx, 1, s, ap); - va_end(ap); - return (p); + return (vmod_updown(ctx, 1, s)); } VCL_STRING v_matchproto_(td_std_tolower) -vmod_tolower(VRT_CTX, const char *s, ...) +vmod_tolower(VRT_CTX, VCL_STRANDS s) { - const char *p; - va_list ap; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - va_start(ap, s); - p = vmod_updown(ctx, 0, s, ap); - va_end(ap); - return (p); + return (vmod_updown(ctx, 0, s)); } VCL_REAL v_matchproto_(td_std_random) From phk at FreeBSD.org Tue Jun 18 07:26:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 18 Jun 2019 07:26:09 +0000 (UTC) Subject: [master] 8bf0a33ae Convert std.log() and std.syslog from STRING_LIST to STRANDS. Message-ID: <20190618072609.D2426943C2@lists.varnish-cache.org> commit 8bf0a33aee49e10b01dd9aea54a6c01e60bc85d5 Author: Poul-Henning Kamp Date: Tue Jun 18 07:07:47 2019 +0000 Convert std.log() and std.syslog from STRING_LIST to STRANDS. diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index ee56f584e..a30d7809b 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -419,7 +419,7 @@ Examples:: LOGGING functions ================= -$Function VOID log(STRING_LIST s) +$Function VOID log(STRANDS s) Logs the string *s* to the shared memory log, using :ref:`vsl(7)` tag ``SLT_VCL_Log``. @@ -428,7 +428,7 @@ Example:: std.log("Something fishy is going on with the vhost " + req.http.host); -$Function VOID syslog(INT priority, STRING_LIST s) +$Function VOID syslog(INT priority, STRANDS s) Logs the string *s* to syslog tagged with *priority*. *priority* is formed by ORing the facility and level values. See your system's diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 7d2871e57..d1b7411ec 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -129,45 +129,33 @@ vmod_random(VRT_CTX, VCL_REAL lo, VCL_REAL hi) } VCL_VOID v_matchproto_(td_std_log) -vmod_log(VRT_CTX, const char *fmt, ...) +vmod_log(VRT_CTX, VCL_STRANDS s) { const char *p; - va_list ap; uintptr_t sn; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); sn = WS_Snapshot(ctx->ws); - va_start(ap, fmt); - p = VRT_String(ctx->ws, NULL, fmt, ap); - va_end(ap); - - if (p == NULL) { - WS_Reset(ctx->ws, sn); - WS_MarkOverflow(ctx->ws); - return; + p = VRT_StrandsWS(ctx->ws, NULL, s); + if (p != NULL) { + if (ctx->vsl != NULL) + VSLb(ctx->vsl, SLT_VCL_Log, "%s", p); + else + VSL(SLT_VCL_Log, 0, "%s", p); } - - AN(p); - if (ctx->vsl != NULL) - VSLb(ctx->vsl, SLT_VCL_Log, "%s", p); - else - VSL(SLT_VCL_Log, 0, "%s", p); WS_Reset(ctx->ws, sn); } /* XXX use vsyslog() ? */ VCL_VOID v_matchproto_(td_std_syslog) -vmod_syslog(VRT_CTX, VCL_INT fac, const char *fmt, ...) +vmod_syslog(VRT_CTX, VCL_INT fac, VCL_STRANDS s) { const char *p; - va_list ap; uintptr_t sn; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); sn = WS_Snapshot(ctx->ws); - va_start(ap, fmt); - p = VRT_String(ctx->ws, NULL, fmt, ap); - va_end(ap); + p = VRT_StrandsWS(ctx->ws, NULL, s); if (p != NULL) syslog((int)fac, "%s", p); WS_Reset(ctx->ws, sn); From phk at FreeBSD.org Tue Jun 18 07:26:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 18 Jun 2019 07:26:09 +0000 (UTC) Subject: [master] 7c3fdb42b Move VRT_BundleStrands() to VPI_BundleStrands() Message-ID: <20190618072609.EC71E943C6@lists.varnish-cache.org> commit 7c3fdb42b53227d816d429d9231f4c6b39d1bfed Author: Poul-Henning Kamp Date: Tue Jun 18 07:14:13 2019 +0000 Move VRT_BundleStrands() to VPI_BundleStrands() diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 81cc12b09..348344846 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -179,7 +179,7 @@ VRT_GetHdr(VRT_CTX, const struct gethdr_s *hs) */ VCL_STRANDS -VRT_BundleStrands(int n, struct strands *s, char const **d, const char *f, ...) +VPI_BundleStrands(int n, struct strands *s, char const **d, const char *f, ...) { va_list ap; diff --git a/include/vcc_interface.h b/include/vcc_interface.h index 682767265..78dcccdcf 100644 --- a/include/vcc_interface.h +++ b/include/vcc_interface.h @@ -64,3 +64,5 @@ struct vrt_acl { const char *name; }; +VCL_STRANDS VPI_BundleStrands(int, struct strands *, char const **, + const char *f, ...); diff --git a/include/vrt.h b/include/vrt.h index 4cb78e002..92f3e71fa 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -52,6 +52,7 @@ * binary/load-time compatible, increment MAJOR version * * unreleased (planned for 2019-09-15) + * VRT_BundleStrands() moved to vcc_interface.h * VRT_VCL_{Busy|Unbusy} changed to VRT_VCL_{Prevent|Allow}_Cold * VRT_re[fl]_vcl changed to VRT_VCL_{Prevent|Allow}_Discard * VRT_Vmod_{Init|Unload} moved to vcc_interface.h @@ -528,8 +529,6 @@ VCL_STEVEDORE VRT_stevedore(const char *nm); /* Convert things to string */ -VCL_STRANDS VRT_BundleStrands(int, struct strands *, char const **, - const char *f, ...); int VRT_CompareStrands(VCL_STRANDS a, VCL_STRANDS b); char *VRT_Strands(char *, size_t, VCL_STRANDS); VCL_STRING VRT_StrandsWS(struct ws *, const char *, VCL_STRANDS); diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 6301cb722..a23f61f35 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -186,7 +186,7 @@ vcc_expr_edit(struct vcc *tl, vcc_type_t fmt, const char *p, struct expr *e1, " const char * strs_%u_s[%d];\n", tl->unique, tl->unique, e3->nstr); VSB_printf(e->vsb, - "VRT_BundleStrands(%d, &strs_%u_a, strs_%u_s," + "VPI_BundleStrands(%d, &strs_%u_a, strs_%u_s," "\v+\n%s,\nvrt_magic_string_end\v-\n)", e3->nstr, tl->unique, tl->unique, VSB_data(e3->vsb)); From phk at FreeBSD.org Wed Jun 19 20:08:11 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 19 Jun 2019 20:08:11 +0000 (UTC) Subject: [master] 287213b11 Add a missing '=' Message-ID: <20190619200811.331849CDAB@lists.varnish-cache.org> commit 287213b11c8b1bc5fa1e135c536eadc8dfb909ea Author: Poul-Henning Kamp Date: Wed Jun 19 20:06:52 2019 +0000 Add a missing '=' Spotted by: Steven diff --git a/doc/sphinx/reference/varnishtest.rst b/doc/sphinx/reference/varnishtest.rst index 495affc18..b6133d70c 100644 --- a/doc/sphinx/reference/varnishtest.rst +++ b/doc/sphinx/reference/varnishtest.rst @@ -168,7 +168,7 @@ both your VMOD and the built-in VMODs:: SBINDIR="$(pkg-config --variable=sbindir varnishapi)" PATH="SBINDIR:BINDIR:$PATH" - VMODDIR"$(pkg-config --variable=vmoddir varnishapi)" + VMODDIR="$(pkg-config --variable=vmoddir varnishapi)" VMOD_PATH="/path/to/your/vmod/build/dir:$VMODDIR" varnishtest -p vmod_path="$VMOD_PATH" ... From phk at FreeBSD.org Thu Jun 20 08:49:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 20 Jun 2019 08:49:09 +0000 (UTC) Subject: [master] 2f1c3bce3 Avoid detour over VRT_CollectString() Message-ID: <20190620084909.6F3B4B07E4@lists.varnish-cache.org> commit 2f1c3bce3bc092cb0c9fb64508dbbefe18d22dba Author: Poul-Henning Kamp Date: Thu Jun 20 08:46:36 2019 +0000 Avoid detour over VRT_CollectString() diff --git a/lib/libvmod_debug/vmod_debug_obj.c b/lib/libvmod_debug/vmod_debug_obj.c index 3928e5598..6dd6b48d0 100644 --- a/lib/libvmod_debug/vmod_debug_obj.c +++ b/lib/libvmod_debug/vmod_debug_obj.c @@ -232,15 +232,16 @@ xyzzy_obj_opt_meth_opt(VRT_CTX, assert(args->arg1 != args->arg2); assert(args->arg2 != args->arg3); - return (VRT_CollectString(ctx, - "obj ", o->name, - " obj_s ", (o->args.valid_s ? o->args.s : "*undef*"), - " obj_b ", (o->args.valid_b + return (WS_Printf(ctx->ws, + "obj %s obj_s %s obj_b %s met_s %s met_b %s", + o->name, + (o->args.valid_s ? o->args.s : "*undef*"), + (o->args.valid_b ? (o->args.b ? "true" : "false" ) : "*undef*"), - " met_s ", (args->valid_s ? args->s : "*undef*"), - " met_b ", (args->valid_b + (args->valid_s ? args->s : "*undef*"), + (args->valid_b ? (args->b ? "true" : "false" ) - : "*undef*"), - vrt_magic_string_end)); + : "*undef*") + )); } From phk at FreeBSD.org Thu Jun 20 09:28:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 20 Jun 2019 09:28:08 +0000 (UTC) Subject: [master] 94abb7725 Avoid STRING_LIST and simplify sha256 hashing. Message-ID: <20190620092808.11E32B14D0@lists.varnish-cache.org> commit 94abb772548196f47c7c256fe222124691fcb957 Author: Poul-Henning Kamp Date: Thu Jun 20 09:08:00 2019 +0000 Avoid STRING_LIST and simplify sha256 hashing. diff --git a/lib/libvmod_directors/shard_cfg.c b/lib/libvmod_directors/shard_cfg.c index b72bad27f..532b0d9e8 100644 --- a/lib/libvmod_directors/shard_cfg.c +++ b/lib/libvmod_directors/shard_cfg.c @@ -236,6 +236,8 @@ shardcfg_hashcircle(struct sharddir *shardd, VCL_INT replicas) const char *ident; const int len = 12; // log10(UINT32_MAX) + 2; char s[len]; + struct strands ss[1]; + const char *ssp[2]; CHECK_OBJ_NOTNULL(shardd, SHARDDIR_MAGIC); AZ(shardd->hashcircle); @@ -261,8 +263,12 @@ shardcfg_hashcircle(struct sharddir *shardd, VCL_INT replicas) for (j = 0; j < replicas; j++) { assert(snprintf(s, len, "%d", j) < len); + ss->n = 2; + ssp[0] = ident; + ssp[1] = s; + ss->p = ssp; shardd->hashcircle[i * replicas + j].point = - sharddir_sha256(ident, s, vrt_magic_string_end); + sharddir_sha256(ss); shardd->hashcircle[i * replicas + j].host = i; } /* not used in current interface */ diff --git a/lib/libvmod_directors/shard_dir.c b/lib/libvmod_directors/shard_dir.c index e295be1e9..4c707dc5e 100644 --- a/lib/libvmod_directors/shard_dir.c +++ b/lib/libvmod_directors/shard_dir.c @@ -89,44 +89,22 @@ sharddir_err(VRT_CTX, enum VSL_tag_e tag, const char *fmt, ...) } uint32_t -sharddir_sha256v(const char *s, va_list ap) +sharddir_sha256(VCL_STRANDS s) { struct VSHA256Context sha256; - union { - unsigned char digest[32]; - uint32_t uint32_digest[8]; - } sha256_digest; - uint32_t r; - const char *p; + unsigned char digest[VSHA256_LEN]; + int i; + AN(s); VSHA256_Init(&sha256); - p = s; - while (p != vrt_magic_string_end) { - if (p != NULL && *p != '\0') - VSHA256_Update(&sha256, p, strlen(p)); - p = va_arg(ap, const char *); + for (i = 0; i < s->n; i++) { + if (s->p[i] != NULL) + VSHA256_Update(&sha256, s->p[i], strlen(s->p[i])); } - VSHA256_Final(sha256_digest.digest, &sha256); - - /* - * use low 32 bits only - * XXX: Are these the best bits to pick? - */ - vle32enc(&r, sha256_digest.uint32_digest[7]); - return (r); -} - -uint32_t -sharddir_sha256(const char *s, ...) -{ - va_list ap; - uint32_t r; - - va_start(ap, s); - r = sharddir_sha256v(s, ap); - va_end(ap); + VSHA256_Final(digest, &sha256); - return (r); + /* The low 32 bits are as good as any. */ + return (vle32dec(&digest[VSHA256_LEN - 4])); } static int diff --git a/lib/libvmod_directors/shard_dir.h b/lib/libvmod_directors/shard_dir.h index bf5bb1ed4..021fa1257 100644 --- a/lib/libvmod_directors/shard_dir.h +++ b/lib/libvmod_directors/shard_dir.h @@ -117,8 +117,7 @@ sharddir_backend(const struct sharddir *shardd, int id) void sharddir_debug(struct sharddir *shardd, const uint32_t flags); void sharddir_err(VRT_CTX, enum VSL_tag_e tag, const char *fmt, ...); -uint32_t sharddir_sha256v(const char *s, va_list ap); -uint32_t sharddir_sha256(const char *s, ...); +uint32_t sharddir_sha256(VCL_STRANDS s); void sharddir_new(struct sharddir **sharddp, const char *vcl_name, const struct vmod_directors_shard_param *param); void sharddir_set_param(struct sharddir *shardd, diff --git a/lib/libvmod_directors/vmod.vcc b/lib/libvmod_directors/vmod.vcc index 7a81ee422..5bb6837f9 100644 --- a/lib/libvmod_directors/vmod.vcc +++ b/lib/libvmod_directors/vmod.vcc @@ -415,7 +415,7 @@ Reconfigure the consistent hashing ring to reflect backend changes. This method must be called at least once before the director can be used. -$Method INT .key(STRING_LIST) +$Method INT .key(STRANDS) Convenience method to generate a sharding key for use with the *key* argument to the `vmod_directors.shard.backend`_ method by hashing the diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c index 73611b95c..9de023190 100644 --- a/lib/libvmod_directors/vmod_shard.c +++ b/lib/libvmod_directors/vmod_shard.c @@ -281,19 +281,13 @@ vmod_shard__fini(struct vmod_directors_shard **vshardp) } VCL_INT v_matchproto_(td_directors_shard_key) -vmod_shard_key(VRT_CTX, struct vmod_directors_shard *vshard, const char *s, ...) +vmod_shard_key(VRT_CTX, struct vmod_directors_shard *vshard, VCL_STRANDS s) { - va_list ap; - uint32_t r; (void)ctx; (void)vshard; - va_start(ap, s); - r = sharddir_sha256v(s, ap); - va_end(ap); - - return ((VCL_INT)r); + return ((VCL_INT)sharddir_sha256(s)); } VCL_VOID v_matchproto_(td_directors_set_warmup) @@ -397,6 +391,8 @@ static inline uint32_t shard_get_key(VRT_CTX, const struct vmod_directors_shard_param *p) { struct http *http; + struct strands s[1]; + const char *sp[1]; switch (p->by) { case BY_HASH: @@ -412,8 +408,10 @@ shard_get_key(VRT_CTX, const struct vmod_directors_shard_param *p) AN(ctx->http_bereq); AN(http = ctx->http_bereq); } - return (sharddir_sha256(http->hd[HTTP_HDR_URL].b, - vrt_magic_string_end)); + sp[0] = http->hd[HTTP_HDR_URL].b; + s->n = 1; + s->p = sp; + return (sharddir_sha256(s)); case BY_KEY: case BY_BLOB: return (p->key); From phk at FreeBSD.org Thu Jun 20 09:28:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 20 Jun 2019 09:28:08 +0000 (UTC) Subject: [master] 3726b255f Start being a little bit annoying about STRING_LIST going away Message-ID: <20190620092808.26817B14D3@lists.varnish-cache.org> commit 3726b255f89dc84a40538edbebc560654a9f5ad5 Author: Poul-Henning Kamp Date: Thu Jun 20 09:22:03 2019 +0000 Start being a little bit annoying about STRING_LIST going away diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index d431df1cf..79cff3ee8 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -42,6 +42,7 @@ import unittest import copy import json import hashlib +import time AMBOILERPLATE = ''' # Generated by vmodtool.py --boilerplate. @@ -117,6 +118,22 @@ CTYPES = { CTYPES.update(PRIVS) +DEPRECATED = {} + +####################################################################### + +def deprecated(key, txt): + ''' + Be annoying about features which are going away + ''' + if DEPRECATED.get(key): + return + sys.stderr.write('#' * 72 + '\n') + sys.stderr.write(txt + '\n') + sys.stderr.write('#' * 72 + '\n') + time.sleep(3) + DEPRECATED[key] = True + ####################################################################### def is_quoted(txt): @@ -213,6 +230,12 @@ class CType(object): self.opt = False self.vt = wl.pop(0) + if self.vt == "STRING_LIST": + deprecated("STRING_LIST", ''' +STRING_LIST will be discontinued before the 2019-09-15 release + +Please switch to STRANDS +''') self.ct = CTYPES.get(self.vt) if self.ct is None: err("Expected type got '%s'" % self.vt, warn=False) @@ -774,7 +797,7 @@ class ObjectStanza(Stanza): ll = [ "$OBJ", self.proto.name, - { "NULL_OK": self.null_ok }, + {"NULL_OK": self.null_ok}, "struct %s%s_%s" % (self.vcc.sympfx, self.vcc.modname, self.proto.name), ] From phk at FreeBSD.org Thu Jun 20 15:25:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 20 Jun 2019 15:25:09 +0000 (UTC) Subject: [master] efa582f5e Add VRT_Strands2Bool() so we dont reassemble a multi-part string on the workspace to check if any element of it is non-NULL. Message-ID: <20190620152509.592186248C@lists.varnish-cache.org> commit efa582f5e8073fdc95e15d450bf7e112071febff Author: Poul-Henning Kamp Date: Thu Jun 20 15:22:21 2019 +0000 Add VRT_Strands2Bool() so we dont reassemble a multi-part string on the workspace to check if any element of it is non-NULL. diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 348344846..fee4b8567 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -232,6 +232,22 @@ VRT_CompareStrands(VCL_STRANDS a, VCL_STRANDS b) } } +/*-------------------------------------------------------------------- + * STRANDS to BOOL + */ + +VCL_BOOL +VRT_Strands2Bool(VCL_STRANDS s) +{ + int i; + + AN(s); + for (i = 0; i < s->n; i++) + if (s->p[i] != NULL) + return (1); + return (0); +} + /*-------------------------------------------------------------------- * Collapse a STRING_LIST in the space provided, or return NULL */ diff --git a/include/vrt.h b/include/vrt.h index 92f3e71fa..0f022a3b2 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -52,6 +52,7 @@ * binary/load-time compatible, increment MAJOR version * * unreleased (planned for 2019-09-15) + * VCL_BOOL VRT_Strands2Bool(VCL_STRANDS) added. * VRT_BundleStrands() moved to vcc_interface.h * VRT_VCL_{Busy|Unbusy} changed to VRT_VCL_{Prevent|Allow}_Cold * VRT_re[fl]_vcl changed to VRT_VCL_{Prevent|Allow}_Discard @@ -530,6 +531,7 @@ VCL_STEVEDORE VRT_stevedore(const char *nm); /* Convert things to string */ int VRT_CompareStrands(VCL_STRANDS a, VCL_STRANDS b); +VCL_BOOL VRT_Strands2Bool(VCL_STRANDS); char *VRT_Strands(char *, size_t, VCL_STRANDS); VCL_STRING VRT_StrandsWS(struct ws *, const char *, VCL_STRANDS); VCL_STRING VRT_CollectStrands(VRT_CTX, VCL_STRANDS); diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index a23f61f35..6776a3f86 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -261,7 +261,7 @@ vcc_expr_tobool(struct vcc *tl, struct expr **e) else if ((*e)->fmt == DURATION) *e = vcc_expr_edit(tl, BOOL, "(\v1 > 0)", *e, NULL); else if ((*e)->fmt == STRINGS) - *e = vcc_expr_edit(tl, BOOL, "(\vS != 0)", *e, NULL); + *e = vcc_expr_edit(tl, BOOL, "VRT_Strands2Bool(\vT)", *e, NULL); /* * We do not provide automatic folding from REAL to BOOL * because comparing to zero is seldom an exact science From phk at FreeBSD.org Thu Jun 20 15:25:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 20 Jun 2019 15:25:09 +0000 (UTC) Subject: [master] dffae17cf Whitespace OCD Message-ID: <20190620152509.6E7346248F@lists.varnish-cache.org> commit dffae17cf2e338feaa85174c094d82af2951be2f Author: Poul-Henning Kamp Date: Thu Jun 20 15:23:24 2019 +0000 Whitespace OCD diff --git a/lib/libvmod_debug/vmod_debug_obj.c b/lib/libvmod_debug/vmod_debug_obj.c index 6dd6b48d0..bd8cda714 100644 --- a/lib/libvmod_debug/vmod_debug_obj.c +++ b/lib/libvmod_debug/vmod_debug_obj.c @@ -234,7 +234,7 @@ xyzzy_obj_opt_meth_opt(VRT_CTX, return (WS_Printf(ctx->ws, "obj %s obj_s %s obj_b %s met_s %s met_b %s", - o->name, + o->name, (o->args.valid_s ? o->args.s : "*undef*"), (o->args.valid_b ? (o->args.b ? "true" : "false" ) From phk at FreeBSD.org Thu Jun 20 20:27:11 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 20 Jun 2019 20:27:11 +0000 (UTC) Subject: [master] f0de32ec0 Convert VRT_synth_page() to take STRANDS Message-ID: <20190620202711.92E1692937@lists.varnish-cache.org> commit f0de32ec0b9353d169566907d3361a429bf2f14e Author: Poul-Henning Kamp Date: Thu Jun 20 20:26:01 2019 +0000 Convert VRT_synth_page() to take STRANDS diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 812883fe9..5e68b07d8 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -675,26 +675,19 @@ VRT_Rollback(VRT_CTX, VCL_HTTP hp) /*--------------------------------------------------------------------*/ VCL_VOID -VRT_synth_page(VRT_CTX, const char *str, ...) +VRT_synth_page(VRT_CTX, VCL_STRANDS s) { - va_list ap; - const char *p; struct vsb *vsb; + int i; CAST_OBJ_NOTNULL(vsb, ctx->specific, VSB_MAGIC); - va_start(ap, str); - p = str; - while (p != vrt_magic_string_end) { - if (p == NULL) - p = "(null)"; - if (VSB_cat(vsb, p)) { - VRT_fail(ctx, "synthetic(): %s", - vstrerror(VSB_error(vsb))); - break; - } - p = va_arg(ap, const char *); + AN(s); + for (i = 0; i < s->n; i++) { + if (s->p[i] != NULL) + VSB_cat(vsb, s->p[i]); + else + VSB_cat(vsb, "(null)"); } - va_end(ap); } /*--------------------------------------------------------------------*/ diff --git a/include/vrt.h b/include/vrt.h index a5d6d00ff..0d9b91ac1 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -52,6 +52,7 @@ * binary/load-time compatible, increment MAJOR version * * unreleased (planned for 2019-09-15) + * VRT_synth_page now takes STRANDS argument * VRT_hashdata() now takes STRANDS argument * VCL_BOOL VRT_Strands2Bool(VCL_STRANDS) added. * VRT_BundleStrands() moved to vcc_interface.h @@ -450,7 +451,7 @@ VCL_BLOB VRT_blob(VRT_CTX, const char *, const void *, size_t, unsigned); VCL_VOID VRT_Rollback(VRT_CTX, VCL_HTTP); /* Synthetic pages */ -VCL_VOID VRT_synth_page(VRT_CTX, const char *, ...); +VCL_VOID VRT_synth_page(VRT_CTX, VCL_STRANDS); /* Backend related */ VCL_BACKEND VRT_new_backend(VRT_CTX, const struct vrt_backend *); diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 83c897df4..c243dbcb7 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -375,7 +375,7 @@ vcc_act_synthetic(struct vcc *tl, struct token *t, struct symbol *sym) vcc_NextToken(tl); Fb(tl, 1, "VRT_synth_page(ctx, "); - vcc_Expr(tl, STRING_LIST); + vcc_Expr(tl, STRANDS); ERRCHK(tl); Fb(tl, 1, ");\n"); From phk at FreeBSD.org Thu Jun 20 20:27:11 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 20 Jun 2019 20:27:11 +0000 (UTC) Subject: [master] 5db1061f3 Change VRT_hashdata() to take STRANDS Message-ID: <20190620202711.7DD6A9292C@lists.varnish-cache.org> commit 5db1061f31443382f2c4c84a10827626b2cee41c Author: Poul-Henning Kamp Date: Thu Jun 20 20:11:50 2019 +0000 Change VRT_hashdata() to take STRANDS diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index fee4b8567..812883fe9 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -555,23 +555,16 @@ VRT_fail(VRT_CTX, const char *fmt, ...) */ VCL_VOID -VRT_hashdata(VRT_CTX, const char *str, ...) +VRT_hashdata(VRT_CTX, VCL_STRANDS s) { - va_list ap; - const char *p; + int i; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); AN(ctx->specific); - HSH_AddString(ctx->req, ctx->specific, str); - va_start(ap, str); - while (1) { - p = va_arg(ap, const char *); - if (p == vrt_magic_string_end) - break; - HSH_AddString(ctx->req, ctx->specific, p); - } - va_end(ap); + AN(s); + for (i = 0; i < s->n; i++) + HSH_AddString(ctx->req, ctx->specific, s->p[i]); /* * Add a 'field-separator' to make it more difficult to * manipulate the hash. diff --git a/include/vrt.h b/include/vrt.h index 0f022a3b2..a5d6d00ff 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -52,6 +52,7 @@ * binary/load-time compatible, increment MAJOR version * * unreleased (planned for 2019-09-15) + * VRT_hashdata() now takes STRANDS argument * VCL_BOOL VRT_Strands2Bool(VCL_STRANDS) added. * VRT_BundleStrands() moved to vcc_interface.h * VRT_VCL_{Busy|Unbusy} changed to VRT_VCL_{Prevent|Allow}_Cold @@ -438,7 +439,7 @@ VCL_VOID VRT_hit_for_pass(VRT_CTX, VCL_DURATION); VCL_VOID VRT_SetHdr(VRT_CTX, VCL_HEADER, const char *, ...); VCL_VOID VRT_handling(VRT_CTX, unsigned hand); VCL_VOID VRT_fail(VRT_CTX, const char *fmt, ...) v_printflike_(2,3); -VCL_VOID VRT_hashdata(VRT_CTX, const char *str, ...); +VCL_VOID VRT_hashdata(VRT_CTX, VCL_STRANDS); /* Simple stuff */ int VRT_strcmp(const char *s1, const char *s2); diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 9ce0e6312..83c897df4 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -193,7 +193,7 @@ vcc_act_hash_data(struct vcc *tl, struct token *t, struct symbol *sym) SkipToken(tl, '('); Fb(tl, 1, "VRT_hashdata(ctx,\n "); - vcc_Expr(tl, STRING_LIST); + vcc_Expr(tl, STRANDS); ERRCHK(tl); Fb(tl, 1, ");\n"); SkipToken(tl, ')'); From dridi.boukelmoune at gmail.com Fri Jun 21 07:37:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 21 Jun 2019 07:37:08 +0000 (UTC) Subject: [master] db54739aa Homework for later Message-ID: <20190621073708.5454AA5964@lists.varnish-cache.org> commit db54739aa6b1b8d7b315623072d87a90e5a58c8e Author: Dridi Boukelmoune Date: Fri Jun 21 09:35:50 2019 +0200 Homework for later diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index 224b81b9f..7c26ae580 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -39,6 +39,8 @@ VCL variables Other changes to VCL ~~~~~~~~~~~~~~~~~~~~ +**TODO: return (error);** + VMODs ===== From dridi.boukelmoune at gmail.com Fri Jun 21 12:48:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 21 Jun 2019 12:48:07 +0000 (UTC) Subject: [master] d869640ba Steal stream 0 from its h2 session before releasing Message-ID: <20190621124807.DC05CAD9FE@lists.varnish-cache.org> commit d869640ba8b4978c890610a1a6dcd1bf82a600d3 Author: Dridi Boukelmoune Date: Fri Apr 19 10:31:15 2019 +0200 Steal stream 0 from its h2 session before releasing diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index efd560db6..4fd379cd9 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -150,7 +150,7 @@ h2_del_sess(struct worker *wrk, struct h2_sess *h2, enum sess_close reason) VHT_Fini(h2->dectbl); AZ(pthread_cond_destroy(h2->winupd_cond)); - req = h2->srq; + TAKE_OBJ_NOTNULL(req, &h2->srq, REQ_MAGIC); AZ(req->ws->r); sp = h2->sess; Req_Cleanup(sp, wrk, req); From dridi.boukelmoune at gmail.com Fri Jun 21 12:48:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 21 Jun 2019 12:48:07 +0000 (UTC) Subject: [master] 1506c5cff Flatten h2_stream_tmo() with an early return Message-ID: <20190621124807.F187DADA01@lists.varnish-cache.org> commit 1506c5cffc9b7882eb059ce128dfdf824c41445f Author: Dridi Boukelmoune Date: Fri Apr 19 11:43:51 2019 +0200 Flatten h2_stream_tmo() with an early return diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 7681bfff5..68c52e54f 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -992,25 +992,26 @@ h2_stream_tmo(struct h2_sess *h2, const struct h2_req *r2) CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC); CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC); - if (r2->t_winupd != 0 || r2->t_send != 0) { - Lck_Lock(&h2->sess->mtx); - if (r2->t_winupd != 0 && - h2->sess->t_idle - r2->t_winupd > - cache_param->idle_send_timeout) { - VSLb(h2->vsl, SLT_Debug, - "H2: stream %u: Hit idle_send_timeout waiting " - "for WINDOW_UPDATE", r2->stream); - r = 1; - } + if (r2->t_winupd == 0 && r2->t_send == 0) + return (0); - if (r == 0 && r2->t_send != 0 && - h2->sess->t_idle - r2->t_send > cache_param->send_timeout) { - VSLb(h2->vsl, SLT_Debug, - "H2: stream %u: Hit send_timeout", r2->stream); - r = 1; - } - Lck_Unlock(&h2->sess->mtx); + Lck_Lock(&h2->sess->mtx); + if (r2->t_winupd != 0 && + h2->sess->t_idle - r2->t_winupd > + cache_param->idle_send_timeout) { + VSLb(h2->vsl, SLT_Debug, + "H2: stream %u: Hit idle_send_timeout waiting for" + " WINDOW_UPDATE", r2->stream); + r = 1; + } + + if (r == 0 && r2->t_send != 0 && + h2->sess->t_idle - r2->t_send > cache_param->send_timeout) { + VSLb(h2->vsl, SLT_Debug, + "H2: stream %u: Hit send_timeout", r2->stream); + r = 1; } + Lck_Unlock(&h2->sess->mtx); return (r); } From dridi.boukelmoune at gmail.com Fri Jun 21 12:48:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 21 Jun 2019 12:48:08 +0000 (UTC) Subject: [master] 5ecbde381 Make a special case for sending h2 RST frames Message-ID: <20190621124808.3AA92ADA06@lists.varnish-cache.org> commit 5ecbde3812f9d17b47faf3b6c44567bcb7060fac Author: Dridi Boukelmoune Date: Fri Apr 19 11:48:43 2019 +0200 Make a special case for sending h2 RST frames diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index 83bf5460c..44bd91783 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -223,6 +223,9 @@ void H2_Send_Frame(struct worker *, struct h2_sess *, h2_frame type, uint8_t flags, uint32_t len, uint32_t stream, const void *); +void H2_Send_RST(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2, + uint32_t stream, h2_error h2e); + void H2_Send(struct worker *, struct h2_req *, h2_frame type, uint8_t flags, uint32_t len, const void *, uint64_t *acct); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 68c52e54f..577f777c2 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Varnish Software AS + * Copyright (c) 2016-2019 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp @@ -132,28 +132,6 @@ h2_connectionerror(uint32_t u) /**********************************************************************/ -static void -h2_tx_rst(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2, - uint32_t stream, h2_error h2e) -{ - char b[4]; - - CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC); - CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC); - - Lck_Lock(&h2->sess->mtx); - VSLb(h2->vsl, SLT_Debug, "H2: stream %u: %s", stream, h2e->txt); - Lck_Unlock(&h2->sess->mtx); - vbe32enc(b, h2e->val); - - H2_Send_Get(wrk, h2, r2); - H2_Send_Frame(wrk, h2, H2_F_RST_STREAM, 0, sizeof b, stream, b); - H2_Send_Rel(h2, r2); -} - -/********************************************************************** - */ - struct h2_req * h2_new_req(const struct worker *wrk, struct h2_sess *h2, unsigned stream, struct req *req) @@ -875,8 +853,10 @@ h2_vfp_body_fini(struct vfp_ctx *vc, struct vfp_entry *vfe) if (vc->failed) { CHECK_OBJ_NOTNULL(r2->req->wrk, WORKER_MAGIC); - h2_tx_rst(r2->req->wrk, h2, r2, r2->stream, + H2_Send_Get(r2->req->wrk, h2, r2); + H2_Send_RST(r2->req->wrk, h2, r2, r2->stream, H2SE_REFUSED_STREAM); + H2_Send_Rel(h2, r2); Lck_Lock(&h2->sess->mtx); r2->error = H2SE_REFUSED_STREAM; if (h2->mailcall == r2) { @@ -980,7 +960,9 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2, h2_frame h2f) if (h2->rxf_stream == 0 || h2e->connection) return (h2e); // Connection errors one level up - h2_tx_rst(wrk, h2, h2->req0, h2->rxf_stream, h2e); + H2_Send_Get(wrk, h2, h2->req0); + H2_Send_RST(wrk, h2, h2->req0, h2->rxf_stream, h2e); + H2_Send_Rel(h2, h2->req0); return (0); } @@ -1041,8 +1023,10 @@ h2_sweep(struct worker *wrk, struct h2_sess *h2) break; case H2_S_CLOS_REM: if (!r2->scheduled) { - h2_tx_rst(wrk, h2, h2->req0, r2->stream, + H2_Send_Get(wrk, h2, h2->req0); + H2_Send_RST(wrk, h2, h2->req0, r2->stream, H2SE_REFUSED_STREAM); + H2_Send_Rel(h2, h2->req0); h2_del_req(wrk, r2); continue; } diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c index d1c3573ef..a778b35ea 100644 --- a/bin/varnishd/http2/cache_http2_send.c +++ b/bin/varnishd/http2/cache_http2_send.c @@ -113,7 +113,7 @@ h2_mk_hdr(uint8_t *hdr, h2_frame ftyp, uint8_t flags, } /* - * This is the "raw" frame sender, all per stream accounting and + * This is the "raw" frame sender, all per-stream accounting and * prioritization must have happened before this is called, and * the session mtx must be held. */ @@ -349,6 +349,24 @@ h2_send(struct worker *wrk, struct h2_req *r2, h2_frame ftyp, uint8_t flags, } } +void +H2_Send_RST(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2, + uint32_t stream, h2_error h2e) +{ + char b[4]; + + CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC); + CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC); + AN(H2_SEND_HELD(h2, r2)); + + Lck_Lock(&h2->sess->mtx); + VSLb(h2->vsl, SLT_Debug, "H2: stream %u: %s", stream, h2e->txt); + Lck_Unlock(&h2->sess->mtx); + vbe32enc(b, h2e->val); + + H2_Send_Frame(wrk, h2, H2_F_RST_STREAM, 0, sizeof b, stream, b); +} + void H2_Send(struct worker *wrk, struct h2_req *r2, h2_frame ftyp, uint8_t flags, uint32_t len, const void *ptr, uint64_t *counter) From dridi.boukelmoune at gmail.com Mon Jun 24 08:10:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 24 Jun 2019 08:10:09 +0000 (UTC) Subject: [master] 4e12ead23 Polish Message-ID: <20190624081009.2716C2D53@lists.varnish-cache.org> commit 4e12ead2308da0e277a061f926b802aa3de2ef94 Author: Dridi Boukelmoune Date: Mon Jun 24 10:09:25 2019 +0200 Polish diff --git a/bin/varnishtest/tests/b00067.vtc b/bin/varnishtest/tests/b00067.vtc index e7b43a36a..6eb38996c 100644 --- a/bin/varnishtest/tests/b00067.vtc +++ b/bin/varnishtest/tests/b00067.vtc @@ -4,7 +4,7 @@ varnish v1 -arg "-p timeout_idle=1" \ -arg "-a 127.0.0.1:0" \ -arg "-a ${tmpdir}/v1.sock" \ -vcl { - backend dummy { .host = "${bad_ip}"; } + backend dummy { .host = "${bad_backend}"; } sub vcl_deliver { if (req.url == "/sess") { From dridi.boukelmoune at gmail.com Mon Jun 24 08:17:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 24 Jun 2019 08:17:06 +0000 (UTC) Subject: [master] 495f8f665 Polish Message-ID: <20190624081706.CD93440E8@lists.varnish-cache.org> commit 495f8f66519a0b681ac43daed57cd0c2bd2136c3 Author: Dridi Boukelmoune Date: Mon Jun 24 10:16:10 2019 +0200 Polish diff --git a/bin/varnishtest/tests/r02976.vtc b/bin/varnishtest/tests/r02976.vtc index 421cb3fe9..218c027f5 100644 --- a/bin/varnishtest/tests/r02976.vtc +++ b/bin/varnishtest/tests/r02976.vtc @@ -37,7 +37,7 @@ varnish v1 -vcl { } backend b2 { - .host = "${bad_ip}"; + .host = "${bad_backend}"; .probe = { .interval = 24h; } @@ -50,4 +50,4 @@ varnish v1 -vcl { } } -start -barrier bprobe sync \ No newline at end of file +barrier bprobe sync From fgsch at lodoss.net Mon Jun 24 10:55:07 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 24 Jun 2019 10:55:07 +0000 (UTC) Subject: [master] e6ace0955 Bump osx image Message-ID: <20190624105507.9BE247709@lists.varnish-cache.org> commit e6ace0955e935fffea0af3bb854c6442da981708 Author: Federico G. Schwindt Date: Mon Jun 24 11:48:28 2019 +0100 Bump osx image Hopefully this has a newer version of brew that fixes the outdated error we are currently experiencing. diff --git a/.travis.yml b/.travis.yml index 35053aac7..5de9b6b3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,7 +54,7 @@ jobs: - ./configure --enable-developer-warnings --enable-debugging-symbols --disable-stack-protector --with-persistent-storage --enable-asan --enable-ubsan - stage: test os: osx - osx_image: xcode10.1 + osx_image: xcode10.2 compiler: clang addons: homebrew: From fgsch at lodoss.net Mon Jun 24 10:55:07 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 24 Jun 2019 10:55:07 +0000 (UTC) Subject: [master] f4de32063 Small helper file to make my life easier Message-ID: <20190624105507.B017D770F@lists.varnish-cache.org> commit f4de320631a34ea91a592b9d85d6d66ee360654b Author: Federico G. Schwindt Date: Mon Jun 24 11:49:03 2019 +0100 Small helper file to make my life easier diff --git a/.envrc b/.envrc new file mode 100644 index 000000000..ff965d222 --- /dev/null +++ b/.envrc @@ -0,0 +1,4 @@ +export ASAN_OPTIONS=abort_on_error=1,detect_odr_violation=1,detect_leaks=0,detect_stack_use_after_return=1,detect_invalid_pointer_pairs=1,handle_segv=0,handle_sigbus=0,use_sigaltstack=0,disable_coredump=0 +export LSAN_OPTIONS=abort_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/lsan.suppr +export TSAN_OPTIONS=abort_on_error=1,halt_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/tsan.suppr +export UBSAN_OPTIONS=halt_on_error=1,print_stacktrace=1,use_sigaltstack=0,suppressions=$(pwd)/tools/ubsan.suppr From dridi.boukelmoune at gmail.com Mon Jun 24 11:45:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 24 Jun 2019 11:45:10 +0000 (UTC) Subject: [master] e1a1fdc76 Start honoring [idle_]send_timeout of h2 streams Message-ID: <20190624114510.63BB19AAF@lists.varnish-cache.org> commit e1a1fdc7688de5f37e35fc528639019d5bd3efbf Author: Dridi Boukelmoune Date: Fri Apr 19 11:58:14 2019 +0200 Start honoring [idle_]send_timeout of h2 streams Unlike HTTP/1 that relies on the underlying transport, we can time streams out simply by not crediting them. This is our first usage of the CANCEL error with the RST frame, even though this change is not comprehensive since the window only applies to DATA frames. In addition to the session send timeouts, we can now kill streams that aren't making progress and free the resources they hold onto even when the session is continuously active. There is one caveat though, there is currently no timeout for trying to write to the session, so unless a client maintains a stream forever by not crediting it we won't catch it. For that to happen the next step could be to change this pattern: H2_Send_Get(...); /* send something */ H2_Send_Rel(...); And instead check a return value: if (H2_Send_Get(...) == 0) { /* send something */ H2_Send_Rel(...); } else { /* error handling */ } But unfortunately, not all uses of get/rel enclose an attempt to send something. diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index 44bd91783..a7a1001f5 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -232,6 +232,7 @@ void H2_Send(struct worker *, struct h2_req *, h2_frame type, uint8_t flags, /* cache_http2_proto.c */ struct h2_req * h2_new_req(const struct worker *, struct h2_sess *, unsigned stream, struct req *); +int h2_stream_tmo(struct h2_sess *, const struct h2_req *, vtim_real); void h2_del_req(struct worker *, const struct h2_req *); void h2_kill_req(struct worker *, struct h2_sess *, struct h2_req *, h2_error); int h2_rxframe(struct worker *, struct h2_sess *); diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index 025d431d2..f5faedce8 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -87,6 +87,10 @@ h2_fini(struct req *req, void **priv) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); TAKE_OBJ_NOTNULL(r2, priv, H2_REQ_MAGIC); + + if (r2->error) + return (0); + H2_Send_Get(req->wrk, r2->h2sess, r2); H2_Send(req->wrk, r2, H2_F_DATA, H2FF_DATA_END_STREAM, 0, "", NULL); H2_Send_Rel(r2->h2sess, r2); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 577f777c2..e9e626ac1 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -966,21 +966,20 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2, h2_frame h2f) return (0); } -static int -h2_stream_tmo(struct h2_sess *h2, const struct h2_req *r2) +int +h2_stream_tmo(struct h2_sess *h2, const struct h2_req *r2, vtim_real now) { int r = 0; CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC); CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC); + Lck_AssertHeld(&h2->sess->mtx); if (r2->t_winupd == 0 && r2->t_send == 0) return (0); - Lck_Lock(&h2->sess->mtx); if (r2->t_winupd != 0 && - h2->sess->t_idle - r2->t_winupd > - cache_param->idle_send_timeout) { + now - r2->t_winupd > cache_param->idle_send_timeout) { VSLb(h2->vsl, SLT_Debug, "H2: stream %u: Hit idle_send_timeout waiting for" " WINDOW_UPDATE", r2->stream); @@ -988,11 +987,22 @@ h2_stream_tmo(struct h2_sess *h2, const struct h2_req *r2) } if (r == 0 && r2->t_send != 0 && - h2->sess->t_idle - r2->t_send > cache_param->send_timeout) { + now - r2->t_send > cache_param->send_timeout) { VSLb(h2->vsl, SLT_Debug, "H2: stream %u: Hit send_timeout", r2->stream); r = 1; } + + return (r); +} + +static int +h2_stream_tmo_unlocked(struct h2_sess *h2, const struct h2_req *r2) +{ + int r; + + Lck_Lock(&h2->sess->mtx); + r = h2_stream_tmo(h2, r2, h2->sess->t_idle); Lck_Unlock(&h2->sess->mtx); return (r); @@ -1033,7 +1043,7 @@ h2_sweep(struct worker *wrk, struct h2_sess *h2) /* FALLTHROUGH */ case H2_S_CLOS_LOC: case H2_S_OPEN: - if (h2_stream_tmo(h2, r2)) { + if (h2_stream_tmo_unlocked(h2, r2)) { tmo = 1; continue; } diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c index a778b35ea..6b2a34935 100644 --- a/bin/varnishd/http2/cache_http2_send.c +++ b/bin/varnishd/http2/cache_http2_send.c @@ -41,6 +41,41 @@ #define H2_SEND_HELD(h2, r2) (VTAILQ_FIRST(&(h2)->txqueue) == (r2)) +static int +h2_cond_wait(pthread_cond_t *cond, struct h2_sess *h2, struct h2_req *r2) +{ + vtim_real now, when = 0.; + int r; + + AN(cond); + CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC); + CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC); + + Lck_AssertHeld(&h2->sess->mtx); + + now = VTIM_real(); + if (cache_param->idle_send_timeout > 0.) + when = now + cache_param->idle_send_timeout; + + r = Lck_CondWait(cond, &h2->sess->mtx, when); + + now = VTIM_real(); + /* NB: when we grab idle_send_timeout before acquiring the session + * lock we may time out, but once we wake up both send_timeout and + * idle_send_timeout may have changed meanwhile. For this reason + * h2_stream_tmo() may not log what timed out and we need to check + * both conditions to decide whether we cancel the stream or not. + */ + if (h2_stream_tmo(h2, r2, now) || r == ETIMEDOUT) { + if (r2->error == NULL) + r2->error = H2SE_CANCEL; + return (-1); + } + + AZ(r); + return (0); +} + static void h2_send_get_locked(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { @@ -224,12 +259,11 @@ h2_do_window(struct worker *wrk, struct h2_req *r2, h2_send_rel_locked(h2, r2); while (r2->t_window <= 0 && h2_errcheck(r2, h2) == 0) { r2->cond = &wrk->cond; - AZ(Lck_CondWait(r2->cond, &h2->sess->mtx, 0)); + (void)h2_cond_wait(r2->cond, h2, r2); r2->cond = NULL; } - while (h2->req0->t_window <= 0 && h2_errcheck(r2, h2) == 0) { - AZ(Lck_CondWait(h2->winupd_cond, &h2->sess->mtx, 0)); - } + while (h2->req0->t_window <= 0 && h2_errcheck(r2, h2) == 0) + (void)h2_cond_wait(h2->winupd_cond, h2, r2); if (h2_errcheck(r2, h2) == 0) { w = h2_win_limit(r2, h2); @@ -377,4 +411,7 @@ H2_Send(struct worker *wrk, struct h2_req *r2, h2_frame ftyp, uint8_t flags, counter = &dummy_counter; h2_send(wrk, r2, ftyp, flags, len, ptr, counter); + + if (h2_errcheck(r2, r2->h2sess) == H2SE_CANCEL) + H2_Send_RST(wrk, r2->h2sess, r2, r2->stream, H2SE_CANCEL); } diff --git a/bin/varnishtest/tests/t02016.vtc b/bin/varnishtest/tests/t02016.vtc new file mode 100644 index 000000000..05ad99616 --- /dev/null +++ b/bin/varnishtest/tests/t02016.vtc @@ -0,0 +1,76 @@ +varnishtest "client h2 send timeouts" + +server s1 { + rxreq + txresp -bodylen 12345 +} -start + +varnish v1 -cliok "param.set feature +http2" +varnish v1 -vcl+backend "" -start + +varnish v1 -cliok "param.set send_timeout 1" + +logexpect l1 -v v1 { + expect * * Debug "Hit send_timeout" +} -start + +client c1 { + txpri + + stream 0 { + rxsettings + expect settings.ack == false + txsettings -ack + txsettings -winsize 1000 + rxsettings + expect settings.ack == true + } -run + + stream 1 { + txreq + rxhdrs + rxdata + # keep the stream idle for 2 seconds + delay 2 + txwinup -size 256 + # too late + rxrst + expect rst.err == CANCEL + } -run + +} -run + +logexpect l1 -wait + +varnish v1 -cliok "param.set idle_send_timeout 1" +varnish v1 -cliok "param.reset send_timeout" + +logexpect l2 -v v1 { + expect * * Debug "Hit idle_send_timeout" +} -start + +client c2 { + txpri + + stream 0 { + rxsettings + expect settings.ack == false + txsettings -ack + txsettings -winsize 1000 + rxsettings + expect settings.ack == true + } -run + + stream 1 { + txreq + rxhdrs + rxdata + # keep the stream idle for 2 seconds + delay 2 + rxrst + expect rst.err == CANCEL + } -run + +} -run + +logexpect l2 -wait From dridi.boukelmoune at gmail.com Mon Jun 24 12:01:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 24 Jun 2019 12:01:07 +0000 (UTC) Subject: [master] 4d95941d1 Make b1 and b2 look similar, and more compact Message-ID: <20190624120107.8188E602F3@lists.varnish-cache.org> commit 4d95941d15282f4499c33a6a16d46dffee86ac78 Author: Dridi Boukelmoune Date: Mon Jun 24 13:59:49 2019 +0200 Make b1 and b2 look similar, and more compact diff --git a/bin/varnishtest/tests/r02976.vtc b/bin/varnishtest/tests/r02976.vtc index 218c027f5..6fbb57e03 100644 --- a/bin/varnishtest/tests/r02976.vtc +++ b/bin/varnishtest/tests/r02976.vtc @@ -29,18 +29,13 @@ server s1 { varnish v1 -vcl { backend b1 { - .host = "${s1_addr}"; - .port = "${s1_port}"; - .probe = { - .interval = 1s; - } + .host = "${s1_sock}"; + .probe = { .interval = 1s; } } backend b2 { .host = "${bad_backend}"; - .probe = { - .interval = 24h; - } + .probe = { .interval = 24h; } } sub vcl_recv { From dridi.boukelmoune at gmail.com Mon Jun 24 12:10:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 24 Jun 2019 12:10:09 +0000 (UTC) Subject: [master] d4498956b Simplify r02976.vtc further Message-ID: <20190624121009.ACF2460751@lists.varnish-cache.org> commit d4498956b1b54fd4065640a0e25a2c52b3d203d7 Author: Dridi Boukelmoune Date: Mon Jun 24 14:08:28 2019 +0200 Simplify r02976.vtc further This time, once and for all. diff --git a/bin/varnishtest/tests/r02976.vtc b/bin/varnishtest/tests/r02976.vtc index 6fbb57e03..f3a7aa2ce 100644 --- a/bin/varnishtest/tests/r02976.vtc +++ b/bin/varnishtest/tests/r02976.vtc @@ -27,6 +27,8 @@ server s1 { barrier bprobe sync } -start +varnish v1 -cliok {param.set vcc_err_unref off} + varnish v1 -vcl { backend b1 { .host = "${s1_sock}"; @@ -37,12 +39,6 @@ varnish v1 -vcl { .host = "${bad_backend}"; .probe = { .interval = 24h; } } - - sub vcl_recv { - if (!req.url) { - set req.backend_hint = b2; - } - } } -start barrier bprobe sync From dridi at varni.sh Mon Jun 24 12:20:24 2019 From: dridi at varni.sh (Dridi Boukelmoune) Date: Mon, 24 Jun 2019 12:20:24 +0000 Subject: [master] f4de32063 Small helper file to make my life easier In-Reply-To: <20190624105507.B017D770F@lists.varnish-cache.org> References: <20190624105507.B017D770F@lists.varnish-cache.org> Message-ID: On Mon, Jun 24, 2019 at 10:55 AM Federico G. Schwindt wrote: > > > commit f4de320631a34ea91a592b9d85d6d66ee360654b > Author: Federico G. Schwindt > Date: Mon Jun 24 11:49:03 2019 +0100 > > Small helper file to make my life easier > > diff --git a/.envrc b/.envrc > new file mode 100644 > index 000000000..ff965d222 > --- /dev/null > +++ b/.envrc > @@ -0,0 +1,4 @@ > +export ASAN_OPTIONS=abort_on_error=1,detect_odr_violation=1,detect_leaks=0,detect_stack_use_after_return=1,detect_invalid_pointer_pairs=1,handle_segv=0,handle_sigbus=0,use_sigaltstack=0,disable_coredump=0 > +export LSAN_OPTIONS=abort_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/lsan.suppr > +export TSAN_OPTIONS=abort_on_error=1,halt_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/tsan.suppr > +export UBSAN_OPTIONS=halt_on_error=1,print_stacktrace=1,use_sigaltstack=0,suppressions=$(pwd)/tools/ubsan.suppr Do you mind if I break lines like this? ASAN_OPTIONS="\ abort_on_error=1,\ detect_odr_violation=1,\ [...] disable_coredump=0" Dridi From dridi.boukelmoune at gmail.com Mon Jun 24 16:12:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 24 Jun 2019 16:12:07 +0000 (UTC) Subject: [master] 9a19fa438 Simplify r02976.vtc furtherer Message-ID: <20190624161207.E05EB65772@lists.varnish-cache.org> commit 9a19fa4386d5a2a548f18883a9de09599cd65e9a Author: Dridi Boukelmoune Date: Mon Jun 24 18:09:48 2019 +0200 Simplify r02976.vtc furtherer I was wrong, or I lied. This is the final cleanup. diff --git a/bin/varnishtest/tests/r02976.vtc b/bin/varnishtest/tests/r02976.vtc index f3a7aa2ce..fdfe50fdf 100644 --- a/bin/varnishtest/tests/r02976.vtc +++ b/bin/varnishtest/tests/r02976.vtc @@ -1,30 +1,8 @@ varnishtest "Detect probe interval inversion" -barrier bprobe cond 2 - -server s1 { - # 5 probe requests - rxreq - txresp - close - accept - rxreq - txresp - close - accept - rxreq - txresp - close - accept - rxreq - txresp - close - accept +server s1 -repeat 5 { # probe requests rxreq txresp - close - accept - barrier bprobe sync } -start varnish v1 -cliok {param.set vcc_err_unref off} @@ -41,4 +19,4 @@ varnish v1 -vcl { } } -start -barrier bprobe sync +server s1 -wait From dridi.boukelmoune at gmail.com Wed Jun 26 07:44:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 26 Jun 2019 07:44:09 +0000 (UTC) Subject: [master] ff0496594 Use the same ${pkgsysconfdir} everywhere Message-ID: <20190626074409.253FF9817B@lists.varnish-cache.org> commit ff049659496b1d85216c22663e23684fd4f5852e Author: Dridi Boukelmoune Date: Wed Jun 26 09:41:34 2019 +0200 Use the same ${pkgsysconfdir} everywhere The pkg-config file wasn't using the one defined by the configure script and could lead to a mismatch if the package name changes. diff --git a/varnishapi.pc.in b/varnishapi.pc.in index 644195246..694f3a232 100644 --- a/varnishapi.pc.in +++ b/varnishapi.pc.in @@ -4,7 +4,7 @@ bindir=@bindir@ sbindir=@sbindir@ libdir=@libdir@ sysconfdir=@sysconfdir@ -pkgsysconfdir=${sysconfdir}/@PACKAGE@ +pkgsysconfdir=@pkgsysconfdir@ includedir=@includedir@ pkgincludedir=${includedir}/@PACKAGE@ datarootdir=@datarootdir@ From dridi.boukelmoune at gmail.com Wed Jun 26 07:52:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 26 Jun 2019 07:52:07 +0000 (UTC) Subject: [master] 69f2e2843 Polish Message-ID: <20190626075207.4E8F5985EB@lists.varnish-cache.org> commit 69f2e284340ad2a4af200bcbbea995cee5103aff Author: Dridi Boukelmoune Date: Wed Jun 26 09:51:40 2019 +0200 Polish diff --git a/varnishapi.pc.in b/varnishapi.pc.in index 694f3a232..04fe45602 100644 --- a/varnishapi.pc.in +++ b/varnishapi.pc.in @@ -18,5 +18,5 @@ vsctool=${pkgdatadir}/vsctool.py Name: VarnishAPI Description: Varnish API Version: @PACKAGE_VERSION@ -Cflags: -I${includedir}/@PACKAGE@ +Cflags: -I${pkgincludedir} Libs: -L${libdir} -lvarnishapi From dridi.boukelmoune at gmail.com Wed Jun 26 10:34:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 26 Jun 2019 10:34:07 +0000 (UTC) Subject: [master] 0c4f0ec45 Missing VRT ABI update Message-ID: <20190626103407.6186FA0D13@lists.varnish-cache.org> commit 0c4f0ec45d0a403f6279e059f804a3b44a04bc51 Author: Dridi Boukelmoune Date: Wed Jun 26 12:33:09 2019 +0200 Missing VRT ABI update diff --git a/include/vrt.h b/include/vrt.h index 0d9b91ac1..a288cb2fd 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -66,6 +66,7 @@ * VRT_vcl_select moved to vcc_interface.h * VRT_VSA_GetPtr() changed * VRT_ipcmp() changed + * VRT_Stv_*() functions renamed to VRT_stevedore_*() * [cache.h] WS_ReserveAll() added * [cache.h] WS_Reserve(ws, 0) deprecated * 9.0 (2019-03-15) From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:08 +0000 (UTC) Subject: [6.0] 095990085 Sync documentation with mgt_main.c Message-ID: <20190627170508.E61A69B769@lists.varnish-cache.org> commit 0959900854c93656f26fe0dc8a619427d2bb10f3 Author: Dridi Boukelmoune Date: Tue Dec 11 18:20:14 2018 +0100 Sync documentation with mgt_main.c See `git grep PROXY -- bin/varnishd/mgt/mgt_main.c`. diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index de7ee866f..57c657711 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -57,7 +57,7 @@ Basic options Name is referenced in logs. If name is not specified, "a0", "a1", etc. is used. An additional protocol type can be set for the - listening socket with PROTO. Valid protocol types are: HTTP/1 + listening socket with PROTO. Valid protocol types are: HTTP (default), and PROXY. Multiple listening addresses can be specified by using different From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:09 +0000 (UTC) Subject: [6.0] 4d7b204cc More details on 6.0 packaging changes Message-ID: <20190627170509.0BCB99B76C@lists.varnish-cache.org> commit 4d7b204cc03319f254b51213907d5b802c0e0f54 Author: Dridi Boukelmoune Date: Tue Dec 11 18:46:55 2018 +0100 More details on 6.0 packaging changes It turns out people are really attached to their varnish.params file. diff --git a/doc/sphinx/whats-new/upgrading-6.0.rst b/doc/sphinx/whats-new/upgrading-6.0.rst index 2006a97b1..438dc606e 100644 --- a/doc/sphinx/whats-new/upgrading-6.0.rst +++ b/doc/sphinx/whats-new/upgrading-6.0.rst @@ -592,6 +592,17 @@ since there's no more reasons to have them diverge: we initially inherited packaging support from downstream package maintainers, and they deserve many thanks for that. +The biggest change that resulted in unifying our systemd setup across +all official packages is that the ``varnish.params`` file available on +Red Hat derivatives is gone. We noticed that using an environment file +to hide the fact that ``varnishd`` is configured via command line +arguments misled some people into thinking that what was proposed in +the file was your only set of configuration options. For example, you +can specify multiple listen addresses using multiple ``-a`` options +but you only get variables for one address and a catch-all variable +``DAEMON_OPTS`` for anything not fitting in the template. In addition +using an environment file pollutes the process's environment. + Another big difference between Red Hat and Debian derivatives was the way we handled VCL reloads via the service manager. We introduced a new ``varnishreload`` script that operates on top of ``varnishadm`` From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:09 +0000 (UTC) Subject: [6.0] 4d16ee921 Allow now to be used in vcl_init Message-ID: <20190627170509.235099B770@lists.varnish-cache.org> commit 4d16ee921440f002e6d2b8b13ac8c7e00605227b Author: Reza Naghibi Date: Thu Dec 6 20:58:38 2018 -0500 Allow now to be used in vcl_init diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 4cf196ea0..f267fd01a 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -44,6 +44,7 @@ #include "cache_director.h" #include "cache_vcl.h" #include "vcli_serve.h" +#include "vtim.h" const char * const VCL_TEMP_INIT = "init"; const char * const VCL_TEMP_COLD = "cold"; @@ -115,6 +116,7 @@ vcl_get_ctx(unsigned method, int msg) handling_cli = 0; ctx_cli.handling = &handling_cli; ctx_cli.method = method; + ctx_cli.now = VTIM_real(); if (msg) { ctx_cli.msg = VSB_new_auto(); AN(ctx_cli.msg); From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:09 +0000 (UTC) Subject: [6.0] 23ce52411 NULL terminate list of commands. Message-ID: <20190627170509.4D61F9B775@lists.varnish-cache.org> commit 23ce52411f56a032288158aeb322cd1496f5ff92 Author: Poul-Henning Kamp Date: Wed Dec 19 11:23:11 2018 +0000 NULL terminate list of commands. Submitted by: Frederic Lecaille diff --git a/bin/varnishtest/vtc_haproxy.c b/bin/varnishtest/vtc_haproxy.c index bd37aadb7..0ff037f6d 100644 --- a/bin/varnishtest/vtc_haproxy.c +++ b/bin/varnishtest/vtc_haproxy.c @@ -278,6 +278,7 @@ static const struct cmds haproxy_cli_cmds[] = { CMD_HAPROXY_CLI(send) CMD_HAPROXY_CLI(expect) #undef CMD_HAPROXY_CLI + { NULL, NULL } }; /********************************************************************** diff --git a/bin/varnishtest/vtc_syslog.c b/bin/varnishtest/vtc_syslog.c index 666b82d3c..fe61fa079 100644 --- a/bin/varnishtest/vtc_syslog.c +++ b/bin/varnishtest/vtc_syslog.c @@ -430,6 +430,7 @@ static const struct cmds syslog_cmds[] = { CMD_SYSLOG(expect) CMD_SYSLOG(recv) #undef CMD_SYSLOG + { NULL, NULL } }; /********************************************************************** From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:09 +0000 (UTC) Subject: [6.0] 31ad449b8 Ignore generated RST files. Message-ID: <20190627170509.67EFE9B778@lists.varnish-cache.org> commit 31ad449b86d08473f415d1292edde026ab195002 Author: Lasse Karstensen Date: Fri Dec 21 15:02:01 2018 +0100 Ignore generated RST files. diff --git a/.gitignore b/.gitignore index c96ca4b91..f6870aa1b 100644 --- a/.gitignore +++ b/.gitignore @@ -97,6 +97,8 @@ cscope.*out /doc/*.html /doc/sphinx/build/ /doc/sphinx/conf.py +/doc/sphinx/reference/vmod_*.generated.rst + # graphviz-generated /doc/graphviz/*.pdf From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:09 +0000 (UTC) Subject: [6.0] 1c6d80ed5 Tidy up Message-ID: <20190627170509.8B15C9B77C@lists.varnish-cache.org> commit 1c6d80ed5afd636a17ce470811e08e4387ec3cef Author: Federico G. Schwindt Date: Fri Dec 21 16:46:14 2018 +0000 Tidy up Conflicts: bin/varnishd/cache/cache_fetch.c diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 4193c4e2c..ad44b3041 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -569,8 +569,6 @@ vbf_figure_out_vfp(struct busyobj *bo) static enum fetch_step vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) { - const char *p; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC); @@ -610,8 +608,8 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (!(bo->fetch_objcore->flags & OC_F_HFM) && http_IsStatus(bo->beresp, 200) && ( - http_GetHdr(bo->beresp, H_Last_Modified, &p) || - http_GetHdr(bo->beresp, H_ETag, &p))) + http_GetHdr(bo->beresp, H_Last_Modified, NULL) || + http_GetHdr(bo->beresp, H_ETag, NULL))) ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_IMSCAND, 1); if (bo->htc->body_status != BS_NONE && From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:09 +0000 (UTC) Subject: [6.0] e03d6c436 Polish Message-ID: <20190627170509.B837D9B780@lists.varnish-cache.org> commit e03d6c4361c70e816f8e4b0c9291acc50a144499 Author: Dridi Boukelmoune Date: Mon Dec 24 17:14:31 2018 +0100 Polish diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index 52fd156b7..6657cdfb6 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -199,6 +199,6 @@ VCL_TaskLeave(const struct vcl *vcl, struct vrt_privs *privs) VTAILQ_REMOVE(&privs->privs, vp, list); VRT_priv_fini(vp->priv); } - INIT_OBJ(privs, 0); + ZERO_OBJ(privs, sizeof *privs); } From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:09 +0000 (UTC) Subject: [6.0] 57941abf8 Permit subsequent conditional requests on 304 Message-ID: <20190627170509.D49349B785@lists.varnish-cache.org> commit 57941abf81ba089c6530666cd6309886a9361073 Author: Federico G. Schwindt Date: Thu Dec 27 17:10:20 2018 +0000 Permit subsequent conditional requests on 304 Fixes #2871. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index ad44b3041..a5701ec8e 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -714,7 +714,8 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) OA_ESIDATA)); AZ(ObjCopyAttr(bo->wrk, bo->fetch_objcore, bo->stale_oc, OA_FLAGS)); - ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_IMSCAND, 0); + if (bo->fetch_objcore->flags & OC_F_HFM) + ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_IMSCAND, 0); AZ(ObjCopyAttr(bo->wrk, bo->fetch_objcore, bo->stale_oc, OA_GZIPBITS)); if (bo->do_stream) { diff --git a/bin/varnishtest/tests/b00039.vtc b/bin/varnishtest/tests/b00039.vtc index b9d40bfeb..ba4285369 100644 --- a/bin/varnishtest/tests/b00039.vtc +++ b/bin/varnishtest/tests/b00039.vtc @@ -6,6 +6,9 @@ server s1 { rxreq expect req.http.if-modified-since == "Wed, 11 Sep 2013 13:36:55 GMT" txresp -status 304 + rxreq + expect req.http.if-modified-since == "Wed, 11 Sep 2013 13:36:55 GMT" + txresp -status 304 } -start varnish v1 -vcl+backend { @@ -44,3 +47,13 @@ client c1 { expect resp.body == "Geoff Rules" expect resp.http.was-304 == "true" } -run + +delay 1 + +client c1 { + txreq + rxresp + expect resp.status == 200 + expect resp.body == "Geoff Rules" + expect resp.http.was-304 == "true" +} -run From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:09 +0000 (UTC) Subject: [6.0] 375412b77 Do you feel lucky Punk ? Message-ID: <20190627170509.EE4699B789@lists.varnish-cache.org> commit 375412b7762d30c02a8e8b45226dfd15d6054e46 Author: Poul-Henning Kamp Date: Thu Jan 3 00:44:48 2019 +0000 Do you feel lucky Punk ? diff --git a/doc/sphinx/phk/index.rst b/doc/sphinx/phk/index.rst index 7962d9ea5..d258654d8 100644 --- a/doc/sphinx/phk/index.rst +++ b/doc/sphinx/phk/index.rst @@ -8,6 +8,7 @@ You may or may not want to know what Poul-Henning thinks. .. toctree:: :maxdepth: 1 + lucky.rst apispaces.rst VSV00001.rst somethinghappened.rst diff --git a/doc/sphinx/phk/lucky.rst b/doc/sphinx/phk/lucky.rst new file mode 100644 index 000000000..328f66e6a --- /dev/null +++ b/doc/sphinx/phk/lucky.rst @@ -0,0 +1,179 @@ +.. _phk_lucky: + +=================== +Do you feel lucky ? +=================== + +Whenever a corporate cotton-mouth says anything, their laywers +always make them add a footnote to the effect that *"Past performance +is not predictive of future results."* so they do not get sued for +being insufficiently clairvoyant. + +The lawyers are wrong. + +Past performance *is* predictive of future results: That is how +we determine the odds. + +Just never forget that the roll of the dice is still pure luck. + +Or as author Neil Gaiman said it in +`a commencement speech in 2012 `_: + + *?Often you will discover that the harder you work, + and the more wisely you work, the luckier you get. + But there is luck, and it helps.?* + +Approximately four million real websites use Varnish now and the +number seems to grow by half a million sites per year, as it has +been doing for the last 8 years. + +That took a lot of luck, and wisdom was probably also involved, but +mostly it was lot of hard work by a lot of people. + +Wisdom is a tricky thing, the hypothesized "older?wiser" correlation +is still in clinical testing and in the meantime Neil Gaiman suggests: + + *?So be wise, because the world needs more wisdom, and if you + cannot be wise, pretend to be someone who is wise, and then just + behave like they would.?* + +Works for me. + +---- +2018 +---- + +Despite sucking in pretty much any other aspect, 2018 was a good +year for Open Source Software in general and Varnish Cache in +particular. + +People have finally started to understand that Free does not mean +Gratis, and that quality software takes time and effort. + +From to the dot-com generation reinventing reproducible builds (like +we had then in the 1980'ies) to the EU setting up a pot +of `850M? bug-bounties +`_ [#f1]_, +things are moving in the right direction with respect to software +quality. + +In 2018 the Varnish Cache project had settled into our "March and +September 15th" release strategy, and released 6.0 in March and 6.1 +in September, as promised, and the next release will be out in ten +weeks. + +We also had no security issues, and we have managed to keep the +number of open issues and bug reports down. + +Writing it like that makes it sound boring, but with four million +web sites depending on Varnish, boring is good thing. + +No news is indeed good news. + +--------------- +2019 and HTTP/3 +--------------- + +The Next Big Thing in our world seems like it will be HTTP/3 ("The +protocol formerly known as QUIC"), and I suspect it will drive +much of our work in 2019. + +It is far too early to say anything about if, when or how, but I +do spend a lot of time with pencil and paper, pretending to be +somebody who is good at designing secure and efficient software. + +Around the time of the 2019-03-15 release we will gather for a VDD +(Varnish Developer Day), and the big topic there will be HTTP/3, +and then we will know and be ready to say something more detailed. + +I don't think it is realistic to roll out any kind of H3 support +in the september release, that release will probably only contain +a some of the necessary prepatory reorganization, so expect to +run production on 6.1 for a while. + +--------------------- +Varnish Moral License +--------------------- + +I want to thank the companies who have paid for a `Varnish +Moral License `_: + +* Fastly + +* Uplex + +* Varnish Software + +* Section.io + +* Globo + +The VML funding is why Varnish Cache is not on EU's hit-list and +why another half million websites who started using Varnish in +2018 will not regret it. + +Much appreciated! + +------- +ENOLUCK +------- + +For me 2018 ended on a sour note, when my dear friend `Jacob Sparre +Andersen `_ died from cancer a week +before christmas. + +Society as such knows how to deal with deaths, and all sorts of +procedures and rules kick in, to tie the loose ends up, respectfully +and properly. + +The Internet is not there yet, people on the Internet have only +just started dying, and there are not yet any automatic routines +or generally perceived procedures for informing the people and +communities who should know, or for tying up the loose ends, accounts, +repositories and memberships on the Internet. + +But deaths happen, and I can tell you from personal experience that +few things feel more awful, than having sent an email to somebody, +to receive the reply from their heartbroken spouse, that you are +many months too late [#f2]_. + +Jacob was not a major persona on the Internet, but between doing a +lot of interesting stuff as a multi-disicpline phd. in physics, +being a really good Ada programmer, a huge Lego enthusiast, an +incredibly helpful person *and* really *good* at helping, he had a +lot of friends in many corners of the Internet. + +Jacob knew what was coming, and being his usual helpful self, he +used the last few weeks to make a list of who to tell online, where +things were stored, what the passwords were, and he even appointed +a close friend to be his "digital executor", who will help his widow +sort all these things out in the coming months. + +When people die in our age-bracket, they usually do not get a few +weeks notice. If Jacob had been hit by a bus, his widow would have +have been stuck in an almost impossible digital situation, starting +with the need to guess, well, pretty much everything, including +the passwords. + +In honour of my helpful friend Jacob, and for the sake of your loved +ones, please sit down tonight, and write your own list of digital +who, what and where, including how to gain access to the necessary +passwords, and file it away in a way where it will be found, if +you run out of luck. + +Good luck! + +*phk* + +.. rubric:: Footnotes + +.. [#f1] I am not a big fan of bug-bounties, but I will grudingly admit + that wiser men than me, notably `Dan Geer + `_, have proposed that + tax-money be used to snatch the vulnerabilities up, before bad guys + get hold of them, and they seem to have a point. + +.. [#f2] And it does not feel any less awful if the loved ones + left behind tries to fill the blanks by asking you how you knew + each other and if you have any memories you could share with them. + From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:10 +0000 (UTC) Subject: [6.0] 33b6d4e81 Improve function call argument error messages. Message-ID: <20190627170510.156FD9B790@lists.varnish-cache.org> commit 33b6d4e817eef0992afff2df380acd99b2469bb5 Author: Poul-Henning Kamp Date: Thu Jan 3 12:40:05 2019 +0000 Improve function call argument error messages. Fixes: #2874 diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 780befa0c..b92781047 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -576,6 +576,10 @@ vcc_func(struct vcc *tl, struct expr **e, const void *priv, break; } vcc_do_arg(tl, fa); + if (tl->err) + VSB_printf(tl->sb, "Expected argument: %s %s\n\n", + fa->type->name, + fa->name ? fa->name : "(unnamed argument)"); ERRCHK(tl); if (tl->t->tok == ')') break; @@ -666,6 +670,8 @@ vcc_Eval_Func(struct vcc *tl, const struct vjsn_val *spec, struct expr *e = NULL; vcc_func(tl, &e, spec, extra, sym); + if (tl->err) + VSB_printf(tl->sb, "While compiling function call:\n"); ERRCHK(tl); vcc_expr_fmt(tl->fb, tl->indent, e); VSB_cat(tl->fb, ";\n"); @@ -752,6 +758,11 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt) AN(sym->eval); AZ(*e); sym->eval(tl, e, t, sym, fmt); + if (tl->err) { + VSB_printf(tl->sb, + "While compiling function call:\n\n"); + vcc_ErrWhere2(tl, t, tl->t); + } ERRCHK(tl); /* Unless asked for a HEADER, fold to string here */ if (*e && fmt != HEADER && (*e)->fmt == HEADER) { @@ -1372,6 +1383,7 @@ vcc_Act_Call(struct vcc *tl, struct token *t, struct symbol *sym) SkipToken(tl, ';'); VSB_cat(tl->fb, ";\n"); } else if (t != tl->t) { + VSB_printf(tl->sb, "While compiling function call:\n\n"); vcc_ErrWhere2(tl, t, tl->t); } vcc_delete_expr(e); From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:10 +0000 (UTC) Subject: [6.0] 1e058f8b5 Enable some features based on the input Message-ID: <20190627170510.31F769B7A4@lists.varnish-cache.org> commit 1e058f8b5919af4251f4fa1bc7c51580546713f0 Author: Federico G. Schwindt Date: Thu Jan 3 20:01:37 2019 +0000 Enable some features based on the input diff --git a/bin/varnishd/fuzzers/esi_parse_fuzzer.c b/bin/varnishd/fuzzers/esi_parse_fuzzer.c index 972ffa0b1..34548b90f 100644 --- a/bin/varnishd/fuzzers/esi_parse_fuzzer.c +++ b/bin/varnishd/fuzzers/esi_parse_fuzzer.c @@ -94,8 +94,17 @@ LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) VSC_C_main = &__VSC_C_main; cache_param = &__cache_param; - /* Zero out the esi feature bits for now */ memset(&__cache_param, 0, sizeof(__cache_param)); +#define BSET(b, no) (b)[(no) >> 3] |= (0x80 >> ((no) & 7)) + if (data[0] & 0x8f) + BSET(__cache_param.feature_bits, FEATURE_ESI_IGNORE_HTTPS); + if (size > 1 && data[1] & 0x8f) + BSET(__cache_param.feature_bits, FEATURE_ESI_DISABLE_XML_CHECK); + if (size > 2 && data[2] & 0x8f) + BSET(__cache_param.feature_bits, FEATURE_ESI_IGNORE_OTHER_ELEMENTS); + if (size > 3 && data[3] & 0x8f) + BSET(__cache_param.feature_bits, FEATURE_ESI_REMOVE_BOM); +#undef BSET /* Setup req */ req.hd = hd; From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:10 +0000 (UTC) Subject: [6.0] e42d926bf Field values are case insensitive Message-ID: <20190627170510.4985B9B7C2@lists.varnish-cache.org> commit e42d926bf7a613e56d2dc543b77c0e79141040f8 Author: Federico G. Schwindt Date: Thu Dec 27 17:14:37 2018 +0000 Field values are case insensitive Should address "HTTP cache must not use a cached response with Cache-Control: No-CaChE, even with max-age and Expires" from https://cache-tests.fyi. diff --git a/bin/varnishd/builtin.vcl b/bin/varnishd/builtin.vcl index a578a9c33..4835a231c 100644 --- a/bin/varnishd/builtin.vcl +++ b/bin/varnishd/builtin.vcl @@ -156,9 +156,9 @@ sub vcl_backend_response { return (deliver); } else if (beresp.ttl <= 0s || beresp.http.Set-Cookie || - beresp.http.Surrogate-control ~ "no-store" || + beresp.http.Surrogate-control ~ "(?i)no-store" || (!beresp.http.Surrogate-Control && - beresp.http.Cache-Control ~ "no-cache|no-store|private") || + beresp.http.Cache-Control ~ "(?i:no-cache|no-store|private)") || beresp.http.Vary == "*") { # Mark as "Hit-For-Miss" for the next 2 minutes set beresp.ttl = 120s; From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:10 +0000 (UTC) Subject: [6.0] 91682e53f Ignore fields with invalid C-C values Message-ID: <20190627170510.626F89B7D0@lists.varnish-cache.org> commit 91682e53fa7d18c53b480f3916d791f9905a3ba3 Author: Federico G. Schwindt Date: Thu Dec 27 17:14:55 2018 +0000 Ignore fields with invalid C-C values Should address "HTTP cache must not reuse a response with an invalid Cache-Control: max-age (trailing alpha)" from https://cache-tests.fyi. diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index c9341fdd0..e78204782 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -34,6 +34,7 @@ #include "cache_varnishd.h" #include "vtim.h" +#include "vct.h" /*-------------------------------------------------------------------- * TTL and Age calculation in Varnish @@ -61,6 +62,21 @@ * */ +static inline int +rfc2616_time(const char *p) +{ + char *ep; + int val; + if (*p == '-') + return (0); + val = strtoul(p, &ep, 10); + for (; *ep != '\0' && vct_issp(*ep); ep++) + continue; + if (*ep == '\0' || *ep == ',') + return (val); + return (0); +} + void RFC2616_Ttl(struct busyobj *bo, vtim_real now, vtim_real *t_origin, float *ttl, float *grace, float *keep) @@ -140,12 +156,7 @@ RFC2616_Ttl(struct busyobj *bo, vtim_real now, vtim_real *t_origin, if ((http_GetHdrField(hp, H_Cache_Control, "s-maxage", &p) || http_GetHdrField(hp, H_Cache_Control, "max-age", &p)) && p != NULL) { - - if (*p == '-') - max_age = 0; - else - max_age = strtoul(p, NULL, 0); - + max_age = rfc2616_time(p); *ttl = max_age; break; } @@ -190,11 +201,7 @@ RFC2616_Ttl(struct busyobj *bo, vtim_real now, vtim_real *t_origin, */ if (*ttl >= 0 && http_GetHdrField(hp, H_Cache_Control, "stale-while-revalidate", &p) && p != NULL) { - - if (*p == '-') - *grace = 0; - else - *grace = strtoul(p, NULL, 0); + *grace = rfc2616_time(p); } VSLb(bo->vsl, SLT_TTL, From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:10 +0000 (UTC) Subject: [6.0] d7be5334f Test max-age, s-maxage and Expires Message-ID: <20190627170510.7C77B9B7EA@lists.varnish-cache.org> commit d7be5334fb9f7212ea2cba53a0064367984953f1 Author: Federico G. Schwindt Date: Thu Jan 3 20:15:18 2019 +0000 Test max-age, s-maxage and Expires diff --git a/bin/varnishtest/tests/b00066.vtc b/bin/varnishtest/tests/b00066.vtc new file mode 100644 index 000000000..7eb286f4b --- /dev/null +++ b/bin/varnishtest/tests/b00066.vtc @@ -0,0 +1,102 @@ +varnishtest "Test CC:max-age, CC:s-maxage and Expires handling" + +server s1 { + rxreq + txresp -hdr "Cache-Control: max-age=-2" + rxreq + txresp -hdr "Cache-Control: max-age=a2" + rxreq + txresp -hdr "Cache-Control: max-age=2a" + rxreq + txresp -hdr "Cache-Control: s-maxage=-2" + rxreq + txresp -hdr "Cache-Control: s-maxage=a2" + rxreq + txresp -hdr "Cache-Control: s-maxage=2a" + rxreq + txresp -hdr "Expires: THU, 18 Aug 2050 02:01:18 GMT" + rxreq + txresp -hdr "Expires: Thu, 18 AUG 2050 02:01:18 GMT" + rxreq + txresp -hdr "Expires: Thu, 18 Aug 2050 02:01:18 gMT" + rxreq + txresp -hdr "Cache-Control: max-age=5, s-maxage=1" + rxreq + txresp -hdr "Cache-Control: s-maxage=2, max-age=5" + rxreq + txresp \ + -hdr "Cache-Control: max-age=5" \ + -hdr "Cache-Control: s-maxage=3" +} -start + +varnish v1 -arg "-pdefault_ttl=0" -vcl+backend { + sub vcl_backend_response { + set beresp.http.ttl = beresp.ttl; + set beresp.uncacheable = true; + } +} -start + +client c1 { + # negative max-age + txreq + rxresp + expect resp.http.ttl == 0.000 + + # invalid max-age - leading alpha + txreq + rxresp + expect resp.http.ttl == 0.000 + + # invalid max-age - trailing alpha + txreq + rxresp + expect resp.http.ttl == 0.000 + + # negative s-maxage + txreq + rxresp + expect resp.http.ttl == 0.000 + + # invalid s-maxage - leading alpha + txreq + rxresp + expect resp.http.ttl == 0.000 + + # invalid s-maxage - trailing alpha + txreq + rxresp + expect resp.http.ttl == 0.000 + + # Expires using wrong case (weekday) + txreq + rxresp + expect resp.http.ttl == 0.000 + + # Expires using wrong case (month) + txreq + rxresp + expect resp.http.ttl == 0.000 + + # Expires using wrong case (tz) + txreq + rxresp + expect resp.http.ttl == 0.000 + + # s-maxage wins over longer max-age + txreq + rxresp + expect resp.http.ttl == 1.000 + + # s-maxage wins over longer max-age - reversed + txreq + rxresp + expect resp.http.ttl == 2.000 + + # s-maxage wins over longer max-age - multiple headers + txreq + rxresp + expect resp.http.ttl == 3.000 +} -run + + +varnish v1 -expect *.s1.req == 12 diff --git a/bin/varnishtest/tests/r00887.vtc b/bin/varnishtest/tests/r00887.vtc deleted file mode 100644 index 627e2c5fa..000000000 --- a/bin/varnishtest/tests/r00887.vtc +++ /dev/null @@ -1,20 +0,0 @@ -varnishtest "Ticket #887" - -server s1 { - rxreq - txresp -hdr "Cache-control: max-age=-1000" -body "FOO" - rxreq - txresp -body "FOOBAR" -} -start - -varnish v1 -vcl+backend { -} -start - -client c1 { - txreq - rxresp - expect resp.bodylen == 3 - txreq - rxresp - expect resp.bodylen == 6 -} -run From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:10 +0000 (UTC) Subject: [6.0] ad398ddb8 Handle Home and End keys in varnishstat. Message-ID: <20190627170510.98F0E9B80B@lists.varnish-cache.org> commit ad398ddb84dbb7fa69a9f4a481f8dd6b3f81574f Author: Lasse Karstensen Date: Wed Jan 9 08:41:26 2019 +0100 Handle Home and End keys in varnishstat. This has bugged me (slightly) for ages. Too trivial to warrant its own line(s) in test-case/u00008.vtc. diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 4b1703e6c..1038f0200 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -890,6 +890,12 @@ handle_keypress(int ch) if (page_start + l_points < n_ptarray - 1) page_start += l_points; break; + case KEY_HOME: + current = 0; + break; + case KEY_END: + current = n_ptarray - 1; + break; case 'd': hide_unseen = 1 - hide_unseen; rebuild = 1; diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index 023a6d784..d8b7f2399 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -85,6 +85,12 @@ The following keys control the interactive display: or Navigate the counter list one page down. + + Navigate the counter list to the top. + + + Navigate the counter list to the bottom. + Toggle between showing and hiding unseen counters. Unseen counters are those that has been zero for the entire runtime From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:10 +0000 (UTC) Subject: [6.0] f5420f4e9 Wrap the "if (ctx->handling) return; " check in a macro for readability Message-ID: <20190627170510.B86109B82A@lists.varnish-cache.org> commit f5420f4e9e849881d64c26e2421f94d13f556bff Author: Poul-Henning Kamp Date: Wed Jan 9 09:32:31 2019 +0000 Wrap the "if (ctx->handling) return;" check in a macro for readability diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index bcfaadcab..c0ee7b0bb 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -580,6 +580,8 @@ vcc_CompileSource(struct vcc *tl, struct source *sp) Fh(tl, 0, "/* ---===### VCC generated .h code ###===---*/\n"); Fc(tl, 0, "\n/* ---===### VCC generated .c code ###===---*/\n"); + Fc(tl, 0, "\n#define END_ if (*ctx->handling) return\n"); + vcc_Parse_Init(tl); vcc_Expr_Init(tl); diff --git a/lib/libvcc/vcc_parse.c b/lib/libvcc/vcc_parse.c index 2b5075358..af8e6a45e 100644 --- a/lib/libvcc/vcc_parse.c +++ b/lib/libvcc/vcc_parse.c @@ -149,7 +149,7 @@ vcc_Compound(struct vcc *tl) Fb(tl, 1, "{\n"); tl->indent += INDENT; C(tl, ";"); - Fb(tl, 1, "if (*ctx->handling) return;\n"); + Fb(tl, 1, "END_;\n"); while (1) { ERRCHK(tl); t = tl->t; @@ -206,7 +206,7 @@ vcc_Compound(struct vcc *tl) vcc_ErrWhere(tl, tl->t); return; } - Fb(tl, 1, "if (*ctx->handling) return;\n"); + Fb(tl, 1, "END_;\n"); } } From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:10 +0000 (UTC) Subject: [6.0] f3c0d915c VSB_quote(QUOTE_CSTR) should not indent with "\t" unless asked. Message-ID: <20190627170510.D42B79B83E@lists.varnish-cache.org> commit f3c0d915cf16269245b961779c24f0d1cc5fb0e6 Author: Poul-Henning Kamp Date: Wed Jan 9 09:37:39 2019 +0000 VSB_quote(QUOTE_CSTR) should not indent with "\t" unless asked. diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c index b44323854..1261ee57d 100644 --- a/lib/libvarnish/vsb.c +++ b/lib/libvarnish/vsb.c @@ -574,7 +574,7 @@ VSB_quote_pfx(struct vsb *s, const char *pfx, const void *v, int len, int how) break; case '\n': if (how & VSB_QUOTE_CSTR) { - (void)VSB_printf(s, "\\n\"\n%s\t\"", pfx); + (void)VSB_printf(s, "\\n\"\n%s\"", pfx); } else if (how & (VSB_QUOTE_NONL|VSB_QUOTE_UNSAFE)) { (void)VSB_printf(s, "\n"); nl = 1; diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index c0ee7b0bb..71016bc89 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -234,9 +234,8 @@ EmitCoordinates(const struct vcc *tl, struct vsb *vsb) VTAILQ_FOREACH(sp, &tl->sources, list) { VSB_printf(vsb, " /* "); VSB_quote(vsb, sp->name, -1, VSB_QUOTE_CSTR); - VSB_printf(vsb, "*/\n"); - VSB_printf(vsb, "\t"); - VSB_quote(vsb, sp->b, sp->e - sp->b, VSB_QUOTE_CSTR); + VSB_printf(vsb, " */\n"); + VSB_quote_pfx(vsb, "\t", sp->b, sp->e - sp->b, VSB_QUOTE_CSTR); VSB_printf(vsb, ",\n"); } VSB_printf(vsb, "};\n\n"); From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:10 +0000 (UTC) Subject: [6.0] bb84a8790 Improve indentation of VGC Message-ID: <20190627170510.EE56C9B84B@lists.varnish-cache.org> commit bb84a8790be30907d39192471b62176a1fa9bea9 Author: Poul-Henning Kamp Date: Wed Jan 9 09:48:02 2019 +0000 Improve indentation of VGC diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index b92781047..2b3602bcb 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -130,8 +130,9 @@ vcc_delete_expr(struct expr *e) * \v1 insert subexpression 1 * \v2 insert subexpression 2 * \vS insert subexpression 1(STRINGS) as STRING + * \vs insert subexpression 2(STRINGS) as STRING * \vT insert subexpression 1(STRINGS) as STRANDS - * \vt insert subexpression 1(STRINGS) as STRANDS + * \vt insert subexpression 2(STRINGS) as STRANDS * \v+ increase indentation * \v- decrease indentation * anything else is literal @@ -161,8 +162,8 @@ vcc_expr_edit(struct vcc *tl, vcc_type_t fmt, const char *p, struct expr *e1, } assert(*p == '\v'); switch (*++p) { - case '+': VSB_cat(e->vsb, "\v+"); break; - case '-': VSB_cat(e->vsb, "\v-"); break; + case '+': VSB_cat(e->vsb, "\v+"); nl = 0; break; + case '-': VSB_cat(e->vsb, "\v-"); nl = 0; break; case 'S': case 's': e3 = (*p == 'S' ? e1 : e2); @@ -654,7 +655,7 @@ vcc_func(struct vcc *tl, struct expr **e, const void *priv, if (sa != NULL) { *e = vcc_expr_edit(tl, e1->fmt, "\v1\n})\v-", e1, NULL); } else { - *e = vcc_expr_edit(tl, e1->fmt, "\v1\n)\v-", e1, NULL); + *e = vcc_expr_edit(tl, e1->fmt, "\v1\v-\n)", e1, NULL); } SkipToken(tl, ')'); } @@ -1329,7 +1330,7 @@ vcc_expr0(struct vcc *tl, struct expr **e, vcc_type_t fmt) if ((*e)->fmt == STRING_LIST) *e = vcc_expr_edit(tl, STRING_LIST, - "\v+\n\v1,\nvrt_magic_string_end\v-", *e, NULL); + "\n\v1,\nvrt_magic_string_end", *e, NULL); if (fmt == BOOL) { vcc_expr_tobool(tl, e); From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:11 +0000 (UTC) Subject: [6.0] 691b07328 Avoid printing %s, NULL in case of errors we do not expect. Message-ID: <20190627170511.191E79B85D@lists.varnish-cache.org> commit 691b073287917899c54cf89258b3b4ac281b1e57 Author: Poul-Henning Kamp Date: Fri Jan 11 10:26:44 2019 +0000 Avoid printing %s,NULL in case of errors we do not expect. Fixes #2879 diff --git a/lib/libvarnish/vnum.c b/lib/libvarnish/vnum.c index b619199c6..59e804ec8 100644 --- a/lib/libvarnish/vnum.c +++ b/lib/libvarnish/vnum.c @@ -349,15 +349,17 @@ main(int argc, char *argv[]) for (tc = test_cases; tc->str; ++tc) { e = VNUM_2bytes(tc->str, &val, tc->rel); - if (e != tc->err) { - printf("%s: VNUM_2bytes(\"%s\", %ju) (%s) != (%s)\n", - *argv, tc->str, tc->rel, tc->err, e); - ++ec; - } else if (e == NULL && val != tc->val) { - printf("%s: VNUM_2bytes(\"%s\", %ju) %ju != %ju (%s)\n", - *argv, tc->str, tc->rel, val, tc->val, e); - ++ec; - } + if (e != NULL) + val = 0; + if (e == tc->err && val == tc->val) + continue; + ++ec; + printf("%s: VNUM_2bytes(\"%s\", %ju)\n", + *argv, tc->str, tc->rel); + printf("\tExpected:\tstatus %s - value %ju\n", + tc->err ? tc->err : "Success", tc->val); + printf("\tGot:\t\tstatus %s - value %ju\n", + e ? e : "Success", val); } if (!isnan(VNUM_duration(NULL))) { printf("%s: VNUM_Duration(NULL) fail\n", *argv); From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:11 +0000 (UTC) Subject: [6.0] d868adb3b Use VSBs to generate code for VMOD objects. Message-ID: <20190627170511.3A04E9B86A@lists.varnish-cache.org> commit d868adb3b52180bbd0001064a53802f119980d75 Author: Geoff Simmons Date: Fri Jan 11 11:42:16 2019 +0100 Use VSBs to generate code for VMOD objects. Fixes #2880 diff --git a/bin/varnishtest/tests/r02880.vtc b/bin/varnishtest/tests/r02880.vtc new file mode 100644 index 000000000..1d554230b --- /dev/null +++ b/bin/varnishtest/tests/r02880.vtc @@ -0,0 +1,13 @@ +varnishtest "Long VMOD object names" + +varnish v1 -vcl { + import debug; + backend b { .host = "${bad_ip}"; } + + sub vcl_init { + new l234567890123456789012345678901234567890123456789012345678 + = debug.obj(); + new l2345678901234567890123456789012345678901234567890123456789 + = debug.obj(); + } +} diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index babd70eef..9fe6ddddf 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -38,6 +38,7 @@ #include "vfil.h" #include "vjsn.h" #include "vmod_abi.h" +#include "vsb.h" static int vcc_path_dlopen(void *priv, const char *fn) @@ -349,8 +350,7 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) { struct symbol *sy1, *sy2, *sy3; struct inifin *ifp; - char buf1[128]; - char buf2[128]; + struct vsb *buf; const struct vjsn_val *vv, *vf; const char *p; @@ -393,8 +393,10 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) vf = VTAILQ_NEXT(vf, list); - bprintf(buf1, ", &%s, \"%s\"", sy1->rname, sy1->name); - vcc_Eval_Func(tl, vf, buf1, sy2); + buf = VSB_new_auto(); + VSB_printf(buf, ", &%s, \"%s\"", sy1->rname, sy1->name); + VSB_finish(buf); + vcc_Eval_Func(tl, vf, VSB_data(buf), sy2); ERRCHK(tl); SkipToken(tl, ';'); sy1->def_e = tl->t; @@ -411,8 +413,10 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) VSB_printf(ifp->fin, "\t\t%s(&%s);", vf->value, sy1->rname); /* Instantiate symbols for the methods */ - bprintf(buf1, ", %s", sy1->rname); - p = TlDup(tl, buf1); + VSB_clear(buf); + VSB_printf(buf, ", %s", sy1->rname); + VSB_finish(buf); + p = TlDup(tl, VSB_data(buf)); while (vv != NULL) { vf = VTAILQ_FIRST(&vv->children); assert(vf->type == VJSN_STRING); @@ -420,11 +424,14 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) vf = VTAILQ_NEXT(vf, list); assert(vf->type == VJSN_STRING); - bprintf(buf2, "%s.%s", sy1->name, vf->value); - sy3 = VCC_MkSym(tl, buf2, SYM_FUNC, VCL_LOW, VCL_HIGH); + VSB_clear(buf); + VSB_printf(buf, "%s.%s", sy1->name, vf->value); + VSB_finish(buf); + sy3 = VCC_MkSym(tl, VSB_data(buf), SYM_FUNC, VCL_LOW, VCL_HIGH); AN(sy3); func_sym(sy3, sy2->vmod, VTAILQ_NEXT(vf, list)); sy3->extra = p; vv = VTAILQ_NEXT(vv, list); } + VSB_destroy(&buf); } From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:11 +0000 (UTC) Subject: [6.0] 126cf670e Missing closing bracket Message-ID: <20190627170511.5AF829B87C@lists.varnish-cache.org> commit 126cf670e32e7a2d3b709e3202fcb0a5e3ea360e Author: Dridi Boukelmoune Date: Fri Jan 11 14:30:05 2019 +0100 Missing closing bracket diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index bed475be0..4c999c350 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -110,7 +110,7 @@ ved_include(struct req *preq, const char *src, const char *host, if (preq->esi_level >= cache_param->max_esi_depth) { VSLb(preq->vsl, SLT_VCL_Error, - "ESI depth limit reach (param max_esi_depth = %u", + "ESI depth limit reach (param max_esi_depth = %u)", cache_param->max_esi_depth); return; } From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:11 +0000 (UTC) Subject: [6.0] 1c2c1c4e8 assert VSB_finish() works Message-ID: <20190627170511.764599B88C@lists.varnish-cache.org> commit 1c2c1c4e8ecc0250388da908ebefb84391445efd Author: Poul-Henning Kamp Date: Fri Jan 11 17:01:17 2019 +0000 assert VSB_finish() works diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index 9fe6ddddf..8b308c03f 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -395,7 +395,7 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) buf = VSB_new_auto(); VSB_printf(buf, ", &%s, \"%s\"", sy1->rname, sy1->name); - VSB_finish(buf); + AZ(VSB_finish(buf)); vcc_Eval_Func(tl, vf, VSB_data(buf), sy2); ERRCHK(tl); SkipToken(tl, ';'); @@ -415,7 +415,7 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) /* Instantiate symbols for the methods */ VSB_clear(buf); VSB_printf(buf, ", %s", sy1->rname); - VSB_finish(buf); + AZ(VSB_finish(buf)); p = TlDup(tl, VSB_data(buf)); while (vv != NULL) { vf = VTAILQ_FIRST(&vv->children); @@ -426,7 +426,7 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) VSB_clear(buf); VSB_printf(buf, "%s.%s", sy1->name, vf->value); - VSB_finish(buf); + AZ(VSB_finish(buf)); sy3 = VCC_MkSym(tl, VSB_data(buf), SYM_FUNC, VCL_LOW, VCL_HIGH); AN(sy3); func_sym(sy3, sy2->vmod, VTAILQ_NEXT(vf, list)); From dridi.boukelmoune at gmail.com Thu Jun 27 17:05:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Jun 2019 17:05:11 +0000 (UTC) Subject: [6.0] b47ce49b8 Explain string->boolean better. Message-ID: <20190627170511.8D5859B898@lists.varnish-cache.org> commit b47ce49b8fa6fbaa6f494bc6152160aade5dd04a Author: Poul-Henning Kamp Date: Mon Jan 14 09:32:08 2019 +0000 Explain string->boolean better. Fixes #2846 diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index f402c2f06..4057ee50a 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -93,7 +93,12 @@ Booleans can be either ``true`` or ``false``. In addition, in a boolean context some data types will evaluate to ``true`` or ``false`` depending on their value. -String types will evaluate to ``false`` if they are not set; backend types +String types will evaluate to ``false`` if they are unset. This allows +checks of the type ``if (req.http.opthdr) {}`` to test if a header +exists, even if it is empty, whereas ``if (req.http.opthdr == "") {}`` +does not distinguish if the header does not exist or if it is empty. + +Backend types will evaluate to ``false`` if they don't have a backend assigned; integer types will evaluate to ``false`` if their value is zero; duration types will evaluate to ``false`` if their value is equal or less than zero. From fgsch at lodoss.net Sun Jun 30 20:14:10 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 30 Jun 2019 20:14:10 +0000 (UTC) Subject: [master] 26aa43eb2 Plug minor leak reported by coverity Message-ID: <20190630201410.8CCBEAD1A1@lists.varnish-cache.org> commit 26aa43eb283b657c03b8b26e6b0c5fad98a8a13a Author: Federico G. Schwindt Date: Sun Jun 30 21:02:08 2019 +0100 Plug minor leak reported by coverity diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index beb4bfe1d..a65c26df9 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -569,6 +569,7 @@ ip_magic(void) sa = VSS_ResolveOne(NULL, "127.0.0.1", "0", 0, SOCK_STREAM, 0); AN(sa); bad_backend_fd = VTCP_bind(sa, NULL); + free(sa); assert(bad_backend_fd >= 0); VTCP_myname(bad_backend_fd, abuf, sizeof abuf, pbuf, sizeof(pbuf)); extmacro_def("localhost", "%s", abuf);