From dridi.boukelmoune at gmail.com Wed Apr 1 07:49:07 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 1 Apr 2020 07:49:07 +0000 (UTC) Subject: [master] 4807f6a5e Polish Message-ID: <20200401074907.E7B3611C562@lists.varnish-cache.org> commit 4807f6a5e398bf5fbe3ea56f864c389e221a8de1 Author: Dridi Boukelmoune Date: Thu Mar 5 10:44:46 2020 +0100 Polish diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 9543448c5..6f303d5df 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -317,6 +317,17 @@ sample_data(void) sample_hitrate(); } +static void +destroy_window(WINDOW **w) +{ + + AN(w); + if (*w == NULL) + return; + assert(delwin(*w) != ERR); + *w = NULL; +} + static void make_windows(void) { @@ -324,26 +335,11 @@ make_windows(void) int y; int y_status, y_bar_t, y_points, y_bar_b, y_info; - if (w_status) { - delwin(w_status); - w_status = NULL; - } - if (w_bar_t) { - delwin(w_bar_t); - w_bar_t = NULL; - } - if (w_points) { - delwin(w_points); - w_points = NULL; - } - if (w_bar_b) { - delwin(w_bar_b); - w_bar_b = NULL; - } - if (w_info) { - delwin(w_info); - w_info = NULL; - } + destroy_window(&w_status); + destroy_window(&w_bar_t); + destroy_window(&w_points); + destroy_window(&w_bar_b); + destroy_window(&w_info); Y = LINES; X = COLS; From dridi.boukelmoune at gmail.com Wed Apr 1 07:49:08 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 1 Apr 2020 07:49:08 +0000 (UTC) Subject: [master] ec8eb15f4 Introduce a blank help screen in varnishstat Message-ID: <20200401074908.110A911C565@lists.varnish-cache.org> commit ec8eb15f4c60142157dfa204df19de6818c131ac Author: Dridi Boukelmoune Date: Thu Mar 5 11:33:27 2020 +0100 Introduce a blank help screen in varnishstat The plan is to reuse the points window and keep the status window going. Refs #2990 diff --git a/bin/varnishstat/varnishstat_bindings.h b/bin/varnishstat/varnishstat_bindings.h index be9ec8c8e..4051a53eb 100644 --- a/bin/varnishstat/varnishstat_bindings.h +++ b/bin/varnishstat/varnishstat_bindings.h @@ -36,6 +36,9 @@ #define BINDING_CTRL(c) ((c) & 0x1f) +BINDING_KEY('h', "h",) +BINDING(HELP, "\tToggle the help screen.") + BINDING_KEY(KEY_UP, "UP", " or ") BINDING_KEY('k', "k",) BINDING(UP, "\tNavigate the counter list one line up.") diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 6f303d5df..73a0e8f96 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -117,6 +117,7 @@ static WINDOW *w_bar_b = NULL; static WINDOW *w_info = NULL; static const struct VSC_level_desc *verbosity; +static int show_help = 0; static int keep_running = 1; static int hide_unseen = 1; static int page_start = 0; @@ -443,6 +444,7 @@ draw_status(void) running(w_status, up_mgt, VSM_MGT_RUNNING); mvwprintw(w_status, 1, 0, "Uptime child: "); running(w_status, up_chld, VSM_WRK_RUNNING); + mvwprintw(w_status, 2, 0, "Press to toggle help screen"); if (VTIM_mono() < notification_eol) mvwaddstr(w_status, 2, 0, notification_message); @@ -803,6 +805,14 @@ draw_points(void) wnoutrefresh(w_points); } +static void +draw_help(void) +{ + + werase(w_points); + wnoutrefresh(w_points); +} + static void draw_bar_b(void) { @@ -860,32 +870,33 @@ static void draw_screen(void) { draw_status(); - draw_bar_t(); - draw_points(); - draw_bar_b(); - draw_info(); + if (show_help) { + werase(w_bar_t); + werase(w_bar_b); + werase(w_info); + wnoutrefresh(w_bar_t); + wnoutrefresh(w_bar_b); + wnoutrefresh(w_info); + draw_help(); + } else { + draw_bar_t(); + draw_points(); + draw_bar_b(); + draw_info(); + } doupdate(); redraw = 0; } static void -handle_keypress(int ch) +handle_points_keypress(enum kb_e kb) { - enum kb_e kb; - - switch (ch) { -#define BINDING_KEY(chr, name, or) \ - case chr: -#define BINDING(name, desc) \ - kb = KB_ ## name; \ - break; -#define BINDING_SIG -#include "varnishstat_bindings.h" - default: - return; - } switch (kb) { + case KB_HELP: + show_help = 1; + redraw = 1; + return; case KB_UP: if (current == 0) return; @@ -963,6 +974,43 @@ handle_keypress(int ch) redraw = 1; } +static void +handle_help_keypress(enum kb_e kb) +{ + + switch (kb) { + case KB_HELP: + show_help = 0; + redraw = 1; + /* FALLTHROUGH */ + default: + return; + } +} + +static void +handle_keypress(int ch) +{ + enum kb_e kb; + + switch (ch) { +#define BINDING_KEY(chr, name, or) \ + case chr: +#define BINDING(name, desc) \ + kb = KB_ ## name; \ + break; +#define BINDING_SIG +#include "varnishstat_bindings.h" + default: + return; + } + + if (show_help) + handle_help_keypress(kb); + else + handle_points_keypress(kb); +} + static void * v_matchproto_(VSC_new_f) newpt(void *priv, const struct VSC_point *const vpt) { From dridi.boukelmoune at gmail.com Wed Apr 1 07:49:08 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 1 Apr 2020 07:49:08 +0000 (UTC) Subject: [master] 5d145c1d3 Remove unused variables Message-ID: <20200401074908.2DFAF11C568@lists.varnish-cache.org> commit 5d145c1d35bc9d2ac1b6c0ee31f0751ef6ede9df Author: Dridi Boukelmoune Date: Thu Mar 5 11:44:26 2020 +0100 Remove unused variables diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 73a0e8f96..45ff7e2f4 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -770,7 +770,6 @@ draw_line(WINDOW *w, int y, const struct pt *pt) static void draw_points(void) { - int Y, X; int line; int n; @@ -789,9 +788,6 @@ draw_points(void) assert(current >= page_start); assert(current - page_start < l_points); - getmaxyx(w_points, Y, X); - (void)Y; - (void)X; for (line = 0; line < l_points; line++) { n = line + page_start; if (n >= n_ptarray) From dridi.boukelmoune at gmail.com Wed Apr 1 07:49:08 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 1 Apr 2020 07:49:08 +0000 (UTC) Subject: [master] f6cae5a75 Generate an array of lines for the varnishstat help Message-ID: <20200401074908.5E50411C56D@lists.varnish-cache.org> commit f6cae5a756beac1cacb2cee9b38e3d7240880ffd Author: Dridi Boukelmoune Date: Thu Mar 5 12:26:41 2020 +0100 Generate an array of lines for the varnishstat help Refs #2990 diff --git a/.gitignore b/.gitignore index 5872c9a6b..c476a47dc 100644 --- a/.gitignore +++ b/.gitignore @@ -88,6 +88,8 @@ cscope.*out /bin/varnishlog/varnishlog /bin/varnishncsa/varnishncsa /bin/varnishstat/varnishstat +/bin/varnishstat/varnishstat_help_gen +/bin/varnishstat/varnishstat_curses_help.c /bin/varnishstat/vsc2rst /bin/varnishtest/teken_state.h /bin/varnishtest/varnishtest diff --git a/bin/varnishstat/Makefile.am b/bin/varnishstat/Makefile.am index 2e29e7932..6721d3437 100644 --- a/bin/varnishstat/Makefile.am +++ b/bin/varnishstat/Makefile.am @@ -4,15 +4,26 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/include \ -I$(top_builddir)/include -bin_PROGRAMS = varnishstat +bin_PROGRAMS = varnishstat varnishstat_help_gen varnishstat_SOURCES = \ varnishstat.h \ varnishstat.c \ varnishstat_bindings.h \ varnishstat_curses.c \ + varnishstat_curses_help.c \ varnishstat_options.h +BUILT_SOURCES = varnishstat_curses_help.c + +varnishstat_help_gen_SOURCES = \ + varnishstat_help_gen.c \ + varnishstat_bindings.h + +varnishstat_curses_help.c: varnishstat_help_gen + $(AM_V_GEN) ./varnishstat_help_gen >$@_ + @mv $@_ $@ + varnishstat_CFLAGS = \ @SAN_CFLAGS@ @@ -20,3 +31,7 @@ varnishstat_LDADD = \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ @SAN_LDFLAGS@ \ @CURSES_LIBS@ ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS} + +varnishstat_help_gen_LDADD = \ + $(top_builddir)/lib/libvarnish/libvarnish.la \ + @SAN_LDFLAGS@ diff --git a/bin/varnishstat/varnishstat.h b/bin/varnishstat/varnishstat.h index 4b0377864..2785407d6 100644 --- a/bin/varnishstat/varnishstat.h +++ b/bin/varnishstat/varnishstat.h @@ -38,3 +38,6 @@ #include "vcs.h" void do_curses(struct vsm *, struct vsc *); + +extern const char *const bindings_help[]; +extern const int bindings_help_len; diff --git a/bin/varnishstat/varnishstat_help_gen.c b/bin/varnishstat/varnishstat_help_gen.c new file mode 100644 index 000000000..1c189bcd8 --- /dev/null +++ b/bin/varnishstat/varnishstat_help_gen.c @@ -0,0 +1,86 @@ +/*- + * Copyright (c) 2020 Varnish Software AS + * All rights reserved. + * + * Author: Dridi Boukelmoune + * + * SPDX-License-Identifier: BSD-2-Clause + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +#include +#include +#include + +static const char help[] = "\n\n" +#define BINDING_KEY(key, name, next) "<" name ">" next +#define BINDING(name, desc) "\n\n" desc "\n\n" +#include "varnishstat_bindings.h" +; + +int +main(void) +{ + struct vsb vsb[1]; + const char *p, *n; + unsigned u; + + AN(VSB_new(vsb, NULL, 0, VSB_AUTOEXTEND)); + VSB_cat(vsb, + "/*\n" + " * NB: This file is machine generated, DO NOT EDIT!\n" + " *\n" + " * Edit varnishstat_bindings.h and run make instead\n" + " */\n" + "\n" + "#include \n" + "\n" + "const char *const bindings_help[] = {\n"); + + n = help; + u = 0; + do { + p = n + 1; + n = strchr(p, '\n'); + if (n != NULL) { + VSB_putc(vsb, '\t'); + VSB_quote(vsb, p, (int)(n - p), VSB_QUOTE_CSTR); + VSB_cat(vsb, ",\n"); + u++; + } + } while (n != NULL); + + VSB_printf(vsb, + "\tNULL\n" + "};\n" + "\n" + "const int bindings_help_len = %u;\n", u); + AZ(VSB_finish(vsb)); + AZ(VSB_tofile(vsb, STDOUT_FILENO)); + VSB_delete(vsb); + return (0); +} From dridi.boukelmoune at gmail.com Wed Apr 1 07:49:08 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 1 Apr 2020 07:49:08 +0000 (UTC) Subject: [master] f4d726d99 Draw the varnishstat help screen Message-ID: <20200401074908.7D8D411C571@lists.varnish-cache.org> commit f4d726d99d17613d15dacedb98ae03b16610f16b Author: Dridi Boukelmoune Date: Thu Mar 5 15:37:22 2020 +0100 Draw the varnishstat help screen Refs #2990 diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 45ff7e2f4..6a829a838 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -118,6 +118,7 @@ static WINDOW *w_info = NULL; static const struct VSC_level_desc *verbosity; static int show_help = 0; +static int help_line = 0; static int keep_running = 1; static int hide_unseen = 1; static int page_start = 0; @@ -804,8 +805,31 @@ draw_points(void) static void draw_help(void) { + const char *const *p; + int l, y, X; + if (l_points >= bindings_help_len) { + assert(help_line == 0); + l = bindings_help_len; + } else { + assert(help_line >= 0); + assert(help_line <= bindings_help_len - l_points); + l = l_points; + } + + X = getmaxx(w_points); werase(w_points); + + for (y = 0, p = bindings_help + help_line; y < l; y++, p++) { + if (**p == '\t') { + mvwprintw(w_points, y, 0, " %.*s", X - 4, *p + 1); + } else { + wattron(w_points, A_BOLD); + mvwprintw(w_points, y, 0, "%.*s", X, *p); + wattroff(w_points, A_BOLD); + } + } + wnoutrefresh(w_points); } @@ -884,6 +908,25 @@ draw_screen(void) redraw = 0; } +static void +handle_common_keypress(enum kb_e kb) +{ + + switch (kb) { + case KB_QUIT: + keep_running = 0; + return; + case KB_SIG_INT: + AZ(raise(SIGINT)); + return; + case KB_SIG_TSTP: + AZ(raise(SIGTSTP)); + return; + default: + WRONG("unexpected key binding"); + } +} + static void handle_points_keypress(enum kb_e kb) { @@ -891,6 +934,7 @@ handle_points_keypress(enum kb_e kb) switch (kb) { case KB_HELP: show_help = 1; + help_line = 0; redraw = 1; return; case KB_UP: @@ -950,17 +994,13 @@ handle_points_keypress(enum kb_e kb) verbosity = VSC_ChangeLevel(verbosity, -1); rebuild = 1; break; - case KB_QUIT: - keep_running = 0; - return; - case KB_SIG_INT: - AZ(raise(SIGINT)); - return; case KB_SAMPLE: sample = 1; return; + case KB_QUIT: + case KB_SIG_INT: case KB_SIG_TSTP: - AZ(raise(SIGTSTP)); + handle_common_keypress(kb); return; default: WRONG("unhandled key binding"); @@ -973,15 +1013,55 @@ handle_points_keypress(enum kb_e kb) static void handle_help_keypress(enum kb_e kb) { + int hl = help_line; switch (kb) { case KB_HELP: show_help = 0; redraw = 1; - /* FALLTHROUGH */ - default: return; + case KB_UP: + help_line--; + break; + case KB_DOWN: + help_line++; + break; + case KB_PAGEUP: + help_line -= l_points; + break; + case KB_PAGEDOWN: + help_line += l_points; + break; + case KB_TOP: + help_line = 0; + break; + case KB_BOTTOM: + help_line = bindings_help_len; + break; + case KB_UNSEEN: + case KB_SCALE: + case KB_ACCEL: + case KB_DECEL: + case KB_VERBOSE: + case KB_QUIET: + case KB_SAMPLE: + break; + case KB_QUIT: + case KB_SIG_INT: + case KB_SIG_TSTP: + handle_common_keypress(kb); + return; + default: + WRONG("unhandled key binding"); } + + if (help_line > bindings_help_len - l_points) + help_line = bindings_help_len - l_points; + + if (help_line < 0) + help_line = 0; + + redraw = (help_line != hl); } static void diff --git a/bin/varnishtest/tests/u00008.vtc b/bin/varnishtest/tests/u00008.vtc index 86503c972..6a0ce88f9 100644 --- a/bin/varnishtest/tests/u00008.vtc +++ b/bin/varnishtest/tests/u00008.vtc @@ -43,6 +43,25 @@ process p1 -write {dek} process p1 -expect-text 0 1 "Concurrent connections to backend:" process p1 -screen_dump +process p1 -write {h} +process p1 -expect-text 0 0 "Navigate the counter list one line up." +process p1 -screen_dump + +process p1 -write {G} +process p1 -expect-text 0 0 "Decrease refresh interval." +process p1 -screen_dump + +# the counters screen is preserved +process p1 -write {h} +process p1 -expect-text 0 1 "Concurrent connections to backend:" +process p1 -screen_dump + +# the help screen always appears from the top +process p1 -write {h} +process p1 -expect-text 0 0 "Navigate the counter list one line up." +process p1 -screen_dump + +process p1 -write {h} process p1 -winsz 25 132 process p1 -expect-text 4 124 "AVG_1000" process p1 -expect-text 22 108 "UNSEEN DIAG" From dridi.boukelmoune at gmail.com Wed Apr 1 07:49:08 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 1 Apr 2020 07:49:08 +0000 (UTC) Subject: [master] 3399615ad Start interactive varnishstat with relevant verbosity Message-ID: <20200401074908.A1F4E11C575@lists.varnish-cache.org> commit 3399615ad49617e427ab461555c0665888520953 Author: Dridi Boukelmoune Date: Fri Mar 6 11:42:45 2020 +0100 Start interactive varnishstat with relevant verbosity Where relevant means the highest verbosity when fields are filtered with -f on the command line. There is still a caveat that this only applies for the first iteration, and some parameters may conditionally appear and not be visible when that event occurs (for example, when the child process starts). The rebuild variable was used as a bitmap but did not make use of individual bits. This is now the case, but only for the two actionable rebuild conditions. Closes #2990 diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 6247f5035..f9e6b89c1 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -54,6 +54,7 @@ #include "varnishstat.h" static struct VUT *vut; +int has_f = 0; /*--------------------------------------------------------------------*/ @@ -278,7 +279,6 @@ main(int argc, char * const *argv) int once = 0, xml = 0, json = 0, f_list = 0, curses = 0; signed char opt; int i; - int has_f = 0; struct vsc *vsc; if (argc == 2 && !strcmp(argv[1], "--bindings")) diff --git a/bin/varnishstat/varnishstat.h b/bin/varnishstat/varnishstat.h index 2785407d6..dbdadaf7c 100644 --- a/bin/varnishstat/varnishstat.h +++ b/bin/varnishstat/varnishstat.h @@ -37,7 +37,12 @@ #include "vas.h" #include "vcs.h" +/* varnishstat.c */ +extern int has_f; + +/* varnishstat_curses.c */ void do_curses(struct vsm *, struct vsc *); +/* varnishstat_curses_help.c */ extern const char *const bindings_help[]; extern const int bindings_help_len; diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 6a829a838..b8d5c7cf4 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -64,6 +64,9 @@ #define VALUE_MAX 999999999999 +#define REBUILD_NEXT (1u << 0) +#define REBUILD_FIRST (1u << 1) + enum kb_e { #define BINDING(name, desc) KB_ ## name, #define BINDING_SIG @@ -220,10 +223,15 @@ build_pt_array(void) VTAILQ_FOREACH(pt, &ptlist, list) { CHECK_OBJ_NOTNULL(pt, PT_MAGIC); + if (pt->vpt->level > verbosity) { + if (has_f && (rebuild & REBUILD_FIRST)) + verbosity = VSC_ChangeLevel(verbosity, + pt->vpt->level - verbosity); + else + continue; + } if (!pt->seen && hide_unseen) continue; - if (pt->vpt->level > verbosity) - continue; assert(n_ptarray < n_ptlist); ptarray[n_ptarray++] = pt; } @@ -254,7 +262,7 @@ sample_points(void) continue; if (!pt->seen) { pt->seen = 1; - rebuild = 1; + rebuild = REBUILD_NEXT; } pt->last = pt->cur; pt->cur = v; @@ -964,11 +972,11 @@ handle_points_keypress(enum kb_e kb) break; case KB_UNSEEN: hide_unseen = 1 - hide_unseen; - rebuild = 1; + rebuild = REBUILD_NEXT; break; case KB_SCALE: scale = 1 - scale; - rebuild = 1; + rebuild = REBUILD_NEXT; break; case KB_ACCEL: interval += 0.1; @@ -988,11 +996,11 @@ handle_points_keypress(enum kb_e kb) break; case KB_VERBOSE: verbosity = VSC_ChangeLevel(verbosity, 1); - rebuild = 1; + rebuild = REBUILD_NEXT; break; case KB_QUIET: verbosity = VSC_ChangeLevel(verbosity, -1); - rebuild = 1; + rebuild = REBUILD_NEXT; break; case KB_SAMPLE: sample = 1; @@ -1094,7 +1102,7 @@ newpt(void *priv, const struct VSC_point *const vpt) AZ(priv); ALLOC_OBJ(pt, PT_MAGIC); - rebuild |= 1; + rebuild |= REBUILD_NEXT; AN(pt); pt->vpt = vpt; pt->last = *pt->vpt->ptr; @@ -1125,7 +1133,7 @@ delpt(void *priv, const struct VSC_point *const vpt) AZ(priv); CAST_OBJ_NOTNULL(pt, vpt->priv, PT_MAGIC); - rebuild |= 2; + rebuild |= REBUILD_NEXT; VTAILQ_REMOVE(&ptlist, pt, list); n_ptlist--; FREE_OBJ(pt); @@ -1159,6 +1167,7 @@ do_curses(struct vsm *vsm, struct vsc *vsc) VSC_State(vsc, newpt, delpt, NULL); + rebuild |= REBUILD_FIRST; (void)VSC_Iter(vsc, vsm, NULL, NULL); build_pt_array(); init_hitrate(); diff --git a/bin/varnishtest/tests/r02990.vtc b/bin/varnishtest/tests/r02990.vtc new file mode 100644 index 000000000..6d38efa2a --- /dev/null +++ b/bin/varnishtest/tests/r02990.vtc @@ -0,0 +1,13 @@ +varnishtest "Initial varnishstat verbosity" + +varnish v1 -vcl {backend be none;} -start + +process p1 -dump {varnishstat -n ${v1_name}} -start +process p2 -dump {varnishstat -n ${v1_name} -f MGT.child_start} -start + +process p1 -expect-text 0 0 INFO +process p1 -screen_dump + +process p2 -expect-text 0 0 MGT.child_start +process p2 -expect-text 0 0 DIAG +process p2 -screen_dump From dridi.boukelmoune at gmail.com Wed Apr 1 07:49:08 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 1 Apr 2020 07:49:08 +0000 (UTC) Subject: [master] df4804b92 Manage symbol references with higher-level types Message-ID: <20200401074908.C029311C579@lists.varnish-cache.org> commit df4804b923eb2f47741dee300f05d2a1bf281488 Author: Dridi Boukelmoune Date: Wed Dec 18 16:57:38 2019 +0100 Manage symbol references with higher-level types That would be the symbol itself instead of only the relevant mask, and a XREF constants wrapping the error message as well. The `struct xrefuse` pun was definitely intended. diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 542e1289f..bcbeea9ba 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -135,7 +135,7 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym) VSB_printf(tl->sb, "Variable cannot be set.\n"); return; } - vcc_AddUses(tl, t, tl->t, sym->w_methods, "Cannot be set"); + vcc_AddUses(tl, t, tl->t, sym, XREF_WRITE); type = sym->type; for (ap = assign; ap->type != VOID; ap++) { if (ap->type != type) @@ -177,7 +177,7 @@ vcc_act_unset(struct vcc *tl, struct token *t, struct symbol *sym) VSB_printf(tl->sb, "Variable cannot be unset.\n"); return; } - vcc_AddUses(tl, t, tl->t, sym->u_methods, "Cannot be unset"); + vcc_AddUses(tl, t, tl->t, sym, XREF_UNSET); Fb(tl, 1, "%s;\n", sym->uname); SkipToken(tl, ';'); } diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index ad1af617a..6a291c50b 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -406,8 +406,16 @@ void VCC_XrefTable(struct vcc *); void vcc_AddCall(struct vcc *, struct token *, struct symbol *); void vcc_ProcAction(struct proc *p, unsigned action, struct token *t); int vcc_CheckAction(struct vcc *tl); + + +struct xrefuse { const char *name, *err; }; +extern const struct xrefuse XREF_READ[1]; +extern const struct xrefuse XREF_WRITE[1]; +extern const struct xrefuse XREF_UNSET[1]; +extern const struct xrefuse XREF_ACTION[1]; + void vcc_AddUses(struct vcc *, const struct token *, const struct token *, - unsigned mask, const char *use); + const struct symbol *sym, const struct xrefuse *use); int vcc_CheckUses(struct vcc *tl); const char *vcc_MarkPriv(struct vcc *, struct procprivhead *, const char *); diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index dc36effeb..dd62b279d 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -341,7 +341,7 @@ vcc_Eval_Var(struct vcc *tl, struct expr **e, struct token *t, (void)type; assert(sym->kind == SYM_VAR); - vcc_AddUses(tl, t, NULL, sym->r_methods, "Not available"); + vcc_AddUses(tl, t, NULL, sym, XREF_READ); ERRCHK(tl); *e = vcc_mk_expr(sym->type, "%s", sym->rname); (*e)->constant = EXPR_VAR; diff --git a/lib/libvcc/vcc_parse.c b/lib/libvcc/vcc_parse.c index 2bfeb86fb..f5dc8c364 100644 --- a/lib/libvcc/vcc_parse.c +++ b/lib/libvcc/vcc_parse.c @@ -196,9 +196,7 @@ vcc_Compound(struct vcc *tl) return; } if (sym->action_mask != 0) - vcc_AddUses(tl, t, NULL, - sym->action_mask, - "Not a valid action"); + vcc_AddUses(tl, t, NULL, sym, XREF_ACTION); sym->action(tl, t, sym); break; default: diff --git a/lib/libvcc/vcc_xref.c b/lib/libvcc/vcc_xref.c index 9e66bdd8a..d2e933db3 100644 --- a/lib/libvcc/vcc_xref.c +++ b/lib/libvcc/vcc_xref.c @@ -57,8 +57,9 @@ struct procuse { VTAILQ_ENTRY(procuse) list; const struct token *t1; const struct token *t2; + const struct symbol *sym; + const struct xrefuse *use; unsigned mask; - const char *use; struct proc *fm; }; @@ -102,22 +103,41 @@ vcc_CheckReferences(struct vcc *tl) * Returns checks */ +const struct xrefuse XREF_READ[1] = {{"xref_read", "Not available"}}; +const struct xrefuse XREF_WRITE[1] = {{"xref_write", "Cannot be set"}}; +const struct xrefuse XREF_UNSET[1] = {{"xref_unset", "Cannot be unset"}}; +const struct xrefuse XREF_ACTION[1] = {{"xref_action", "Not a valid action"}}; + void vcc_AddUses(struct vcc *tl, const struct token *t1, const struct token *t2, - unsigned mask, const char *use) + const struct symbol *sym, const struct xrefuse *use) { struct procuse *pu; AN(tl->curproc); pu = TlAlloc(tl, sizeof *pu); AN(pu); + AN(sym); + AN(use); pu->t1 = t1; pu->t2 = t2; if (pu->t2 == NULL) pu->t2 = VTAILQ_NEXT(t1, list); - pu->mask = mask; + pu->sym = sym; pu->use = use; pu->fm = tl->curproc; + + if (pu->use == XREF_READ) + pu->mask = sym->r_methods; + else if (pu->use == XREF_WRITE) + pu->mask = sym->w_methods; + else if (pu->use == XREF_UNSET) + pu->mask = sym->u_methods; + else if (pu->use == XREF_ACTION) + pu->mask = sym->action_mask; + else + WRONG("wrong xref use"); + VTAILQ_INSERT_TAIL(&tl->curproc->uses, pu, list); } @@ -252,7 +272,7 @@ vcc_CheckUseRecurse(struct vcc *tl, const struct proc *p, if (pu != NULL) { vcc_ErrWhere2(tl, pu->t1, pu->t2); VSB_printf(tl->sb, "%s from subroutine '%s'.\n", - pu->use, m->name); + pu->use->err, m->name); VSB_printf(tl->sb, "\n...in subroutine \"%.*s\"\n", PF(pu->fm->name)); vcc_ErrWhere(tl, p->name); @@ -283,7 +303,7 @@ vcc_checkuses(struct vcc *tl, const struct symbol *sym) if (pu != NULL) { vcc_ErrWhere2(tl, pu->t1, pu->t2); VSB_printf(tl->sb, "%s in subroutine '%.*s'.", - pu->use, PF(p->name)); + pu->use->err, PF(p->name)); VSB_cat(tl->sb, "\nAt: "); return; } From dridi.boukelmoune at gmail.com Wed Apr 1 07:49:08 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 1 Apr 2020 07:49:08 +0000 (UTC) Subject: [master] ed36b6389 Defer the illegal write check a bit Message-ID: <20200401074908.DC57911C57D@lists.varnish-cache.org> commit ed36b6389f9dbf6962e726f0df34d59132d9241a Author: Dridi Boukelmoune Date: Wed Dec 18 18:14:59 2019 +0100 Defer the illegal write check a bit After the initial discussion from #3163, and looking more closely at how variable access is handled in subroutines I noticed a discrepancy. Setting a read only variable like obj.ttl in vcl_recv would result in a misleading error message explaining that it is read only, instead of simply not available. This change defers the illegal write check, registering unconditionally that the symbol was used in a set action. As a result we always get the correct error message but depending on whether this is happening in a vcl_ or custom subroutine we may either get "in subroutine" or "from subroutine" in the error message. A minor discrepancy probably worth getting rid of the prior inconsistency. This is covered by the v21 test case. diff --git a/bin/varnishtest/tests/v00021.vtc b/bin/varnishtest/tests/v00021.vtc index dd3392ee8..ab0618f98 100644 --- a/bin/varnishtest/tests/v00021.vtc +++ b/bin/varnishtest/tests/v00021.vtc @@ -2,14 +2,26 @@ varnishtest "VCL compiler coverage test: vcc_xref.c vcc_var.c vcc_symb.c" varnish v1 -errvcl {Variable is read only.} { backend b { .host = "127.0.0.1"; } - sub vcl_recv { set obj.ttl = 1 w; } + sub vcl_deliver { set obj.ttl = 1 w; } } varnish v1 -errvcl {Variable is read only.} { backend b { .host = "127.0.0.1"; } sub foo { set obj.ttl = 1 w; } - sub vcl_recv { call foo ; } + sub vcl_deliver { call foo; } +} + +varnish v1 -errvcl {Not available in subroutine 'vcl_recv'.} { + backend b { .host = "127.0.0.1"; } + sub vcl_recv { set obj.ttl = 1 w; } +} + +varnish v1 -errvcl {Not available from subroutine 'vcl_recv'.} { + backend b { .host = "127.0.0.1"; } + + sub foo { set obj.ttl = 1 w; } + sub vcl_recv { call foo; } } varnish v1 -errvcl "Symbol not found" { diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index bcbeea9ba..8fa48b37c 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -127,15 +127,8 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym) sym = VCC_SymbolGet(tl, SYM_VAR, SYMTAB_EXISTING, XREF_NONE); ERRCHK(tl); AN(sym); - if (sym->w_methods == 0) { - vcc_ErrWhere2(tl, t, tl->t); - if (sym->r_methods != 0) - VSB_printf(tl->sb, "Variable is read only.\n"); - else - VSB_printf(tl->sb, "Variable cannot be set.\n"); - return; - } vcc_AddUses(tl, t, tl->t, sym, XREF_WRITE); + ERRCHK(tl); type = sym->type; for (ap = assign; ap->type != VOID; ap++) { if (ap->type != type) diff --git a/lib/libvcc/vcc_xref.c b/lib/libvcc/vcc_xref.c index d2e933db3..eff883274 100644 --- a/lib/libvcc/vcc_xref.c +++ b/lib/libvcc/vcc_xref.c @@ -139,6 +139,9 @@ vcc_AddUses(struct vcc *tl, const struct token *t1, const struct token *t2, WRONG("wrong xref use"); VTAILQ_INSERT_TAIL(&tl->curproc->uses, pu, list); + + if (pu->mask == 0) + vcc_CheckUses(tl); } void @@ -251,13 +254,40 @@ vcc_CheckAction(struct vcc *tl) /*--------------------------------------------------------------------*/ static struct procuse * -vcc_FindIllegalUse(const struct proc *p, const struct method *m) +vcc_illegal_write(struct vcc *tl, struct procuse *pu, const struct method *m) { - struct procuse *pu; - VTAILQ_FOREACH(pu, &p->uses, list) + if (pu->mask || pu->use != XREF_WRITE) + return (NULL); + + if (pu->sym->r_methods == 0) { + vcc_ErrWhere2(tl, pu->t1, pu->t2); + VSB_printf(tl->sb, "Variable cannot be set.\n"); + return (NULL); + } + + if (!(pu->sym->r_methods & m->bitval)) { + pu->use = XREF_READ; /* NB: change the error message. */ + return (pu); + } + + vcc_ErrWhere2(tl, pu->t1, pu->t2); + VSB_printf(tl->sb, "Variable is read only.\n"); + return (NULL); +} + +static struct procuse * +vcc_FindIllegalUse(struct vcc *tl, const struct proc *p, const struct method *m) +{ + struct procuse *pu, *pw; + + VTAILQ_FOREACH(pu, &p->uses, list) { + pw = vcc_illegal_write(tl, pu, m); + if (tl->err) + return (pw); if (!(pu->mask & m->bitval)) return (pu); + } return (NULL); } @@ -268,7 +298,7 @@ vcc_CheckUseRecurse(struct vcc *tl, const struct proc *p, struct proccall *pc; struct procuse *pu; - pu = vcc_FindIllegalUse(p, m); + pu = vcc_FindIllegalUse(tl, p, m); if (pu != NULL) { vcc_ErrWhere2(tl, pu->t1, pu->t2); VSB_printf(tl->sb, "%s from subroutine '%s'.\n", @@ -278,6 +308,8 @@ vcc_CheckUseRecurse(struct vcc *tl, const struct proc *p, vcc_ErrWhere(tl, p->name); return (1); } + if (tl->err) + return (1); VTAILQ_FOREACH(pc, &p->calls, list) { if (vcc_CheckUseRecurse(tl, pc->sym->proc, m)) { VSB_printf(tl->sb, "\n...called from \"%.*s\"\n", @@ -299,7 +331,7 @@ vcc_checkuses(struct vcc *tl, const struct symbol *sym) AN(p); if (p->method == NULL) return; - pu = vcc_FindIllegalUse(p, p->method); + pu = vcc_FindIllegalUse(tl, p, p->method); if (pu != NULL) { vcc_ErrWhere2(tl, pu->t1, pu->t2); VSB_printf(tl->sb, "%s in subroutine '%.*s'.", @@ -307,6 +339,7 @@ vcc_checkuses(struct vcc *tl, const struct symbol *sym) VSB_cat(tl->sb, "\nAt: "); return; } + ERRCHK(tl); if (vcc_CheckUseRecurse(tl, p, p->method)) { VSB_printf(tl->sb, "\n...which is the \"%s\" subroutine\n", p->method->name); From nils.goroll at uplex.de Wed Apr 1 08:10:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 08:10:07 +0000 (UTC) Subject: [master] 0f3af407f Handle workspace allocation errors in VEP_Init() Message-ID: <20200401081007.89DF311D622@lists.varnish-cache.org> commit 0f3af407f65ac4bc6d446c61fb3e3b50747194cd Author: Nils Goroll Date: Wed Mar 18 16:57:15 2020 +0100 Handle workspace allocation errors in VEP_Init() Turn assertion into VFP error The vtc is based upon r02645.vtc and reliably reproduces the panic without the patch by sweeping through possible amounts of free workspace ranging from 4 to 400 bytes. Fixes #3253 diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 74b430173..4592d37cc 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -165,8 +165,13 @@ vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) if (vef == NULL) return (VFP_ERROR); vc->obj_flags |= OF_GZIPED | OF_CHGCE | OF_ESIPROC; - vef->vgz = VGZ_NewGzip(vc->wrk->vsl, "G F E"); vef->vep = VEP_Init(vc, vc->req, vfp_vep_callback, vef); + if (vef->vep == NULL) { + FREE_OBJ(vef); + return (VFP_ERROR); + } + vef->vgz = VGZ_NewGzip(vc->wrk->vsl, "G F E"); + vef->ibuf_sz = cache_param->gzip_buffer; vef->ibuf = calloc(1L, vef->ibuf_sz); if (vef->ibuf == NULL) @@ -232,6 +237,7 @@ static enum vfp_status v_matchproto_(vfp_init_f) vfp_esi_init(struct vfp_ctx *vc, struct vfp_entry *vfe) { struct vef_priv *vef; + struct vep_state *vep; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vc->req, HTTP_MAGIC); @@ -240,11 +246,14 @@ vfp_esi_init(struct vfp_ctx *vc, struct vfp_entry *vfe) "Attempted ESI on partial (206) response"); return (VFP_ERROR); } + vep = VEP_Init(vc, vc->req, NULL, NULL); + if (vep == NULL) + return (VFP_ERROR); ALLOC_OBJ(vef, VEF_MAGIC); if (vef == NULL) return (VFP_ERROR); vc->obj_flags |= OF_ESIPROC; - vef->vep = VEP_Init(vc, vc->req, NULL, NULL); + vef->vep = vep; vfe->priv1 = vef; return (VFP_OK); } diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 2cd1f85c8..995087aa5 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -1042,7 +1042,11 @@ VEP_Init(struct vfp_ctx *vc, const struct http *req, vep_callback_t *cb, CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(req, HTTP_MAGIC); vep = WS_Alloc(vc->resp->ws, sizeof *vep); - AN(vep); + if (vep == NULL) { + VSLb(vc->wrk->vsl, SLT_VCL_Error, + "VEP_Init() workspace overflow"); + return (NULL); + } INIT_OBJ(vep, VEP_MAGIC); vep->url = req->hd[HTTP_HDR_URL].b; diff --git a/bin/varnishtest/tests/r03253.vtc b/bin/varnishtest/tests/r03253.vtc new file mode 100644 index 000000000..af72560c5 --- /dev/null +++ b/bin/varnishtest/tests/r03253.vtc @@ -0,0 +1,26 @@ +varnishtest "ESI: sweep through tight backend workspace conditions" + +server s1 -repeat 100 { + rxreq + txresp -gzipbody "" +} -start + +varnish v1 -vcl+backend { + import vtc; + import std; + sub vcl_recv { + return (pass); + } + sub vcl_backend_response { + vtc.workspace_alloc(backend, -4 * + (std.integer(bereq.xid, 1002) - 1000) / 2); + set beresp.do_esi = true; + } +} -start + +client c1 -repeat 100 { + txreq -url "/" + # some responses will fail (503), some won't. All we care + # about here is the fact that we don't panic + rxresp +} -run From nils.goroll at uplex.de Wed Apr 1 08:10:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 08:10:07 +0000 (UTC) Subject: [master] d1bd80e83 assert for VGZ_NewGzip() failures Message-ID: <20200401081007.A12F511D625@lists.varnish-cache.org> commit d1bd80e83a88a0caaaf7e5021472e23d244a8ac6 Author: Nils Goroll Date: Thu Mar 19 10:52:15 2020 +0100 assert for VGZ_NewGzip() failures VGZ_NewGzip will either assert or succeed. diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 4592d37cc..221822059 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -171,6 +171,7 @@ vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) return (VFP_ERROR); } vef->vgz = VGZ_NewGzip(vc->wrk->vsl, "G F E"); + AN(vef->vgz); vef->ibuf_sz = cache_param->gzip_buffer; vef->ibuf = calloc(1L, vef->ibuf_sz); diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 27e6c9926..569ca1e56 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -503,8 +503,7 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) vc->obj_flags |= OF_GZIPED; } } - if (vg == NULL) - return (VFP_ERROR); + AN(vg); vfe->priv1 = vg; if (vgz_getmbuf(vg)) return (VFP_ERROR); From nils.goroll at uplex.de Wed Apr 1 08:12:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 08:12:07 +0000 (UTC) Subject: [master] 27349a30f support concurrent access to PRIV_TOP Message-ID: <20200401081207.2327011D992@lists.varnish-cache.org> commit 27349a30fba4e77ab45c3c3905caebf7d1fe16de Author: Nils Goroll Date: Sat Mar 21 18:54:47 2020 +0100 support concurrent access to PRIV_TOP in varnish-cache, access to all ESI sub-requests happens in a single thread, but vmods (VDPs) may add concurrency. We thus protect access to PRIV_TOP with the session mutex. Any vmods using this facility will likely need to add additional locking for the actual data structures referenced through the PRIV_TOP and any other access to the top request. For alternatives previously considered, see #3139 diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index 6493698b7..bcc7bfca5 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -166,6 +166,9 @@ struct vmod_priv * VRT_priv_top(VRT_CTX, const void *vmod_id) { struct req *req; + struct sess *sp; + struct reqtop *top; + struct vmod_priv *priv; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); if (ctx->req == NULL) { @@ -174,12 +177,15 @@ VRT_priv_top(VRT_CTX, const void *vmod_id) } req = ctx->req; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(req->top, REQTOP_MAGIC); - return (vrt_priv_dynamic( - req->ws, - req->top->privs, - (uintptr_t)vmod_id - )); + sp = ctx->sp; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + top = req->top; + CHECK_OBJ_NOTNULL(top, REQTOP_MAGIC); + + Lck_Lock(&sp->mtx); + priv = vrt_priv_dynamic(req->ws, top->privs, (uintptr_t)vmod_id); + Lck_Unlock(&sp->mtx); + return (priv); } /*-------------------------------------------------------------------- From nils.goroll at uplex.de Wed Apr 1 08:14:02 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 08:14:02 +0000 (UTC) Subject: [master] 9427a6104 bring thread name panic output in line with pthread.attr Message-ID: <20200401081402.D3D3D11DB99@lists.varnish-cache.org> commit 9427a61049e4fe9008d8d5858e32976a5c534bc8 Author: Nils Goroll Date: Fri Mar 20 16:30:33 2020 +0100 bring thread name panic output in line with pthread.attr diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 502fcaae0..8707ab51c 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -785,7 +785,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, q = THR_GetName(); if (q != NULL) - VSB_printf(pan_vsb, "thread = (%s)\n", q); + VSB_printf(pan_vsb, "pthread.name = (%s)\n", q); #ifdef HAVE_PTHREAD_GETATTR_NP pan_threadattr(pan_vsb); From nils.goroll at uplex.de Wed Apr 1 08:14:02 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 08:14:02 +0000 (UTC) Subject: [master] 410354f14 add pthread_self() to panic output Message-ID: <20200401081402.ED5CD11DB9C@lists.varnish-cache.org> commit 410354f143fb9f27ad30a3d765827d2849cea1ae Author: Nils Goroll Date: Fri Mar 20 16:32:49 2020 +0100 add pthread_self() to panic output This should help locating the panicking thread in a core dump when when the principle thread as determined by the debugger is a different one. diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 8707ab51c..d4cfc8293 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -783,6 +783,8 @@ pan_ic(const char *func, const char *file, int line, const char *cond, if (err) VSB_printf(pan_vsb, "errno = %d (%s)\n", err, vstrerror(err)); + VSB_printf(pan_vsb, "pthread.self = %p\n", (void *)pthread_self()); + q = THR_GetName(); if (q != NULL) VSB_printf(pan_vsb, "pthread.name = (%s)\n", q); From nils.goroll at uplex.de Wed Apr 1 08:25:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 08:25:07 +0000 (UTC) Subject: [master] f1392d0fa Error handling for out-of-workspace VDP_Push during ESI processing Message-ID: <20200401082507.51E8B11E18B@lists.varnish-cache.org> commit f1392d0faded9a10a61b948e3cdff8063fb3b59d Author: Nils Goroll Date: Tue Mar 3 15:52:34 2020 +0100 Error handling for out-of-workspace VDP_Push during ESI processing As with any other out-of-workspace condition during ESI processing, we do not have any better way than to deliver an incomplete response (missing ESI include). Or do we? Fixes #3241 diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index e8d51637f..b4b30fa3f 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -835,16 +835,28 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody) INIT_OBJ(foo, VED_FOO_MAGIC); foo->ecx = ecx; - XXXAZ(VDP_Push(req, &ved_gzgz, foo)); + i = VDP_Push(req, &ved_gzgz, foo); } else if (ecx->isgzip && !i) { /* Non-Gzip'ed include in gzip'ed parent */ - XXXAZ(VDP_Push(req, &ved_pretend_gz, ecx)); + i = VDP_Push(req, &ved_pretend_gz, ecx); } else { /* Anything else goes straight through */ - XXXAZ(VDP_Push(req, &ved_ved, ecx)); + i = VDP_Push(req, &ved_ved, ecx); } - (void)VDP_DeliverObj(req); - (void)VDP_bytes(req, VDP_FLUSH, NULL, 0); + + if (i == 0) { + i = VDP_DeliverObj(req); + } else { + VSLb(req->vsl, SLT_Error, "Failure to push ESI processors"); + req->doclose = SC_OVERLOAD; + } + + if (i == 0) + i = VDP_bytes(req, VDP_FLUSH, NULL, 0); + + if (i && req->doclose == SC_NULL) + req->doclose = SC_REM_CLOSE; + VDP_close(req); } diff --git a/bin/varnishtest/tests/r03241.vtc b/bin/varnishtest/tests/r03241.vtc new file mode 100644 index 000000000..ac7fab446 --- /dev/null +++ b/bin/varnishtest/tests/r03241.vtc @@ -0,0 +1,56 @@ +varnishtest "ESI include out of workspace" + + +server s1 { + rxreq + expect req.http.esi0 == "foo" + txresp -body { + + Before include + + After include + + } + rxreq + expect req.url == "/body1" + expect req.http.esi0 != "foo" + txresp -body { + Included file + } +} -start + +varnish v1 -vcl+backend { + import vtc; + + sub vcl_recv { + if (req.esi_level > 0) { + set req.url = req.url + req.esi_level; + } else { + set req.http.esi0 = "foo"; + } + } + sub vcl_backend_response { + if (bereq.url == "/") { + set beresp.do_esi = true; + } + } + sub vcl_deliver { + if (req.esi_level > 0) { + vtc.workspace_alloc(client, -16); + } + } +} -start + +logexpect l1 -v v1 -g raw { + expect * * Error "^Failure to push ESI processors" +} -start + +client c1 { + txreq -hdr "Host: foo" + rxresp + # XXX this is actually wrong (missed include) + expect resp.bodylen == 57 + expect resp.status == 200 +} -run + +logexpect l1 -wait From nils.goroll at uplex.de Wed Apr 1 08:33:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 08:33:07 +0000 (UTC) Subject: [master] d1c87cc1e [vstat] remove useless if Message-ID: <20200401083307.2A6F511E5AD@lists.varnish-cache.org> commit d1c87cc1ed23309a461c157474affc115805f767 Author: Guillaume Quintard Date: Tue Feb 4 16:31:05 2020 -0800 [vstat] remove useless if diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index f9e6b89c1..347493e7a 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -123,9 +123,6 @@ do_json_cb(void *priv, const struct VSC_point * const pt) printf("\"format\": \"%c\",\n", pt->format); printf(" \"value\": %ju", (uintmax_t)val); printf("\n }"); - - if (*jp) - printf("\n"); return (0); } From nils.goroll at uplex.de Wed Apr 1 08:33:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 08:33:07 +0000 (UTC) Subject: [master] ff8caf99a [vstat] save a pair of lines Message-ID: <20200401083307.3EC2611E5B0@lists.varnish-cache.org> commit ff8caf99aa9d67f5d5df7cae31d60b3c1d1cebb2 Author: Guillaume Quintard Date: Tue Feb 4 16:33:07 2020 -0800 [vstat] save a pair of lines diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 347493e7a..df654b008 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -134,12 +134,10 @@ do_json(struct vsm *vsm, struct vsc *vsc) int jp; jp = 1; - - printf("{\n"); now = time(NULL); (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); - printf(" \"timestamp\": \"%s\",\n", time_stamp); + printf("{\n \"timestamp\": \"%s\",\n", time_stamp); (void)VSC_Iter(vsc, vsm, do_json_cb, &jp); printf("\n}\n"); } From nils.goroll at uplex.de Wed Apr 1 08:33:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 08:33:07 +0000 (UTC) Subject: [master] 4b4411d2e [vstat] new json schema Message-ID: <20200401083307.5A06911E5B4@lists.varnish-cache.org> commit 4b4411d2e877ceb2d5b1fdae9a7481b075153a73 Author: Guillaume Quintard Date: Tue Feb 4 16:46:45 2020 -0800 [vstat] new json schema diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index df654b008..00548320e 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -114,15 +114,13 @@ do_json_cb(void *priv, const struct VSC_point * const pt) else printf(",\n"); - printf(" \""); - /* build the JSON key name. */ - printf("%s\": {\n", pt->name); - printf(" \"description\": \"%s\",\n", pt->sdesc); + printf(" \"%s\": {\n", pt->name); + printf(" \"description\": \"%s\",\n", pt->sdesc); - printf(" \"flag\": \"%c\", ", pt->semantics); + printf(" \"flag\": \"%c\", ", pt->semantics); printf("\"format\": \"%c\",\n", pt->format); - printf(" \"value\": %ju", (uintmax_t)val); - printf("\n }"); + printf(" \"value\": %ju", (uintmax_t)val); + printf("\n }"); return (0); } @@ -137,9 +135,12 @@ do_json(struct vsm *vsm, struct vsc *vsc) now = time(NULL); (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); - printf("{\n \"timestamp\": \"%s\",\n", time_stamp); + printf("{\n" + " \"version\": 1,\n" + " \"timestamp\": \"%s\",\n" + " \"counters\": {\n", time_stamp); (void)VSC_Iter(vsc, vsm, do_json_cb, &jp); - printf("\n}\n"); + printf("\n }\n}\n"); } From nils.goroll at uplex.de Wed Apr 1 08:33:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 08:33:07 +0000 (UTC) Subject: [master] 5aede725f add test Message-ID: <20200401083307.7653C11E5BC@lists.varnish-cache.org> commit 5aede725f875e575c7884dc80cc130cd98c26c23 Author: Guillaume Quintard Date: Fri Mar 20 12:02:31 2020 -0700 add test diff --git a/bin/varnishtest/tests/u00015.vtc b/bin/varnishtest/tests/u00015.vtc new file mode 100644 index 000000000..ec415e19f --- /dev/null +++ b/bin/varnishtest/tests/u00015.vtc @@ -0,0 +1,19 @@ +varnishtest "varnishstat -j" + +server s1 -repeat 5 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend {} -start + +client c1 -repeat 5 { + txreq + rxresp +} -run + +delay 1 + +shell { varnishstat -n ${v1_name} -j } +shell -expect "1" { varnishstat -n ${v1_name} -j | python3 -c 'import sys, json; print(json.load(sys.stdin)["version"])' } +shell -expect "5" { varnishstat -n ${v1_name} -j | python3 -c 'import sys, json; print(json.load(sys.stdin)["counters"]["MAIN.client_req"]["value"])' } From dridi.boukelmoune at gmail.com Wed Apr 1 09:26:07 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 1 Apr 2020 09:26:07 +0000 (UTC) Subject: [master] 9d53b1f6c Bump the varnishstat json schema version to 2 Message-ID: <20200401092607.722936CF7@lists.varnish-cache.org> commit 9d53b1f6cce8784b766e5049017f06ba3c9225df Author: Dridi Boukelmoune Date: Wed Apr 1 11:20:33 2020 +0200 Bump the varnishstat json schema version to 2 diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 00548320e..f816184a8 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -99,48 +99,52 @@ do_xml(struct vsm *vsm, struct vsc *vsc) static int v_matchproto_(VSC_iter_f) do_json_cb(void *priv, const struct VSC_point * const pt) { - uint64_t val; - int *jp; + const char **sep; + uintmax_t val; if (pt == NULL) return (0); - jp = priv; AZ(strcmp(pt->ctype, "uint64_t")); - val = *(const volatile uint64_t*)pt->ptr; + val = (uintmax_t)*(const volatile uint64_t*)pt->ptr; - if (*jp) - *jp = 0; - else - printf(",\n"); + sep = priv; - printf(" \"%s\": {\n", pt->name); - printf(" \"description\": \"%s\",\n", pt->sdesc); + printf( + "%s" + " \"%s\": {\n" + " \"description\": \"%s\",\n" + " \"flag\": \"%c\",\n" + " \"format\": \"%c\",\n" + " \"value\": %ju\n" + " }", + *sep, pt->name, pt->sdesc, pt->semantics, pt->format, val); - printf(" \"flag\": \"%c\", ", pt->semantics); - printf("\"format\": \"%c\",\n", pt->format); - printf(" \"value\": %ju", (uintmax_t)val); - printf("\n }"); + *sep = ",\n"; return (0); } static void do_json(struct vsm *vsm, struct vsc *vsc) { + const char *sep; char time_stamp[20]; time_t now; - int jp; - jp = 1; + sep = ""; now = time(NULL); (void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now)); - printf("{\n" + printf( + "{\n" " \"version\": 1,\n" " \"timestamp\": \"%s\",\n" " \"counters\": {\n", time_stamp); - (void)VSC_Iter(vsc, vsm, do_json_cb, &jp); - printf("\n }\n}\n"); + (void)VSC_Iter(vsc, vsm, do_json_cb, &sep); + printf( + "\n" + " }\n" + "}\n"); } From dridi.boukelmoune at gmail.com Wed Apr 1 13:26:07 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 1 Apr 2020 13:26:07 +0000 (UTC) Subject: [master] 98b38e9f9 New HAVE_STRUCT_SOCKADDR_SA_LEN macro Message-ID: <20200401132607.2228C100B93@lists.varnish-cache.org> commit 98b38e9f9d67aac16e0c7da884a45361c572640a Author: Dridi Boukelmoune Date: Wed Apr 1 15:20:59 2020 +0200 New HAVE_STRUCT_SOCKADDR_SA_LEN macro Only present if struct sockaddr.sa_len exists, to be checked with preprocessor's #ifdef. Refs #3154 diff --git a/configure.ac b/configure.ac index dd43dc82f..578d596e1 100644 --- a/configure.ac +++ b/configure.ac @@ -502,6 +502,11 @@ AM_CONDITIONAL([WITH_PERSISTENT_STORAGE], AM_MISSING_HAS_RUN +AC_CHECK_MEMBER([struct sockaddr.sa_len], + [AC_DEFINE([HAVE_STRUCT_SOCKADDR_SA_LEN], [1], + [Define if sa_len is present in struct sockaddr])], + [], [#include ]) + AC_CHECK_DECL([SO_ACCEPTFILTER], AC_DEFINE(HAVE_ACCEPT_FILTERS,1,[Define to 1 if you have accept filters]), , From nils.goroll at uplex.de Wed Apr 1 18:30:11 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 18:30:11 +0000 (UTC) Subject: [master] 105be6a64 VSA_Build: Assign (struct sockaddr).sa_len where present Message-ID: <20200401183011.629BD1070BC@lists.varnish-cache.org> commit 105be6a644d7dee09184040f056248214ffebe3f Author: Nils Goroll Date: Wed Apr 1 20:27:42 2020 +0200 VSA_Build: Assign (struct sockaddr).sa_len where present In #3154 we said we would add this to the upcoming VSA_BuildFAP(), but actually VSA_Build() is the right place. diff --git a/lib/libvarnish/vsa.c b/lib/libvarnish/vsa.c index 2d79f571c..3ade79e14 100644 --- a/lib/libvarnish/vsa.c +++ b/lib/libvarnish/vsa.c @@ -282,6 +282,9 @@ VSA_Build(void *d, const void *s, unsigned sal) INIT_OBJ(sua, SUCKADDR_MAGIC); memcpy(&sua->sa, s, l); +#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN + sua->sa.sa_len = (unsigned char)l; +#endif return (sua); } From nils.goroll at uplex.de Wed Apr 1 18:30:11 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 18:30:11 +0000 (UTC) Subject: [master] 50970bc90 Deflate VSA_* code a bit Message-ID: <20200401183011.4E0AD1070BB@lists.varnish-cache.org> commit 50970bc9031f7d1d08863dd565a7ebaca7d28541 Author: Nils Goroll Date: Wed Apr 1 20:07:47 2020 +0200 Deflate VSA_* code a bit - Centralize duplicated code in sua_len() - Have VSA_Malloc call VSA_Build - Use INIT_OBJ instead of memset + magic assignment April sales extra exclusively to customers in Paris: Now with free capitalized letters! diff --git a/lib/libvarnish/vsa.c b/lib/libvarnish/vsa.c index cd8dd4f72..2d79f571c 100644 --- a/lib/libvarnish/vsa.c +++ b/lib/libvarnish/vsa.c @@ -229,39 +229,41 @@ VSA_GetPtr(const struct suckaddr *sua, const unsigned char ** dst) } /* - * Malloc a suckaddr from a sockaddr of some kind. + * Return the size of a struct sockaddr in a struck suckaddr + * or 0 if unknown family */ - -struct suckaddr * -VSA_Malloc(const void *s, unsigned sal) +static inline +socklen_t sua_len(const struct sockaddr *sa) { - struct suckaddr *sua = NULL; - const struct sockaddr *sa = s; - unsigned l = 0; + struct suckaddr *sua; - AN(s); switch (sa->sa_family) { case PF_INET: - if (sal == sizeof sua->sa4) - l = sal; - break; + return (sizeof sua->sa4); case PF_INET6: - if (sal == sizeof sua->sa6) - l = sal; - break; + return (sizeof sua->sa6); default: - break; - } - if (l != 0) { - ALLOC_OBJ(sua, SUCKADDR_MAGIC); - /* XXX: shouldn't we AN(sua) instead of mixing up failed - * allocations with unsupported address family or bogus - * sockaddr? - */ - if (sua != NULL) - memcpy(&sua->sa, s, l); + return (0); } - return (sua); +} + +/* + * Malloc a suckaddr from a sockaddr of some kind. + */ + +struct suckaddr * +VSA_Malloc(const void *s, unsigned sal) +{ + void *d; + + d = malloc(vsa_suckaddr_len); + /* XXX: shouldn't we AN(sua) instead of mixing up failed allocations + * with unsupported address family or bogus sockaddr? + */ + if (d == NULL) + return (NULL); + + return (VSA_Build(d, s, sal)); } /* 'd' SHALL point to vsa_suckaddr_len aligned bytes of storage */ @@ -270,47 +272,30 @@ VSA_Build(void *d, const void *s, unsigned sal) { struct suckaddr *sua = d; const struct sockaddr *sa = s; - unsigned l = 0; + unsigned l; AN(d); AN(s); - switch (sa->sa_family) { - case PF_INET: - if (sal == sizeof sua->sa4) - l = sal; - break; - case PF_INET6: - if (sal == sizeof sua->sa6) - l = sal; - break; - default: - break; - } - if (l != 0) { - memset(sua, 0, sizeof *sua); - sua->magic = SUCKADDR_MAGIC; - memcpy(&sua->sa, s, l); - return (sua); - } - return (NULL); + l = sua_len(sa); + if (l == 0 || l != sal) + return (NULL); + + INIT_OBJ(sua, SUCKADDR_MAGIC); + memcpy(&sua->sa, s, l); + return (sua); } const void * -VSA_Get_Sockaddr(const struct suckaddr *sua, socklen_t *sl) +VSA_Get_Sockaddr(const struct suckaddr *sua, socklen_t *slp) { + socklen_t sl; CHECK_OBJ_NOTNULL(sua, SUCKADDR_MAGIC); - AN(sl); - switch (sua->sa.sa_family) { - case PF_INET: - *sl = sizeof sua->sa4; - break; - case PF_INET6: - *sl = sizeof sua->sa6; - break; - default: + AN(slp); + sl = sua_len(&sua->sa); + if (sl == 0) return (NULL); - } + *slp = sl; return (&sua->sa); } @@ -326,14 +311,7 @@ int VSA_Sane(const struct suckaddr *sua) { CHECK_OBJ_NOTNULL(sua, SUCKADDR_MAGIC); - - switch (sua->sa.sa_family) { - case PF_INET: - case PF_INET6: - return (1); - default: - return (0); - } + return (sua_len(&sua->sa) != 0); } int From nils.goroll at uplex.de Wed Apr 1 18:33:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 18:33:08 +0000 (UTC) Subject: [master] 544f62bdc Appease Solaris gcc 64bit Message-ID: <20200401183308.3CFF1107477@lists.varnish-cache.org> commit 544f62bdc5c623112025d39c15a2bf687da8801d Author: Nils Goroll Date: Wed Apr 1 20:31:39 2020 +0200 Appease Solaris gcc 64bit diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index d4cfc8293..48d6c7618 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -783,7 +783,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, if (err) VSB_printf(pan_vsb, "errno = %d (%s)\n", err, vstrerror(err)); - VSB_printf(pan_vsb, "pthread.self = %p\n", (void *)pthread_self()); + VSB_printf(pan_vsb, "pthread.self = %p\n", TRUST_ME(pthread_self())); q = THR_GetName(); if (q != NULL) From nils.goroll at uplex.de Wed Apr 1 18:37:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 18:37:07 +0000 (UTC) Subject: [master] 358f7331c VSA_BuildFAP: Build a suckaddr from Family, Address and Port Message-ID: <20200401183707.BF52E107712@lists.varnish-cache.org> commit 358f7331c3bcc595fb161370256c0b13b960ccda Author: Nils Goroll Date: Thu Dec 12 15:31:11 2019 +0100 VSA_BuildFAP: Build a suckaddr from Family, Address and Port Follow the spirit of the vsa.c top level rant and spare callers the hassle of creating sockaddrs specific to ip4/ip6 just to build a VSA, which is intended to avoid having to special-case the protocols in the first place. diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c index 4eb5526ee..53851a24c 100644 --- a/bin/varnishd/proxy/cache_proxy_proto.c +++ b/bin/varnishd/proxy/cache_proxy_proto.c @@ -326,8 +326,6 @@ vpx_proto2(const struct worker *wrk, struct req *req) const uint8_t *p; char *d, *tlv_start; sa_family_t pfam = 0xff; - struct sockaddr_in sin4; - struct sockaddr_in6 sin6; struct suckaddr *sa = NULL; char ha[VTCP_ADDRBUFSIZE]; char pa[VTCP_PORTBUFSIZE]; @@ -387,23 +385,17 @@ vpx_proto2(const struct worker *wrk, struct req *req) } l -= 12; d += 12; - memset(&sin4, 0, sizeof sin4); - sin4.sin_family = pfam; /* dst/server */ - memcpy(&sin4.sin_addr, p + 20, 4); - memcpy(&sin4.sin_port, p + 26, 2); if (! SES_Reserve_server_addr(req->sp, &sa)) return (vpx_ws_err(req)); - AN(VSA_Build(sa, &sin4, sizeof sin4)); + AN(VSA_BuildFAP(sa, pfam, p + 20, 4, p + 26, 2)); VTCP_name(sa, ha, sizeof ha, pa, sizeof pa); /* src/client */ - memcpy(&sin4.sin_addr, p + 16, 4); - memcpy(&sin4.sin_port, p + 24, 2); if (! SES_Reserve_client_addr(req->sp, &sa)) return (vpx_ws_err(req)); - AN(VSA_Build(sa, &sin4, sizeof sin4)); + AN(VSA_BuildFAP(sa, pfam, p + 16, 4, p + 24, 2)); break; case 0x21: /* IPv6|TCP */ @@ -415,23 +407,17 @@ vpx_proto2(const struct worker *wrk, struct req *req) } l -= 36; d += 36; - memset(&sin6, 0, sizeof sin6); - sin6.sin6_family = pfam; /* dst/server */ - memcpy(&sin6.sin6_addr, p + 32, 16); - memcpy(&sin6.sin6_port, p + 50, 2); if (! SES_Reserve_server_addr(req->sp, &sa)) return (vpx_ws_err(req)); - AN(VSA_Build(sa, &sin6, sizeof sin6)); + AN(VSA_BuildFAP(sa, pfam, p + 32, 16, p + 50, 2)); VTCP_name(sa, ha, sizeof ha, pa, sizeof pa); /* src/client */ - memcpy(&sin6.sin6_addr, p + 16, 16); - memcpy(&sin6.sin6_port, p + 48, 2); if (! SES_Reserve_client_addr(req->sp, &sa)) return (vpx_ws_err(req)); - AN(VSA_Build(sa, &sin6, sizeof sin6)); + AN(VSA_BuildFAP(sa, pfam, p + 16, 16, p + 48, 2)); break; default: /* Ignore proxy header */ diff --git a/include/vsa.h b/include/vsa.h index e44544d55..eb6e4a2df 100644 --- a/include/vsa.h +++ b/include/vsa.h @@ -57,6 +57,18 @@ struct suckaddr *VSA_Malloc(const void *s, unsigned sal); */ struct suckaddr *VSA_Build(void *d, const void *s, unsigned sal); +/* 'd' SHALL point to vsa_suckaddr_len aligned bytes of storage + * + * fam: address family + * a / al : address and length + * p / pl : port and length + * + * NULL or 0 length argument are ignored. + * argument of the wrong length are an error (NULL return value, EINVAL) + */ +struct suckaddr * VSA_BuildFAP(void *d, sa_family_t fam, + const void *a, unsigned al, const void *p, unsigned pl); + /* * This VRT interface is for the VCC generated ACL code, which needs * to know the address family and a pointer to the actual address. diff --git a/lib/libvarnish/vsa.c b/lib/libvarnish/vsa.c index 3ade79e14..3f842458d 100644 --- a/lib/libvarnish/vsa.c +++ b/lib/libvarnish/vsa.c @@ -187,16 +187,7 @@ const struct suckaddr *bogo_ip = &bogo_ip_vsa; void VSA_Init() { - struct addrinfo hints, *res = NULL; - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_INET; - hints.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV; - hints.ai_socktype = SOCK_STREAM; - AZ(getaddrinfo("0.0.0.0", "0", &hints, &res)); - AN(VSA_Build(&bogo_ip_vsa, res->ai_addr, res->ai_addrlen)); - assert(VSA_Sane(bogo_ip)); - freeaddrinfo(res); + AN(VSA_BuildFAP(&bogo_ip_vsa, PF_INET, NULL, 0, NULL, 0)); } /* @@ -266,6 +257,59 @@ VSA_Malloc(const void *s, unsigned sal) return (VSA_Build(d, s, sal)); } +/* 'd' SHALL point to vsa_suckaddr_len aligned bytes of storage + * + * fam: address family + * a / al : address and length + * p / pl : port and length + * + * NULL or 0 length argument are ignored. + * argument of the wrong length are an error (NULL return value, EINVAL) + */ +struct suckaddr * +VSA_BuildFAP(void *d, sa_family_t fam, const void *a, unsigned al, + const void *p, unsigned pl) +{ + struct sockaddr_in sin4; + struct sockaddr_in6 sin6; + + switch (fam) { + case PF_INET: + memset(&sin4, 0, sizeof sin4); + sin4.sin_family = fam; + if (a != NULL && al > 0) { + if (al != sizeof(sin4.sin_addr)) + break; + memcpy(&sin4.sin_addr, a, al); + } + if (p != NULL && pl > 0) { + if (pl != sizeof(sin4.sin_port)) + break; + memcpy(&sin4.sin_port, p, pl); + } + return (VSA_Build(d, &sin4, sizeof sin4)); + case PF_INET6: + memset(&sin6, 0, sizeof sin6); + sin6.sin6_family = fam; + if (a != NULL && al > 0) { + if (al != sizeof(sin6.sin6_addr)) + break; + memcpy(&sin6.sin6_addr, a, al); + } + if (p != NULL && pl > 0) { + if (pl != sizeof(sin6.sin6_port)) + break; + memcpy(&sin6.sin6_port, p, pl); + } + return (VSA_Build(d, &sin6, sizeof sin6)); + default: + errno = EAFNOSUPPORT; + return (NULL); + } + errno = EINVAL; + return (NULL); +} + /* 'd' SHALL point to vsa_suckaddr_len aligned bytes of storage */ struct suckaddr * VSA_Build(void *d, const void *s, unsigned sal) From nils.goroll at uplex.de Wed Apr 1 18:37:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 18:37:07 +0000 (UTC) Subject: [master] 4e5fcfebf More proxy code cleanup thanks to VSA_BuildFAP Message-ID: <20200401183707.C65F6107713@lists.varnish-cache.org> commit 4e5fcfebf7028b9e5e32daf343f6a837fb3911ea Author: Nils Goroll Date: Thu Dec 12 15:55:18 2019 +0100 More proxy code cleanup thanks to VSA_BuildFAP diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c index 53851a24c..b174f3142 100644 --- a/bin/varnishd/proxy/cache_proxy_proto.c +++ b/bin/varnishd/proxy/cache_proxy_proto.c @@ -323,7 +323,7 @@ vpx_proto2(const struct worker *wrk, struct req *req) int l, hdr_len; uintptr_t *up; uint16_t tlv_len; - const uint8_t *p; + const uint8_t *p, *ap, *pp; char *d, *tlv_start; sa_family_t pfam = 0xff; struct suckaddr *sa = NULL; @@ -333,6 +333,8 @@ vpx_proto2(const struct worker *wrk, struct req *req) char pb[VTCP_PORTBUFSIZE]; struct vpx_tlv_iter vpi[1], vpi2[1]; struct vpx_tlv *tlv; + unsigned flen, alen; + unsigned const plen = 2, aoff = 16; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); @@ -378,46 +380,12 @@ vpx_proto2(const struct worker *wrk, struct req *req) case 0x11: /* IPv4|TCP */ pfam = AF_INET; - if (l < 12) { - VSL(SLT_ProxyGarbage, req->sp->vxid, - "PROXY2: Ignoring short IPv4 addresses (%d)", l); - return (0); - } - l -= 12; - d += 12; - - /* dst/server */ - if (! SES_Reserve_server_addr(req->sp, &sa)) - return (vpx_ws_err(req)); - AN(VSA_BuildFAP(sa, pfam, p + 20, 4, p + 26, 2)); - VTCP_name(sa, ha, sizeof ha, pa, sizeof pa); - - /* src/client */ - if (! SES_Reserve_client_addr(req->sp, &sa)) - return (vpx_ws_err(req)); - AN(VSA_BuildFAP(sa, pfam, p + 16, 4, p + 24, 2)); + alen = 4; break; case 0x21: /* IPv6|TCP */ pfam = AF_INET6; - if (l < 36) { - VSL(SLT_ProxyGarbage, req->sp->vxid, - "PROXY2: Ignoring short IPv6 addresses (%d)", l); - return (0); - } - l -= 36; - d += 36; - - /* dst/server */ - if (! SES_Reserve_server_addr(req->sp, &sa)) - return (vpx_ws_err(req)); - AN(VSA_BuildFAP(sa, pfam, p + 32, 16, p + 50, 2)); - VTCP_name(sa, ha, sizeof ha, pa, sizeof pa); - - /* src/client */ - if (! SES_Reserve_client_addr(req->sp, &sa)) - return (vpx_ws_err(req)); - AN(VSA_BuildFAP(sa, pfam, p + 16, 16, p + 48, 2)); + alen = 16; break; default: /* Ignore proxy header */ @@ -426,8 +394,36 @@ vpx_proto2(const struct worker *wrk, struct req *req) return (0); } - AN(sa); + flen = 2 * alen + 2 * plen; + + if (l < flen) { + VSL(SLT_ProxyGarbage, req->sp->vxid, + "PROXY2: Ignoring short %s addresses (%d)", + pfam == AF_INET ? "IPv4" : "IPv6", l); + return (0); + } + + l -= flen; + d += flen; + + ap = p + aoff; + pp = ap + 2 * alen; + + /* src/client */ + if (! SES_Reserve_client_addr(req->sp, &sa)) + return (vpx_ws_err(req)); + AN(VSA_BuildFAP(sa, pfam, ap, alen, pp, plen)); VTCP_name(sa, hb, sizeof hb, pb, sizeof pb); + + ap += alen; + pp += plen; + + /* dst/server */ + if (! SES_Reserve_server_addr(req->sp, &sa)) + return (vpx_ws_err(req)); + AN(VSA_BuildFAP(sa, pfam, ap, alen, pp, plen)); + VTCP_name(sa, ha, sizeof ha, pa, sizeof pa); + if (! SES_Set_String_Attr(req->sp, SA_CLIENT_IP, hb)) return (vpx_ws_err(req)); if (! SES_Set_String_Attr(req->sp, SA_CLIENT_PORT, pb)) From nils.goroll at uplex.de Wed Apr 1 18:48:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 18:48:08 +0000 (UTC) Subject: [master] b9756475f Warn about ACL entries with non-zero host bits Message-ID: <20200401184808.68452107D50@lists.varnish-cache.org> commit b9756475fa0ca69e0a3a31b919a6f26141c30f79 Author: Nils Goroll Date: Thu Dec 12 20:32:53 2019 +0100 Warn about ACL entries with non-zero host bits Summary: ACL entries with netmasks shorter than the maximum for the respective protocol represent network addresses and as such, by convention, should be written with all zero bits in the host part to avoid confusion. This patch adds VCL compile warnings and improved logging if they are not. Discussion: For example, while 1.2.3.0/24 and 1.2.3.255/24, in CIDR notation, both specify all addresses with the first three octets matching 1, 2 and 3, using the latter can be a source of subtle confusion. This becomes particularly apparent with netmasks outside byte boundaries: 1.2.6.0/22 specifies addresses 1.2.4.0 - 1.2.7.255, but not so experienced administrators might be tempted to think that it specified 1.2.6.0 - 1.2.9.255. To summarize, denoting network addresses in non-canonical form is confusing, a possible source of error and additionally complicates analyses. This patch makes sure that such mishaps do not remain unnoticed by - issuing warnings during VCL compilation about non-canonical network addresses - Logging ACL matches together with the canonical address The actual matching code is not touched, but a minor simplification can be applied later. diff --git a/bin/varnishtest/tests/c00005.vtc b/bin/varnishtest/tests/c00005.vtc index 92ef9f9f2..0eed7ef55 100644 --- a/bin/varnishtest/tests/c00005.vtc +++ b/bin/varnishtest/tests/c00005.vtc @@ -115,11 +115,11 @@ varnish v1 -vcl { logexpect l1 -v v1 -g raw { expect * 1007 ReqHeader {^\Qip: 1.2.3.0\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.2.3.4"/24\E$} + expect 0 = VCL_acl {^\QMATCH acl1 "1.2.3.4"/24 fixed: 1.2.3.0/24\E$} expect 1 = ReqHeader {^\Qip: 1.2.3.63\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.2.3.4"/24\E$} + expect 0 = VCL_acl {^\QMATCH acl1 "1.2.3.4"/24 fixed: 1.2.3.0/24\E$} expect 1 = ReqHeader {^\Qip: 1.2.3.64\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.2.3.66"/26\E$} + expect 0 = VCL_acl {^\QMATCH acl1 "1.2.3.66"/26 fixed: 1.2.3.64/26\E$} expect 1 = ReqHeader {^\Qip: 1.3.4.255\E$} expect 0 = VCL_acl {^\QMATCH acl1 "1.3.4.0"/23\E$} diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index cf18107d7..443d9189e 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -40,6 +40,8 @@ #include #include "vcc_compile.h" +#include +#include #define ACL_MAXADDR (sizeof(struct in6_addr) + 1) @@ -50,6 +52,7 @@ struct acl_e { unsigned not; unsigned para; char *addr; + char *fixed; struct token *t_addr; struct token *t_mask; }; @@ -91,10 +94,60 @@ vcl_acl_cmp(struct acl_e *ae1, struct acl_e *ae2) return (0); } +static char * +vcc_acl_chk(struct vcc *tl, const struct acl_e *ae, const int l, + unsigned char *p, int fam) +{ + const unsigned char *u; + char h[VTCP_ADDRBUFSIZE]; + char t[VTCP_ADDRBUFSIZE + 10]; + char s[vsa_suckaddr_len]; + struct suckaddr *sa; + unsigned m; + int ll, ret = 0; + + u = p; + ll = l; + m = ae->mask; + + p += m / 8; + ll -= m / 8; + assert (ll >= 0); + m %= 8; + + if (m && (*p << m & 0xff) != 0) { + ret = 1; + m = 0xff00 >> m; + *p &= m; + } + if (m) { + p++; + ll--; + } + + for ( ; ll > 0; p++, ll--) { + if (*p == 0) + continue; + ret = 1; + *p = 0; + } + if (ret == 0) + return (NULL); + + sa = VSA_BuildFAP(s, fam, u, l, NULL, 0); + AN(sa); + VTCP_name(sa, h, sizeof h, NULL, 0); + bprintf(t, "%s/%d", h, ae->mask); + VSB_printf(tl->sb, "Address/Netmask mismatch, changed to %s\n", t); + vcc_ErrWhere(tl, ae->t_addr); + vcc_Warn(tl); + return (strdup(t)); +} + static void vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l, - const unsigned char *u, int fam) + unsigned char *u, int fam) { struct acl_e *ae2, *aen; int i; @@ -120,6 +173,8 @@ vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l, AN(aen); *aen = *ae; + aen->fixed = vcc_acl_chk(tl, ae, l, u, fam); + /* We treat family as part of address, it saves code */ assert(fam <= 0xff); aen->data[0] = fam & 0xff; @@ -410,6 +465,7 @@ vcc_acl_emit(struct vcc *tl, const char *name, const char *rname, int anon) } if (m > 0) { + // XXX can remove masking due to fixup /* Do fractional byte compares */ Fh(tl, 0, "\t%*s%sif ((a[%d] & 0x%x) == %d) {\n", -i, "", "", i - 1, (0xff00 >> m) & 0xff, @@ -436,6 +492,9 @@ vcc_acl_emit(struct vcc *tl, const char *name, const char *rname, int anon) t = VTAILQ_NEXT(t, list); AN(t); } while (ae->t_mask != NULL); + if (ae->fixed) + Fh(tl, 0, "\" fixed: %s\"", + ae->fixed); Fh(tl, 0, ");\n"); } From nils.goroll at uplex.de Wed Apr 1 18:48:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 18:48:08 +0000 (UTC) Subject: [master] 6c8f25e71 add vcc_acl_pedantic parameter Message-ID: <20200401184808.8DA10107D52@lists.varnish-cache.org> commit 6c8f25e712bcd59b85a0486044eba740848a739b Author: Nils Goroll Date: Fri Dec 13 15:28:33 2019 +0100 add vcc_acl_pedantic parameter See also previous commit: With this parameter set to on, any ACL entries in non-canonical form cause a VCL compilation error rather than only a warning. diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 7daf52b60..43987de1c 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -222,6 +222,7 @@ extern char *mgt_cc_cmd; extern const char *mgt_vcl_path; extern const char *mgt_vmod_path; extern unsigned mgt_vcc_err_unref; +extern unsigned mgt_vcc_acl_pedantic; extern unsigned mgt_vcc_allow_inline_c; extern unsigned mgt_vcc_unsafe_path; diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index f0fabec51..fec7493a9 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -76,6 +76,19 @@ struct parspec mgt_parspec[] = { NULL, NULL, "on", "bool", "Unreferenced VCL objects result in error." }, + { "vcc_acl_pedantic", tweak_bool, &mgt_vcc_acl_pedantic, + NULL, NULL, "off", + "bool", + "Insist that network numbers used in ACLs have an " + "all-zero host part, e.g. make 1.2.3.4/24 an error.\n" + "With this option set to off (the default), the host " + "part of network numbers is being fixed to all-zeroes " + "(e.g. the above changed to 1.2.3.0/24), a warning is " + "output during VCL compilation and any ACL entry hits " + "are logged with the fixed address as \"fixed: ...\" " + "after the original VCL entry.\n" + "With this option set to on, any ACL entries with non-zero " + "host parts cause VCL compilation to fail." }, { "vcc_allow_inline_c", tweak_bool, &mgt_vcc_allow_inline_c, NULL, NULL, "off", "bool", diff --git a/bin/varnishtest/tests/c00005.vtc b/bin/varnishtest/tests/c00005.vtc index 0eed7ef55..a39d5ee04 100644 --- a/bin/varnishtest/tests/c00005.vtc +++ b/bin/varnishtest/tests/c00005.vtc @@ -148,3 +148,19 @@ client c1 { } -run logexpect l1 -wait + +varnish v1 -cliok "param.set vcc_acl_pedantic on" + +varnish v1 -errvcl {Address/Netmask mismatch, need be 1.2.3.0/24} { + import std; + + backend dummy None; + + acl acl1 { + "1.2.3.4"/24; + } + + sub vcl_recv { + if (client.ip ~ acl1) {} + } +} diff --git a/include/tbl/params.h b/include/tbl/params.h index bfbeb5ac9..b67c3c0dc 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -1551,6 +1551,26 @@ PARAM( /* flags */ EXPERIMENTAL ) +/* actual location mgt_param_tbl.c */ +PARAM( + /* name */ vcc_acl_pedantic, + /* type */ bool, + /* min */ NULL, + /* max */ NULL, + /* def */ "off", // XXX change to on in 7.x ? + /* units */ "bool", + /* descr */ + "Insist that network numbers used in ACLs have an all-zero host part, " + "e.g. make 1.2.3.4/24 an error.\n" + "With this option set to off (the default), the host part of network " + "numbers is being fixed to all-zeroes (e.g. the above changed to " + "1.2.3.0/24), a warning is output during VCL compilation and any ACL " + "entry hits are logged with the fixed address as \"fixed: ...\" " + "after the original VCL entry.\n" + "With this option set to on, any ACL entries with non-zero host parts " + "cause VCL compilation to fail." +) + /* actual location mgt_param_tbl.c */ PARAM( /* name */ vcc_allow_inline_c, diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index 443d9189e..274f158de 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -43,6 +43,8 @@ #include #include +unsigned mgt_vcc_acl_pedantic; + #define ACL_MAXADDR (sizeof(struct in6_addr) + 1) struct acl_e { @@ -138,9 +140,13 @@ vcc_acl_chk(struct vcc *tl, const struct acl_e *ae, const int l, AN(sa); VTCP_name(sa, h, sizeof h, NULL, 0); bprintf(t, "%s/%d", h, ae->mask); - VSB_printf(tl->sb, "Address/Netmask mismatch, changed to %s\n", t); + if (mgt_vcc_acl_pedantic) + VSB_printf(tl->sb, "Address/Netmask mismatch, need be %s\n", t); + else + VSB_printf(tl->sb, "Address/Netmask mismatch, changed to %s\n", t); vcc_ErrWhere(tl, ae->t_addr); - vcc_Warn(tl); + if (mgt_vcc_acl_pedantic == 0) + vcc_Warn(tl); return (strdup(t)); } From nils.goroll at uplex.de Wed Apr 1 18:48:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 1 Apr 2020 18:48:08 +0000 (UTC) Subject: [master] c3c3de4f0 Document VCL_acl format changes from the previous two commits Message-ID: <20200401184808.B496A107D56@lists.varnish-cache.org> commit c3c3de4f0545bb1686866c40ad6bfe5320944242 Author: Nils Goroll Date: Fri Dec 13 15:42:22 2019 +0100 Document VCL_acl format changes from the previous two commits diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index ad51c1e04..31fed3547 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -285,11 +285,12 @@ SLTM(Fetch_Body, 0, "Body fetched from backend", SLTM(VCL_acl, 0, "VCL ACL check results", "Logs VCL ACL evaluation results.\n\n" "The format is::\n\n" - "\t%s [%s [%s]]\n" - "\t| | |\n" - "\t| | +- Matching entry (only for MATCH)\n" - "\t| +----- Name of the ACL for MATCH or NO_MATCH\n" - "\t+--------- MATCH, NO_MATCH or NO_FAM\n" + "\t%s [%s [%s [fixed: %s]]]\n" + "\t| | | |\n" + "\t| | | +- Fixed entry (see vcc_acl_pedantic parameter)\n" + "\t| | +------------ Matching entry (only for MATCH)\n" + "\t| +---------------- Name of the ACL for MATCH or NO_MATCH\n" + "\t+-------------------- MATCH, NO_MATCH or NO_FAM\n" "\n" "MATCH denotes an ACL match\n" "NO_MATCH denotes that a checked ACL has not matched\n" From nils.goroll at uplex.de Thu Apr 2 06:43:09 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 2 Apr 2020 06:43:09 +0000 (UTC) Subject: [master] 6a9192574 Defuse test depending on python+json for now Message-ID: <20200402064309.A2B30118F1F@lists.varnish-cache.org> commit 6a9192574b35eaa6f8c1f4a454997e625f137f72 Author: Nils Goroll Date: Thu Apr 2 08:42:20 2020 +0200 Defuse test depending on python+json for now diff --git a/bin/varnishtest/tests/u00015.vtc b/bin/varnishtest/tests/u00015.vtc index ec415e19f..0a53593d3 100644 --- a/bin/varnishtest/tests/u00015.vtc +++ b/bin/varnishtest/tests/u00015.vtc @@ -15,5 +15,8 @@ client c1 -repeat 5 { delay 1 shell { varnishstat -n ${v1_name} -j } -shell -expect "1" { varnishstat -n ${v1_name} -j | python3 -c 'import sys, json; print(json.load(sys.stdin)["version"])' } -shell -expect "5" { varnishstat -n ${v1_name} -j | python3 -c 'import sys, json; print(json.load(sys.stdin)["counters"]["MAIN.client_req"]["value"])' } +## XXX: +## - use @PYTHON@ discovered via autogen/automake +## - make this test depend on json being available +#shell -expect "1" { varnishstat -n ${v1_name} -j | python3 -c 'import sys, json; print(json.load(sys.stdin)["version"])' } +#shell -expect "5" { varnishstat -n ${v1_name} -j | python3 -c 'import sys, json; print(json.load(sys.stdin)["counters"]["MAIN.client_req"]["value"])' } From dridi.boukelmoune at gmail.com Thu Apr 2 10:06:07 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 2 Apr 2020 10:06:07 +0000 (UTC) Subject: [master] 69b7de9a2 Back to trunk Message-ID: <20200402100607.3E7AD11E9E3@lists.varnish-cache.org> commit 69b7de9a24d78a5827fa3d25986d124828d9e3c4 Author: Dridi Boukelmoune Date: Thu Apr 2 12:04:34 2020 +0200 Back to trunk diff --git a/configure.ac b/configure.ac index 578d596e1..7c63ce667 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2020 Varnish Software]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [6.4.0], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [trunk], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) From dridi.boukelmoune at gmail.com Fri Apr 3 12:42:06 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 3 Apr 2020 12:42:06 +0000 (UTC) Subject: [master] a67a9d560 Turn pool_task fields into single-element arrays Message-ID: <20200403124206.B70E511EF97@lists.varnish-cache.org> commit a67a9d5606210245dd0c51966698dcd07206c91e Author: Dridi Boukelmoune Date: Fri Apr 3 12:30:11 2020 +0200 Turn pool_task fields into single-element arrays That is, when the struct is embedded in another struct. This is a mechanical change allowing to always treat tasks like pointers. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e661804e7..9cb57970c 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -247,7 +247,7 @@ struct worker { struct VSC_main_wrk *stats; struct vsl_log *vsl; // borrowed from req/bo - struct pool_task task; + struct pool_task task[1]; vtim_real lastused; int strangelove; @@ -409,7 +409,7 @@ struct busyobj { struct http_conn *htc; - struct pool_task fetch_task; + struct pool_task fetch_task[1]; #define BO_FLAG(l, r, w, d) unsigned l:1; #include "tbl/bo_flags.h" @@ -471,7 +471,7 @@ struct req { struct sess *sp; struct worker *wrk; - struct pool_task task; + struct pool_task task[1]; const struct transport *transport; void *transport_priv; diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index b40987e00..d43144dfc 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -73,7 +73,7 @@ struct poolsock { #define POOLSOCK_MAGIC 0x1b0a2d38 VTAILQ_ENTRY(poolsock) list; struct listen_sock *lsock; - struct pool_task task; + struct pool_task task[1]; struct pool *pool; }; @@ -525,7 +525,7 @@ vca_accept_task(struct worker *wrk, void *arg) * taken up by another thread again. */ if (!ps->pool->die) { - AZ(Pool_Task(wrk->pool, &ps->task, + AZ(Pool_Task(wrk->pool, ps->task, TASK_QUEUE_VCA)); return; } @@ -554,11 +554,11 @@ VCA_NewPool(struct pool *pp) ALLOC_OBJ(ps, POOLSOCK_MAGIC); AN(ps); ps->lsock = ls; - ps->task.func = vca_accept_task; - ps->task.priv = ps; + ps->task->func = vca_accept_task; + ps->task->priv = ps; ps->pool = pp; VTAILQ_INSERT_TAIL(&pp->poolsocks, ps, list); - AZ(Pool_Task(pp, &ps->task, TASK_QUEUE_VCA)); + AZ(Pool_Task(pp, ps->task, TASK_QUEUE_VCA)); } } diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 39bc68196..4db99c2c1 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -84,7 +84,7 @@ struct vbp_target { vtim_real due; int running; int heap_idx; - struct pool_task task; + struct pool_task task[1]; }; static struct lock vbp_mtx; @@ -485,10 +485,10 @@ vbp_thread(struct worker *wrk, void *priv) vt->due = now + vt->interval; if (!vt->running) { vt->running = 1; - vt->task.func = vbp_task; - vt->task.priv = vt; + vt->task->func = vbp_task; + vt->task->priv = vt; Lck_Unlock(&vbp_mtx); - r = Pool_Task_Any(&vt->task, TASK_QUEUE_REQ); + r = Pool_Task_Any(vt->task, TASK_QUEUE_REQ); Lck_Lock(&vbp_mtx); if (r) vt->running = 0; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 5319d6a76..f911f7ca7 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -1064,10 +1064,10 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, AZ(bo->req); bo->req = req; - bo->fetch_task.priv = bo; - bo->fetch_task.func = vbf_fetch_thread; + bo->fetch_task->priv = bo; + bo->fetch_task->func = vbf_fetch_thread; - if (Pool_Task(wrk->pool, &bo->fetch_task, TASK_QUEUE_BO)) { + if (Pool_Task(wrk->pool, bo->fetch_task, TASK_QUEUE_BO)) { wrk->stats->fetch_no_thread++; (void)vbf_stp_fail(req->wrk, bo); if (bo->stale_oc != NULL) diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 51d2f972f..831572956 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -634,7 +634,7 @@ hsh_rush2(struct worker *wrk, struct rush *r) * may be vmod_privs to cleanup and we need a proper * workerthread for that. */ - AZ(Pool_Task(req->sp->pool, &req->task, TASK_QUEUE_RUSH)); + AZ(Pool_Task(req->sp->pool, req->task, TASK_QUEUE_RUSH)); } } } diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 8a417fb14..2dd248558 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -73,8 +73,8 @@ SES_SetTransport(struct worker *wrk, struct sess *sp, struct req *req, sp->sattr[SA_TRANSPORT] = xp->number; req->transport = xp; - wrk->task.func = xp->new_session; - wrk->task.priv = req; + wrk->task->func = xp->new_session; + wrk->task->priv = req; } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 1d34efe54..54e962cd7 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -209,7 +209,7 @@ pool_getidleworker(struct pool *pp, enum task_prio prio) CAST_OBJ_NOTNULL(wrk, pt->priv, WORKER_MAGIC); AN(pp->nidle); - VTAILQ_REMOVE(&pp->idle_queue, &wrk->task, list); + VTAILQ_REMOVE(&pp->idle_queue, wrk->task, list); pp->nidle--; return (wrk); @@ -244,11 +244,11 @@ Pool_Task_Arg(struct worker *wrk, enum task_prio prio, task_func_t *func, wrk2 = wrk; retval = 0; } - AZ(wrk2->task.func); + AZ(wrk2->task->func); assert(arg_len <= WS_ReserveSize(wrk2->aws, arg_len)); memcpy(wrk2->aws->f, arg, arg_len); - wrk2->task.func = func; - wrk2->task.priv = wrk2->aws->f; + wrk2->task->func = func; + wrk2->task->priv = wrk2->aws->f; Lck_Unlock(&pp->mtx); // see signaling_note at the top for explanation if (retval) @@ -287,9 +287,9 @@ Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio) wrk = pool_getidleworker(pp, prio); if (wrk != NULL) { - AZ(wrk->task.func); - wrk->task.func = task->func; - wrk->task.priv = task->priv; + AZ(wrk->task->func); + wrk->task->func = task->func; + wrk->task->priv = task->priv; Lck_Unlock(&pp->mtx); // see signaling_note at the top for explanation AZ(pthread_cond_signal(&wrk->cond)); @@ -383,9 +383,9 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk) /* Nothing to do: To sleep, perchance to dream ... */ if (isnan(wrk->lastused)) wrk->lastused = VTIM_real(); - wrk->task.func = NULL; - wrk->task.priv = wrk; - VTAILQ_INSERT_HEAD(&pp->idle_queue, &wrk->task, list); + wrk->task->func = NULL; + wrk->task->priv = wrk; + VTAILQ_INSERT_HEAD(&pp->idle_queue, wrk->task, list); pp->nidle++; do { // see signaling_note at the top for explanation @@ -398,8 +398,8 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk) i = Lck_CondWait(&wrk->cond, &pp->mtx, tmo); if (i == ETIMEDOUT) VCL_Rel(&wrk->vcl); - } while (wrk->task.func == NULL); - tpx = wrk->task; + } while (wrk->task->func == NULL); + tpx = *wrk->task; tp = &tpx; wrk->stats->summs++; } @@ -414,7 +414,7 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk) tp->func(wrk, tp->priv); if (DO_DEBUG(DBG_VCLREL) && wrk->vcl != NULL) VCL_Rel(&wrk->vcl); - tpx = wrk->task; + tpx = *wrk->task; tp = &tpx; } while (tp->func != NULL); @@ -586,9 +586,9 @@ pool_herder(void *priv) pp->nthr > cache_param->wthread_max) { /* Give it a kiss on the cheek... */ VTAILQ_REMOVE(&pp->idle_queue, - &wrk->task, list); + wrk->task, list); pp->nidle--; - wrk->task.func = pool_kiss_of_death; + wrk->task->func = pool_kiss_of_death; AZ(pthread_cond_signal(&wrk->cond)); } else { delay = wrk->lastused - t_idle; diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 67ab7016b..ff4aaa72b 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -124,8 +124,8 @@ http1_new_session(struct worker *wrk, void *arg) return; } http1_setstate(sp, H1NEWREQ); - wrk->task.func = http1_req; - wrk->task.priv = req; + wrk->task->func = http1_req; + wrk->task->priv = req; } static void v_matchproto_(task_func_t) @@ -142,8 +142,8 @@ http1_unwait(struct worker *wrk, void *arg) req->htc->rfd = &sp->fd; HTC_RxInit(req->htc, req->ws); http1_setstate(sp, H1NEWREQ); - wrk->task.func = http1_req; - wrk->task.priv = req; + wrk->task->func = http1_req; + wrk->task->priv = req; } static void v_matchproto_(vtr_req_body_t) @@ -392,8 +392,8 @@ HTTP1_Session(struct worker *wrk, struct req *req) req->req_step = R_STP_TRANSPORT; http1_setstate(sp, H1PROC); } else if (st == H1PROC) { - req->task.func = http1_req; - req->task.priv = req; + req->task->func = http1_req; + req->task->priv = req; wrk->stats->client_req++; CNT_Embark(wrk, req); if (req->req_step == R_STP_TRANSPORT) { @@ -403,8 +403,8 @@ HTTP1_Session(struct worker *wrk, struct req *req) if (CNT_Request(req) == REQ_FSM_DISEMBARK) return; AZ(req->top->vcl0); - req->task.func = NULL; - req->task.priv = NULL; + req->task->func = NULL; + req->task->priv = NULL; AZ(req->ws->r); AZ(wrk->aws->r); http1_setstate(sp, H1CLEANUP); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 317b3287b..704b5cc94 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -598,10 +598,10 @@ h2_end_headers(struct worker *wrk, struct h2_sess *h2, AN(req->http->hd[HTTP_HDR_PROTO].b); req->req_step = R_STP_TRANSPORT; - req->task.func = h2_do_req; - req->task.priv = req; + req->task->func = h2_do_req; + req->task->priv = req; r2->scheduled = 1; - if (Pool_Task(wrk->pool, &req->task, TASK_QUEUE_STR) != 0) { + if (Pool_Task(wrk->pool, req->task, TASK_QUEUE_STR) != 0) { r2->scheduled = 0; r2->state = H2_S_CLOSED; return (H2SE_REFUSED_STREAM); //rfc7540,l,3326,3329 diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 543eea868..571a42843 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -278,8 +278,8 @@ h2_ou_session(struct worker *wrk, struct h2_sess *h2, r2 = h2_new_req(wrk, h2, 1, req); req->transport = &H2_transport; req->req_step = R_STP_TRANSPORT; - req->task.func = h2_do_req; - req->task.priv = req; + req->task->func = h2_do_req; + req->task->priv = req; r2->scheduled = 1; r2->state = H2_S_CLOS_REM; // rfc7540,l,489,491 req->err_code = 0; @@ -295,7 +295,7 @@ h2_ou_session(struct worker *wrk, struct h2_sess *h2, h2_del_req(wrk, r2); return (0); } - if (Pool_Task(wrk->pool, &req->task, TASK_QUEUE_REQ)) { + if (Pool_Task(wrk->pool, req->task, TASK_QUEUE_REQ)) { r2->scheduled = 0; h2_del_req(wrk, r2); VSLb(h2->vsl, SLT_Debug, "H2: No Worker-threads"); From phk at FreeBSD.org Fri Apr 3 12:58:06 2020 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 3 Apr 2020 12:58:06 +0000 (UTC) Subject: [master] f17743d6e Flexelinting Message-ID: <20200403125806.2AE5011F5E0@lists.varnish-cache.org> commit f17743d6ed22d0c08d929689bd61a71a11ff4f07 Author: Poul-Henning Kamp Date: Fri Apr 3 12:56:45 2020 +0000 Flexelinting diff --git a/lib/libvmod_cookie/flint.lnt b/lib/libvmod_cookie/flint.lnt new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libvmod_cookie/flint.sh b/lib/libvmod_cookie/flint.sh new file mode 100755 index 000000000..522e30d4d --- /dev/null +++ b/lib/libvmod_cookie/flint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +FLOPS=' + -I../../bin/varnishd + *.c +' + +. ../../tools/flint_skel.sh diff --git a/lib/libvmod_cookie/vmod_cookie.c b/lib/libvmod_cookie/vmod_cookie.c index d4b71cdd7..87a963e33 100644 --- a/lib/libvmod_cookie/vmod_cookie.c +++ b/lib/libvmod_cookie/vmod_cookie.c @@ -146,7 +146,7 @@ vmod_parse(VRT_CTX, struct vmod_priv *priv, VCL_STRING cookieheader) } static struct cookie * -find_cookie(struct vmod_cookie *vcp, VCL_STRING name) +find_cookie(const struct vmod_cookie *vcp, VCL_STRING name) { struct cookie *cookie; diff --git a/lib/libvmod_proxy/flint.sh b/lib/libvmod_proxy/flint.sh new file mode 100755 index 000000000..522e30d4d --- /dev/null +++ b/lib/libvmod_proxy/flint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +FLOPS=' + -I../../bin/varnishd + *.c +' + +. ../../tools/flint_skel.sh diff --git a/lib/libvmod_unix/flint.lnt b/lib/libvmod_unix/flint.lnt new file mode 100644 index 000000000..e69de29bb diff --git a/lib/libvmod_unix/flint.sh b/lib/libvmod_unix/flint.sh new file mode 100755 index 000000000..522e30d4d --- /dev/null +++ b/lib/libvmod_unix/flint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +FLOPS=' + -I../../bin/varnishd + *.c +' + +. ../../tools/flint_skel.sh From nils.goroll at uplex.de Fri Apr 3 17:22:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 3 Apr 2020 17:22:07 +0000 (UTC) Subject: [master] 3e5d5f29e try to stabilize test Message-ID: <20200403172207.50606102185@lists.varnish-cache.org> commit 3e5d5f29e8648030be8b7daaed7426a73972d76a Author: Nils Goroll Date: Fri Apr 3 14:44:27 2020 +0200 try to stabilize test Yes, we do not want to rely on timing, but I do not see how we could test the lru_interval timer otherwise seen in vtc: ---- v1 Not true: MAIN.n_lru_moved (0) == 1 (1) * top RESETTING after ../../../../bin/varnishtest/tests/r02527.vtc ** s1 Waiting for server (3/-1) ** v1 Wait diff --git a/bin/varnishtest/tests/r02527.vtc b/bin/varnishtest/tests/r02527.vtc index ae8ed0364..c70739c97 100644 --- a/bin/varnishtest/tests/r02527.vtc +++ b/bin/varnishtest/tests/r02527.vtc @@ -18,7 +18,7 @@ client c1 { varnish v1 -expect MAIN.n_lru_moved == 0 -delay 1 +delay 2 client c1 { txreq From nils.goroll at uplex.de Fri Apr 3 17:22:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 3 Apr 2020 17:22:07 +0000 (UTC) Subject: [master] d3b6409ea vbf_stp_condfetch: handle storage error instead of crashing Message-ID: <20200403172207.638DE102188@lists.varnish-cache.org> commit d3b6409ea3f52851aa63fde8120af5cfc430db8b Author: Emanuele Rocca Date: Fri Apr 3 17:10:22 2020 +0200 vbf_stp_condfetch: handle storage error instead of crashing Fixes: #3273 diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index f911f7ca7..036108954 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -733,7 +733,12 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) AZ(stale_boc); AZ(bo->stale_oc->flags & OC_F_FAILED); - AZ(vbf_beresp2obj(bo)); + if (vbf_beresp2obj(bo)) { + (void)VFP_Error(bo->vfc, "Could not get storage in vbf_stp_condfetch"); + vbf_cleanup(bo); + wrk->stats->fetch_failed++; + return (F_STP_FAIL); + } if (ObjHasAttr(bo->wrk, bo->stale_oc, OA_ESIDATA)) AZ(ObjCopyAttr(bo->wrk, bo->fetch_objcore, bo->stale_oc, diff --git a/bin/varnishtest/tests/v00064.vtc b/bin/varnishtest/tests/v00064.vtc new file mode 100644 index 000000000..8a608e38e --- /dev/null +++ b/bin/varnishtest/tests/v00064.vtc @@ -0,0 +1,66 @@ +varnishtest "vbf_stp_condfetch could not get storage #3273" + +server s1 { + rxreq + expect req.url == "/transient" + txresp -bodylen 1048400 + + rxreq + expect req.url == "/malloc" + txresp -hdr "Cache-Control: max-age=2" -hdr "Last-Modified: Fri, 03 Apr 2020 13:00:01 GMT" -bodylen 1048300 + + rxreq + expect req.http.If-Modified-Since == "Fri, 03 Apr 2020 13:00:01 GMT" + expect req.url == "/malloc" + txresp -status 304 +} -start + +varnish v1 \ + -arg "-s Transient=default,1m" \ + -arg "-s malloc,1m" \ + -arg "-p nuke_limit=0" \ + -syntax 4.0 \ + -vcl+backend { + sub vcl_backend_response { + if (bereq.url == "/transient") { + set beresp.storage = storage.Transient; + # Unset Date header to not change the object sizes + unset beresp.http.Date; + } + } +} -start + +varnish v1 -cliok "param.set debug +syncvsl" + +delay .1 + +client c1 { + # Fill transient + txreq -url "/transient" + rxresp + expect resp.status == 200 +} -run + +delay .1 + +varnish v1 -expect SM?.Transient.g_bytes > 1048000 +varnish v1 -expect SM?.Transient.g_space == 8 + +client c1 { + # Fill malloc + txreq -url "/malloc" -hdr "If-Modified-Since: Fri, 03 Apr 2020 12:00:01 GMT" + rxresp + expect resp.status == 200 + + delay 3 +} -run + +varnish v1 -expect SM?.s0.g_bytes > 1048000 +varnish v1 -expect SM?.s0.g_space == 4 + +client c1 { + # Check that Varnish is still alive + txreq -url "/malloc" -hdr "If-Modified-Since: Fri, 03 Apr 2020 12:00:01 GMT" + rxresp + expect resp.status == 200 +} -run From nils.goroll at uplex.de Sat Apr 4 11:12:11 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 11:12:11 +0000 (UTC) Subject: [master] 119b41747 polish: remove a superfluous variable Message-ID: <20200404111211.73723119AE7@lists.varnish-cache.org> commit 119b41747f9dd3360d1fe1ea1cb181c9aefb2e81 Author: Nils Goroll Date: Sat Apr 4 12:28:22 2020 +0200 polish: remove a superfluous variable diff --git a/lib/libvarnish/vsa.c b/lib/libvarnish/vsa.c index 3f842458d..6c593132f 100644 --- a/lib/libvarnish/vsa.c +++ b/lib/libvarnish/vsa.c @@ -316,18 +316,16 @@ VSA_Build(void *d, const void *s, unsigned sal) { struct suckaddr *sua = d; const struct sockaddr *sa = s; - unsigned l; AN(d); AN(s); - l = sua_len(sa); - if (l == 0 || l != sal) + if (sal == 0 || sua_len(sa) != sal) return (NULL); INIT_OBJ(sua, SUCKADDR_MAGIC); - memcpy(&sua->sa, s, l); + memcpy(&sua->sa, s, sal); #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - sua->sa.sa_len = (unsigned char)l; + sua->sa.sa_len = (unsigned char)sal; #endif return (sua); } From nils.goroll at uplex.de Sat Apr 4 11:12:11 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 11:12:11 +0000 (UTC) Subject: [master] 39a03ec60 Avoid flexelint 419 warning for memcpy to a union Message-ID: <20200404111211.8F8D9119AEA@lists.varnish-cache.org> commit 39a03ec60cfb48602d78530de04549fd6012dc41 Author: Nils Goroll Date: Sat Apr 4 12:28:54 2020 +0200 Avoid flexelint 419 warning for memcpy to a union Closes #3275 diff --git a/lib/libvarnish/vsa.c b/lib/libvarnish/vsa.c index 6c593132f..31703c547 100644 --- a/lib/libvarnish/vsa.c +++ b/lib/libvarnish/vsa.c @@ -323,7 +323,16 @@ VSA_Build(void *d, const void *s, unsigned sal) return (NULL); INIT_OBJ(sua, SUCKADDR_MAGIC); - memcpy(&sua->sa, s, sal); + switch (sal) { + case sizeof sua->sa4: + memcpy(&sua->sa4, s, sal); + break; + case sizeof sua->sa6: + memcpy(&sua->sa6, s, sal); + break; + default: + WRONG("VSA protocol vs. size"); + } #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN sua->sa.sa_len = (unsigned char)sal; #endif From nils.goroll at uplex.de Sat Apr 4 11:12:11 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 11:12:11 +0000 (UTC) Subject: [master] e53414140 Assert on malloc to succeed Message-ID: <20200404111211.AA354119AED@lists.varnish-cache.org> commit e53414140973820dca9e96d42f29f005599de4dd Author: Nils Goroll Date: Sat Apr 4 12:34:26 2020 +0200 Assert on malloc to succeed This ticks off an XXX comment: We basically assert on malloc to succeed everywhere, so we should stick with it here, too. diff --git a/lib/libvarnish/vsa.c b/lib/libvarnish/vsa.c index 31703c547..a2cab79df 100644 --- a/lib/libvarnish/vsa.c +++ b/lib/libvarnish/vsa.c @@ -248,11 +248,7 @@ VSA_Malloc(const void *s, unsigned sal) void *d; d = malloc(vsa_suckaddr_len); - /* XXX: shouldn't we AN(sua) instead of mixing up failed allocations - * with unsupported address family or bogus sockaddr? - */ - if (d == NULL) - return (NULL); + AN(d); return (VSA_Build(d, s, sal)); } From nils.goroll at uplex.de Sat Apr 4 11:12:11 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 11:12:11 +0000 (UTC) Subject: [master] 9168ee5ed help flexelint understand what happens with memory Message-ID: <20200404111211.C47C1119AF2@lists.varnish-cache.org> commit 9168ee5edc83fecc1ac2d2ec27ecd4edeef1ff90 Author: Nils Goroll Date: Sat Apr 4 12:39:52 2020 +0200 help flexelint understand what happens with memory Flexelint sput warning 429 that the malloc() return value was neither freed not returned. This simplification makes it clear. The assertion on malloc() having succeeded is in VSA_Build() Ref #3275 diff --git a/lib/libvarnish/vsa.c b/lib/libvarnish/vsa.c index a2cab79df..03a2ed3e4 100644 --- a/lib/libvarnish/vsa.c +++ b/lib/libvarnish/vsa.c @@ -245,12 +245,7 @@ socklen_t sua_len(const struct sockaddr *sa) struct suckaddr * VSA_Malloc(const void *s, unsigned sal) { - void *d; - - d = malloc(vsa_suckaddr_len); - AN(d); - - return (VSA_Build(d, s, sal)); + return (VSA_Build(malloc(vsa_suckaddr_len), s, sal)); } /* 'd' SHALL point to vsa_suckaddr_len aligned bytes of storage From nils.goroll at uplex.de Sat Apr 4 11:12:11 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 11:12:11 +0000 (UTC) Subject: [master] 2baf7c0b7 flexelinting Message-ID: <20200404111211.DCD38119AF5@lists.varnish-cache.org> commit 2baf7c0b7807fff9292e5f88ed7dad344a58f2e6 Author: Nils Goroll Date: Sat Apr 4 12:46:02 2020 +0200 flexelinting diff --git a/lib/libvarnish/vsa.c b/lib/libvarnish/vsa.c index 03a2ed3e4..2c7be641c 100644 --- a/lib/libvarnish/vsa.c +++ b/lib/libvarnish/vsa.c @@ -305,7 +305,7 @@ VSA_BuildFAP(void *d, sa_family_t fam, const void *a, unsigned al, struct suckaddr * VSA_Build(void *d, const void *s, unsigned sal) { - struct suckaddr *sua = d; + struct suckaddr *sua; const struct sockaddr *sa = s; AN(d); @@ -313,6 +313,8 @@ VSA_Build(void *d, const void *s, unsigned sal) if (sal == 0 || sua_len(sa) != sal) return (NULL); + sua = d; + INIT_OBJ(sua, SUCKADDR_MAGIC); switch (sal) { case sizeof sua->sa4: From nils.goroll at uplex.de Sat Apr 4 11:48:06 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 11:48:06 +0000 (UTC) Subject: [master] 548a4e6ed make test less timing sensitive Message-ID: <20200404114806.DDBA011AC53@lists.varnish-cache.org> commit 548a4e6ed34e6459cdda2a1fdfbbe371fde2195f Author: Nils Goroll Date: Sat Apr 4 13:24:27 2020 +0200 make test less timing sensitive when the second request did not happen within the default backend_remote_error_holddown == 0.25s, we would see two ECONNREFUSED instead of one and a holddown. Seen in vtest: ** top === varnish v1 -expect VBE.vcl1.foo.fail_econnrefused > 0 **** dT 6.132 ** v1 as expected: VBE.vcl1.foo.fail_econnrefused (2) > 0 ** top === varnish v1 -expect VBE.vcl1.foo.helddown > 0 diff --git a/bin/varnishtest/tests/b00015.vtc b/bin/varnishtest/tests/b00015.vtc index 5f3b69c03..396da7899 100644 --- a/bin/varnishtest/tests/b00015.vtc +++ b/bin/varnishtest/tests/b00015.vtc @@ -67,6 +67,8 @@ server s1 { txresp -status 502 } -start +varnish v1 -cliok "param.set backend_remote_error_holddown 10" + varnish v1 -vcl+backend { sub vcl_backend_response { if (beresp.status == 502) { From nils.goroll at uplex.de Sat Apr 4 11:48:06 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 11:48:06 +0000 (UTC) Subject: [master] 413177862 stabilize varnishstat curses mode test Message-ID: <20200404114807.000C911AC56@lists.varnish-cache.org> commit 413177862db791f530b951f7dc13ee34762d6662 Author: Nils Goroll Date: Sat Apr 4 13:40:22 2020 +0200 stabilize varnishstat curses mode test Could be that there is the bereq # printed right next to the client | as in this vtest result: ** top === process p1 -expect-text 22 0 { | } **** dT 3.593 **** v1 vsl| 0 CLI - Rd ping **** v1 vsl| 0 CLI - Wr 200 19 PONG 1585796425 1.0 **** dT 3.806 **** p1 stdout|\x1b[1;10H2\x1b[22;24H|# diff --git a/bin/varnishtest/tests/u00009.vtc b/bin/varnishtest/tests/u00009.vtc index 07743d128..05c14b046 100644 --- a/bin/varnishtest/tests/u00009.vtc +++ b/bin/varnishtest/tests/u00009.vtc @@ -34,7 +34,7 @@ client c1 { varnish v1 -vsl_catchup -process p1 -expect-text 22 0 { | } +process p1 -expect-text 22 0 { |} process p1 -expect-text 3 1 {20_} From nils.goroll at uplex.de Sat Apr 4 11:54:06 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 11:54:06 +0000 (UTC) Subject: [master] 87d003e6e flexelinting Message-ID: <20200404115406.CB9BF11B09E@lists.varnish-cache.org> commit 87d003e6e1dbca2232ff6c5d9354b34c11f3b786 Author: Nils Goroll Date: Sat Apr 4 13:52:48 2020 +0200 flexelinting const char *const bindings_help[] = { varnishstat_curses_help.c 9 Note 9075: external symbol 'bindings_help' defined without a prior declaration _ const int bindings_help_len = 65; varnishstat_curses_help.c 78 Note 9075: external symbol 'bindings_help_len' defined without a prior declaration diff --git a/bin/varnishstat/varnishstat_help_gen.c b/bin/varnishstat/varnishstat_help_gen.c index 1c189bcd8..2b145bed3 100644 --- a/bin/varnishstat/varnishstat_help_gen.c +++ b/bin/varnishstat/varnishstat_help_gen.c @@ -58,6 +58,8 @@ main(void) " */\n" "\n" "#include \n" + "#include \"vdef.h\"\n" + "#include \"varnishstat.h\"\n" "\n" "const char *const bindings_help[] = {\n"); From nils.goroll at uplex.de Sat Apr 4 12:00:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 12:00:07 +0000 (UTC) Subject: [master] 49b407439 stabilize test: do not expect exact byte counts Message-ID: <20200404120007.E44DF11B3CC@lists.varnish-cache.org> commit 49b40743981e695a239c8a32934de19d930267bc Author: Nils Goroll Date: Sat Apr 4 13:58:12 2020 +0200 stabilize test: do not expect exact byte counts Across the platforms we support, the overhead of stevedore allocations varies slightly due to different sizes of our structs. diff --git a/bin/varnishtest/tests/v00064.vtc b/bin/varnishtest/tests/v00064.vtc index 8a608e38e..080029b4d 100644 --- a/bin/varnishtest/tests/v00064.vtc +++ b/bin/varnishtest/tests/v00064.vtc @@ -44,7 +44,7 @@ client c1 { delay .1 varnish v1 -expect SM?.Transient.g_bytes > 1048000 -varnish v1 -expect SM?.Transient.g_space == 8 +varnish v1 -expect SM?.Transient.g_space < 50 client c1 { # Fill malloc @@ -56,7 +56,7 @@ client c1 { } -run varnish v1 -expect SM?.s0.g_bytes > 1048000 -varnish v1 -expect SM?.s0.g_space == 4 +varnish v1 -expect SM?.s0.g_space < 50 client c1 { # Check that Varnish is still alive From nils.goroll at uplex.de Sat Apr 4 12:07:06 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 12:07:06 +0000 (UTC) Subject: [master] 95162cf4b relex expect window even more Message-ID: <20200404120706.E047011B73B@lists.varnish-cache.org> commit 95162cf4b097ee3812513c94b6d13101a11d3005 Author: Nils Goroll Date: Sat Apr 4 14:05:43 2020 +0200 relex expect window even more vtest has seen a case where other workspace debug messages interfered. FTR, it would be nice if we could backref a prior expect in order to expect the same workspace address diff --git a/bin/varnishtest/tests/c00071.vtc b/bin/varnishtest/tests/c00071.vtc index 7b033fcec..7c25657f4 100644 --- a/bin/varnishtest/tests/c00071.vtc +++ b/bin/varnishtest/tests/c00071.vtc @@ -56,7 +56,7 @@ logexpect l1 -v v1 -g vxid -q "vxid == 1006" { logexpect l2 -v v1 -g raw -i Debug { expect * 0 Debug {^WS_Snapshot.* = overflowed} - expect 12 0 Debug {^WS_Reset.*, overflowed} + expect 24 0 Debug {^WS_Reset.*, overflowed} } -start client c2 { From nils.goroll at uplex.de Sat Apr 4 12:40:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 12:40:07 +0000 (UTC) Subject: [master] 4a69e1ae8 another concession to flexelint Message-ID: <20200404124007.0CC3611C299@lists.varnish-cache.org> commit 4a69e1ae81702a5c07af93c31ce6377d874214f2 Author: Nils Goroll Date: Sat Apr 4 14:19:57 2020 +0200 another concession to flexelint I would have preferred avoiding the duplication of the suckaddr member types, but flexelint spits "Warning 550: Symbol 'sua' (line 229) not accessed" diff --git a/lib/libvarnish/vsa.c b/lib/libvarnish/vsa.c index 2c7be641c..edad67d6d 100644 --- a/lib/libvarnish/vsa.c +++ b/lib/libvarnish/vsa.c @@ -226,13 +226,11 @@ VSA_GetPtr(const struct suckaddr *sua, const unsigned char ** dst) static inline socklen_t sua_len(const struct sockaddr *sa) { - struct suckaddr *sua; - switch (sa->sa_family) { case PF_INET: - return (sizeof sua->sa4); + return (sizeof(struct sockaddr_in)); case PF_INET6: - return (sizeof sua->sa6); + return (sizeof(struct sockaddr_in6)); default: return (0); } From nils.goroll at uplex.de Sat Apr 4 12:40:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 12:40:07 +0000 (UTC) Subject: [master] 03463abf5 add back a local variable which makes flexelint grok the code Message-ID: <20200404124007.20A0611C29C@lists.varnish-cache.org> commit 03463abf52bad7a538d0a8b7292892055d7a41f9 Author: Nils Goroll Date: Sat Apr 4 14:32:49 2020 +0200 add back a local variable which makes flexelint grok the code I did not understand when I committed 119b41747f9dd3360d1fe1ea1cb181c9aefb2e81 that the local variable was required for flexelint to unterstand that this is not an out-of-bounds access. This quote of phk from the top level rant sais it all: * Do I need to tell you that static code analysis tools have a * really hard time coping with this, and that they give a lot of * false negatives which confuse people ? So true. Sorry for going a smaller but almost full circle here, I started with good intentions and now all that's left is the desire to leave the code at least a little cleaner as I found it. diff --git a/lib/libvarnish/vsa.c b/lib/libvarnish/vsa.c index edad67d6d..a46e8ac08 100644 --- a/lib/libvarnish/vsa.c +++ b/lib/libvarnish/vsa.c @@ -305,27 +305,29 @@ VSA_Build(void *d, const void *s, unsigned sal) { struct suckaddr *sua; const struct sockaddr *sa = s; + unsigned l; // for flexelint AN(d); AN(s); - if (sal == 0 || sua_len(sa) != sal) + l = sua_len(sa); + if (l == 0 || l != sal) return (NULL); sua = d; INIT_OBJ(sua, SUCKADDR_MAGIC); - switch (sal) { + switch (l) { case sizeof sua->sa4: - memcpy(&sua->sa4, s, sal); + memcpy(&sua->sa4, s, l); break; case sizeof sua->sa6: - memcpy(&sua->sa6, s, sal); + memcpy(&sua->sa6, s, l); break; default: WRONG("VSA protocol vs. size"); } #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN - sua->sa.sa_len = (unsigned char)sal; + sua->sa.sa_len = (unsigned char)l; #endif return (sua); } From nils.goroll at uplex.de Sat Apr 4 13:12:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 13:12:08 +0000 (UTC) Subject: [master] 0ce0d37c3 Clean up the mgt->vcc interface for vcc_acl_pedantic Message-ID: <20200404131208.A651111CF44@lists.varnish-cache.org> commit 0ce0d37c3df9dbc47afabe3360ea37e51db5d9f7 Author: Nils Goroll Date: Sat Apr 4 14:59:28 2020 +0200 Clean up the mgt->vcc interface for vcc_acl_pedantic Spotted by flexelint Ref: 6c8f25e712bcd59b85a0486044eba740848a739b diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index 8f742e16c..39e9ddcd3 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -68,6 +68,7 @@ const char *mgt_vmod_path; unsigned mgt_vcc_err_unref; unsigned mgt_vcc_allow_inline_c; unsigned mgt_vcc_unsafe_path; +unsigned mgt_vcc_acl_pedantic; #define VGC_SRC "vgc.c" @@ -109,6 +110,7 @@ run_vcc(void *priv) VCC_Err_Unref(vcc, mgt_vcc_err_unref); VCC_Allow_InlineC(vcc, mgt_vcc_allow_inline_c); VCC_Unsafe_Path(vcc, mgt_vcc_unsafe_path); + VCC_Acl_Pedantic(vcc, mgt_vcc_acl_pedantic); STV_Foreach(stv) VCC_Predef(vcc, "VCL_STEVEDORE", stv->ident); VTAILQ_FOREACH(vpg, &vclhead, list) diff --git a/include/libvcc.h b/include/libvcc.h index 3bf2d1ea1..63cd136a0 100644 --- a/include/libvcc.h +++ b/include/libvcc.h @@ -37,6 +37,7 @@ void VCC_Allow_InlineC(struct vcc *, unsigned); void VCC_Builtin_VCL(struct vcc *, const char *); void VCC_Err_Unref(struct vcc *, unsigned); void VCC_Unsafe_Path(struct vcc *, unsigned); +void VCC_Acl_Pedantic(struct vcc *, unsigned); void VCC_VCL_path(struct vcc *, const char *); void VCC_VMOD_path(struct vcc *, const char *); void VCC_Predef(struct vcc *, const char *type, const char *name); diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index 274f158de..c3fb9a6ce 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -43,8 +43,6 @@ #include #include -unsigned mgt_vcc_acl_pedantic; - #define ACL_MAXADDR (sizeof(struct in6_addr) + 1) struct acl_e { @@ -140,12 +138,12 @@ vcc_acl_chk(struct vcc *tl, const struct acl_e *ae, const int l, AN(sa); VTCP_name(sa, h, sizeof h, NULL, 0); bprintf(t, "%s/%d", h, ae->mask); - if (mgt_vcc_acl_pedantic) + if (tl->acl_pedantic != 0) VSB_printf(tl->sb, "Address/Netmask mismatch, need be %s\n", t); else VSB_printf(tl->sb, "Address/Netmask mismatch, changed to %s\n", t); vcc_ErrWhere(tl, ae->t_addr); - if (mgt_vcc_acl_pedantic == 0) + if (tl->acl_pedantic == 0) vcc_Warn(tl); return (strdup(t)); } diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index 87c6614e9..94fabd984 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -913,6 +913,14 @@ VCC_Unsafe_Path(struct vcc *vcc, unsigned u) vcc->unsafe_path = u; } +void +VCC_Acl_Pedantic(struct vcc *vcc, unsigned u) +{ + + CHECK_OBJ_NOTNULL(vcc, VCC_MAGIC); + vcc->acl_pedantic = u; +} + /*-------------------------------------------------------------------- * Configure settings */ diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index 6a291c50b..f47b6dede 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -222,6 +222,7 @@ struct vcc { unsigned err_unref; unsigned allow_inline_c; unsigned unsafe_path; + unsigned acl_pedantic; struct symtab *syms; From nils.goroll at uplex.de Sat Apr 4 13:12:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 13:12:08 +0000 (UTC) Subject: [master] 3df0771d3 exclude the curses help generator from flexelint runs Message-ID: <20200404131208.C162211CF47@lists.varnish-cache.org> commit 3df0771d3e06420c9f5c82b96ef0943a5d331397 Author: Nils Goroll Date: Sat Apr 4 15:02:23 2020 +0200 exclude the curses help generator from flexelint runs diff --git a/bin/varnishstat/flint.sh b/bin/varnishstat/flint.sh index 631bb1394..67dd342d4 100755 --- a/bin/varnishstat/flint.sh +++ b/bin/varnishstat/flint.sh @@ -1,7 +1,10 @@ #!/bin/sh FLOPS=' - *.c + varnishstat.c + varnishstat_curses.c + varnishstat_curses_help.c + ../../lib/libvarnishapi/flint.lnt ../../lib/libvarnishapi/*.c ' From nils.goroll at uplex.de Sat Apr 4 13:12:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 13:12:08 +0000 (UTC) Subject: [master] ea5917c60 fix an oversight from the pool_task field to array change Message-ID: <20200404131208.E428711CF4A@lists.varnish-cache.org> commit ea5917c601b97f64c31f2595bf74a5f1ef3e18fd Author: Nils Goroll Date: Sat Apr 4 15:05:42 2020 +0200 fix an oversight from the pool_task field to array change spotted by flexelint Ref a67a9d5606210245dd0c51966698dcd07206c91e diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 54e962cd7..13a7cb8ac 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -409,7 +409,7 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk) break; do { - memset(&wrk->task, 0, sizeof wrk->task); + memset(wrk->task, 0, sizeof wrk->task); assert(wrk->pool == pp); tp->func(wrk, tp->priv); if (DO_DEBUG(DBG_VCLREL) && wrk->vcl != NULL) From nils.goroll at uplex.de Sat Apr 4 15:14:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 15:14:07 +0000 (UTC) Subject: [master] cc8740e72 signedness fixes Message-ID: <20200404151407.BB87911F890@lists.varnish-cache.org> commit cc8740e72825a551315d4155595d3c3d0d0082cd Author: Nils Goroll Date: Sat Apr 4 17:09:15 2020 +0200 signedness fixes reported by flexelint diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c index b174f3142..f825273b2 100644 --- a/bin/varnishd/proxy/cache_proxy_proto.c +++ b/bin/varnishd/proxy/cache_proxy_proto.c @@ -320,7 +320,6 @@ VPX_tlv(const struct req *req, int typ, void **dst, int *len) static int vpx_proto2(const struct worker *wrk, struct req *req) { - int l, hdr_len; uintptr_t *up; uint16_t tlv_len; const uint8_t *p, *ap, *pp; @@ -333,7 +332,7 @@ vpx_proto2(const struct worker *wrk, struct req *req) char pb[VTCP_PORTBUFSIZE]; struct vpx_tlv_iter vpi[1], vpi2[1]; struct vpx_tlv *tlv; - unsigned flen, alen; + unsigned l, hdr_len, flen, alen; unsigned const plen = 2, aoff = 16; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -343,7 +342,7 @@ vpx_proto2(const struct worker *wrk, struct req *req) assert(req->htc->rxbuf_e - req->htc->rxbuf_b >= 16L); l = vbe16dec(req->htc->rxbuf_b + 14); hdr_len = l + 16L; - assert(req->htc->rxbuf_e - req->htc->rxbuf_b >= hdr_len); + assert(req->htc->rxbuf_e >= req->htc->rxbuf_b + hdr_len); HTC_RxPipeline(req->htc, req->htc->rxbuf_b + hdr_len); WS_Rollback(req->ws, 0); p = (const void *)req->htc->rxbuf_b; @@ -398,7 +397,7 @@ vpx_proto2(const struct worker *wrk, struct req *req) if (l < flen) { VSL(SLT_ProxyGarbage, req->sp->vxid, - "PROXY2: Ignoring short %s addresses (%d)", + "PROXY2: Ignoring short %s addresses (%u)", pfam == AF_INET ? "IPv4" : "IPv6", l); return (0); } diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index c3fb9a6ce..60e4321a4 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -115,7 +115,7 @@ vcc_acl_chk(struct vcc *tl, const struct acl_e *ae, const int l, assert (ll >= 0); m %= 8; - if (m && (*p << m & 0xff) != 0) { + if (m && (*p << m & UINT8_C(0xff)) != 0) { ret = 1; m = 0xff00 >> m; *p &= m; From nils.goroll at uplex.de Sat Apr 4 15:14:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 15:14:07 +0000 (UTC) Subject: [master] 30861fb4d copy over some flexelint silencing from libvarnish Message-ID: <20200404151407.CD2CB11F893@lists.varnish-cache.org> commit 30861fb4da98e10395ace06e74dd62360dbc7510 Author: Nils Goroll Date: Sat Apr 4 17:12:50 2020 +0200 copy over some flexelint silencing from libvarnish diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index 3d682d52f..d9175cacd 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -151,6 +151,10 @@ -e441 // for clause irregularity: loop variable '___' not found in 2nd for expression +// from libvarnish +--emacro((835),BINHEAP_NOIDX) +--emacro((835),O_CLOEXEC) + // Review all below this line /////////////////////////////////////////////// -e713 // 42 Loss of precision (___) (___ to ___) From nils.goroll at uplex.de Sat Apr 4 15:29:06 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 15:29:06 +0000 (UTC) Subject: [master] dfcfbf59c assertion for flexelint Message-ID: <20200404152906.A3A2411FF9D@lists.varnish-cache.org> commit dfcfbf59c9cf1b5cd144d8be519cc72ca8766105 Author: Nils Goroll Date: Sat Apr 4 17:15:43 2020 +0200 assertion for flexelint diff --git a/lib/libvcc/vcc_xref.c b/lib/libvcc/vcc_xref.c index eff883274..483805f3d 100644 --- a/lib/libvcc/vcc_xref.c +++ b/lib/libvcc/vcc_xref.c @@ -141,7 +141,8 @@ vcc_AddUses(struct vcc *tl, const struct token *t1, const struct token *t2, VTAILQ_INSERT_TAIL(&tl->curproc->uses, pu, list); if (pu->mask == 0) - vcc_CheckUses(tl); + if (vcc_CheckUses(tl)) + AN(tl->err); } void From nils.goroll at uplex.de Sat Apr 4 15:29:06 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 15:29:06 +0000 (UTC) Subject: [master] 417e93486 signedness fix Message-ID: <20200404152906.B5EF911FFA0@lists.varnish-cache.org> commit 417e93486405a95f204948e37b38b57ce3213b40 Author: Nils Goroll Date: Sat Apr 4 17:18:06 2020 +0200 signedness fix reported by flexelint diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c index 0fc157ef8..8d842365e 100644 --- a/bin/varnishd/storage/storage_file.c +++ b/bin/varnishd/storage/storage_file.c @@ -379,7 +379,7 @@ smf_open_chunk(struct smf_sc *sc, off_t sz, off_t off, off_t *fail, off_t *sum) AN(sz); AZ(sz % sc->pagesize); - if (*fail < (uintmax_t)sc->pagesize * MINPAGES) + if (*fail < (off_t)sc->pagesize * MINPAGES) return; if (sz > 0 && sz < *fail && sz < SSIZE_MAX) { From nils.goroll at uplex.de Sat Apr 4 15:29:06 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 15:29:06 +0000 (UTC) Subject: [master] 6a3cff82e take 2 on this signedness fix Message-ID: <20200404152906.CFD3711FFA3@lists.varnish-cache.org> commit 6a3cff82e820031604ff9e77f67ad66b2c384b81 Author: Nils Goroll Date: Sat Apr 4 17:24:55 2020 +0200 take 2 on this signedness fix sorry, I got the first attempt wrong diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index 60e4321a4..689455926 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -115,7 +115,7 @@ vcc_acl_chk(struct vcc *tl, const struct acl_e *ae, const int l, assert (ll >= 0); m %= 8; - if (m && (*p << m & UINT8_C(0xff)) != 0) { + if (m && ((unsigned)*p << m & 0xff) != 0) { ret = 1; m = 0xff00 >> m; *p &= m; From nils.goroll at uplex.de Sat Apr 4 17:50:13 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 17:50:13 +0000 (UTC) Subject: [master] 586bfa496 add obj.can_esi Message-ID: <20200404175013.658E062B47@lists.varnish-cache.org> commit 586bfa496bf6ea9604d14ebdc2a0c3ac106b7d83 Author: Nils Goroll Date: Sat Apr 4 18:22:30 2020 +0200 add obj.can_esi Ref #3002 diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 8409511f8..a94606daf 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -442,6 +442,17 @@ VRT_r_obj_storage(VRT_CTX) /*--------------------------------------------------------------------*/ +VCL_BOOL +VRT_r_obj_can_esi(VRT_CTX) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC); + return (ObjHasAttr(ctx->req->wrk, ctx->req->objcore, OA_ESIDATA)); +} + +/*--------------------------------------------------------------------*/ + #define REQ_VAR_L(nm, elem, type, extra) \ \ VCL_VOID \ diff --git a/bin/varnishtest/tests/e00000.vtc b/bin/varnishtest/tests/e00000.vtc index 844855061..3030a11c7 100644 --- a/bin/varnishtest/tests/e00000.vtc +++ b/bin/varnishtest/tests/e00000.vtc @@ -12,6 +12,9 @@ varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.do_esi = true; } + sub vcl_deliver { + set resp.http.can_esi = obj.can_esi; + } } -start logexpect l1 -v v1 -g raw { @@ -23,6 +26,7 @@ client c1 { rxresp expect resp.status == 200 expect resp.bodylen == 33 + expect resp.http.can_esi == "false" } client c1 -run diff --git a/bin/varnishtest/tests/e00001.vtc b/bin/varnishtest/tests/e00001.vtc index be0b0c15c..8a4a42480 100644 --- a/bin/varnishtest/tests/e00001.vtc +++ b/bin/varnishtest/tests/e00001.vtc @@ -17,6 +17,9 @@ varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.do_esi = true; } + sub vcl_deliver { + set resp.http.can_esi = obj.can_esi; + } } -start logexpect l1 -v v1 -g raw { @@ -29,6 +32,7 @@ client c1 { rxresp expect resp.status == 200 expect resp.bodylen == 40 + expect resp.http.can_esi == "true" } client c1 -run diff --git a/bin/varnishtest/tests/e00003.vtc b/bin/varnishtest/tests/e00003.vtc index 0a1d657ad..929e6515c 100644 --- a/bin/varnishtest/tests/e00003.vtc +++ b/bin/varnishtest/tests/e00003.vtc @@ -32,12 +32,15 @@ varnish v1 -vcl+backend { set beresp.do_esi = true; } } + sub vcl_deliver { + set resp.http.can_esi = obj.can_esi; + } } -start logexpect l1 -v v1 -g request { expect 0 1001 Begin "^req .* rxreq" # ReqAcct body counts include chunked overhead - expect * = ReqAcct "^29 0 29 187 104 291$" + expect * = ReqAcct "^29 0 29 202 104 306$" expect 0 = End } -start @@ -61,7 +64,7 @@ logexpect l5 -v v1 -g request { expect * 1005 Begin "^req .* rxreq" # ReqAcct body counts include chunked overhead # Header bytes is 5 larger than in l1 due to two item X-Varnish hdr - expect * = ReqAcct "^29 0 29 192 104 296$" + expect * = ReqAcct "^29 0 29 207 104 311$" expect 0 = End } -start @@ -70,6 +73,7 @@ client c1 { rxresp expect resp.bodylen == 75 expect resp.status == 200 + expect resp.http.can_esi == "true" delay .1 # test that there is no difference on miss/hit @@ -77,6 +81,7 @@ client c1 { rxresp expect resp.bodylen == 75 expect resp.status == 200 + expect resp.http.can_esi == "true" } client c1 -run diff --git a/bin/varnishtest/tests/e00032.vtc b/bin/varnishtest/tests/e00032.vtc index 96c9e8deb..137647465 100644 --- a/bin/varnishtest/tests/e00032.vtc +++ b/bin/varnishtest/tests/e00032.vtc @@ -14,12 +14,16 @@ varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.do_esi = true; } + sub vcl_deliver { + set resp.http.can_esi = obj.can_esi; + } } -start client c1 { txreq -hdr "Accept-Encoding: gzip" rxresp expect resp.status == 200 + expect resp.http.can_esi == "true" gunzip expect resp.bodylen == 3 } -run diff --git a/doc/sphinx/reference/vcl_var.rst b/doc/sphinx/reference/vcl_var.rst index ab7d96df7..a26c6d7ff 100644 --- a/doc/sphinx/reference/vcl_var.rst +++ b/doc/sphinx/reference/vcl_var.rst @@ -1107,6 +1107,18 @@ obj.storage The storage backend where this object is stored. +obj.can_esi + + Type: BOOL + + Readable from: vcl_hit, vcl_deliver + + If the object can be ESI processed, that is if setting + ``resp.do_esi`` or adding ``esi`` to ``resp.filters`` in + ``vcl_deliver {}`` would cause the response body to be ESI + processed. + + resp ~~~~ From nils.goroll at uplex.de Sat Apr 4 17:50:13 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 17:50:13 +0000 (UTC) Subject: [master] 9fa55a59f polish rst formatting Message-ID: <20200404175013.5746562B45@lists.varnish-cache.org> commit 9fa55a59fed54bcd1c41a3c346a5be304d2ebd58 Author: Nils Goroll Date: Sat Apr 4 17:54:11 2020 +0200 polish rst formatting diff --git a/doc/sphinx/reference/vcl_var.rst b/doc/sphinx/reference/vcl_var.rst index 62c768fdd..ab7d96df7 100644 --- a/doc/sphinx/reference/vcl_var.rst +++ b/doc/sphinx/reference/vcl_var.rst @@ -12,24 +12,24 @@ Reading a variable is done simply by using its name in VCL:: return (synth(400)); } -Writing a variable, where this is possible, is done with a `set` +Writing a variable, where this is possible, is done with a ``set`` statement:: set resp.http.never = "Let You Down"; Similarly, deleting a variable, for the few variables where this is -possible, is done with a `unset` statement:: +possible, is done with a ``unset`` statement:: unset req.http.cookie; Which operations are possible on each variable is described below, -often with the shorthand "backend" which covers the `vcl_backend_*` -subroutines and "client" which covers the rest, except `vcl_init` -and `vcl_fini`. +often with the shorthand "backend" which covers the ``vcl_backend_* {}`` +subroutines and "client" which covers the rest, except ``vcl_init {}`` +and ``vcl_fini {}``. When setting a variable, the right hand side of the equal sign must have the variables type, you cannot assign a STRING to -a variable of type NUMBER, even if the string is `"42"`. +a variable of type NUMBER, even if the string is ``"42"``. (Explicit conversion functions can be found in :ref:`vmod_std(3)`). @@ -61,10 +61,10 @@ local.ip Readable from: client, backend The IP address (and port number) of the local end of the - TCP connection, for instance `192.168.1.1:81` + TCP connection, for instance ``192.168.1.1:81`` If the connection is a UNIX domain socket, the value - will be `0.0.0.0:0` + will be ``0.0.0.0:0`` local.endpoint ``VCL >= 4.1`` @@ -74,7 +74,7 @@ local.endpoint ``VCL >= 4.1`` The address of the '-a' socket the session was accepted on. - If the argument was `-a foo=:81` this would be ":81" + If the argument was ``-a foo=:81`` this would be ":81" local.socket ``VCL >= 4.1`` @@ -85,9 +85,9 @@ local.socket ``VCL >= 4.1`` The name of the '-a' socket the session was accepted on. - If the argument was `-a foo=:81` this would be "foo". + If the argument was ``-a foo=:81`` this would be "foo". - Note that all '-a' gets a default name on the form `a%d` + Note that all '-a' gets a default name on the form ``a%d`` if no name is provided. remote.ip @@ -101,7 +101,7 @@ remote.ip of a proxy server. If the connection is a UNIX domain socket, the value - will be `0.0.0.0:0` + will be ``0.0.0.0:0`` client.ip @@ -110,7 +110,7 @@ client.ip Readable from: client, backend - The client's IP address, either the same as `local.ip` + The client's IP address, either the same as ``local.ip`` or what the PROXY protocol told us. client.identity @@ -123,10 +123,10 @@ client.identity Identification of the client, used to load balance - in the client director. Defaults to `client.ip` + in the client director. Defaults to ``client.ip`` This variable can be overwritten with more precise - information, for instance extracted from a `Cookie:` + information, for instance extracted from a ``Cookie:`` header. @@ -138,7 +138,7 @@ server.ip The IP address of the socket on which the client - connection was received, either the same as `server.ip` + connection was received, either the same as ``server.ip`` or what the PROXY protocol told us. @@ -158,9 +158,9 @@ server.identity Readable from: all - The identity of the server, as set by the `-i` parameter. + The identity of the server, as set by the ``-i`` parameter. - If an `-i` parameter is not passed to varnishd, the return + If an ``-i`` parameter is not passed to varnishd, the return value from `gethostname(3)` system function will be used. req and req_top @@ -249,10 +249,10 @@ req.http.* Unsetable from: client - The headers of request, things like `req.http.date`. + The headers of request, things like ``req.http.date``. The RFCs allow multiple headers with the same name, and both - `set` and `unset` will remove *all* headers with the name given. + ``set`` and ``unset`` will remove *all* headers with the name given. req.restarts @@ -328,9 +328,9 @@ req.esi ``VCL <= 4.0`` Writable from: client - Set to `false` to disable ESI processing + Set to ``false`` to disable ESI processing regardless of any value in beresp.do_esi. Defaults - to `true`. This variable is replaced by `resp.do_esi` + to ``true``. This variable is replaced by ``resp.do_esi`` in VCL 4.1. req.can_gzip @@ -339,8 +339,8 @@ req.can_gzip Readable from: client - True if the client provided `gzip` or `x-gzip` in the - `Accept-Encoding` header. + True if the client provided ``gzip`` or ``x-gzip`` in the + ``Accept-Encoding`` header. req.backend_hint @@ -454,11 +454,11 @@ bereq ~~~~~ This is the request we send to the backend, it is built from the -clients `req.*` fields by filtering out "per-hop" fields which -should not be passed along (`Connection:`, `Range:` and similar). +clients ``req.*`` fields by filtering out "per-hop" fields which +should not be passed along (``Connection:``, ``Range:`` and similar). -Slightly more fields are allowed through for `pass` fetches -than for `miss` fetches, for instance `Range`. +Slightly more fields are allowed through for ``pass` fetches +than for `miss` fetches, for instance ``Range``. bereq @@ -512,7 +512,7 @@ bereq.body The request body. - Unset will also remove `bereq.http.Content-Length`. + Unset will also remove ``bereq.http.Content-Length``. bereq.hash @@ -520,7 +520,7 @@ bereq.hash Readable from: vcl_pipe, backend - The hash key of this request, a copy of `req.hash`. + The hash key of this request, a copy of ``req.hash``. bereq.method @@ -544,7 +544,7 @@ bereq.url Writable from: vcl_pipe, backend - The requested URL, copied from `req.url` + The requested URL, copied from ``req.url`` bereq.proto ``VCL <= 4.0`` @@ -556,7 +556,7 @@ bereq.proto ``VCL <= 4.0`` Writable from: vcl_pipe, backend The HTTP protocol version, "HTTP/1.1" unless a pass or pipe - request has "HTTP/1.0" in `req.proto` + request has "HTTP/1.0" in ``req.proto`` bereq.proto ``VCL >= 4.1`` @@ -565,7 +565,7 @@ bereq.proto ``VCL >= 4.1`` Readable from: vcl_pipe, backend The HTTP protocol version, "HTTP/1.1" unless a pass or pipe - request has "HTTP/1.0" in `req.proto` + request has "HTTP/1.0" in ``req.proto`` bereq.http.* @@ -654,7 +654,7 @@ beresp ~~~~~~ The response received from the backend, one cache misses, the -store object is built from `beresp`. +store object is built from ``beresp``. beresp @@ -707,8 +707,8 @@ beresp.status Only YZZ will be sent back to clients. XX can be therefore be used to pass information - around inside VCL, for instance `return(synth(22404))` - from `vcl_recv{}` to `vcl_synth{}` + around inside VCL, for instance ``return(synth(22404))`` + from ``vcl_recv{}`` to ``vcl_synth{}`` beresp.reason @@ -776,9 +776,9 @@ beresp.do_gzip Default: ``false``. - Set to `true` to gzip the object while storing it. + Set to ``true`` to gzip the object while storing it. - If `http_gzip_support` is disabled, setting this variable + If ``http_gzip_support`` is disabled, setting this variable has no effect. beresp.do_gunzip @@ -791,10 +791,10 @@ beresp.do_gunzip Default: ``false``. - Set to `true` to gunzip the object while storing it in the + Set to ``true`` to gunzip the object while storing it in the cache. - If `http_gzip_support` is disabled, setting this variable + If ``http_gzip_support`` is disabled, setting this variable has no effect. beresp.was_304 @@ -804,9 +804,9 @@ beresp.was_304 Readable from: vcl_backend_response, vcl_backend_error - When `true` this indicates that we got a 304 response + When ``true`` this indicates that we got a 304 response to our conditional fetch from the backend and turned - that into `beresp.status = 200` + that into ``beresp.status = 200`` beresp.uncacheable @@ -1111,10 +1111,10 @@ resp ~~~~ This is the response we send to the client, it is built from either -`beresp` (pass/miss), `obj` (hits) or created from whole cloth (synth). +``beresp`` (pass/miss), ``obj`` (hits) or created from whole cloth (synth). -With the exception of `resp.body` all `resp.*` variables available -in both `vcl_deliver{}` and `vcl_synth{}` as a matter of symmetry. +With the exception of ``resp.body`` all ``resp.*`` variables available +in both ``vcl_deliver{}`` and ``vcl_synth{}`` as a matter of symmetry. resp @@ -1253,7 +1253,7 @@ now The current time, in seconds since the UNIX epoch. When converted to STRING in expressions it returns - a formatted timestamp like `Tue, 20 Feb 2018 09:30:31 GMT` + a formatted timestamp like ``Tue, 20 Feb 2018 09:30:31 GMT`` sess ~~~~ From nils.goroll at uplex.de Sat Apr 4 17:50:13 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 17:50:13 +0000 (UTC) Subject: [master] 68ce690c9 The default filter list must not take resp_len into account Message-ID: <20200404175013.9955B62B4D@lists.varnish-cache.org> commit 68ce690c990211c967c944aa3bf3b7a85b142a2e Author: Nils Goroll Date: Sat Apr 4 18:49:00 2020 +0200 The default filter list must not take resp_len into account We do not know if we are going to send a body when we construct the filter list. It is up to the vdps to handle a null response Ref #3002 diff --git a/bin/varnishd/cache/cache_vrt_filter.c b/bin/varnishd/cache/cache_vrt_filter.c index 2bbdcf862..06ae0f6bc 100644 --- a/bin/varnishd/cache/cache_vrt_filter.c +++ b/bin/varnishd/cache/cache_vrt_filter.c @@ -346,7 +346,7 @@ resp_default_filter_list(void *arg, struct vsb *vsb) CAST_OBJ_NOTNULL(req, arg, REQ_MAGIC); - if (!req->disable_esi && req->resp_len != 0 && + if (!req->disable_esi && ObjHasAttr(req->wrk, req->objcore, OA_ESIDATA)) VSB_cat(vsb, " esi"); From nils.goroll at uplex.de Sat Apr 4 17:50:13 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 4 Apr 2020 17:50:13 +0000 (UTC) Subject: [master] 7fa4ac7e3 ESI VDP to veto being pushed Message-ID: <20200404175013.7F5B362B4A@lists.varnish-cache.org> commit 7fa4ac7e309f480e3418f79e80d69e96d82e5db9 Author: Nils Goroll Date: Sat Apr 4 18:45:09 2020 +0200 ESI VDP to veto being pushed So far, we relied upon esi not being added to resp_filters for no esi object, but as the filters can be set freely from VCL, the esi vdp itself should veto being pushed if it has not business to do with the object at hand. diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index b4b30fa3f..44d6657b0 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -259,8 +259,13 @@ ved_vdp_esi_init(struct req *req, void **priv) { struct ecx *ecx; + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); AN(priv); AZ(*priv); + + if (!ObjHasAttr(req->wrk, req->objcore, OA_ESIDATA)) + return (1); + ALLOC_OBJ(ecx, ECX_MAGIC); AN(ecx); assert(sizeof gzip_hdr == 10); From nils.goroll at uplex.de Sun Apr 5 14:16:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 5 Apr 2020 14:16:08 +0000 (UTC) Subject: [master] d099d7f6f esi can be turned off at esi_level > 0 Message-ID: <20200405141608.1350411A083@lists.varnish-cache.org> commit d099d7f6f176ffbb1fc9e8f0e40d1f1eba3b8815 Author: Nils Goroll Date: Sun Apr 5 13:47:35 2020 +0200 esi can be turned off at esi_level > 0 diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index a94606daf..a911a3622 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -538,6 +538,8 @@ VRT_l_req_esi(VRT_CTX, VCL_BOOL process_esi) /* * Only allow you to turn of esi in the main request * else everything gets confused + * NOTE: this is not true, but we do not change behavior + * for vcl 4.0. For 4.1, see VRT_l_resp_do_esi() */ if (IS_TOPREQ(ctx->req)) ctx->req->disable_esi = !process_esi; @@ -874,10 +876,6 @@ VRT_l_resp_do_esi(VRT_CTX, VCL_BOOL process_esi) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); assert(ctx->syntax >= 41); - /* - * Only allow you to turn of esi in the main request - * else everything gets confused - */ ctx->req->disable_esi = !process_esi; } diff --git a/bin/varnishtest/tests/e00015.vtc b/bin/varnishtest/tests/e00015.vtc index e8b47deb7..c704f557c 100644 --- a/bin/varnishtest/tests/e00015.vtc +++ b/bin/varnishtest/tests/e00015.vtc @@ -58,6 +58,14 @@ server s1 { After include } + rxreq + expect req.url == /recurse + txresp -body { + + Before include + + After include + } } -start varnish v1 -syntax 4.1 -vcl+backend { @@ -83,6 +91,8 @@ client c1 { expect resp.bodylen == 76 expect resp.status == 200 expect resp.http.was == true + txreq -url "/recurse" + rxresp } -run varnish v1 -expect esi_errors == 0 From nils.goroll at uplex.de Sun Apr 5 14:16:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 5 Apr 2020 14:16:08 +0000 (UTC) Subject: [master] 2ab29dc47 Test resp.filters with esi, gunzip and range Message-ID: <20200405141608.293FF11A086@lists.varnish-cache.org> commit 2ab29dc47c1784748e46c60964ca86efa2cdd866 Author: Nils Goroll Date: Sun Apr 5 14:22:16 2020 +0200 Test resp.filters with esi, gunzip and range diff --git a/bin/varnishtest/tests/e00015.vtc b/bin/varnishtest/tests/e00015.vtc index c704f557c..4df48cec0 100644 --- a/bin/varnishtest/tests/e00015.vtc +++ b/bin/varnishtest/tests/e00015.vtc @@ -1,4 +1,4 @@ -varnishtest "ESI requests turned off" +varnishtest "ESI requests turned off and other filters with esi" server s1 { rxreq @@ -52,7 +52,7 @@ varnish v1 -expect esi_errors == 0 server s1 { rxreq expect req.url == /top2 - txresp -body { + txresp -gzipbody { Before include @@ -60,7 +60,7 @@ server s1 { } rxreq expect req.url == /recurse - txresp -body { + txresp -gzipbody { Before include @@ -74,25 +74,52 @@ varnish v1 -syntax 4.1 -vcl+backend { if (req.url == "/top2") { set resp.do_esi = false; } + set resp.http.filters = resp.filters; } sub vcl_backend_response { set beresp.do_esi = true; } } +# Note on Range requests: The range VDP is active, but as it cannot +# reliably determine the size of the response, it falls back to a 200 client c1 { txreq -url /top2 rxresp expect resp.bodylen == 73 expect resp.status == 200 expect resp.http.was == true + expect resp.http.filters == "gunzip" + txreq -url "/esi" rxresp expect resp.bodylen == 76 expect resp.status == 200 expect resp.http.was == true + expect resp.http.filters == "esi" + + # see Note on Range above + txreq -url "/esi" -hdr "Range: bytes=1-2" + rxresp + expect resp.bodylen == 76 + expect resp.status == 200 + expect resp.http.was == true + expect resp.http.filters == "esi range" + txreq -url "/recurse" rxresp + expect resp.bodylen == 120 + expect resp.status == 200 + expect resp.http.was == true + expect resp.http.filters == "esi gunzip" + + # see Note on Range above + txreq -url "/recurse" -hdr "Range: bytes=1-2" + rxresp + expect resp.bodylen == 120 + expect resp.status == 200 + expect resp.http.was == true + expect resp.http.filters == "esi gunzip range" } -run varnish v1 -expect esi_errors == 0 From nils.goroll at uplex.de Sun Apr 5 14:16:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 5 Apr 2020 14:16:08 +0000 (UTC) Subject: [master] ad1762243 NULL any filters for VRT_fail() and return(synth()) Message-ID: <20200405141608.4A58C11A089@lists.varnish-cache.org> commit ad1762243268bbf625203f8b2fab2441d05f9d12 Author: Nils Goroll Date: Sun Apr 5 14:44:56 2020 +0200 NULL any filters for VRT_fail() and return(synth()) The synthetic response has nothing to do with the filters set for the original body. See next commit for implicit test diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index aee7140c6..7a9e7060e 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -256,6 +256,7 @@ cnt_vclfail(const struct worker *wrk, struct req *req) req->err_reason = "VCL failed"; req->req_step = R_STP_SYNTH; req->doclose = SC_VCL_FAILURE; + req->filter_list = NULL; return (REQ_FSM_MORE); } @@ -283,6 +284,7 @@ cnt_synth(struct worker *wrk, struct req *req) Resp_Setup_Synth(req); + req->filter_list = NULL; synth_body = VSB_new_auto(); AN(synth_body); From nils.goroll at uplex.de Sun Apr 5 14:16:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 5 Apr 2020 14:16:08 +0000 (UTC) Subject: [master] 2b3c76a84 resp.do_esi is undefined after setting resp.filters Message-ID: <20200405141608.6B84A11A092@lists.varnish-cache.org> commit 2b3c76a843207324bb2f3a3ece5e3d36881dfc52 Author: Nils Goroll Date: Sun Apr 5 14:48:28 2020 +0200 resp.do_esi is undefined after setting resp.filters After fixing resp.filters, resp.do_esi loses its meaning. Note: Setting resp.filters also fixes whether or not the gunzip and range VDPs are being pushed. These do not depend on switches, but on request headers. So we need to consider the case that a VCL author - fixes resp.filters - and then adds or removes relevant headers * req.http.Accept-Encoding for the gunzip vdp if removed: gunzip stays in the VDP list, which is always ok if added: that is probably wrong anyway and the VCL author can be held responsible for their actions as per the warning in the resp.filters documentation. * req.http.Range for the range vdp if removed: the range vdp vetoes itself in the _init callback if added: no range handling will be present, which is always ok (and see above for VCL author responsibilities) Fixes #3002 diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index a911a3622..8782df08d 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -869,6 +869,15 @@ VRT_r_resp_is_streaming(VRT_CTX) /*--------------------------------------------------------------------*/ +static inline int +resp_filter_fixed(VRT_CTX, const char *s) +{ + if (ctx->req->filter_list == NULL) + return (0); + VRT_fail(ctx, "resp.filters are already fixed, %s is undefined", s); + return (1); +} + VCL_VOID VRT_l_resp_do_esi(VRT_CTX, VCL_BOOL process_esi) { @@ -876,6 +885,8 @@ VRT_l_resp_do_esi(VRT_CTX, VCL_BOOL process_esi) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); assert(ctx->syntax >= 41); + if (resp_filter_fixed(ctx, "resp.do_esi")) + return; ctx->req->disable_esi = !process_esi; } @@ -886,6 +897,8 @@ VRT_r_resp_do_esi(VRT_CTX) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); assert(ctx->syntax >= 41); + if (resp_filter_fixed(ctx, "resp.do_esi")) + return (0); return (!ctx->req->disable_esi); } diff --git a/bin/varnishtest/tests/e00015.vtc b/bin/varnishtest/tests/e00015.vtc index 4df48cec0..951785115 100644 --- a/bin/varnishtest/tests/e00015.vtc +++ b/bin/varnishtest/tests/e00015.vtc @@ -71,10 +71,15 @@ server s1 { varnish v1 -syntax 4.1 -vcl+backend { sub vcl_deliver { set resp.http.was = resp.do_esi; + set resp.http.filter0 = resp.filters; if (req.url == "/top2") { set resp.do_esi = false; } set resp.http.filters = resp.filters; + if (req.http.fiddle) { + set resp.filters = resp.filters; + set resp.do_esi = false; + } } sub vcl_backend_response { set beresp.do_esi = true; @@ -89,6 +94,7 @@ client c1 { expect resp.bodylen == 73 expect resp.status == 200 expect resp.http.was == true + expect resp.http.filter0 == "esi gunzip" expect resp.http.filters == "gunzip" txreq -url "/esi" @@ -96,6 +102,7 @@ client c1 { expect resp.bodylen == 76 expect resp.status == 200 expect resp.http.was == true + expect resp.http.filter0 == "esi" expect resp.http.filters == "esi" # see Note on Range above @@ -120,6 +127,10 @@ client c1 { expect resp.status == 200 expect resp.http.was == true expect resp.http.filters == "esi gunzip range" + + txreq -url /top2 -hdr "fiddle: do_esi" + rxresp + expect resp.status == 503 } -run varnish v1 -expect esi_errors == 0 diff --git a/doc/sphinx/reference/vcl_var.rst b/doc/sphinx/reference/vcl_var.rst index a26c6d7ff..93d0414b8 100644 --- a/doc/sphinx/reference/vcl_var.rst +++ b/doc/sphinx/reference/vcl_var.rst @@ -1218,6 +1218,8 @@ resp.http.* The HTTP headers that will be returned. +.. XXX does vcl_synth make any sense? + resp.do_esi ``VCL >= 4.1`` Type: BOOL @@ -1226,12 +1228,14 @@ resp.do_esi ``VCL >= 4.1`` Writable from: vcl_deliver, vcl_synth - Default: Set if ESI parsing has happened. + Default: obj.can_esi This can be used to selectively disable ESI processing, even though ESI parsing happened during fetch. This is useful when Varnish caches peer with each other. + It is a VCL error to use resp.do_esi after setting resp.filters. + resp.is_streaming @@ -1252,6 +1256,15 @@ resp.filters List of VDP filters the resp.body will be pushed through. + Before resp.filters is set, the value read will be the default + filter list as determined by varnish based on resp.do_esi and + request headers. + + After resp.filters is set, changing any of the conditions + which otherwise determine the filter selection will have no + effiect. Using resp.do_esi is an error once resp.filters is + set. + Special variables ~~~~~~~~~~~~~~~~~ From nils.goroll at uplex.de Sun Apr 5 14:16:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 5 Apr 2020 14:16:08 +0000 (UTC) Subject: [master] a80d03629 some beresp.do_* flags are undefined after setting beresp.filters Message-ID: <20200405141608.8E40D11A09D@lists.varnish-cache.org> commit a80d03629c96338ed6e51ca9071820b9f5e55a3d Author: Nils Goroll Date: Sun Apr 5 16:02:09 2020 +0200 some beresp.do_* flags are undefined after setting beresp.filters See previous commit: Analogous to resp.do_esi, any access to the beresp.do_* flags which influence beresp.filters is now a VCL error. Ref #3002 diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 9cb57970c..c8ad67d1c 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -411,7 +411,7 @@ struct busyobj { struct pool_task fetch_task[1]; -#define BO_FLAG(l, r, w, d) unsigned l:1; +#define BO_FLAG(l, r, w, f, d) unsigned l:1; #include "tbl/bo_flags.h" /* Timeouts */ diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 48d6c7618..45a162bcb 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -441,7 +441,7 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) VSB_cat(vsb, "flags = {"); p = ""; /*lint -save -esym(438,p) -e539 */ -#define BO_FLAG(l, r, w, d) \ +#define BO_FLAG(l, r, w, f, d) \ if (bo->l) { VSB_printf(vsb, "%s" #l, p); p = ", "; } #include "tbl/bo_flags.h" /*lint -restore */ diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 8782df08d..1f3138e1c 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -186,31 +186,63 @@ VRT_r_obj_reason(VRT_CTX) * bool-fields (.do_*) */ -#define VBERESPW0(field) -#define VBERESPW1(field) \ +static inline int +beresp_filter_fixed(VRT_CTX, const char *s) +{ + if (ctx->bo->filter_list == NULL) + return (0); + VRT_fail(ctx, "beresp.filters are already fixed, beresp.%s is undefined", s); + return (1); +} + +#define VBERESPWF0(ctx, str) (void) 0 +#define VBERESPWF1(ctx, str) do { \ + if (beresp_filter_fixed((ctx), str)) \ + return; \ + } while(0) + +#define VBERESPW0(field, str, fltchk) +#define VBERESPW1(field, str, fltchk) \ void \ VRT_l_beresp_##field(VRT_CTX, VCL_BOOL a) \ { \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); \ + VBERESPWF##fltchk(ctx, str); \ ctx->bo->field = a ? 1 : 0; \ } -#define VBERESPR0(field) -#define VBERESPR1(field) \ +#define VBERESPRF0(ctx, str) (void) 0 +#define VBERESPRF1(ctx, str) do { \ + if (beresp_filter_fixed((ctx), str)) \ + return (0); \ + } while(0) + +#define VBERESPR0(field, str, fltchk) +#define VBERESPR1(field, str, fltchk) \ VCL_BOOL \ VRT_r_beresp_##field(VRT_CTX) \ { \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); \ + VBERESPRF##fltchk(ctx, str); \ return (ctx->bo->field); \ } -#define BO_FLAG(l, r, w, d) \ - VBERESPR##r(l) \ - VBERESPW##w(l) +#define BO_FLAG(l, r, w, f, d) \ + VBERESPR##r(l, #l, f) \ + VBERESPW##w(l, #l, f) #include "tbl/bo_flags.h" +#undef VBERESPWF0 +#undef VBERESPWF1 +#undef VBERESPW0 +#undef VBERESPW1 + +#undef VBERESPRF0 +#undef VBERESPRF1 +#undef VBERESPR0 +#undef VBERESPR1 /*--------------------------------------------------------------------*/ VCL_BOOL diff --git a/bin/varnishtest/tests/c00101.vtc b/bin/varnishtest/tests/c00101.vtc new file mode 100644 index 000000000..c75f73749 --- /dev/null +++ b/bin/varnishtest/tests/c00101.vtc @@ -0,0 +1,48 @@ +varnishtest "bo_* with effect on filters" + + +server s1 -repeat 2 -keepalive { + rxreq + txresp -body { + -This is a test: Hello world + } +} -start + +varnish v1 -vcl+backend { + sub backend_response_filter { + set beresp.http.filter0 = beresp.filters; + set beresp.do_esi = true; + set beresp.http.filter1 = beresp.filters; + set beresp.do_gzip = true; + set beresp.http.filter2 = beresp.filters; + set beresp.do_esi = false; + set beresp.do_gzip = false; + set beresp.http.Content-Encoding = "gzip"; + set beresp.do_gunzip = true; + set beresp.http.filter3 = beresp.filters; + set beresp.filters = ""; + + # does not affect filters + set beresp.do_stream = true; + + } + sub vcl_backend_response { + call backend_response_filter; + if (bereq.http.fiddle) { + call backend_response_filter; + } + } + sub vcl_recv { + return (pass); + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 + + txreq -hdr "fiddle: yes" + rxresp + expect resp.status == 503 +} -run diff --git a/doc/sphinx/reference/vcl_var.rst b/doc/sphinx/reference/vcl_var.rst index 93d0414b8..306f82eee 100644 --- a/doc/sphinx/reference/vcl_var.rst +++ b/doc/sphinx/reference/vcl_var.rst @@ -745,6 +745,7 @@ beresp.do_esi Set it to true to parse the object for ESI directives. Will only be honored if req.esi is true. + It is a VCL error to use beresp.do_esi after setting beresp.filters. beresp.do_stream @@ -781,6 +782,8 @@ beresp.do_gzip If ``http_gzip_support`` is disabled, setting this variable has no effect. + It is a VCL error to use beresp.do_gzip after setting beresp.filters. + beresp.do_gunzip Type: BOOL @@ -797,6 +800,8 @@ beresp.do_gunzip If ``http_gzip_support`` is disabled, setting this variable has no effect. + It is a VCL error to use beresp.do_gunzip after setting beresp.filters. + beresp.was_304 Type: BOOL @@ -997,6 +1002,9 @@ beresp.filters * ``testgunzip`` gets added for compressed content if ``beresp.do_gunzip`` is false. + After beresp.filters is set, using any of the beforementioned + ``beresp.do_*`` switches is a VCL error. + obj ~~~ diff --git a/include/tbl/bo_flags.h b/include/tbl/bo_flags.h index 91293f5d6..9d26d6a97 100644 --- a/include/tbl/bo_flags.h +++ b/include/tbl/bo_flags.h @@ -31,15 +31,18 @@ /*lint -save -e525 -e539 */ -/* lower, vcl_r, vcl_w, doc */ -BO_FLAG(do_esi, 1, 1, "") -BO_FLAG(do_gzip, 1, 1, "") -BO_FLAG(do_gunzip, 1, 1, "") -BO_FLAG(do_stream, 1, 1, "") -BO_FLAG(do_pass, 0, 0, "") -BO_FLAG(uncacheable, 0, 0, "") -BO_FLAG(was_304, 1, 0, "") -BO_FLAG(is_bgfetch, 0, 0, "") +/* + * filters: whether this flag determines beresp.filters default + * + * lower, vcl_r, vcl_w, filters, doc */ +BO_FLAG(do_esi, 1, 1, 1, "") +BO_FLAG(do_gzip, 1, 1, 1, "") +BO_FLAG(do_gunzip, 1, 1, 1, "") +BO_FLAG(do_stream, 1, 1, 0, "") +BO_FLAG(do_pass, 0, 0, 0, "") +BO_FLAG(uncacheable, 0, 0, 0, "") +BO_FLAG(was_304, 1, 0, 0, "") +BO_FLAG(is_bgfetch, 0, 0, 0, "") #undef BO_FLAG /*lint -restore */ From nils.goroll at uplex.de Thu Apr 9 11:15:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 9 Apr 2020 11:15:08 +0000 (UTC) Subject: [master] d0a896766 VDP/VFP sanity Message-ID: <20200409111508.384E19492@lists.varnish-cache.org> commit d0a896766fd58fa7f7c298fb92944e108984c1b9 Author: Nils Goroll Date: Thu Apr 9 13:13:22 2020 +0200 VDP/VFP sanity * there is no NULL filter * the filter name cannot be NULL or empty diff --git a/bin/varnishd/cache/cache_vrt_filter.c b/bin/varnishd/cache/cache_vrt_filter.c index 06ae0f6bc..5f972520e 100644 --- a/bin/varnishd/cache/cache_vrt_filter.c +++ b/bin/varnishd/cache/cache_vrt_filter.c @@ -70,6 +70,10 @@ VRT_AddVFP(VRT_CTX, const struct vfp *filter) struct vfilter_head *hd = &vfp_filters; CHECK_OBJ_ORNULL(ctx, VRT_CTX_MAGIC); + AN(filter); + AN(filter->name); + AN(*filter->name); + VTAILQ_FOREACH(vp, hd, list) { xxxassert(vp->vfp != filter); xxxassert(strcasecmp(vp->name, filter->name)); @@ -97,6 +101,10 @@ VRT_AddVDP(VRT_CTX, const struct vdp *filter) struct vfilter_head *hd = &vdp_filters; CHECK_OBJ_ORNULL(ctx, VRT_CTX_MAGIC); + AN(filter); + AN(filter->name); + AN(*filter->name); + VTAILQ_FOREACH(vp, hd, list) { xxxassert(vp->vdp != filter); xxxassert(strcasecmp(vp->name, filter->name)); @@ -124,6 +132,10 @@ VRT_RemoveVFP(VRT_CTX, const struct vfp *filter) struct vfilter_head *hd = &ctx->vcl->vfps; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AN(filter); + AN(filter->name); + AN(*filter->name); + ASSERT_CLI(); VTAILQ_FOREACH(vp, hd, list) { if (vp->vfp == filter) @@ -141,6 +153,10 @@ VRT_RemoveVDP(VRT_CTX, const struct vdp *filter) struct vfilter_head *hd = &ctx->vcl->vdps; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AN(filter); + AN(filter->name); + AN(*filter->name); + ASSERT_CLI(); VTAILQ_FOREACH(vp, hd, list) { if (vp->vdp == filter) From nils.goroll at uplex.de Thu Apr 9 12:41:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 9 Apr 2020 12:41:07 +0000 (UTC) Subject: [master] 430bbce96 tabularize parameters to be passed to vcc Message-ID: <20200409124107.A2F3C6387E@lists.varnish-cache.org> commit 430bbce965d170f1afaf6ea3f6fa339743621fa0 Author: Nils Goroll Date: Thu Apr 9 14:32:30 2020 +0200 tabularize parameters to be passed to vcc Parameters are passed to vcc via specific setter functions, presumably to avoid binary compability issues between the main program (here: vanishd) and a library (here: libvcc). This commit does not change that interface in any way, but generates both sides from a common table include to avoid having to edit five spots in four different source files and write trivial setter functions for a simple mgt_vcc parameter change. diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 43987de1c..54b42ad80 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -221,10 +221,8 @@ int mgt_has_vcl(void); extern char *mgt_cc_cmd; extern const char *mgt_vcl_path; extern const char *mgt_vmod_path; -extern unsigned mgt_vcc_err_unref; -extern unsigned mgt_vcc_acl_pedantic; -extern unsigned mgt_vcc_allow_inline_c; -extern unsigned mgt_vcc_unsafe_path; +#define MGT_VCC(t, n, cc) extern t mgt_vcc_ ## n; +#include #if defined(PTHREAD_CANCELED) || defined(PTHREAD_MUTEX_DEFAULT) #error "Keep pthreads out of in manager process" diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index 39e9ddcd3..e82fa81c5 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -65,11 +65,8 @@ struct vcc_priv { char *mgt_cc_cmd; const char *mgt_vcl_path; const char *mgt_vmod_path; -unsigned mgt_vcc_err_unref; -unsigned mgt_vcc_allow_inline_c; -unsigned mgt_vcc_unsafe_path; -unsigned mgt_vcc_acl_pedantic; - +#define MGT_VCC(t, n, cc) t mgt_vcc_ ## n; +#include #define VGC_SRC "vgc.c" #define VGC_LIB "vgc.so" @@ -107,10 +104,11 @@ run_vcc(void *priv) VCC_Builtin_VCL(vcc, builtin_vcl); VCC_VCL_path(vcc, mgt_vcl_path); VCC_VMOD_path(vcc, mgt_vmod_path); - VCC_Err_Unref(vcc, mgt_vcc_err_unref); - VCC_Allow_InlineC(vcc, mgt_vcc_allow_inline_c); - VCC_Unsafe_Path(vcc, mgt_vcc_unsafe_path); - VCC_Acl_Pedantic(vcc, mgt_vcc_acl_pedantic); + +#define MGT_VCC(type, name, camelcase) \ + VCC_ ## camelcase (vcc, mgt_vcc_ ## name); +#include "tbl/mgt_vcc.h" + STV_Foreach(stv) VCC_Predef(vcc, "VCL_STEVEDORE", stv->ident); VTAILQ_FOREACH(vpg, &vclhead, list) diff --git a/include/Makefile.am b/include/Makefile.am index 9186df797..23e355c86 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -22,6 +22,7 @@ nobase_pkginclude_HEADERS = \ tbl/http_headers.h \ tbl/http_response.h \ tbl/locks.h \ + tbl/mgt_vcc.h \ tbl/obj_attr.h \ tbl/oc_exp_flags.h \ tbl/oc_flags.h \ diff --git a/include/libvcc.h b/include/libvcc.h index 63cd136a0..aa5f17288 100644 --- a/include/libvcc.h +++ b/include/libvcc.h @@ -33,15 +33,15 @@ struct vcc; struct vcc *VCC_New(void); -void VCC_Allow_InlineC(struct vcc *, unsigned); void VCC_Builtin_VCL(struct vcc *, const char *); -void VCC_Err_Unref(struct vcc *, unsigned); -void VCC_Unsafe_Path(struct vcc *, unsigned); -void VCC_Acl_Pedantic(struct vcc *, unsigned); void VCC_VCL_path(struct vcc *, const char *); void VCC_VMOD_path(struct vcc *, const char *); void VCC_Predef(struct vcc *, const char *type, const char *name); void VCC_VCL_Range(unsigned *, unsigned *); +#define MGT_VCC(t, n, cc) \ + void VCC_ ## cc (struct vcc *, t); +#include "tbl/mgt_vcc.h" + int VCC_Compile(struct vcc *, struct vsb **, const char *, const char *, const char *, const char *); diff --git a/include/tbl/mgt_vcc.h b/include/tbl/mgt_vcc.h new file mode 100644 index 000000000..efff37265 --- /dev/null +++ b/include/tbl/mgt_vcc.h @@ -0,0 +1,5 @@ +MGT_VCC(unsigned, acl_pedantic, Acl_Pedantic) +MGT_VCC(unsigned, allow_inline_c, Allow_InlineC) +MGT_VCC(unsigned, err_unref, Err_Unref) +MGT_VCC(unsigned, unsafe_path, Unsafe_Path) +#undef MGT_VCC diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index 94fabd984..78b08d04d 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -889,37 +889,13 @@ VCC_VMOD_path(struct vcc *vcc, const char *str) * Configure settings */ -void -VCC_Err_Unref(struct vcc *vcc, unsigned u) -{ - - CHECK_OBJ_NOTNULL(vcc, VCC_MAGIC); - vcc->err_unref = u; -} - -void -VCC_Allow_InlineC(struct vcc *vcc, unsigned u) -{ - - CHECK_OBJ_NOTNULL(vcc, VCC_MAGIC); - vcc->allow_inline_c = u; -} - -void -VCC_Unsafe_Path(struct vcc *vcc, unsigned u) -{ - - CHECK_OBJ_NOTNULL(vcc, VCC_MAGIC); - vcc->unsafe_path = u; -} - -void -VCC_Acl_Pedantic(struct vcc *vcc, unsigned u) -{ - - CHECK_OBJ_NOTNULL(vcc, VCC_MAGIC); - vcc->acl_pedantic = u; -} +#define MGT_VCC(type, name, camelcase) \ + void VCC_ ## camelcase (struct vcc *vcc, type val) \ + { \ + CHECK_OBJ_NOTNULL(vcc, VCC_MAGIC); \ + vcc->name = val; \ + } +#include "tbl/mgt_vcc.h" /*-------------------------------------------------------------------- * Configure settings From nils.goroll at uplex.de Thu Apr 9 12:49:06 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 9 Apr 2020 12:49:06 +0000 (UTC) Subject: [master] 83c23d9a7 fix oversight from previous commit Message-ID: <20200409124906.EE1E763DAC@lists.varnish-cache.org> commit 83c23d9a7040f1ab2b1c9616e8761c551a43e790 Author: Nils Goroll Date: Thu Apr 9 14:46:36 2020 +0200 fix oversight from previous commit sorry, I overlooked the sixth spot from a total of five different source files. diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index f47b6dede..7ba6cbb62 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -219,10 +219,8 @@ struct vcc { char *builtin_vcl; struct vfil_path *vcl_path; struct vfil_path *vmod_path; - unsigned err_unref; - unsigned allow_inline_c; - unsigned unsafe_path; - unsigned acl_pedantic; +#define MGT_VCC(t, n, cc) t n; +#include struct symtab *syms; From nils.goroll at uplex.de Thu Apr 9 13:18:06 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 9 Apr 2020 13:18:06 +0000 (UTC) Subject: [master] e7ea0de7d give timing critical test a bit more margin Message-ID: <20200409131807.085A8649C2@lists.varnish-cache.org> commit e7ea0de7db04aff585d7e6048f2cd37a7c66a1a1 Author: Nils Goroll Date: Thu Apr 9 15:03:47 2020 +0200 give timing critical test a bit more margin we want to make sure that we do not hit timeout_idle as long as we stay below it, but the margin of just 100ms has triggered a false negative. Double the margin to 200ms... see with vtest (c4u lines extracted) **** c4u Loop #3 ** c4u === delay 0.3 *** c4u delaying 0.3 second(s) **** dT 2.025 ** c4u === sendhex 0d0a **** c4u sendhex| 0d 0a ---- c4u Write failed: Socket is not connected diff --git a/bin/varnishtest/tests/b00067.vtc b/bin/varnishtest/tests/b00067.vtc index 612f5fcd5..9479617a8 100644 --- a/bin/varnishtest/tests/b00067.vtc +++ b/bin/varnishtest/tests/b00067.vtc @@ -82,10 +82,10 @@ client c2u -connect "${tmpdir}/v1.sock" { client c3u -connect "${tmpdir}/v1.sock" { loop 3 { # send a periodic CRLF - delay 0.3 + delay 0.2 sendhex 0d0a } - delay 0.3 + delay 0.4 expect_close } -start @@ -94,10 +94,10 @@ client c4u -connect "${tmpdir}/v1.sock" { rxresp loop 3 { # send a periodic CRLF - delay 0.3 + delay 0.2 sendhex 0d0a } - delay 0.3 + delay 0.4 expect_close } -start From nils.goroll at uplex.de Thu Apr 9 13:18:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 9 Apr 2020 13:18:07 +0000 (UTC) Subject: [master] 05a068dd8 stabilize vtc: tolerate more overflows Message-ID: <20200409131807.1D6C2649C6@lists.varnish-cache.org> commit 05a068dd85dd6935892a217d90f726b40b25a7ab Author: Nils Goroll Date: Thu Apr 9 15:14:00 2020 +0200 stabilize vtc: tolerate more overflows depending on our platform and the timing of events, we might see another overflow. Seen with vtest ---- v1 Not true: ws_session_overflow (3) == 2 (2) diff --git a/bin/varnishtest/tests/o00005.vtc b/bin/varnishtest/tests/o00005.vtc index df2bc747a..7acd25bbf 100644 --- a/bin/varnishtest/tests/o00005.vtc +++ b/bin/varnishtest/tests/o00005.vtc @@ -322,4 +322,4 @@ client c1 { delay 1 -varnish v1 -expect ws_session_overflow == 2 +varnish v1 -expect ws_session_overflow >= 2 From nils.goroll at uplex.de Thu Apr 9 13:45:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 9 Apr 2020 13:45:08 +0000 (UTC) Subject: [master] 7b61372c1 try to make flexelint happy Message-ID: <20200409134508.68E0C65A1B@lists.varnish-cache.org> commit 7b61372c14e4ee5cb9077d88f2344a1aa54aa22e Author: Nils Goroll Date: Thu Apr 9 15:26:46 2020 +0200 try to make flexelint happy if (e - p < l1 + l2) ../../lib/libvarnishapi/vsl_arg.c 133 Info 776: Possible truncation of addition diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c index 25e811424..87fbace64 100644 --- a/lib/libvarnishapi/vsl_arg.c +++ b/lib/libvarnishapi/vsl_arg.c @@ -130,7 +130,7 @@ VSL_Glob2Tags(const char *glob, int l, VSL_tagfind_f *func, void *priv) if (p == NULL) continue; e = strchr(p, '\0'); - if (e - p < l1 + l2) + if (e - p - l1 < l2) continue; if (p1 != NULL && strncasecmp(p, p1, l1)) continue; From nils.goroll at uplex.de Thu Apr 9 14:39:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 9 Apr 2020 14:39:08 +0000 (UTC) Subject: [master] d33f4a860 flexelinting take 2 Message-ID: <20200409143908.0F45A905A8@lists.varnish-cache.org> commit d33f4a86098ac93c141c97ebf4f710cab417052f Author: Nils Goroll Date: Thu Apr 9 16:37:30 2020 +0200 flexelinting take 2 diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c index 87fbace64..eb7985c9f 100644 --- a/lib/libvarnishapi/vsl_arg.c +++ b/lib/libvarnishapi/vsl_arg.c @@ -130,7 +130,7 @@ VSL_Glob2Tags(const char *glob, int l, VSL_tagfind_f *func, void *priv) if (p == NULL) continue; e = strchr(p, '\0'); - if (e - p - l1 < l2) + if ((e - p) - l1 < l2) continue; if (p1 != NULL && strncasecmp(p, p1, l1)) continue; From dridi.boukelmoune at gmail.com Fri Apr 10 14:11:07 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 10 Apr 2020 14:11:07 +0000 (UTC) Subject: [master] d921b1f26 Ensure we don't override Content-Encoding in a 304 conditional fetch Message-ID: <20200410141107.D08736436@lists.varnish-cache.org> commit d921b1f263ba7403427cc9f8c4e82ec05469b90a Author: Dag Haavi Finstad Date: Thu Nov 21 11:50:23 2019 +0100 Ensure we don't override Content-Encoding in a 304 conditional fetch Test inspired by Carlos Abalde diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 036108954..88f5b6e53 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -308,9 +308,9 @@ vbf_304_logic(struct busyobj *bo) * the IMS fetch, and we must weaken any * new ETag we get. */ - http_Unset(bo->beresp, H_Content_Encoding); RFC2616_Weaken_Etag(bo->beresp); } + http_Unset(bo->beresp, H_Content_Encoding); http_Unset(bo->beresp, H_Content_Length); HTTP_Merge(bo->wrk, bo->stale_oc, bo->beresp); assert(http_IsStatus(bo->beresp, 200)); diff --git a/bin/varnishtest/tests/r03169.vtc b/bin/varnishtest/tests/r03169.vtc new file mode 100644 index 000000000..650b15c83 --- /dev/null +++ b/bin/varnishtest/tests/r03169.vtc @@ -0,0 +1,61 @@ +varnishtest "Ensure we don't override Content-Encoding on a cond fetch" + +server s1 { + rxreq + txresp -hdr {ETag: "foo"} -body {****} + + rxreq + expect req.http.If-None-Match == {"foo"} + txresp -status 304 -hdr {ETag: W/"foo"} -hdr "Content-Encoding: gzip" + + rxreq + expect req.url == "/1" + txresp -hdr {Etag: "bar"} -gzipbody {asdf} + + rxreq + expect req.url == "/1" + expect req.http.If-None-Match == {"bar"} + txresp -status 304 + +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_response { + set beresp.ttl = 1s; + set beresp.grace = 0s; + set beresp.keep = 1d; + } +} -start + +client c1 { + txreq -hdr "Accept-Encoding: gzip" + rxresp + expect resp.status == 200 + expect resp.http.ETag == {"foo"} + expect resp.http.Content-Length == "4" + expect resp.http.Content-Encoding == + + delay 1.5 + + txreq -hdr "Accept-Encoding: gzip" + rxresp + expect resp.status == 200 + expect resp.http.ETag == {W/"foo"} + expect resp.http.Content-Length == "4" + expect resp.http.Content-Encoding == + + # Also check that we're still OK in the general case + txreq -url "/1" -hdr "Accept-Encoding: gzip" + rxresp + expect resp.status == 200 + expect resp.http.ETag == {"bar"} + expect resp.http.Content-Encoding == "gzip" + + delay 1.5 + + txreq -url "/1" -hdr "Accept-Encoding: gzip" + rxresp + expect resp.status == 200 + expect resp.http.ETag == {"bar"} + expect resp.http.Content-Encoding == "gzip" +} -run \ No newline at end of file From nils.goroll at uplex.de Sun Apr 12 12:20:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 12 Apr 2020 12:20:08 +0000 (UTC) Subject: [master] 056765e52 move VFP_Push() declaration Message-ID: <20200412122008.7CA1EA5495@lists.varnish-cache.org> commit 056765e527e9e562003772073de1111caf7b95e2 Author: Nils Goroll Date: Sun Apr 12 14:11:46 2020 +0200 move VFP_Push() declaration it is part of the filter side of things, while the remaining declarations in cache_varnishd concern the interface between filters and the rest of the code. This also parallels the location of VDP_Push() diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 4d0c7640d..5887ef01e 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -87,6 +87,7 @@ struct vfp_ctx { unsigned obj_flags; }; +struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *); enum vfp_status VFP_Suck(struct vfp_ctx *, void *p, ssize_t *lp); enum vfp_status VFP_Error(struct vfp_ctx *, const char *fmt, ...) v_printflike_(2, 3); diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index a9050a099..b0a6a1930 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -248,7 +248,6 @@ void Bereq_Rollback(struct busyobj *); void VFP_Init(void); enum vfp_status VFP_GetStorage(struct vfp_ctx *, ssize_t *sz, uint8_t **ptr); void VFP_Extend(const struct vfp_ctx *, ssize_t sz); -struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *); void VFP_Setup(struct vfp_ctx *vc, struct worker *wrk); int VFP_Open(struct vfp_ctx *bo); void VFP_Close(struct vfp_ctx *bo); From nils.goroll at uplex.de Sun Apr 12 13:55:06 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 12 Apr 2020 13:55:06 +0000 (UTC) Subject: [master] e39e5e0dd local variable for (struct busyobj *)->fetch_objcore Message-ID: <20200412135506.DC375A7624@lists.varnish-cache.org> commit e39e5e0dd790cb6e0575ec640dd88a2f0d1394d4 Author: Nils Goroll Date: Sun Apr 12 15:33:25 2020 +0200 local variable for (struct busyobj *)->fetch_objcore Minor uncluttering, no code change other than use of that local variable. The fetch_objcore must not change for the duration of a fetch. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 88f5b6e53..2ff4499de 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -68,7 +68,7 @@ vbf_allocobj(struct busyobj *bo, unsigned l) if (stv == NULL) return (0); - if (STV_NewObject(bo->wrk, bo->fetch_objcore, stv, l)) + if (STV_NewObject(bo->wrk, oc, stv, l)) return (1); if (stv == stv_transient) @@ -83,7 +83,7 @@ vbf_allocobj(struct busyobj *bo, unsigned l) oc->ttl = cache_param->shortlived; oc->grace = 0.0; oc->keep = 0.0; - return (STV_NewObject(bo->wrk, bo->fetch_objcore, stv_transient, l)); + return (STV_NewObject(bo->wrk, oc, stv_transient, l)); } static void @@ -126,11 +126,16 @@ vbf_beresp2obj(struct busyobj *bo) uint8_t *bp; struct vsb *vary = NULL; int varyl = 0; + struct objcore *oc; + + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + oc = bo->fetch_objcore; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); l = 0; /* Create Vary instructions */ - if (!(bo->fetch_objcore->flags & OC_F_PRIVATE)) { + if (!(oc->flags & OC_F_PRIVATE)) { varyl = VRY_Create(bo, &vary); if (varyl > 0) { AN(vary); @@ -156,7 +161,7 @@ vbf_beresp2obj(struct busyobj *bo) l += l2; if (bo->uncacheable) - bo->fetch_objcore->flags |= OC_F_HFM; + oc->flags |= OC_F_HFM; if (!vbf_allocobj(bo, l)) { if (vary != NULL) @@ -166,28 +171,26 @@ vbf_beresp2obj(struct busyobj *bo) } if (vary != NULL) { - AN(ObjSetAttr(bo->wrk, bo->fetch_objcore, OA_VARY, varyl, - VSB_data(vary))); + AN(ObjSetAttr(bo->wrk, oc, OA_VARY, varyl, VSB_data(vary))); VSB_destroy(&vary); } - AZ(ObjSetU32(bo->wrk, bo->fetch_objcore, OA_VXID, VXID(bo->vsl->wid))); + AZ(ObjSetU32(bo->wrk, oc, OA_VXID, VXID(bo->vsl->wid))); /* for HTTP_Encode() VSLH call */ bo->beresp->logtag = SLT_ObjMethod; /* Filter into object */ - bp = ObjSetAttr(bo->wrk, bo->fetch_objcore, OA_HEADERS, l2, NULL); + bp = ObjSetAttr(bo->wrk, oc, OA_HEADERS, l2, NULL); AN(bp); HTTP_Encode(bo->beresp, bp, l2, bo->uncacheable ? HTTPH_A_PASS : HTTPH_A_INS); if (http_GetHdr(bo->beresp, H_Last_Modified, &b)) - AZ(ObjSetDouble(bo->wrk, bo->fetch_objcore, OA_LASTMODIFIED, - VTIM_parse(b))); + AZ(ObjSetDouble(bo->wrk, oc, OA_LASTMODIFIED, VTIM_parse(b))); else - AZ(ObjSetDouble(bo->wrk, bo->fetch_objcore, OA_LASTMODIFIED, - floor(bo->fetch_objcore->t_origin))); + AZ(ObjSetDouble(bo->wrk, oc, OA_LASTMODIFIED, + floor(oc->t_origin))); return (0); } @@ -200,12 +203,15 @@ static enum fetch_step vbf_stp_mkbereq(struct worker *wrk, struct busyobj *bo) { const char *q; + struct objcore *oc; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo->req, REQ_MAGIC); + oc = bo->fetch_objcore; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - assert(bo->fetch_objcore->boc->state == BOS_INVALID); + assert(oc->boc->state == BOS_INVALID); AZ(bo->storage); HTTP_Setup(bo->bereq0, bo->ws, bo->vsl, SLT_BereqMethod); @@ -242,13 +248,13 @@ vbf_stp_mkbereq(struct worker *wrk, struct busyobj *bo) if (bo->req->req_body_status->avail == 0) { bo->req = NULL; - ObjSetState(bo->wrk, bo->fetch_objcore, BOS_REQ_DONE); + ObjSetState(bo->wrk, oc, BOS_REQ_DONE); } else if (bo->req->req_body_status == BS_CACHED) { AN(bo->req->body_oc); bo->bereq_body = bo->req->body_oc; HSH_Ref(bo->bereq_body); bo->req = NULL; - ObjSetState(bo->wrk, bo->fetch_objcore, BOS_REQ_DONE); + ObjSetState(bo->wrk, oc, BOS_REQ_DONE); } return (F_STP_STARTFETCH); } @@ -338,9 +344,12 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) int i; vtim_real now; unsigned handling; + struct objcore *oc; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + oc = bo->fetch_objcore; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AZ(bo->storage); bo->storage = bo->do_pass ? stv_transient : STV_next(); @@ -360,12 +369,12 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) HTTP_Setup(bo->beresp, bo->ws, bo->vsl, SLT_BerespMethod); - assert(bo->fetch_objcore->boc->state <= BOS_REQ_DONE); + assert(oc->boc->state <= BOS_REQ_DONE); AZ(bo->htc); VFP_Setup(bo->vfc, wrk); - bo->vfc->oc = bo->fetch_objcore; + bo->vfc->oc = oc; bo->vfc->resp = bo->beresp; bo->vfc->req = bo->bereq; @@ -417,10 +426,10 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) /* What does RFC2616 think about TTL ? */ RFC2616_Ttl(bo, now, - &bo->fetch_objcore->t_origin, - &bo->fetch_objcore->ttl, - &bo->fetch_objcore->grace, - &bo->fetch_objcore->keep); + &oc->t_origin, + &oc->ttl, + &oc->grace, + &oc->keep); AZ(bo->do_esi); AZ(bo->was_304); @@ -461,21 +470,21 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) return (F_STP_ERROR); } - assert(bo->fetch_objcore->boc->state <= BOS_REQ_DONE); - if (bo->fetch_objcore->boc->state != BOS_REQ_DONE) { + assert(oc->boc->state <= BOS_REQ_DONE); + if (oc->boc->state != BOS_REQ_DONE) { bo->req = NULL; - ObjSetState(wrk, bo->fetch_objcore, BOS_REQ_DONE); + ObjSetState(wrk, oc, BOS_REQ_DONE); } if (bo->do_esi) bo->do_stream = 0; if (wrk->handling == VCL_RET_PASS) { - bo->fetch_objcore->flags |= OC_F_HFP; + oc->flags |= OC_F_HFP; bo->uncacheable = 1; wrk->handling = VCL_RET_DELIVER; } if (bo->do_pass || bo->uncacheable) - bo->fetch_objcore->flags |= OC_F_HFM; + oc->flags |= OC_F_HFM; assert(wrk->handling == VCL_RET_DELIVER); @@ -493,10 +502,13 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo) enum vfp_status vfps = VFP_ERROR; ssize_t est; struct vfp_ctx *vfc; + struct objcore *oc; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); vfc = bo->vfc; CHECK_OBJ_NOTNULL(vfc, VFP_CTX_MAGIC); + oc = bo->fetch_objcore; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AN(vfc->vfp_nxt); @@ -505,13 +517,13 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo) est = 0; do { - if (vfc->oc->flags & OC_F_ABANDON) { + if (oc->flags & OC_F_ABANDON) { /* * A pass object and delivery was terminated * We don't fail the fetch, in order for HitMiss * objects to be created. */ - AN(vfc->oc->flags & OC_F_HFM); + AN(oc->flags & OC_F_HFM); VSLb(wrk->vsl, SLT_Debug, "Fetch: Pass delivery abandoned"); bo->htc->doclose = SC_RX_BODY; @@ -542,7 +554,7 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo) bo->htc->doclose = SC_RX_BODY; vbf_cleanup(bo); if (!bo->do_stream) { - assert(bo->fetch_objcore->boc->state < BOS_STREAM); + assert(oc->boc->state < BOS_STREAM); // XXX: doclose = ? return (F_STP_ERROR); } else { @@ -551,7 +563,7 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo) } } - ObjTrimStore(wrk, vfc->oc); + ObjTrimStore(wrk, oc); return (F_STP_FETCHEND); } @@ -791,11 +803,13 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) uint8_t *ptr; struct vsb *synth_body; struct objcore *stale; + struct objcore *oc; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC); - AN(bo->fetch_objcore->flags & OC_F_BUSY); + oc = bo->fetch_objcore; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + AN(oc->flags & OC_F_BUSY); assert(bo->director_state == DIR_S_NULL); if (wrk->handling != VCL_RET_ERROR) @@ -804,8 +818,8 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) now = W_TIM_real(wrk); VSLb_ts_busyobj(bo, "Error", now); - if (bo->fetch_objcore->stobj->stevedore != NULL) - ObjFreeObj(bo->wrk, bo->fetch_objcore); + if (oc->stobj->stevedore != NULL) + ObjFreeObj(bo->wrk, oc); if (bo->storage == NULL) bo->storage = STV_next(); @@ -824,8 +838,8 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) http_SetHeader(bo->beresp, "Server: Varnish"); stale = bo->stale_oc; - bo->fetch_objcore->t_origin = now; - if (!VTAILQ_EMPTY(&bo->fetch_objcore->objhead->waitinglist)) { + oc->t_origin = now; + if (!VTAILQ_EMPTY(&oc->objhead->waitinglist)) { /* * If there is a waitinglist, it means that there is no * grace-able object, so cache the error return for a @@ -833,14 +847,14 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) * each objcore on the waiting list sequentially attempt * to fetch from the backend. */ - bo->fetch_objcore->ttl = 1; - bo->fetch_objcore->grace = 5; - bo->fetch_objcore->keep = 5; + oc->ttl = 1; + oc->grace = 5; + oc->keep = 5; stale = NULL; } else { - bo->fetch_objcore->ttl = 0; - bo->fetch_objcore->grace = 0; - bo->fetch_objcore->keep = 0; + oc->ttl = 0; + oc->grace = 0; + oc->keep = 0; } synth_body = VSB_new_auto(); @@ -866,7 +880,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) assert(wrk->handling == VCL_RET_DELIVER); assert(bo->vfc->wrk == bo->wrk); - assert(bo->vfc->oc == bo->fetch_objcore); + assert(bo->vfc->oc == oc); assert(bo->vfc->resp == bo->beresp); assert(bo->vfc->req == bo->bereq); @@ -889,13 +903,13 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) ll -= l; o += l; } - AZ(ObjSetU64(wrk, bo->fetch_objcore, OA_LEN, o)); + AZ(ObjSetU64(wrk, oc, OA_LEN, o)); VSB_destroy(&synth_body); - ObjSetState(wrk, bo->fetch_objcore, BOS_PREP_STREAM); - HSH_Unbusy(wrk, bo->fetch_objcore); - if (stale != NULL && bo->fetch_objcore->ttl > 0) + ObjSetState(wrk, oc, BOS_PREP_STREAM); + HSH_Unbusy(wrk, oc); + if (stale != NULL && oc->ttl > 0) HSH_Kill(stale); - ObjSetState(wrk, bo->fetch_objcore, BOS_FINISHED); + ObjSetState(wrk, oc, BOS_FINISHED); return (F_STP_DONE); } @@ -905,15 +919,18 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) static enum fetch_step vbf_stp_fail(struct worker *wrk, const struct busyobj *bo) { + struct objcore *oc; + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC); + oc = bo->fetch_objcore; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - assert(bo->fetch_objcore->boc->state < BOS_FINISHED); - HSH_Fail(bo->fetch_objcore); - if (!(bo->fetch_objcore->flags & OC_F_BUSY)) - HSH_Kill(bo->fetch_objcore); - ObjSetState(wrk, bo->fetch_objcore, BOS_FAILED); + assert(oc->boc->state < BOS_FINISHED); + HSH_Fail(oc); + if (!(oc->flags & OC_F_BUSY)) + HSH_Kill(oc); + ObjSetState(wrk, oc, BOS_FAILED); return (F_STP_DONE); } @@ -931,12 +948,14 @@ static void v_matchproto_(task_func_t) vbf_fetch_thread(struct worker *wrk, void *priv) { struct busyobj *bo; + struct objcore *oc; enum fetch_step stp; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo->req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC); + oc = bo->fetch_objcore; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); THR_SetBusyobj(bo); stp = F_STP_MKBEREQ; @@ -959,8 +978,8 @@ vbf_fetch_thread(struct worker *wrk, void *priv) VCL_TaskEnter(bo->privs); while (stp != F_STP_DONE) { CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - assert(bo->fetch_objcore->boc->refcount >= 1); - if (bo->fetch_objcore->boc->state < BOS_REQ_DONE) + assert(oc->boc->refcount >= 1); + if (oc->boc->state < BOS_REQ_DONE) AN(bo->req); else AZ(bo->req); @@ -986,18 +1005,18 @@ vbf_fetch_thread(struct worker *wrk, void *priv) if (bo->bereq_body != NULL) (void) HSH_DerefObjCore(bo->wrk, &bo->bereq_body, 0); - if (bo->fetch_objcore->boc->state == BOS_FINISHED) { - AZ(bo->fetch_objcore->flags & OC_F_FAILED); + if (oc->boc->state == BOS_FINISHED) { + AZ(oc->flags & OC_F_FAILED); VSLb(bo->vsl, SLT_Length, "%ju", - (uintmax_t)ObjGetLen(bo->wrk, bo->fetch_objcore)); + (uintmax_t)ObjGetLen(bo->wrk, oc)); } - // AZ(bo->fetch_objcore->boc); // XXX + // AZ(oc->boc); // XXX if (bo->stale_oc != NULL) (void)HSH_DerefObjCore(wrk, &bo->stale_oc, 0); wrk->vsl = NULL; - HSH_DerefBoc(wrk, bo->fetch_objcore); + HSH_DerefBoc(wrk, oc); SES_Rel(bo->sp); VBO_ReleaseBusyObj(wrk, &bo); THR_SetBusyobj(NULL); From nils.goroll at uplex.de Sun Apr 12 14:00:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 12 Apr 2020 14:00:07 +0000 (UTC) Subject: [master] 955261837 polish Message-ID: <20200412140007.23211A795C@lists.varnish-cache.org> commit 9552618373158c7082401ebd700edd86e01536a1 Author: Nils Goroll Date: Sun Apr 12 15:58:56 2020 +0200 polish diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 2ff4499de..680eb55d0 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -802,8 +802,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) vtim_real now; uint8_t *ptr; struct vsb *synth_body; - struct objcore *stale; - struct objcore *oc; + struct objcore *stale, *oc; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); From nils.goroll at uplex.de Sun Apr 12 14:17:06 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 12 Apr 2020 14:17:06 +0000 (UTC) Subject: [master] f178ef285 local variable for (struct busyobj *)->fetch_objcore Message-ID: <20200412141706.448EEA80B5@lists.varnish-cache.org> commit f178ef2855692bcc52bb8b8e4995180fea5d3848 Author: Nils Goroll Date: Sun Apr 12 16:15:34 2020 +0200 local variable for (struct busyobj *)->fetch_objcore e39e5e0dd790cb6e0575ec640dd88a2f0d1394d4 continued diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 680eb55d0..5eedaa706 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -570,9 +570,12 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo) static enum fetch_step vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) { + struct objcore *oc; + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC); + oc = bo->fetch_objcore; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); assert(wrk->handling == VCL_RET_DELIVER); @@ -599,10 +602,10 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) return (F_STP_ERROR); } - if (bo->fetch_objcore->flags & OC_F_PRIVATE) + if (oc->flags & OC_F_PRIVATE) AN(bo->uncacheable); - bo->fetch_objcore->boc->len_so_far = 0; + oc->boc->len_so_far = 0; if (VFP_Open(bo->vfc)) { (void)VFP_Error(bo->vfc, "Fetch pipeline failed to open"); @@ -620,23 +623,23 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) #define OBJ_FLAG(U, l, v) \ if (bo->vfc->obj_flags & OF_##U) \ - ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_##U, 1); + ObjSetFlag(bo->wrk, oc, OF_##U, 1); #include "tbl/obj_attr.h" - if (!(bo->fetch_objcore->flags & OC_F_HFM) && + if (!(oc->flags & OC_F_HFM) && http_IsStatus(bo->beresp, 200) && ( http_GetHdr(bo->beresp, H_Last_Modified, NULL) || http_GetHdr(bo->beresp, H_ETag, NULL))) - ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_IMSCAND, 1); + ObjSetFlag(bo->wrk, oc, OF_IMSCAND, 1); - assert(bo->fetch_objcore->boc->refcount >= 1); + assert(oc->boc->refcount >= 1); - assert(bo->fetch_objcore->boc->state == BOS_REQ_DONE); + assert(oc->boc->state == BOS_REQ_DONE); if (bo->do_stream) { - ObjSetState(wrk, bo->fetch_objcore, BOS_PREP_STREAM); - HSH_Unbusy(wrk, bo->fetch_objcore); - ObjSetState(wrk, bo->fetch_objcore, BOS_STREAM); + ObjSetState(wrk, oc, BOS_PREP_STREAM); + HSH_Unbusy(wrk, oc); + ObjSetState(wrk, oc, BOS_STREAM); } VSLb(bo->vsl, SLT_Fetch_Body, "%u %s %s", @@ -655,24 +658,30 @@ static enum fetch_step vbf_stp_fetchend(struct worker *wrk, struct busyobj *bo) { + struct objcore *oc; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + oc = bo->fetch_objcore; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + AZ(bo->vfc->failed); /* Recycle the backend connection before setting BOS_FINISHED to give predictable backend reuse behavior for varnishtest */ vbf_cleanup(bo); - AZ(ObjSetU64(wrk, bo->fetch_objcore, OA_LEN, - bo->fetch_objcore->boc->len_so_far)); + AZ(ObjSetU64(wrk, oc, OA_LEN, oc->boc->len_so_far)); if (bo->do_stream) - assert(bo->fetch_objcore->boc->state == BOS_STREAM); + assert(oc->boc->state == BOS_STREAM); else { - assert(bo->fetch_objcore->boc->state == BOS_REQ_DONE); - ObjSetState(wrk, bo->fetch_objcore, BOS_PREP_STREAM); - HSH_Unbusy(wrk, bo->fetch_objcore); + assert(oc->boc->state == BOS_REQ_DONE); + ObjSetState(wrk, oc, BOS_PREP_STREAM); + HSH_Unbusy(wrk, oc); } - ObjSetState(wrk, bo->fetch_objcore, BOS_FINISHED); + ObjSetState(wrk, oc, BOS_FINISHED); VSLb_ts_busyobj(bo, "BerespBody", W_TIM_real(wrk)); if (bo->stale_oc != NULL) HSH_Kill(bo->stale_oc); @@ -712,13 +721,16 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) { struct boc *stale_boc; enum boc_state_e stale_state; + struct objcore *oc, *stale_oc; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC); - CHECK_OBJ_NOTNULL(bo->stale_oc, OBJCORE_MAGIC); + oc = bo->fetch_objcore; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + stale_oc = bo->stale_oc; + CHECK_OBJ_NOTNULL(stale_oc, OBJCORE_MAGIC); - stale_boc = HSH_RefBoc(bo->stale_oc); + stale_boc = HSH_RefBoc(stale_oc); CHECK_OBJ_ORNULL(stale_boc, BOC_MAGIC); if (stale_boc) { /* Wait for the stale object to become fully fetched, so @@ -731,9 +743,9 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) * (this would be an issue for ie OA_GZIPBITS). */ VSLb(bo->vsl, SLT_Notice, "vsl: Conditional fetch wait for streaming object"); - ObjWaitState(bo->stale_oc, BOS_FINISHED); + ObjWaitState(stale_oc, BOS_FINISHED); stale_state = stale_boc->state; - HSH_DerefBoc(bo->wrk, bo->stale_oc); + HSH_DerefBoc(bo->wrk, stale_oc); stale_boc = NULL; if (stale_state != BOS_FINISHED) { (void)VFP_Error(bo->vfc, "Template object failed"); @@ -743,7 +755,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) } } AZ(stale_boc); - AZ(bo->stale_oc->flags & OC_F_FAILED); + AZ(stale_oc->flags & OC_F_FAILED); if (vbf_beresp2obj(bo)) { (void)VFP_Error(bo->vfc, "Could not get storage in vbf_stp_condfetch"); @@ -752,22 +764,21 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) return (F_STP_FAIL); } - if (ObjHasAttr(bo->wrk, bo->stale_oc, OA_ESIDATA)) - AZ(ObjCopyAttr(bo->wrk, bo->fetch_objcore, bo->stale_oc, - OA_ESIDATA)); + if (ObjHasAttr(bo->wrk, stale_oc, OA_ESIDATA)) + AZ(ObjCopyAttr(bo->wrk, oc, stale_oc, OA_ESIDATA)); - AZ(ObjCopyAttr(bo->wrk, bo->fetch_objcore, bo->stale_oc, OA_FLAGS)); - 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)); + AZ(ObjCopyAttr(bo->wrk, oc, stale_oc, OA_FLAGS)); + if (oc->flags & OC_F_HFM) + ObjSetFlag(bo->wrk, oc, OF_IMSCAND, 0); + AZ(ObjCopyAttr(bo->wrk, oc, stale_oc, OA_GZIPBITS)); if (bo->do_stream) { - ObjSetState(wrk, bo->fetch_objcore, BOS_PREP_STREAM); - HSH_Unbusy(wrk, bo->fetch_objcore); - ObjSetState(wrk, bo->fetch_objcore, BOS_STREAM); + ObjSetState(wrk, oc, BOS_PREP_STREAM); + HSH_Unbusy(wrk, oc); + ObjSetState(wrk, oc, BOS_STREAM); } - if (ObjIterate(wrk, bo->stale_oc, bo, vbf_objiterator, 0)) + if (ObjIterate(wrk, stale_oc, bo, vbf_objiterator, 0)) (void)VFP_Error(bo->vfc, "Template object failed"); if (bo->vfc->failed) { From nils.goroll at uplex.de Mon Apr 13 09:47:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 13 Apr 2020 09:47:07 +0000 (UTC) Subject: [master] 23003cd39 pack structs Message-ID: <20200413094707.1BA8798631@lists.varnish-cache.org> commit 23003cd3929fb97e2b9c0a2179337c76b390e748 Author: Nils Goroll Date: Mon Apr 13 11:43:33 2020 +0200 pack structs diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 5887ef01e..be8b304c8 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -58,10 +58,10 @@ struct vfp { struct vfp_entry { unsigned magic; #define VFP_ENTRY_MAGIC 0xbe32a027 + enum vfp_status closed; const struct vfp *vfp; void *priv1; intptr_t priv2; - enum vfp_status closed; VTAILQ_ENTRY(vfp_entry) list; uint64_t calls; uint64_t bytes_out; @@ -133,9 +133,9 @@ VTAILQ_HEAD(vdp_entry_s, vdp_entry); struct vdp_ctx { unsigned magic; #define VDP_CTX_MAGIC 0xee501df7 + int retval; struct vdp_entry_s vdp; struct vdp_entry *nxt; - int retval; }; int VDP_bytes(struct req *, enum vdp_action act, const void *ptr, ssize_t len); From nils.goroll at uplex.de Tue Apr 14 09:10:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 14 Apr 2020 09:10:07 +0000 (UTC) Subject: [master] a532e3942 For rollback, NULL additional pointers which could point to workspace Message-ID: <20200414091007.334A66E08A@lists.varnish-cache.org> commit a532e39421bfb00aa86dd1371cdba8010c14946b Author: Nils Goroll Date: Tue Apr 14 11:07:40 2020 +0200 For rollback, NULL additional pointers which could point to workspace diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 5eedaa706..2924a9448 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -110,6 +110,8 @@ void Bereq_Rollback(struct busyobj *bo) VCL_TaskLeave(bo->privs); VCL_TaskEnter(bo->privs); HTTP_Clone(bo->bereq, bo->bereq0); + bo->filter_list = NULL; + bo->err_reason = NULL; WS_Rollback(bo->bereq->ws, bo->ws_bo); WS_Rollback(bo->ws, bo->ws_bo); } diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index d9ad87203..43cb3837b 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -198,6 +198,7 @@ Req_Rollback(struct req *req) if (IS_TOPREQ(req)) VCL_TaskEnter(req->top->privs); HTTP_Clone(req->http, req->http0); + req->filter_list = NULL; if (WS_Overflowed(req->ws)) req->wrk->stats->ws_client_overflow++; WS_Rollback(req->ws, req->ws_req); From dridi.boukelmoune at gmail.com Tue Apr 14 15:13:06 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 14 Apr 2020 15:13:06 +0000 (UTC) Subject: [master] b18b9f9da Kill reference to vmod_if.[ch] Message-ID: <20200414151306.683679BCB2@lists.varnish-cache.org> commit b18b9f9da1a4522abfc4eb09b3c684eec4a1e0d3 Author: Dridi Boukelmoune Date: Tue Apr 14 16:54:48 2020 +0200 Kill reference to vmod_if.[ch] Even when it was introduced, it was inaccurate. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 2a8a9444c..8b91be754 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -30,8 +30,8 @@ """ Read the vmod.vcc file (inputvcc) and produce: - vmod_if.h -- Prototypes for the implementation - vmod_if.c -- Magic glue & datastructures to make things a VMOD. + vcc_if.h -- Prototypes for the implementation + vcc_if.c -- Magic glue & datastructures to make things a VMOD. vmod_${name}.rst -- Extracted documentation vmod_${name}.man.rst -- Extracted documentation (rst2man input) """ From dridi.boukelmoune at gmail.com Tue Apr 14 15:13:06 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 14 Apr 2020 15:13:06 +0000 (UTC) Subject: [master] f39b0403a Perpetuate the vmodtool -o option in the boilerplate Message-ID: <20200414151306.80D999BCB5@lists.varnish-cache.org> commit f39b0403a866b7da71bce854473a3d59cb12dd09 Author: Dridi Boukelmoune Date: Tue Apr 14 16:58:03 2020 +0200 Perpetuate the vmodtool -o option in the boilerplate diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 8b91be754..85fd69f96 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -58,7 +58,7 @@ AM_CPPFLAGS = \\ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs ?= --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate -o PFX vmod_LTLIBRARIES = libvmod_XXX.la diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am index 39118cb4d..3b0125e55 100644 --- a/lib/libvmod_blob/automake_boilerplate.am +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -9,7 +9,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs ?= --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate -o vcc_if vmod_LTLIBRARIES = libvmod_blob.la diff --git a/lib/libvmod_cookie/automake_boilerplate.am b/lib/libvmod_cookie/automake_boilerplate.am index ded993389..6c85b1ac4 100644 --- a/lib/libvmod_cookie/automake_boilerplate.am +++ b/lib/libvmod_cookie/automake_boilerplate.am @@ -9,7 +9,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs ?= --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate -o vcc_if vmod_LTLIBRARIES = libvmod_cookie.la diff --git a/lib/libvmod_debug/automake_boilerplate.am b/lib/libvmod_debug/automake_boilerplate.am index 5c8c8afbb..9b92b78cf 100644 --- a/lib/libvmod_debug/automake_boilerplate.am +++ b/lib/libvmod_debug/automake_boilerplate.am @@ -9,7 +9,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs ?= --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate -o vcc_if vmod_LTLIBRARIES = libvmod_debug.la diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am index 2d7a779fb..24012dcf8 100644 --- a/lib/libvmod_directors/automake_boilerplate.am +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -9,7 +9,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs ?= --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate -o vcc_if vmod_LTLIBRARIES = libvmod_directors.la diff --git a/lib/libvmod_proxy/automake_boilerplate.am b/lib/libvmod_proxy/automake_boilerplate.am index c81749811..db74debe4 100644 --- a/lib/libvmod_proxy/automake_boilerplate.am +++ b/lib/libvmod_proxy/automake_boilerplate.am @@ -9,7 +9,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs ?= --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate -o vcc_if vmod_LTLIBRARIES = libvmod_proxy.la diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am index 961c5e967..a3eace00b 100644 --- a/lib/libvmod_purge/automake_boilerplate.am +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -9,7 +9,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs ?= --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate -o vcc_if vmod_LTLIBRARIES = libvmod_purge.la diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am index 9ff7f9425..947b142dd 100644 --- a/lib/libvmod_std/automake_boilerplate.am +++ b/lib/libvmod_std/automake_boilerplate.am @@ -9,7 +9,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs ?= --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate -o vcc_if vmod_LTLIBRARIES = libvmod_std.la diff --git a/lib/libvmod_unix/automake_boilerplate.am b/lib/libvmod_unix/automake_boilerplate.am index f2582e27f..405b2a8ea 100644 --- a/lib/libvmod_unix/automake_boilerplate.am +++ b/lib/libvmod_unix/automake_boilerplate.am @@ -9,7 +9,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs ?= --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate -o vcc_if vmod_LTLIBRARIES = libvmod_unix.la diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am index feb939901..1494b3e67 100644 --- a/lib/libvmod_vtc/automake_boilerplate.am +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -9,7 +9,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs ?= --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate -o vcc_if vmod_LTLIBRARIES = libvmod_vtc.la From dridi.boukelmoune at gmail.com Tue Apr 14 15:13:06 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 14 Apr 2020 15:13:06 +0000 (UTC) Subject: [master] 276bcd7e5 Don't overload automake boilerplate placeholders Message-ID: <20200414151306.A3BC89BCB9@lists.varnish-cache.org> commit 276bcd7e547047d184bbe688f3601ff0b9de1fd8 Author: Dridi Boukelmoune Date: Tue Apr 14 17:00:09 2020 +0200 Don't overload automake boilerplate placeholders Even when they live in different templates. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 85fd69f96..0b674a309 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -89,7 +89,7 @@ CLEANFILES = $(builddir)/PFX.c $(builddir)/PFX.h \\ AMBOILERPLATE_CHECK = ''' TESTS = \\ -\tXXX +\tVTC EXTRA_DIST += $(TESTS) @@ -991,7 +991,7 @@ class vcc(object): tests = glob.glob("tests/*.vtc") if len(tests) > 0: tests.sort() - fo.write(AMBOILERPLATE_CHECK.replace("XXX", " \\\n\t".join(tests))) + fo.write(AMBOILERPLATE_CHECK.replace("VTC", " \\\n\t".join(tests))) fo.close() def mkdefs(self, fo): From dridi.boukelmoune at gmail.com Tue Apr 14 15:13:06 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 14 Apr 2020 15:13:06 +0000 (UTC) Subject: [master] 0c38fc1c3 Add a new placeholder for the VCC file in vmodtool Message-ID: <20200414151306.BAB179BCBD@lists.varnish-cache.org> commit 0c38fc1c38f79ce30e80227b48432529707aa177 Author: Dridi Boukelmoune Date: Tue Apr 14 17:07:44 2020 +0200 Add a new placeholder for the VCC file in vmodtool Unlike the PFX that added a -o option to $(vmodtoolargs) this change doesn't affect already checked-in boilerplate files. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 0b674a309..6fd1843ea 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -77,8 +77,8 @@ $(libvmod_XXX_la_OBJECTS): PFX.h PFX.h vmod_XXX.rst vmod_XXX.man.rst: PFX.c -PFX.c: $(vmodtool) $(srcdir)/vmod.vcc -\t at PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc +PFX.c: $(vmodtool) $(srcdir)/VCC +\t at PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/VCC EXTRA_DIST = vmod.vcc automake_boilerplate.am @@ -987,6 +987,7 @@ class vcc(object): ''' Produce boilplate for autocrap tools ''' fo = self.openfile("automake_boilerplate.am") fo.write(AMBOILERPLATE.replace("XXX", self.modname) + .replace("VCC", os.path.basename(self.inputfile)) .replace("PFX", self.pfx)) tests = glob.glob("tests/*.vtc") if len(tests) > 0: From dridi.boukelmoune at gmail.com Tue Apr 14 21:14:11 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 14 Apr 2020 21:14:11 +0000 (UTC) Subject: [master] 4a3e805fc Define $(vmoddir) in a single location Message-ID: <20200414211411.B4A60A5DAF@lists.varnish-cache.org> commit 4a3e805fca019d4c3acde0fdf97231ffcb957557 Author: Dridi Boukelmoune Date: Tue Apr 14 23:11:24 2020 +0200 Define $(vmoddir) in a single location Trimming more of the automake_boilerplate.am fat that prevents using $(vmodtool) --boilerplate out of tree. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index e124ed5d8..74974525b 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -163,7 +163,7 @@ varnishd_CFLAGS = \ @SAN_CFLAGS@ \ -DNOT_IN_A_VMOD \ -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' \ - -DVARNISH_VMOD_DIR='"${pkglibdir}/vmods"' \ + -DVARNISH_VMOD_DIR='"${vmoddir}"' \ -DVARNISH_VCL_DIR='"${pkgsysconfdir}:${vcldir}"' varnishd_LDFLAGS = -export-dynamic diff --git a/configure.ac b/configure.ac index 7c63ce667..cbdeb59cf 100644 --- a/configure.ac +++ b/configure.ac @@ -665,6 +665,9 @@ AC_SUBST(VARNISH_STATE_DIR) pkgsysconfdir='${sysconfdir}/varnish' AC_SUBST(pkgsysconfdir) +# VMODs directory +AC_SUBST(vmoddir, [$\(pkglibdir\)/vmods]) + # Check for linker script support gl_LD_VERSION_SCRIPT diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 6fd1843ea..8aff20188 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -56,7 +56,6 @@ AM_CPPFLAGS = \\ \t-I$(top_srcdir)/bin/varnishd \\ \t-I$(top_builddir)/include -vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs ?= --strict --boilerplate -o PFX diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am index 3b0125e55..0314308ff 100644 --- a/lib/libvmod_blob/automake_boilerplate.am +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -7,7 +7,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/bin/varnishd \ -I$(top_builddir)/include -vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs ?= --strict --boilerplate -o vcc_if diff --git a/lib/libvmod_cookie/automake_boilerplate.am b/lib/libvmod_cookie/automake_boilerplate.am index 6c85b1ac4..d9742e7c9 100644 --- a/lib/libvmod_cookie/automake_boilerplate.am +++ b/lib/libvmod_cookie/automake_boilerplate.am @@ -7,7 +7,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/bin/varnishd \ -I$(top_builddir)/include -vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs ?= --strict --boilerplate -o vcc_if diff --git a/lib/libvmod_debug/automake_boilerplate.am b/lib/libvmod_debug/automake_boilerplate.am index 9b92b78cf..407d5c1ab 100644 --- a/lib/libvmod_debug/automake_boilerplate.am +++ b/lib/libvmod_debug/automake_boilerplate.am @@ -7,7 +7,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/bin/varnishd \ -I$(top_builddir)/include -vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs ?= --strict --boilerplate -o vcc_if diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am index 24012dcf8..1849ef3c2 100644 --- a/lib/libvmod_directors/automake_boilerplate.am +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -7,7 +7,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/bin/varnishd \ -I$(top_builddir)/include -vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs ?= --strict --boilerplate -o vcc_if diff --git a/lib/libvmod_proxy/automake_boilerplate.am b/lib/libvmod_proxy/automake_boilerplate.am index db74debe4..09c793bc8 100644 --- a/lib/libvmod_proxy/automake_boilerplate.am +++ b/lib/libvmod_proxy/automake_boilerplate.am @@ -7,7 +7,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/bin/varnishd \ -I$(top_builddir)/include -vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs ?= --strict --boilerplate -o vcc_if diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am index a3eace00b..25132b54b 100644 --- a/lib/libvmod_purge/automake_boilerplate.am +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -7,7 +7,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/bin/varnishd \ -I$(top_builddir)/include -vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs ?= --strict --boilerplate -o vcc_if diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am index 947b142dd..7a82bd382 100644 --- a/lib/libvmod_std/automake_boilerplate.am +++ b/lib/libvmod_std/automake_boilerplate.am @@ -7,7 +7,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/bin/varnishd \ -I$(top_builddir)/include -vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs ?= --strict --boilerplate -o vcc_if diff --git a/lib/libvmod_unix/automake_boilerplate.am b/lib/libvmod_unix/automake_boilerplate.am index 405b2a8ea..7a4d0c598 100644 --- a/lib/libvmod_unix/automake_boilerplate.am +++ b/lib/libvmod_unix/automake_boilerplate.am @@ -7,7 +7,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/bin/varnishd \ -I$(top_builddir)/include -vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs ?= --strict --boilerplate -o vcc_if diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am index 1494b3e67..d01e912ea 100644 --- a/lib/libvmod_vtc/automake_boilerplate.am +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -7,7 +7,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/bin/varnishd \ -I$(top_builddir)/include -vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmodtoolargs ?= --strict --boilerplate -o vcc_if From dridi.boukelmoune at gmail.com Tue Apr 14 21:57:11 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 14 Apr 2020 21:57:11 +0000 (UTC) Subject: [master] 7ecd8e546 Substitute remaining hardcoded vmod.vcc references Message-ID: <20200414215711.A7EE7A6ED2@lists.varnish-cache.org> commit 7ecd8e546b86acf666d36da7fb228cd46ee04333 Author: Dridi Boukelmoune Date: Tue Apr 14 23:49:33 2020 +0200 Substitute remaining hardcoded vmod.vcc references Refs 0c38fc1c38f7 diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 8aff20188..87a9ce4b9 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -79,7 +79,7 @@ PFX.h vmod_XXX.rst vmod_XXX.man.rst: PFX.c PFX.c: $(vmodtool) $(srcdir)/VCC \t at PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/VCC -EXTRA_DIST = vmod.vcc automake_boilerplate.am +EXTRA_DIST = $(srcdir)/VCC automake_boilerplate.am CLEANFILES = $(builddir)/PFX.c $(builddir)/PFX.h \\ \t$(builddir)/vmod_XXX.rst \\ @@ -93,7 +93,7 @@ TESTS = \\ EXTRA_DIST += $(TESTS) vtc-refresh-tests: -\t at PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc +\t at PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/VCC \t at cd $(top_builddir) && ./config.status --file=$(subdir)/Makefile include $(top_srcdir)/vtc.am @@ -170,20 +170,20 @@ def fmt_cstruct(fo, a, b): ####################################################################### -def write_file_warning(fo, a, b, c): +def write_file_warning(fo, a, b, c, s): fo.write(a + "\n") fo.write(b + " NB: This file is machine generated, DO NOT EDIT!\n") fo.write(b + "\n") - fo.write(b + " Edit vmod.vcc and run make instead\n") + fo.write(b + " Edit " + s + " and run make instead\n") fo.write(c + "\n\n") -def write_c_file_warning(fo): - write_file_warning(fo, "/*", " *", " */") +def write_c_file_warning(fo, s): + write_file_warning(fo, "/*", " *", " */", s) -def write_rst_file_warning(fo): - write_file_warning(fo, "..", "..", "..") +def write_rst_file_warning(fo, s): + write_file_warning(fo, "..", "..", "..", s) def write_rst_hdr(fo, s, below="-", above=None): @@ -960,7 +960,7 @@ class vcc(object): fn += ".man" fn += ".rst" fo = self.openfile(fn) - write_rst_file_warning(fo) + write_rst_file_warning(fo, self.inputfile) if man: fo.write(".. role:: ref(emphasis)\n") else: @@ -984,14 +984,16 @@ class vcc(object): def amboilerplate(self): ''' Produce boilplate for autocrap tools ''' + vcc = os.path.basename(self.inputfile) fo = self.openfile("automake_boilerplate.am") fo.write(AMBOILERPLATE.replace("XXX", self.modname) - .replace("VCC", os.path.basename(self.inputfile)) + .replace("VCC", vcc) .replace("PFX", self.pfx)) tests = glob.glob("tests/*.vtc") if len(tests) > 0: tests.sort() - fo.write(AMBOILERPLATE_CHECK.replace("VTC", " \\\n\t".join(tests))) + fo.write(AMBOILERPLATE_CHECK.replace("VCC", vcc). + replace("VTC", " \\\n\t".join(tests))) fo.close() def mkdefs(self, fo): @@ -1011,7 +1013,7 @@ class vcc(object): ''' Produce vcc_if.h file ''' fn = self.pfx + ".h" fo = self.openfile(fn) - write_c_file_warning(fo) + write_c_file_warning(fo, self.inputfile) fo.write("#ifndef VDEF_H_INCLUDED\n") fo.write('# error "Include vdef.h first"\n') fo.write("#endif\n") @@ -1102,7 +1104,7 @@ class vcc(object): fnx = fno + ".tmp2" fx = open(fnx, "w") - write_c_file_warning(fo) + write_c_file_warning(fo, self.inputfile) self.mkdefs(fx); diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am index 0314308ff..0ff3f4f98 100644 --- a/lib/libvmod_blob/automake_boilerplate.am +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -30,7 +30,7 @@ vcc_if.h vmod_blob.rst vmod_blob.man.rst: vcc_if.c vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc -EXTRA_DIST = vmod.vcc automake_boilerplate.am +EXTRA_DIST = $(srcdir)/vmod.vcc automake_boilerplate.am CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ $(builddir)/vmod_blob.rst \ diff --git a/lib/libvmod_cookie/automake_boilerplate.am b/lib/libvmod_cookie/automake_boilerplate.am index d9742e7c9..f5333060a 100644 --- a/lib/libvmod_cookie/automake_boilerplate.am +++ b/lib/libvmod_cookie/automake_boilerplate.am @@ -30,7 +30,7 @@ vcc_if.h vmod_cookie.rst vmod_cookie.man.rst: vcc_if.c vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc -EXTRA_DIST = vmod.vcc automake_boilerplate.am +EXTRA_DIST = $(srcdir)/vmod.vcc automake_boilerplate.am CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ $(builddir)/vmod_cookie.rst \ diff --git a/lib/libvmod_debug/automake_boilerplate.am b/lib/libvmod_debug/automake_boilerplate.am index 407d5c1ab..f404971ef 100644 --- a/lib/libvmod_debug/automake_boilerplate.am +++ b/lib/libvmod_debug/automake_boilerplate.am @@ -30,7 +30,7 @@ vcc_if.h vmod_debug.rst vmod_debug.man.rst: vcc_if.c vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc -EXTRA_DIST = vmod.vcc automake_boilerplate.am +EXTRA_DIST = $(srcdir)/vmod.vcc automake_boilerplate.am CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ $(builddir)/vmod_debug.rst \ diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am index 1849ef3c2..69287d3d6 100644 --- a/lib/libvmod_directors/automake_boilerplate.am +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -30,7 +30,7 @@ vcc_if.h vmod_directors.rst vmod_directors.man.rst: vcc_if.c vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc -EXTRA_DIST = vmod.vcc automake_boilerplate.am +EXTRA_DIST = $(srcdir)/vmod.vcc automake_boilerplate.am CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ $(builddir)/vmod_directors.rst \ diff --git a/lib/libvmod_proxy/automake_boilerplate.am b/lib/libvmod_proxy/automake_boilerplate.am index 09c793bc8..fb295e30c 100644 --- a/lib/libvmod_proxy/automake_boilerplate.am +++ b/lib/libvmod_proxy/automake_boilerplate.am @@ -30,7 +30,7 @@ vcc_if.h vmod_proxy.rst vmod_proxy.man.rst: vcc_if.c vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc -EXTRA_DIST = vmod.vcc automake_boilerplate.am +EXTRA_DIST = $(srcdir)/vmod.vcc automake_boilerplate.am CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ $(builddir)/vmod_proxy.rst \ diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am index 25132b54b..d6d552864 100644 --- a/lib/libvmod_purge/automake_boilerplate.am +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -30,7 +30,7 @@ vcc_if.h vmod_purge.rst vmod_purge.man.rst: vcc_if.c vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc -EXTRA_DIST = vmod.vcc automake_boilerplate.am +EXTRA_DIST = $(srcdir)/vmod.vcc automake_boilerplate.am CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ $(builddir)/vmod_purge.rst \ diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am index 7a82bd382..146a4f1a6 100644 --- a/lib/libvmod_std/automake_boilerplate.am +++ b/lib/libvmod_std/automake_boilerplate.am @@ -30,7 +30,7 @@ vcc_if.h vmod_std.rst vmod_std.man.rst: vcc_if.c vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc -EXTRA_DIST = vmod.vcc automake_boilerplate.am +EXTRA_DIST = $(srcdir)/vmod.vcc automake_boilerplate.am CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ $(builddir)/vmod_std.rst \ diff --git a/lib/libvmod_unix/automake_boilerplate.am b/lib/libvmod_unix/automake_boilerplate.am index 7a4d0c598..6eaa08742 100644 --- a/lib/libvmod_unix/automake_boilerplate.am +++ b/lib/libvmod_unix/automake_boilerplate.am @@ -30,7 +30,7 @@ vcc_if.h vmod_unix.rst vmod_unix.man.rst: vcc_if.c vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc -EXTRA_DIST = vmod.vcc automake_boilerplate.am +EXTRA_DIST = $(srcdir)/vmod.vcc automake_boilerplate.am CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ $(builddir)/vmod_unix.rst \ diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am index d01e912ea..e330e3821 100644 --- a/lib/libvmod_vtc/automake_boilerplate.am +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -30,7 +30,7 @@ vcc_if.h vmod_vtc.rst vmod_vtc.man.rst: vcc_if.c vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc -EXTRA_DIST = vmod.vcc automake_boilerplate.am +EXTRA_DIST = $(srcdir)/vmod.vcc automake_boilerplate.am CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ $(builddir)/vmod_vtc.rst \ From nils.goroll at uplex.de Tue Apr 14 22:28:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 14 Apr 2020 22:28:07 +0000 (UTC) Subject: [master] 6f7af3a5a varnishtest: make process -expect-text on the same scale as vX Message-ID: <20200414222807.8D176A7BA1@lists.varnish-cache.org> commit 6f7af3a5a6c99a943c7f016a18a7b7d6c9693d22 Author: Marco Benatto Date: Tue Apr 14 14:06:20 2020 -0300 varnishtest: make process -expect-text on the same scale as vX Currently on process pX -expect-text varnishtest uses at most 300000 us pauses. This make it offscale when compared on what varnish vX -expect does by trying 50 times with 100us pause in a total of 5s. Chaning term_expect_text() wait 3s before failing avoid tests to cause false positive under stress (i.e.: r02990) but putting process pX -expect-text and varnish vX -expect at the same time scale. Signed-off-by: Marco Benatto diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index 24f7bab0b..f8ad2baa8 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -313,7 +313,7 @@ term_expect_text(struct process *pp, AZ(pthread_mutex_unlock(&pp->mtx)); usleep(d); AZ(pthread_mutex_lock(&pp->mtx)); - if (d < 300000) + if (d < 3000000) d += d; } AZ(pthread_mutex_unlock(&pp->mtx)); From nils.goroll at uplex.de Wed Apr 15 11:28:06 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 15 Apr 2020 11:28:06 +0000 (UTC) Subject: [master] 95abb73ef Wasn't 6.4.0 released on March 16th 2020? Message-ID: <20200415112806.0682D64549@lists.varnish-cache.org> commit 95abb73efbeee7f52f1527954ad82dccb4e25fbc Author: Thijs Feryn Date: Wed Apr 15 13:13:07 2020 +0200 Wasn't 6.4.0 released on March 16th 2020? diff --git a/doc/changes.rst b/doc/changes.rst index dc1ceac2a..5512de671 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -27,7 +27,7 @@ individual releases. These documents are updated as part of the release process. ================================ -Varnish Cache 6.4.0 (2019-09-16) +Varnish Cache 6.4.0 (2020-03-16) ================================ * The ``MAIN.sess_drop`` counter is gone. From dridi.boukelmoune at gmail.com Thu Apr 23 20:46:08 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 23 Apr 2020 20:46:08 +0000 (UTC) Subject: [master] 5721b7c0a Fix typos Message-ID: <20200423204608.6CD5492AF4@lists.varnish-cache.org> commit 5721b7c0aa3581ce94e58b65d37a3fd318dfdb11 Author: Pierre Grimaud Date: Thu Apr 23 20:05:34 2020 +0200 Fix typos diff --git a/CONTRIBUTING b/CONTRIBUTING index 1e3a16921..429d58a4e 100644 --- a/CONTRIBUTING +++ b/CONTRIBUTING @@ -25,5 +25,5 @@ Github pull requests Pull requests are handled like other tickets. -Trivial pull requests (fix typos, etc) are welcomed, but they may be commited +Trivial pull requests (fix typos, etc) are welcomed, but they may be committed by a core team member and the author credited in the commit message. diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 1e0b766a2..fdf4b70f1 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -41,7 +41,7 @@ static unsigned fetchfrag; /*-------------------------------------------------------------------- * We want to issue the first error we encounter on fetching and - * supress the rest. This function does that. + * suppress the rest. This function does that. * * Other code is allowed to look at busyobj->fetch_failed to bail out * diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 45a162bcb..05d229227 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -806,7 +806,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, VSL_Flush(bo->vsl, 0); VMOD_Panic(pan_vsb); } else { - VSB_cat(pan_vsb, "Feature short panic supressed details.\n"); + VSB_cat(pan_vsb, "Feature short panic suppressed details.\n"); } VSB_cat(pan_vsb, "\n"); VSB_putc(pan_vsb, '\0'); /* NUL termination */ diff --git a/bin/varnishd/cache/cache_tcp_pool.h b/bin/varnishd/cache/cache_tcp_pool.h index 91bbc642a..11c7ed211 100644 --- a/bin/varnishd/cache/cache_tcp_pool.h +++ b/bin/varnishd/cache/cache_tcp_pool.h @@ -76,7 +76,7 @@ void VTP_Rel(struct tcp_pool **); int VTP_Open(struct tcp_pool *, vtim_dur tmo, const void **, int*); /* - * Open a new connection and return the adress used. + * Open a new connection and return the address used. * errno will be returned in the last argument. */ diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index 2c9d6b4f3..3d17a8451 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -188,7 +188,7 @@ hcb_crit_bit(const uint8_t *digest, const struct objhead *oh2, struct hcb_y *y) /*--------------------------------------------------------------------- * Unless we have the lock, we need to be very careful about pointer * references into the tree, we cannot trust things to be the same - * in two consequtive memory accesses. + * in two consecutive memory accesses. */ static struct objhead * diff --git a/bin/varnishd/mgt/mgt_jail.c b/bin/varnishd/mgt/mgt_jail.c index 60515d28f..36b426ebf 100644 --- a/bin/varnishd/mgt/mgt_jail.c +++ b/bin/varnishd/mgt/mgt_jail.c @@ -101,7 +101,7 @@ VJ_Init(const char *j_arg) if (av[0] != NULL) ARGV_ERR("-j argument: %s\n", av[0]); if (av[1] == NULL) - ARGV_ERR("-j argument is emtpy\n"); + ARGV_ERR("-j argument is empty\n"); vjt = MGT_Pick(vj_choice, av[1], "jail"); CHECK_OBJ_NOTNULL(vjt, JAIL_TECH_MAGIC); (void)vjt->init(av + 2); diff --git a/bin/varnishd/mgt/mgt_param_tcp.c b/bin/varnishd/mgt/mgt_param_tcp.c index 087800a0f..80648c763 100644 --- a/bin/varnishd/mgt/mgt_param_tcp.c +++ b/bin/varnishd/mgt/mgt_param_tcp.c @@ -30,7 +30,7 @@ * * Parameters related to TCP keepalives are not universally available * as socket options, and probing for system-wide defaults more appropriate - * than our own involves slightly too much grunt-work to be neglible + * than our own involves slightly too much grunt-work to be negligible * so we sequestrate that code here. */ diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index 38364cede..ad8fe016e 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -213,7 +213,7 @@ Backend Pattern A backend pattern can be a backend name or a combination of a VCL name and backend name in "VCL.backend" format. If the VCL name is omitted, the active VCL is assumed. Partial matching on the backend and VCL -names is supported using shell-style wilcards, e.g. asterisk (*). +names is supported using shell-style wildcards, e.g. asterisk (*). Examples:: diff --git a/doc/sphinx/reference/varnishtest.rst b/doc/sphinx/reference/varnishtest.rst index 5cd180949..edde1f1ec 100644 --- a/doc/sphinx/reference/varnishtest.rst +++ b/doc/sphinx/reference/varnishtest.rst @@ -144,9 +144,9 @@ they look roughly like this:: exec varnishd [varnishtest -p params] [testing params] [vtc -arg params] -Parameters you define with ``varnishtest -p`` may be overriden by +Parameters you define with ``varnishtest -p`` may be overridden by parameters needed by ``varnishtest`` to run properly, and they may in -turn be overriden by parameters set in test scripts. +turn be overridden by parameters set in test scripts. There's also a special mode in which ``varnishtest`` builds itself a PATH and a *vmod_path* in order to find Varnish binaries (programs and diff --git a/doc/sphinx/users-guide/devicedetection.rst b/doc/sphinx/users-guide/devicedetection.rst index 91a608e71..8719adc13 100644 --- a/doc/sphinx/users-guide/devicedetection.rst +++ b/doc/sphinx/users-guide/devicedetection.rst @@ -55,7 +55,7 @@ Example 1: Send HTTP header to backend The basic case is that Varnish adds the 'X-UA-Device' HTTP header on the backend requests, and the backend mentions in the response 'Vary' header that the content -is dependant on this header. +is dependent on this header. Everything works out of the box from Varnish' perspective. diff --git a/doc/sphinx/users-guide/esi.rst b/doc/sphinx/users-guide/esi.rst index c8cabeef5..4baa38a3a 100644 --- a/doc/sphinx/users-guide/esi.rst +++ b/doc/sphinx/users-guide/esi.rst @@ -98,7 +98,7 @@ Ignoring BOM in ESI objects ~~~~~~~~~~~~~~~~~~~~~~~~~~~ If you backend spits out a Unicode Byte-Order-Mark as the first -bytes of the reponse, the "<" check will fail unless you set:: +bytes of the response, the "<" check will fail unless you set:: param.set feature +esi_remove_bom diff --git a/doc/sphinx/users-guide/increasing-your-hitrate.rst b/doc/sphinx/users-guide/increasing-your-hitrate.rst index 94e1bdbad..def6fcb36 100644 --- a/doc/sphinx/users-guide/increasing-your-hitrate.rst +++ b/doc/sphinx/users-guide/increasing-your-hitrate.rst @@ -438,7 +438,7 @@ A stale object is not removed from the cache for the duration of increase the storage requirements for your cache, but if you have the space, it might be worth it to keep stale objects that can be validated for a fairly long time. If the backend can send a 304 -response long after the TTL has expired, you save bandwith on the +response long after the TTL has expired, you save bandwidth on the fetch and reduce pressure on the storage; if not, then it's no different from any other cache miss. diff --git a/doc/sphinx/users-guide/storage-backends.rst b/doc/sphinx/users-guide/storage-backends.rst index 3e9734a30..8591fb6c9 100644 --- a/doc/sphinx/users-guide/storage-backends.rst +++ b/doc/sphinx/users-guide/storage-backends.rst @@ -99,7 +99,7 @@ Varnish will also output this message to recommend settings for using This recommendation should be followed to achieve an optimal `libumem`_ configuration for Varnish. Setting this environment -variable before starting Varnish is required becuase `libumem`_ cannot +variable before starting Varnish is required because `libumem`_ cannot be reconfigured once loaded. .. _libumem: http://dtrace.org/blogs/ahl/2004/07/13/number-11-of-20-libumem/ @@ -208,7 +208,7 @@ for transient (short lived) objects. This includes the temporary objects created when returning a synthetic object. By default Varnish would use an unlimited malloc backend for this. -.. XXX: Is this another paramater? In that case handled in the same manner as above? benc +.. XXX: Is this another parameter? In that case handled in the same manner as above? benc Varnish will consider an object short lived if the TTL is below the parameter 'shortlived'. From phk at FreeBSD.org Mon Apr 27 07:10:08 2020 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 27 Apr 2020 07:10:08 +0000 (UTC) Subject: [master] c5e9cf1c1 Remove VSB_QUOTE_GLOB, it was committed prematurely and does not quite work the way it should. Message-ID: <20200427071008.53D4762284@lists.varnish-cache.org> commit c5e9cf1c11bb6b6ccb9492887d83be0b2e0ad16f Author: Poul-Henning Kamp Date: Mon Apr 27 07:08:33 2020 +0000 Remove VSB_QUOTE_GLOB, it was committed prematurely and does not quite work the way it should. diff --git a/include/vsb.h b/include/vsb.h index b4305e42a..facea9394 100644 --- a/include/vsb.h +++ b/include/vsb.h @@ -84,7 +84,6 @@ void VSB_destroy(struct vsb **); #define VSB_QUOTE_CSTR 8 #define VSB_QUOTE_UNSAFE 16 #define VSB_QUOTE_ESCHEX 32 -#define VSB_QUOTE_GLOB 64 void VSB_quote_pfx(struct vsb *, const char*, const void *, int len, int how); void VSB_quote(struct vsb *, const void *, int len, int how); diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c index 4c4570c7b..ef9f164b0 100644 --- a/lib/libvarnish/vsb.c +++ b/lib/libvarnish/vsb.c @@ -563,7 +563,7 @@ VSB_quote_pfx(struct vsb *s, const char *pfx, const void *v, int len, int how) nl = 0; switch (*q) { case '?': - if (how & (VSB_QUOTE_CSTR | VSB_QUOTE_GLOB)) + if (how & VSB_QUOTE_CSTR) (void)VSB_putc(s, '\\'); (void)VSB_putc(s, *q); break; @@ -571,10 +571,6 @@ VSB_quote_pfx(struct vsb *s, const char *pfx, const void *v, int len, int how) (void)VSB_putc(s, *q); break; case '\\': - if (!(how & (VSB_QUOTE_UNSAFE))) - (void)VSB_putc(s, '\\'); - (void)VSB_putc(s, *q); - break; case '"': if (!(how & VSB_QUOTE_UNSAFE)) (void)VSB_putc(s, '\\'); @@ -586,38 +582,18 @@ VSB_quote_pfx(struct vsb *s, const char *pfx, const void *v, int len, int how) } else if (how & (VSB_QUOTE_NONL|VSB_QUOTE_UNSAFE)) { (void)VSB_printf(s, "\n"); nl = 1; - } else if (how & VSB_QUOTE_GLOB) { - (void)VSB_printf(s, "\\\\n"); } else { (void)VSB_printf(s, "\\n"); } break; case '\r': - if (how & VSB_QUOTE_GLOB) - (void)VSB_cat(s, "\\\\r"); - else - (void)VSB_cat(s, "\\r"); + (void)VSB_cat(s, "\\r"); break; case '\t': - if (how & VSB_QUOTE_GLOB) - (void)VSB_cat(s, "\\\\t"); - else - (void)VSB_cat(s, "\\t"); + (void)VSB_cat(s, "\\t"); break; case '\v': - if (how & VSB_QUOTE_GLOB) - (void)VSB_cat(s, "\\\\v"); - else - (void)VSB_cat(s, "\\v"); - break; - case '[': - case ']': - case '{': - case '}': - case '*': - if (how & VSB_QUOTE_GLOB) - (void)VSB_putc(s, '\\'); - (void)VSB_putc(s, *q); + (void)VSB_cat(s, "\\v"); break; default: /* XXX: Implement VSB_QUOTE_JSON */ diff --git a/lib/libvarnish/vsb_test.c b/lib/libvarnish/vsb_test.c index c6e4866ff..9ac60154c 100644 --- a/lib/libvarnish/vsb_test.c +++ b/lib/libvarnish/vsb_test.c @@ -16,26 +16,6 @@ struct tc { static struct tc tcs[] = { { - VSB_QUOTE_GLOB, - "abcdefghijklmnopqrstvwxyz", - "abcdefghijklmnopqrstvwxyz" - }, { - VSB_QUOTE_GLOB, - "ABCDEFGHIJKLMNOPQRSTVWXYZ", - "ABCDEFGHIJKLMNOPQRSTVWXYZ" - }, { - VSB_QUOTE_GLOB, - "01234567789", - "01234567789" - }, { - VSB_QUOTE_GLOB, - "abcde[f-g]{h,i,j}\\l?*xyz", - "abcde\\[f-g\\]\\{h,i,j\\}\\\\l\\?\\*xyz" - }, { - VSB_QUOTE_GLOB, - "0123\t \"\r\v\n'", - "0123\\\\t \\\"\\\\r\\\\v\\\\n'" - }, { 0, NULL, NULL } }; From nils.goroll at uplex.de Mon Apr 27 10:08:07 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 27 Apr 2020 10:08:07 +0000 (UTC) Subject: [master] de6288cbe Add VDP_END action for delivery processors Message-ID: <20200427100807.0A3886EA41@lists.varnish-cache.org> commit de6288cbe4ac102ebd3ca66cddb64bc12069ee49 Author: Nils Goroll Date: Wed Nov 13 06:42:03 2019 +0100 Add VDP_END action for delivery processors VDP_END marks the end of successful processing, it is issued by VDP_DeliverObj() and may also be sent downstream by processors ending the stream (for return value != 0) VDP_END must at most be generated once per processor, so any VDP sending it downstream must itself not forward it a second time. * VDP_bytes() The only relevant change is the assertion that VDP_END must not be received by any VDP more than once. This comes with minor restructuring of the handling of the three actions * VDP_DeliverObj() Here, VDP_END is pushed down after succesful iteration over the objects. We could also send the last storage segment with VDP_END, but this would require a change in all stevedores. Unless there is a good case for it, I do not see much value in this minor optimization. * ESI: In ved_vdp_esi_bytes we now push down VDP_END whenever we are done with an ESI object at esi_level == 0. ved_bytes() handles the pushes from higher esi levels downwards, so it now changes VDP_END into VDP_FLUSH. We need to remove the additional VDP_FLUSH from ved_deliver because the VDP_END from VDP_DeliverObj() needs to be the last bit sent. The gzgz vdp actually does something which would be impossible for an esi_level == 0 VDP: push bytes from _fini. This could be reworked, but there is also no need to. * range VDP Here we now send the VDP_END with the last segment before the end of the range is it. We also take the opportunity and eleminate null VDP_bytes calls before the range is reached. * rot13 debug VDP Here we need to ensure that we pass on VDP_END diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c index b7a316733..85f92b4e3 100644 --- a/bin/varnishd/cache/cache_deliver_proc.c +++ b/bin/varnishd/cache/cache_deliver_proc.c @@ -45,6 +45,13 @@ * VDP_bytes will return that value directly without calling the next * processor. * + * VDP_END marks the end of successful processing, it is issued by + * VDP_DeliverObj() and may also be sent downstream by processors ending the + * stream (for return value != 0) + * + * VDP_END must at most be received once per processor, so any VDP sending it + * downstream must itself not forward it a second time. + * * Valid return values (of VDP_bytes and any VDP function): * r < 0: Error, breaks out early on an error condition * r == 0: Continue @@ -59,15 +66,23 @@ VDP_bytes(struct req *req, enum vdp_action act, const void *ptr, ssize_t len) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); vdc = req->vdc; - assert(act == VDP_NULL || act == VDP_FLUSH); if (vdc->retval) return (vdc->retval); vdpe = vdc->nxt; CHECK_OBJ_NOTNULL(vdpe, VDP_ENTRY_MAGIC); - vdc->nxt = VTAILQ_NEXT(vdpe, list); - assert(act > VDP_NULL || len > 0); + /* at most one VDP_END call */ + assert(vdpe->end == VDP_NULL); + + if (act == VDP_NULL) + assert(len > 0); + else if (act == VDP_END) + vdpe->end = VDP_END; + else + assert(act == VDP_FLUSH); + /* Call the present layer, while pointing to the next layer down */ + vdc->nxt = VTAILQ_NEXT(vdpe, list); retval = vdpe->vdp->bytes(req, act, &vdpe->priv, ptr, len); if (retval && (vdc->retval == 0 || retval < vdc->retval)) vdc->retval = retval; /* Latch error value */ @@ -158,6 +173,8 @@ VDP_DeliverObj(struct req *req) final = req->objcore->flags & (OC_F_PRIVATE | OC_F_HFM | OC_F_HFP) ? 1 : 0; r = ObjIterate(req->wrk, req->objcore, req, vdp_objiterator, final); + if (r == 0) + r = VDP_bytes(req, VDP_END, NULL, 0); if (r < 0) return (r); return (0); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 44d6657b0..b22c61f60 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -413,17 +413,20 @@ ved_vdp_esi_bytes(struct req *req, enum vdp_action act, void **priv, /* MOD(2^32) length */ vle32enc(tailbuf + 9, ecx->l_crc); - (void)VDP_bytes(req, VDP_NULL, tailbuf, 13); + retval = VDP_bytes(req, VDP_END, tailbuf, 13); } else if (ecx->pecx != NULL) { ecx->pecx->crc = crc32_combine(ecx->pecx->crc, ecx->crc, ecx->l_crc); ecx->pecx->l_crc += ecx->l_crc; + retval = VDP_bytes(req, VDP_FLUSH, NULL, 0); + } else { + retval = VDP_bytes(req, VDP_END, NULL, 0); } - retval = VDP_bytes(req, VDP_FLUSH, NULL, 0); ecx->state = 99; return (retval); case 3: case 4: + assert(act != VDP_END); /* * There is no guarantee that the 'l' bytes are all * in the same storage segment, so loop over storage @@ -473,6 +476,8 @@ ved_bytes(struct req *req, struct ecx *ecx, enum vdp_action act, const void *ptr, ssize_t len) { req->acct.resp_bodybytes += len; + if (act == VDP_END) + act = VDP_FLUSH; return (VDP_bytes(ecx->preq, act, ptr, len)); } @@ -757,6 +762,12 @@ ved_gzgz_fini(struct req *req, void **priv) CAST_OBJ_NOTNULL(foo, *priv, VED_FOO_MAGIC); *priv = NULL; + /* XXX + * this works due to the esi layering, a VDP pushing bytes from _fini + * will otherwise have it's own _bytes method called. + * + * Could rewrite use VDP_END + */ (void)ved_bytes(req, foo->ecx, VDP_FLUSH, NULL, 0); icrc = vle32dec(foo->tailbuf); @@ -857,9 +868,6 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody) req->doclose = SC_OVERLOAD; } - if (i == 0) - i = VDP_bytes(req, VDP_FLUSH, NULL, 0); - if (i && req->doclose == SC_NULL) req->doclose = SC_REM_CLOSE; diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index be8b304c8..9c3605a1b 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -99,6 +99,7 @@ void VRT_RemoveVFP(VRT_CTX, const struct vfp *); enum vdp_action { VDP_NULL, /* Input buffer valid after call */ VDP_FLUSH, /* Input buffer will be invalidated */ + VDP_END, /* Last buffer or after, implies VDP_FLUSH */ }; typedef int vdp_init_f(struct req *, void **priv); @@ -123,6 +124,7 @@ struct vdp { struct vdp_entry { unsigned magic; #define VDP_ENTRY_MAGIC 0x353eb781 + enum vdp_action end; // VDP_NULL or VDP_END const struct vdp *vdp; void *priv; VTAILQ_ENTRY(vdp_entry) list; diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c index 9becb176b..970e75a75 100644 --- a/bin/varnishd/cache/cache_range.c +++ b/bin/varnishd/cache/cache_range.c @@ -84,13 +84,14 @@ vrg_range_bytes(struct req *req, enum vdp_action act, void **priv, l = vrg_priv->range_high - vrg_priv->range_off; if (l > len) l = len; + vrg_priv->range_off += len; + if (vrg_priv->range_off >= vrg_priv->range_high) + act = VDP_END; if (l > 0) retval = VDP_bytes(req, act, p, l); - else if (act > VDP_NULL) + else if (l == 0 && act > VDP_NULL) retval = VDP_bytes(req, act, p, 0); - vrg_priv->range_off += len; - return (retval || - vrg_priv->range_off >= vrg_priv->range_high ? 1 : 0); + return (retval || act == VDP_END ? 1 : 0); } /*--------------------------------------------------------------------*/ diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 11fddb90a..01013b892 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -117,12 +117,13 @@ xyzzy_rot13_bytes(struct req *req, enum vdp_action act, void **priv, const char *pp; int i, j, retval = 0; - (void)act; AN(priv); AN(*priv); - AN(ptr); if (len <= 0) - return (0); + return (VDP_bytes(req, act, ptr, len)); + AN(ptr); + if (act != VDP_END) + act = VDP_FLUSH; q = *priv; pp = ptr; @@ -134,14 +135,14 @@ xyzzy_rot13_bytes(struct req *req, enum vdp_action act, void **priv, else q[i] = pp[j]; if (i == ROT13_BUFSZ - 1) { - retval = VDP_bytes(req, VDP_FLUSH, q, ROT13_BUFSZ); + retval = VDP_bytes(req, act, q, ROT13_BUFSZ); if (retval != 0) return (retval); i = -1; } } if (i >= 0) - retval = VDP_bytes(req, VDP_FLUSH, q, i + 1L); + retval = VDP_bytes(req, act, q, i + 1L); return (retval); } From dridi.boukelmoune at gmail.com Mon Apr 27 13:54:06 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 27 Apr 2020 13:54:06 +0000 (UTC) Subject: [master] 0d8eb095d Don't distribute varnishstat_curses_help.c Message-ID: <20200427135406.B04A79642A@lists.varnish-cache.org> commit 0d8eb095d602e428fe110b041ab717adebdec0da Author: Dridi Boukelmoune Date: Mon Apr 27 15:50:59 2020 +0200 Don't distribute varnishstat_curses_help.c It's cheap to rebuild, and it might lead to rebuilding it in $(srcdir) instead of $(builddir) in a VPATH build. If the source tree is write protected this will obviously fail. Reported by phk. diff --git a/bin/varnishstat/Makefile.am b/bin/varnishstat/Makefile.am index 6721d3437..dc8664c65 100644 --- a/bin/varnishstat/Makefile.am +++ b/bin/varnishstat/Makefile.am @@ -11,10 +11,12 @@ varnishstat_SOURCES = \ varnishstat.c \ varnishstat_bindings.h \ varnishstat_curses.c \ - varnishstat_curses_help.c \ varnishstat_options.h -BUILT_SOURCES = varnishstat_curses_help.c +nodist_varnishstat_SOURCES = \ + varnishstat_curses_help.c + +BUILT_SOURCES = $(nodist_varnishstat_SOURCES) varnishstat_help_gen_SOURCES = \ varnishstat_help_gen.c \ From dridi.boukelmoune at gmail.com Mon Apr 27 15:17:06 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 27 Apr 2020 15:17:06 +0000 (UTC) Subject: [master] 448e2edcf Dist-clean varnishstat_curses_help.c Message-ID: <20200427151706.AA434A066A@lists.varnish-cache.org> commit 448e2edcf7c1c0f3ed8adf945cd78c29595e59c2 Author: Dridi Boukelmoune Date: Mon Apr 27 17:15:58 2020 +0200 Dist-clean varnishstat_curses_help.c Since we no longer distribute it... diff --git a/bin/varnishstat/Makefile.am b/bin/varnishstat/Makefile.am index dc8664c65..a6bc3eed9 100644 --- a/bin/varnishstat/Makefile.am +++ b/bin/varnishstat/Makefile.am @@ -17,6 +17,7 @@ nodist_varnishstat_SOURCES = \ varnishstat_curses_help.c BUILT_SOURCES = $(nodist_varnishstat_SOURCES) +DISTCLEANFILES = $(nodist_varnishstat_SOURCES) varnishstat_help_gen_SOURCES = \ varnishstat_help_gen.c \ From nils.goroll at uplex.de Tue Apr 28 16:52:08 2020 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 28 Apr 2020 16:52:08 +0000 (UTC) Subject: [master] fe5e82650 When connecting to backends, respect the administrative health Message-ID: <20200428165208.B6C9A97F53@lists.varnish-cache.org> commit fe5e82650788c1ce3dfbd29c8eeacf2b78c04ff4 Author: Nils Goroll Date: Tue Apr 28 18:06:38 2020 +0200 When connecting to backends, respect the administrative health When making a connection a "real" backend (VBE), we checked the probed health state and did not take into account the administrative health state as set with `varnishadm backend.set_health ... {healthy,sick}`. Our documentation was not particularly explicit on this aspect either, but the administrative states `sick` and `healthy` made no sense if `auto` semantics was implied always. Also, the semantics were implicitly documented for `backend.list`. Implementation note: The relevant change is to call `VRT_Healthy()`, which does check the administrative health, in place of checking `(struct backend *)->sick` in `vbe_dir_getfd()`. As a `VRT_CTX` is required by `VRT_Healthy()`, we change the arguments of `vbe_dir_getfd()` accordingly: The busyobj can now be taken from the ctx, but the worker argument differs for pipe mode vs. fetch, so we preserve it as an explicit argument. A test for overriding a probed backend as healthy has been added to c00048.vtc, which requires a second probe to hit server s1 and fail. This is timing sensitive, so I hope that the backend probe interval of 5 seconds is long enough for all our test environments. If not, we probably need to make it longer or add another vtc. Fixes #3299 diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 9cecd54a3..5c1f5b58d 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -110,12 +110,15 @@ VBE_Connect_Error(struct VSC_vbe *vsc, int err) /*-------------------------------------------------------------------- * Get a connection to the backend + * + * note: wrk is a separate argument because it differs for pipe vs. fetch */ static struct pfd * -vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo, +vbe_dir_getfd(VRT_CTX, struct worker *wrk, struct backend *bp, unsigned force_fresh) { + struct busyobj *bo; struct pfd *pfd; int *fdp, err; vtim_dur tmod; @@ -123,11 +126,12 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo, char pbuf1[VTCP_PORTBUFSIZE], pbuf2[VTCP_PORTBUFSIZE]; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + bo = ctx->bo; CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC); AN(bp->vsc); - if (bp->sick) { + if (! VRT_Healthy(ctx, bp->director, NULL)) { VSLb(bo->vsl, SLT_FetchError, "backend %s: unhealthy", VRT_BACKEND_string(bp->director)); bp->vsc->unhealthy++; @@ -280,7 +284,7 @@ vbe_dir_gethdrs(VRT_CTX, VCL_BACKEND d) http_PrintfHeader(bo->bereq, "Host: %s", bp->hosthdr); do { - pfd = vbe_dir_getfd(wrk, bp, bo, extrachance == 0 ? 1 : 0); + pfd = vbe_dir_getfd(ctx, wrk, bp, extrachance == 0 ? 1 : 0); if (pfd == NULL) return (-1); AN(bo->htc); @@ -365,7 +369,7 @@ vbe_dir_http1pipe(VRT_CTX, VCL_BACKEND d) ctx->req->res_mode = RES_PIPE; - pfd = vbe_dir_getfd(ctx->req->wrk, bp, ctx->bo, 0); + pfd = vbe_dir_getfd(ctx, ctx->req->wrk, bp, 0); if (pfd == NULL) { retval = SC_TX_ERROR; diff --git a/bin/varnishtest/tests/c00048.vtc b/bin/varnishtest/tests/c00048.vtc index 161c0d502..a5739503b 100644 --- a/bin/varnishtest/tests/c00048.vtc +++ b/bin/varnishtest/tests/c00048.vtc @@ -1,6 +1,27 @@ varnishtest "Forcing health of backends" -server s1 -repeat 3 { +barrier b1 cond 2 + +server s1 { + # probe + rxreq + txresp + + # req + accept + rxreq + txresp + rxreq + txresp -hdr "Connection: close" + + # probe sick + accept + rxreq + txresp -status 500 + barrier b1 sync + + accept + # req rxreq txresp } -start @@ -13,7 +34,7 @@ varnish v1 -vcl { .window = 8; .initial = 7; .threshold = 8; - .interval = 10s; + .interval = 5s; } } @@ -60,6 +81,18 @@ client c1 { expect resp.status == 200 } -run +# wait for sick probe +barrier b1 sync + +# healthy overrides probe +varnish v1 -cliok "backend.list" + +client c1 { + txreq + rxresp + expect resp.status == 200 +} -run + varnish v1 -vsl_catchup varnish v1 -clierr 106 "backend.set_health s1 foo" diff --git a/include/tbl/cli_cmds.h b/include/tbl/cli_cmds.h index 84b600f80..3e737c641 100644 --- a/include/tbl/cli_cmds.h +++ b/include/tbl/cli_cmds.h @@ -312,8 +312,11 @@ CLI_CMD(BACKEND_LIST, CLI_CMD(BACKEND_SET_HEALTH, "backend.set_health", "backend.set_health [auto|healthy|sick]", - "Set health status on the backends.", - "", + "Set health status of backend(s) matching .", + " * With ``auto``, the health status is determined by a probe\n" + " or some other dynamic mechanism, if any\n" + " * ``healthy`` sets the backend as usable\n" + " * ``sick`` sets the backend as unsable\n", 2, 2 ) From dridi.boukelmoune at gmail.com Tue Apr 28 18:51:08 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 28 Apr 2020 18:51:08 +0000 (UTC) Subject: [master] a9f56f6ab Fix typo Message-ID: <20200428185108.B4E44A0DBD@lists.varnish-cache.org> commit a9f56f6ab2a093718d88b55d72b7d7638b8822cb Author: Jordan Christiansen Date: Tue Apr 28 12:56:00 2020 -0500 Fix typo diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 1c5e2ee4d..faa5e374d 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -144,7 +144,7 @@ valid invocations from vcl:: debug.argtest("1", four=6); The C interface does not change with named arguments and default -values, arguments remain positional and defaul values appear no +values, arguments remain positional and default values appear no different to user specified values. `Note` that default values have to be given in the native C-type From dridi.boukelmoune at gmail.com Thu Apr 30 13:20:07 2020 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 30 Apr 2020 13:20:07 +0000 (UTC) Subject: [master] fcd983451 check for python before running the test Message-ID: <20200430132007.4B9874713@lists.varnish-cache.org> commit fcd983451c52d284561de4534d4726e76c5314cf Author: Guillaume Quintard Date: Mon Apr 20 10:00:50 2020 -0700 check for python before running the test diff --git a/bin/varnishtest/tests/u00015.vtc b/bin/varnishtest/tests/u00015.vtc index 0a53593d3..7917bdae2 100644 --- a/bin/varnishtest/tests/u00015.vtc +++ b/bin/varnishtest/tests/u00015.vtc @@ -1,5 +1,7 @@ varnishtest "varnishstat -j" +feature cmd "python3 -c 'import json'" + server s1 -repeat 5 { rxreq txresp @@ -15,8 +17,5 @@ client c1 -repeat 5 { delay 1 shell { varnishstat -n ${v1_name} -j } -## XXX: -## - use @PYTHON@ discovered via autogen/automake -## - make this test depend on json being available -#shell -expect "1" { varnishstat -n ${v1_name} -j | python3 -c 'import sys, json; print(json.load(sys.stdin)["version"])' } -#shell -expect "5" { varnishstat -n ${v1_name} -j | python3 -c 'import sys, json; print(json.load(sys.stdin)["counters"]["MAIN.client_req"]["value"])' } +shell -match "^1$" { varnishstat -n ${v1_name} -j | python3 -c 'import sys, json; print(json.load(sys.stdin)["version"])' } +shell -match "^5$" { varnishstat -n ${v1_name} -j | python3 -c 'import sys, json; print(json.load(sys.stdin)["counters"]["MAIN.client_req"]["value"])' }