From phk at FreeBSD.org Tue Feb 1 08:46:08 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 1 Feb 2022 08:46:08 +0000 (UTC) Subject: [master] 6c591d170 Minor refactoring. Message-ID: <20220201084608.6BFC99BE1B@lists.varnish-cache.org> commit 6c591d170cb68efdfbf77ac598e0fd1077ff48d3 Author: Poul-Henning Kamp Date: Tue Feb 1 08:11:23 2022 +0000 Minor refactoring. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 12ca1946e..1473822ce 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -434,6 +434,32 @@ mgt_f_read(const char *fn) VTAILQ_INSERT_TAIL(&f_args, fa, list); } +static void +mgt_b_conv(const char *b_arg) +{ + struct f_arg *fa; + struct vsb *vsb; + + ALLOC_OBJ(fa, F_ARG_MAGIC); + AN(fa); + REPLACE(fa->farg, "<-b argument>"); + vsb = VSB_new_auto(); + AN(vsb); + VSB_cat(vsb, "vcl 4.1;\n"); + VSB_cat(vsb, "backend default "); + if (!strcasecmp(b_arg, "none")) + VSB_cat(vsb, "none;\n"); + else if (*b_arg != '/') + VSB_printf(vsb, "{\n .host = \"%s\";\n}\n", optarg); + else + VSB_printf(vsb, "{\n .path = \"%s\";\n}\n", optarg); + AZ(VSB_finish(vsb)); + fa->src = strdup(VSB_data(vsb)); + AN(fa->src); + VSB_destroy(&vsb); + VTAILQ_INSERT_TAIL(&f_args, fa, list); +} + static struct vpf_fh * create_pid_file(pid_t *ppid, const char *fmt, ...) { @@ -617,6 +643,9 @@ main(int argc, char * const *argv) /* Initialize the bogo-IP VSA */ VSA_Init(); + if (b_arg != NULL) + mgt_b_conv(b_arg); + optind = 1; optreset = 1; while ((o = getopt(argc, argv, opt_spec)) != -1) { @@ -631,33 +660,13 @@ main(int argc, char * const *argv) MAC_Arg(optarg); break; case 'b': - ALLOC_OBJ(fa, F_ARG_MAGIC); - AN(fa); - REPLACE(fa->farg, "<-b argument>"); - vsb = VSB_new_auto(); - AN(vsb); - VSB_cat(vsb, "vcl 4.1;\n"); - VSB_cat(vsb, "backend default "); - if (! strcasecmp(optarg, "none")) - VSB_cat(vsb, "none;\n"); - else if (*optarg != '/') - VSB_printf(vsb, "{\n .host = \"%s\";\n}\n", - optarg); - else - VSB_printf(vsb, "{\n .path = \"%s\";\n}\n", - optarg); - AZ(VSB_finish(vsb)); - fa->src = strdup(VSB_data(vsb)); - AN(fa->src); - VSB_destroy(&vsb); - VTAILQ_INSERT_TAIL(&f_args, fa, list); + /* already dealt with */ break; case 'f': - if (*optarg == '\0') { + if (*optarg == '\0') novcl = 1; - break; - } - mgt_f_read(optarg); + else + mgt_f_read(optarg); break; case 'h': h_arg = optarg; From phk at FreeBSD.org Tue Feb 1 08:46:08 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 1 Feb 2022 08:46:08 +0000 (UTC) Subject: [master] 555219dd6 Minor refactoring Message-ID: <20220201084608.87B119BE1D@lists.varnish-cache.org> commit 555219dd66b62963ac1c812d4ffa808eccacf9c7 Author: Poul-Henning Kamp Date: Tue Feb 1 08:21:12 2022 +0000 Minor refactoring diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 1473822ce..08053c5cc 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -460,6 +460,28 @@ mgt_b_conv(const char *b_arg) VTAILQ_INSERT_TAIL(&f_args, fa, list); } +static const char * +create_bogo_n_arg(void) +{ + struct vsb *vsb; + char *p; + + vsb = VSB_new_auto(); + AN(vsb); + if (getenv("TMPDIR") != NULL) + VSB_printf(vsb, "%s", getenv("TMPDIR")); + else + VSB_cat(vsb, "/tmp"); + VSB_cat(vsb, "/varnishd_C_XXXXXXX"); + AZ(VSB_finish(vsb)); + p = strdup(VSB_data(vsb)); + AN(p); + VSB_destroy(&vsb); + AN(mkdtemp(p)); + AZ(chmod(p, 0750)); + return (p); +} + static struct vpf_fh * create_pid_file(pid_t *ppid, const char *fmt, ...) { @@ -515,7 +537,6 @@ main(int argc, char * const *argv) struct sigaction sac; struct vev *e; struct f_arg *fa; - struct vsb *vsb; pid_t pid; if (argc == 2 && !strcmp(argv[1], "--optstring")) { @@ -761,24 +782,8 @@ main(int argc, char * const *argv) assert(d_flag == 0 || F_flag == 0); - if (C_flag) { - if (n_arg == NULL) { - vsb = VSB_new_auto(); - AN(vsb); - if (getenv("TMPDIR") != NULL) - VSB_printf(vsb, "%s", getenv("TMPDIR")); - else - VSB_cat(vsb, "/tmp"); - VSB_cat(vsb, "/varnishd_C_XXXXXXX"); - AZ(VSB_finish(vsb)); - p = strdup(VSB_data(vsb)); - AN(p); - VSB_destroy(&vsb); - AN(mkdtemp(p)); - AZ(chmod(p, 0750)); - n_arg = p; - } - } + if (C_flag && n_arg == NULL) + n_arg = create_bogo_n_arg(); if (S_arg != NULL && !strcmp(S_arg, "none")) { fprintf(stderr, From phk at FreeBSD.org Tue Feb 1 08:46:08 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 1 Feb 2022 08:46:08 +0000 (UTC) Subject: [master] 584903b0b Minor refactoring Message-ID: <20220201084608.CD9DD9BE23@lists.varnish-cache.org> commit 584903b0bedbd52aa23978c8cf802c727238f54e Author: Poul-Henning Kamp Date: Tue Feb 1 08:45:02 2022 +0000 Minor refactoring diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 08053c5cc..5f54dfc27 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -460,6 +460,35 @@ mgt_b_conv(const char *b_arg) VTAILQ_INSERT_TAIL(&f_args, fa, list); } +static int +mgt_process_f_args(struct cli *cli, unsigned C_flag) +{ + int retval = 0; + struct f_arg *fa; + + while (!VTAILQ_EMPTY(&f_args)) { + fa = VTAILQ_FIRST(&f_args); + CHECK_OBJ_NOTNULL(fa, F_ARG_MAGIC); + VTAILQ_REMOVE(&f_args, fa, list); + mgt_vcl_startup(cli, fa->src, + VTAILQ_EMPTY(&f_args) ? "boot" : NULL, fa->farg, C_flag); + if (C_flag) { + if (cli->result != CLIS_OK && + cli->result != CLIS_TRUNCATED) + retval = 2; + AZ(VSB_finish(cli->sb)); + fprintf(stderr, "%s\n", VSB_data(cli->sb)); + VSB_clear(cli->sb); + } else { + cli_check(cli); + } + free(fa->farg); + free(fa->src); + FREE_OBJ(fa); + } + return (retval); +} + static const char * create_bogo_n_arg(void) { @@ -536,7 +565,6 @@ main(int argc, char * const *argv) unsigned u; struct sigaction sac; struct vev *e; - struct f_arg *fa; pid_t pid; if (argc == 2 && !strcmp(argv[1], "--optstring")) { @@ -840,28 +868,7 @@ main(int argc, char * const *argv) mgt_vcl_init(); - u = 0; - while (!VTAILQ_EMPTY(&f_args)) { - fa = VTAILQ_FIRST(&f_args); - CHECK_OBJ_NOTNULL(fa, F_ARG_MAGIC); - VTAILQ_REMOVE(&f_args, fa, list); - mgt_vcl_startup(cli, fa->src, - VTAILQ_EMPTY(&f_args) ? "boot" : NULL, - fa->farg, C_flag); - if (C_flag) { - if (cli->result != CLIS_OK && - cli->result != CLIS_TRUNCATED) - u = 2; - AZ(VSB_finish(cli->sb)); - fprintf(stderr, "%s\n", VSB_data(cli->sb)); - VSB_clear(cli->sb); - } else { - cli_check(cli); - } - free(fa->farg); - free(fa->src); - FREE_OBJ(fa); - } + u = mgt_process_f_args(cli, C_flag); if (C_flag) exit(u); From phk at FreeBSD.org Tue Feb 1 08:46:08 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 1 Feb 2022 08:46:08 +0000 (UTC) Subject: [master] 3f000273f Better mgt_main.c coverage, including actually testing -I Message-ID: <20220201084609.0DD999BE28@lists.varnish-cache.org> commit 3f000273f7b6c952807d614b496444f0ad5514d6 Author: Poul-Henning Kamp Date: Tue Feb 1 08:45:11 2022 +0000 Better mgt_main.c coverage, including actually testing -I diff --git a/bin/varnishtest/tests/u00000.vtc b/bin/varnishtest/tests/u00000.vtc index 5103f85b3..a7e3e1bf4 100644 --- a/bin/varnishtest/tests/u00000.vtc +++ b/bin/varnishtest/tests/u00000.vtc @@ -34,13 +34,22 @@ shell "varnishd -x parameter > ${tmpdir}/_.param" shell "varnishd -x vsl > ${tmpdir}/_.vsl" shell "varnishd -x cli > ${tmpdir}/_.cli" shell "varnishd -x builtin > ${tmpdir}/_.builtin" +shell "varnishd -x optstring > ${tmpdir}/_.optstring" +shell "varnishd --optstring > ${tmpdir}/_.optstring2" shell -err -expect {-C needs either -b or -f } { varnishd -C } + shell -err -expect {Cannot open -S file} { varnishd -S ${tmpdir}/nonexistent -n ${tmpdir}/v0 -f '' } + +shell -err -expect {Cannot create secret-file in} { + mkdir ${tmpdir}/is_a_dir ${tmpdir}/is_a_dir/_.secret + varnishd -n ${tmpdir}/is_a_dir -d -a :0 +} + shell -err -expect {Unknown jail method "xyz"} "varnishd -jxyz -f '' " shell -err -expect {Invalid backslash sequence} { @@ -72,6 +81,10 @@ shell -err -expect {Error: -I file CLI command failed (104)} { varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m } +shell -err -expect {Cant open} { + varnishd -f '' -I non-existent -n ${tmpdir}/v0 -a :0 -l '2m,"' +} + shell -err -expect {Error: -l ...: Missing '"'} { varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l '2m,"' } @@ -84,13 +97,19 @@ shell -err -expect {Warning: Ignoring deprecated second subargument} { varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m,2m } + # Code coverage of mgt_main, (VCL compiler and RSTdump etc) (former a00017) # Test -F mode with no VCL loaded -process p1 "exec varnishd -n ${tmpdir}/v1 -F -f '' -a :0 -l2m,1m" -log -start +shell {echo ping > ${tmpdir}/I_file} +process p1 "exec varnishd -n ${tmpdir}/v1 -F -f '' -a :0 -l2m,1m -I ${tmpdir}/I_file 2>&1" -start + +process p1 -expect-text 0 0 {Warning: Ignoring deprecated second subargument to -l} +process p1 -expect-text 0 1 {PONG} +process p1 -expect-text 0 1 {END of -I file processing} -delay 2 +process p1 -screen_dump shell { ( From dridi.boukelmoune at gmail.com Tue Feb 1 10:00:11 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 1 Feb 2022 10:00:11 +0000 (UTC) Subject: [master] a0d0544d7 mgt: Spelling Message-ID: <20220201100011.4EF45A2B7F@lists.varnish-cache.org> commit a0d0544d7afa684349939016b7515465aff29d30 Author: Dridi Boukelmoune Date: Tue Feb 1 10:59:09 2022 +0100 mgt: Spelling diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 5f54dfc27..3615d142e 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -729,7 +729,7 @@ main(int argc, char * const *argv) VJ_master(JAIL_MASTER_FILE); I_fd = open(optarg, O_RDONLY); if (I_fd < 0) - ARGV_ERR("\tCant open %s: %s\n", + ARGV_ERR("\tCan't open %s: %s\n", optarg, VAS_errtxt(errno)); VJ_master(JAIL_MASTER_LOW); break; diff --git a/bin/varnishtest/tests/u00000.vtc b/bin/varnishtest/tests/u00000.vtc index a7e3e1bf4..a800b8a2c 100644 --- a/bin/varnishtest/tests/u00000.vtc +++ b/bin/varnishtest/tests/u00000.vtc @@ -81,7 +81,7 @@ shell -err -expect {Error: -I file CLI command failed (104)} { varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m } -shell -err -expect {Cant open} { +shell -err -expect "Can't open non-existent" { varnishd -f '' -I non-existent -n ${tmpdir}/v0 -a :0 -l '2m,"' } From phk at FreeBSD.org Tue Feb 1 10:29:04 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 1 Feb 2022 10:29:04 +0000 (UTC) Subject: [master] 59f10690b Use the -b argument passed to the function. Message-ID: <20220201102904.E8E82A3C03@lists.varnish-cache.org> commit 59f10690b1c293bbd2e984f5ee09e7d187c10044 Author: Poul-Henning Kamp Date: Tue Feb 1 10:22:18 2022 +0000 Use the -b argument passed to the function. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 3615d142e..0df2806c0 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -450,9 +450,9 @@ mgt_b_conv(const char *b_arg) if (!strcasecmp(b_arg, "none")) VSB_cat(vsb, "none;\n"); else if (*b_arg != '/') - VSB_printf(vsb, "{\n .host = \"%s\";\n}\n", optarg); + VSB_printf(vsb, "{\n .host = \"%s\";\n}\n", b_arg); else - VSB_printf(vsb, "{\n .path = \"%s\";\n}\n", optarg); + VSB_printf(vsb, "{\n .path = \"%s\";\n}\n", b_arg); AZ(VSB_finish(vsb)); fa->src = strdup(VSB_data(vsb)); AN(fa->src); From phk at FreeBSD.org Tue Feb 1 13:46:06 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 1 Feb 2022 13:46:06 +0000 (UTC) Subject: [master] 15b166f02 Remove old special-case handling of `-l` argument errors. Message-ID: <20220201134606.9C5C2A9B83@lists.varnish-cache.org> commit 15b166f02c2065de108fe0aed46ad66b28c07a56 Author: Poul-Henning Kamp Date: Tue Feb 1 13:44:15 2022 +0000 Remove old special-case handling of `-l` argument errors. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 0df2806c0..4f65216ce 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -560,7 +560,6 @@ main(int argc, char * const *argv) const char *T_arg = "localhost:0"; char *p; struct cli cli[1]; - char **av; const char *err; unsigned u; struct sigaction sac; @@ -734,22 +733,8 @@ main(int argc, char * const *argv) VJ_master(JAIL_MASTER_LOW); break; case 'l': - av = VAV_Parse(optarg, NULL, ARGV_COMMA); - AN(av); - if (av[0] != NULL) - ARGV_ERR("-l ...: %s\n", av[0]); - if (av[1] != NULL && av[2] != NULL && av[3] != NULL) - ARGV_ERR("Too many sub arguments to -l\n"); - if (av[1] != NULL) { - MCF_ParamSet(cli, "vsl_space", av[1]); - cli_check(cli); - } - if (av[1] != NULL && av[2] != NULL) { - fprintf(stderr, - "Warning: Ignoring deprecated second" - " subargument to -l\n"); - } - VAV_Free(av); + MCF_ParamSet(cli, "vsl_space", optarg); + cli_check(cli); break; case 'M': M_arg = optarg; diff --git a/bin/varnishtest/tests/u00000.vtc b/bin/varnishtest/tests/u00000.vtc index a800b8a2c..e568f4adb 100644 --- a/bin/varnishtest/tests/u00000.vtc +++ b/bin/varnishtest/tests/u00000.vtc @@ -52,12 +52,6 @@ shell -err -expect {Cannot create secret-file in} { shell -err -expect {Unknown jail method "xyz"} "varnishd -jxyz -f '' " -shell -err -expect {Invalid backslash sequence} { - varnishd -l 'xyz\kk,xyz\foo' -f '' -} -shell -err -expect {Invalid backslash sequence} { - varnishd -l 'ab\8cd' -f '' -} shell -err -expect {Too many arguments for -V} "varnishd -V -V" shell -expect {Copyright (c) 2006} "varnishd -V" @@ -82,19 +76,7 @@ shell -err -expect {Error: -I file CLI command failed (104)} { } shell -err -expect "Can't open non-existent" { - varnishd -f '' -I non-existent -n ${tmpdir}/v0 -a :0 -l '2m,"' -} - -shell -err -expect {Error: -l ...: Missing '"'} { - varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l '2m,"' -} - -shell -err -expect {Error: Too many sub arguments} { - varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m,2m,2m -} - -shell -err -expect {Warning: Ignoring deprecated second subargument} { - varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 -l 2m,2m + varnishd -f '' -I non-existent -n ${tmpdir}/v0 -a :0 } @@ -103,9 +85,8 @@ shell -err -expect {Warning: Ignoring deprecated second subargument} { # Test -F mode with no VCL loaded shell {echo ping > ${tmpdir}/I_file} -process p1 "exec varnishd -n ${tmpdir}/v1 -F -f '' -a :0 -l2m,1m -I ${tmpdir}/I_file 2>&1" -start +process p1 "exec varnishd -n ${tmpdir}/v1 -F -f '' -a :0 -l2m -I ${tmpdir}/I_file 2>&1" -start -process p1 -expect-text 0 0 {Warning: Ignoring deprecated second subargument to -l} process p1 -expect-text 0 1 {PONG} process p1 -expect-text 0 1 {END of -I file processing} @@ -179,12 +160,12 @@ varnish v2 -stop -wait # Test multiple -f options with a bad VCL shell -err -expect {Cannot read -f file} { - exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ + exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m -f ${tmpdir}/ok1 \ -f ${tmpdir}/ok2 -f ${tmpdir}/bad } shell -err -expect {Cannot read -f file} { - exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ + exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m -f ${tmpdir}/ok1 \ -f ${tmpdir}/bad -f ${tmpdir}/ok2 } From dridi.boukelmoune at gmail.com Wed Feb 2 15:34:05 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 2 Feb 2022 15:34:05 +0000 (UTC) Subject: [master] 635f9f20c vtc: Increase the window height in r3159 Message-ID: <20220202153405.3CC84AFF46@lists.varnish-cache.org> commit 635f9f20c6837255ccc5ee5034708aecd1672e1c Author: Dridi Boukelmoune Date: Wed Feb 2 16:30:03 2022 +0100 vtc: Increase the window height in r3159 Otherwise sanitizers suppressions may scroll the first expectation out. Note to self: `process pNAME -winsz` is not documented. diff --git a/bin/varnishtest/tests/r03159.vtc b/bin/varnishtest/tests/r03159.vtc index 1b4c98600..e9862782b 100644 --- a/bin/varnishtest/tests/r03159.vtc +++ b/bin/varnishtest/tests/r03159.vtc @@ -10,7 +10,7 @@ shell { EOF } -process p1 -log { +process p1 -winsz 200 80 -log { varnishd -F -n "${tmpdir}/t" -a "${tmpdir}/sock" \ -p vcc_err_unref=off -f "${tmpdir}/unref.vcl" 2>&1 } -start From dridi.boukelmoune at gmail.com Mon Feb 7 06:52:09 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 7 Feb 2022 06:52:09 +0000 (UTC) Subject: [master] 6ea42f505 circleci: Remove the arch glibc workaround Message-ID: <20220207065209.EC40D114019@lists.varnish-cache.org> commit 6ea42f50553a06693b4077f138268914de0eab02 Author: Guillaume Quintard Date: Wed Feb 2 21:47:29 2022 -0800 circleci: Remove the arch glibc workaround diff --git a/.circleci/config.yml b/.circleci/config.yml index 77f78ff1e..e0d3857dd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -280,10 +280,6 @@ jobs: tar \ sudo elif [ << parameters.dist >> = archlinux ]; then - # XXX: TEMPORARY fix for https://bugs.archlinux.org/task/69563 - cd /tmp - patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst && curl -LO "https://repo.archlinuxcn.org/x86_64/$patched_glibc" && bsdtar -C / -xvf "$patched_glibc" - cd - pacman -Sy --noconfirm \ ca-certificates \ cpio \ From dridi.boukelmoune at gmail.com Mon Feb 7 06:52:09 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 7 Feb 2022 06:52:09 +0000 (UTC) Subject: [master] e0187925c circleci: Switch to the arch:base-devel image Message-ID: <20220207065209.E1F4E114017@lists.varnish-cache.org> commit e0187925c9a81f366dc7cbd28c50a7754382750b Author: Guillaume Quintard Date: Tue Feb 1 20:19:33 2022 -0800 circleci: Switch to the arch:base-devel image diff --git a/.circleci/Dockerfile.archlinux b/.circleci/Dockerfile.archlinux index c90140d43..b326662cc 100644 --- a/.circleci/Dockerfile.archlinux +++ b/.circleci/Dockerfile.archlinux @@ -1,8 +1,7 @@ -FROM archlinux +FROM archlinux:base-devel RUN set -e; \ pacman -Sy --noconfirm \ - base-devel \ ca-certificates \ cpio \ git \ diff --git a/.circleci/config.yml b/.circleci/config.yml index 1b4a24342..77f78ff1e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -285,7 +285,6 @@ jobs: patched_glibc=glibc-linux4-2.33-4-x86_64.pkg.tar.zst && curl -LO "https://repo.archlinuxcn.org/x86_64/$patched_glibc" && bsdtar -C / -xvf "$patched_glibc" cd - pacman -Sy --noconfirm \ - base-devel \ ca-certificates \ cpio \ git \ @@ -374,7 +373,7 @@ workflows: - distcheck: name: distcheck_archlinux dist: archlinux - release: "latest" + release: base-devel nightly: triggers: - schedule: From dridi.boukelmoune at gmail.com Mon Feb 7 06:52:10 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 7 Feb 2022 06:52:10 +0000 (UTC) Subject: [master] 2ed0ff29b circleci: Use the latest machine executor version Message-ID: <20220207065210.16F4211401C@lists.varnish-cache.org> commit 2ed0ff29beb2fef31ddcb438896243b3ff28eda9 Author: Guillaume Quintard Date: Wed Feb 2 22:26:45 2022 -0800 circleci: Use the latest machine executor version diff --git a/.circleci/config.yml b/.circleci/config.yml index e0d3857dd..eda0536a0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -125,7 +125,7 @@ jobs: description: the resource class to use, usuall arm.medium or medium type: string machine: - image: ubuntu-2004:202101-01 + image: ubuntu-2004:202111-02 resource_class: << parameters.rclass >> steps: - attach_workspace: From phk at FreeBSD.org Mon Feb 7 09:07:07 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 7 Feb 2022 09:07:07 +0000 (UTC) Subject: [master] 4d96d154e Make Coverity happy. Message-ID: <20220207090707.3099B1187C9@lists.varnish-cache.org> commit 4d96d154eb901b38910556b012a19b8ed15de660 Author: Poul-Henning Kamp Date: Mon Feb 7 09:02:16 2022 +0000 Make Coverity happy. diff --git a/bin/varnishd/storage/mgt_storage_persistent.c b/bin/varnishd/storage/mgt_storage_persistent.c index f6bf48a8e..77e8049a2 100644 --- a/bin/varnishd/storage/mgt_storage_persistent.c +++ b/bin/varnishd/storage/mgt_storage_persistent.c @@ -200,7 +200,7 @@ smp_mgt_init(struct stevedore *parent, int ac, char * const *av) /* Try to determine correct mmap address */ i = read(sc->fd, &sgn, sizeof sgn); assert(i == sizeof sgn); - if (!strcmp(sgn.ident, "SILO")) + if (!memcmp(sgn.ident, "SILO", 5)) target = (void*)(uintptr_t)sgn.mapped; else target = NULL; From nils.goroll at uplex.de Mon Feb 7 13:52:06 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 7 Feb 2022 13:52:06 +0000 (UTC) Subject: [master] 8590a2a49 varnishtest: Support vsl debugging with a suicide trigger Message-ID: <20220207135206.5F1597F01@lists.varnish-cache.org> commit 8590a2a49a614dab4c5d0c7ccb79bf39706b1da9 Author: Nils Goroll Date: Mon Feb 7 11:42:42 2022 +0100 varnishtest: Support vsl debugging with a suicide trigger Setting breakpoints in a debugger on select vsl events is tidious, so add a simple facility to trigger abort() with a logexpect command. diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c index ff727b4fc..b9a1300be 100644 --- a/bin/varnishtest/vtc_logexp.c +++ b/bin/varnishtest/vtc_logexp.c @@ -162,6 +162,7 @@ #define LE_SEEN (-4) #define LE_FAIL (-5) #define LE_CLEAR (-6) // clear fail list +#define LE_ABORT (-7) struct logexp_test { unsigned magic; @@ -213,10 +214,12 @@ static VTAILQ_HEAD(, logexp) logexps = static cmd_f cmd_logexp_expect; static cmd_f cmd_logexp_fail; +static cmd_f cmd_logexp_abort; static const struct cmds logexp_cmds[] = { { "expect", cmd_logexp_expect }, { "fail", cmd_logexp_fail }, + { "abort", cmd_logexp_abort }, { NULL, NULL }, }; @@ -354,6 +357,9 @@ logexp_next(struct logexp *le) VTAILQ_INSERT_TAIL(&le->fail, le->test, faillist); logexp_next(le); return; + case LE_ABORT: + abort(); + NEEDLESS(return); default: vtc_log(le->vl, 3, "test | %s", VSB_data(le->test->str)); } @@ -745,6 +751,21 @@ cmd_logexp_fail(CMD_ARGS) cmd_logexp_common(le, vl, LE_FAIL, av); } +/* aid vsl debugging */ +static void +cmd_logexp_abort(CMD_ARGS) +{ + + struct logexp *le; + + CAST_OBJ_NOTNULL(le, priv, LOGEXP_MAGIC); + + if (av[1] == NULL || av[2] == NULL || av[3] == NULL) + vtc_fatal(vl, "Syntax error"); + + cmd_logexp_common(le, vl, LE_ABORT, av); +} + static void logexp_spec(struct logexp *le, const char *spec) { From dridi.boukelmoune at gmail.com Mon Feb 7 17:35:05 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 7 Feb 2022 17:35:05 +0000 (UTC) Subject: [master] b3eae40d5 vtc_process: Rename term_match_text*() functions Message-ID: <20220207173505.D9DC76EF76@lists.varnish-cache.org> commit b3eae40d59af3f47080dbf65b3f8ef9887bd6e21 Author: Dridi Boukelmoune Date: Mon Feb 7 18:17:21 2022 +0100 vtc_process: Rename term_match_text*() functions To match (pun intended) the naming convention in other places, keep "match" for regular expressions matching. diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index 7387dfa39..d9d5ddaad 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -256,7 +256,7 @@ term_resize(struct process *pp, int lin, int col) } static int -term_match_textline(const struct process *pp, int *x, int y, const char *pat) +term_find_textline(const struct process *pp, int *x, int y, const char *pat) { const char *t; @@ -275,19 +275,19 @@ term_match_textline(const struct process *pp, int *x, int y, const char *pat) } static int -term_match_text(const struct process *pp, int *x, int *y, const char *pat) +term_find_text(const struct process *pp, int *x, int *y, const char *pat) { int yy; if (*y == 0) { for (yy = 0; yy < pp->nlin; yy++) { - if (term_match_textline(pp, x, yy, pat)) { + if (term_find_textline(pp, x, yy, pat)) { *y = yy + 1; return (1); } } } else if (*y <= pp->nlin) { - if (term_match_textline(pp, x, *y - 1, pat)) + if (term_find_textline(pp, x, *y - 1, pat)) return (1); } return (0); @@ -310,7 +310,7 @@ term_expect_text(struct process *pp, vtc_fatal(pp->vl, "XXX %d ncol %d", x, pp->ncol); l = strlen(pat); AZ(pthread_mutex_lock(&pp->mtx)); - while (!term_match_text(pp, &x, &y, pat)) { + while (!term_find_text(pp, &x, &y, pat)) { if (x != 0 && y != 0) { t = pp->vram[y - 1] + x - 1; vtc_log(pp->vl, 4, From dridi.boukelmoune at gmail.com Mon Feb 7 17:35:05 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 7 Feb 2022 17:35:05 +0000 (UTC) Subject: [master] f77b11c82 vtc_process: Prevent -expect-text overflows Message-ID: <20220207173505.E89D36EF78@lists.varnish-cache.org> commit f77b11c82f74f3697dd78073a49ab4a18e1e916d Author: Dridi Boukelmoune Date: Mon Feb 7 18:25:47 2022 +0100 vtc_process: Prevent -expect-text overflows diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index d9d5ddaad..1fbcc4650 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -259,6 +259,7 @@ static int term_find_textline(const struct process *pp, int *x, int y, const char *pat) { const char *t; + int l; if (*x == 0) { t = strstr(pp->vram[y], pat); @@ -268,7 +269,9 @@ term_find_textline(const struct process *pp, int *x, int y, const char *pat) } } else if (*x <= pp->ncol) { t = pp->vram[y] + *x - 1; - if (!memcmp(t, pat, strlen(pat))) + l = strlen(pat); + assert((*x - 1) + (l - 1) < pp->ncol); + if (!memcmp(t, pat, l)) return (1); } return (0); @@ -309,6 +312,8 @@ term_expect_text(struct process *pp, if (x < 0 || x > pp->ncol) vtc_fatal(pp->vl, "XXX %d ncol %d", x, pp->ncol); l = strlen(pat); + if (x + l - 1 > pp->ncol) + vtc_fatal(pp->vl, "XXX %d ncol %d", x + l - 1, pp->ncol); AZ(pthread_mutex_lock(&pp->mtx)); while (!term_find_text(pp, &x, &y, pat)) { if (x != 0 && y != 0) { From nils.goroll at uplex.de Thu Feb 10 12:46:06 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 10 Feb 2022 12:46:06 +0000 (UTC) Subject: [master] 6bfbf8d62 vtc.vsl_replay(): Do not emit lines with non-numerical vxid Message-ID: <20220210124606.B901592263@lists.varnish-cache.org> commit 6bfbf8d627d6355892dc52aee583827532829c87 Author: Nils Goroll Date: Wed Feb 9 11:42:58 2022 +0100 vtc.vsl_replay(): Do not emit lines with non-numerical vxid in other words: Allow comments in the replay string diff --git a/vmod/vmod_vtc.c b/vmod/vmod_vtc.c index ee2e5e8f2..8c3d8e7ba 100644 --- a/vmod/vmod_vtc.c +++ b/vmod/vmod_vtc.c @@ -440,7 +440,7 @@ vsl_line(VRT_CTX, char *str) VCL_INT id; VCL_ENUM side; const char *tag, *delim = " \t\r\n"; - char *save; + char *e, *save; if (*str == '*') { // varnishtest @@ -451,7 +451,9 @@ vsl_line(VRT_CTX, char *str) } if ((str = strtok_r(str, delim, &save)) == NULL) return; - id = strtoll(str, NULL, 10); + id = strtoll(str, &e, 10); + if (e == str) + return; if ((str = strtok_r(NULL, delim, &save)) == NULL) return; From nils.goroll at uplex.de Fri Feb 11 09:58:07 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 11 Feb 2022 09:58:07 +0000 (UTC) Subject: [master] ac6b7f5c5 Enable calling vtc.barrier_sync() from vcl_init {} Message-ID: <20220211095808.0028464841@lists.varnish-cache.org> commit ac6b7f5c5d779826ee55aa2ae57224af4d84c06b Author: Nils Goroll Date: Mon Feb 7 17:57:23 2022 +0100 Enable calling vtc.barrier_sync() from vcl_init {} diff --git a/vmod/vmod_vtc.c b/vmod/vmod_vtc.c index 8c3d8e7ba..06bab4bcd 100644 --- a/vmod/vmod_vtc.c +++ b/vmod/vmod_vtc.c @@ -57,7 +57,11 @@ vmod_barrier_sync(VRT_CTX, VCL_STRING addr, VCL_DURATION tmo) AN(*addr); assert(tmo >= 0.0); - VSLb(ctx->vsl, SLT_Debug, "barrier_sync(\"%s\")", addr); + if (ctx->vsl != NULL) + VSLb(ctx->vsl, SLT_Debug, "barrier_sync(\"%s\")", addr); + else + VSL(SLT_Debug, 0, "barrier_sync(\"%s\")", addr); + sock = VTCP_open(addr, NULL, 0., &err); if (sock < 0) { VRT_fail(ctx, "Barrier connection failed: %s", err); From nils.goroll at uplex.de Mon Feb 14 10:53:05 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 14 Feb 2022 10:53:05 +0000 (UTC) Subject: [master] 43af095e6 Extend debug.xid to also set/query the cache chunk size Message-ID: <20220214105305.B6A55A0695@lists.varnish-cache.org> commit 43af095e69726290da50d9fbcf5f5efb86d0be6c Author: Nils Goroll Date: Mon Feb 14 11:49:02 2022 +0100 Extend debug.xid to also set/query the cache chunk size The fixed chunk size of one prevents testing the vxid cache behaviour. diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 2a102940e..ddcc8d8cd 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -222,9 +222,13 @@ cli_debug_xid(struct cli *cli, const char * const *av, void *priv) (void)priv; if (av[2] != NULL) { vxid_base = strtoul(av[2], NULL, 0); - vxid_chunk = 1; + vxid_chunk = 0; + if (av[3] != NULL) + vxid_chunk = strtoul(av[3], NULL, 0); + if (vxid_chunk == 0) + vxid_chunk = 1; } - VCLI_Out(cli, "XID is %u", vxid_base); + VCLI_Out(cli, "XID is %u chunk %u", vxid_base, vxid_chunk); } /* diff --git a/include/tbl/cli_cmds.h b/include/tbl/cli_cmds.h index 27443bc70..7ca9f0802 100644 --- a/include/tbl/cli_cmds.h +++ b/include/tbl/cli_cmds.h @@ -375,10 +375,10 @@ CLI_CMD(DEBUG_SHUTDOWN_DELAY, CLI_CMD(DEBUG_XID, "debug.xid", - "debug.xid", - "Examine or set XID.", + "debug.xid [ []}", + "Examine or set XID. defaults to 1.", "", - 0, 1 + 0, 2 ) CLI_CMD(DEBUG_SRANDOM, From nils.goroll at uplex.de Mon Feb 14 12:19:04 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 14 Feb 2022 12:19:04 +0000 (UTC) Subject: [master] 567340a31 Fix bracket, noted by dridi Message-ID: <20220214121904.E0EF6A33D8@lists.varnish-cache.org> commit 567340a31dabc60c178d8b03059b925440b611cc Author: Nils Goroll Date: Mon Feb 14 13:17:52 2022 +0100 Fix bracket, noted by dridi diff --git a/include/tbl/cli_cmds.h b/include/tbl/cli_cmds.h index 7ca9f0802..d62774e3d 100644 --- a/include/tbl/cli_cmds.h +++ b/include/tbl/cli_cmds.h @@ -375,7 +375,7 @@ CLI_CMD(DEBUG_SHUTDOWN_DELAY, CLI_CMD(DEBUG_XID, "debug.xid", - "debug.xid [ []}", + "debug.xid [ []]", "Examine or set XID. defaults to 1.", "", 0, 2 From dridi.boukelmoune at gmail.com Tue Feb 15 07:11:05 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 15 Feb 2022 07:11:05 +0000 (UTC) Subject: [master] d1535c2bf circleci: The distcheck jobs don't need dist Message-ID: <20220215071105.C84DA97A2F@lists.varnish-cache.org> commit d1535c2bffbc3328ed9f13197f974982be3ed2ac Author: Guillaume Quintard Date: Sun Feb 13 19:03:05 2022 -0800 circleci: The distcheck jobs don't need dist The dist job is here to create a dist archive that serves as input for packaging jobs. The distcheck jobs work directly from a git clone. diff --git a/.circleci/config.yml b/.circleci/config.yml index eda0536a0..eec999dbf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -342,7 +342,6 @@ workflows: version: 2 commit: jobs: - - dist - distcheck: name: distcheck_centos_7 dist: centos From dridi.boukelmoune at gmail.com Tue Feb 15 07:11:05 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 15 Feb 2022 07:11:05 +0000 (UTC) Subject: [master] c3875bbb7 circleci: Avoid building a new container image Message-ID: <20220215071105.E219397A32@lists.varnish-cache.org> commit c3875bbb7a5880f41dd6b576133867a520aba579 Author: Guillaume Quintard Date: Tue Feb 1 20:36:49 2022 -0800 circleci: Avoid building a new container image Instead we can run packaging jobs directly from the target system's base image. diff --git a/.circleci/config.yml b/.circleci/config.yml index eec999dbf..2f4e303e5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -176,14 +176,14 @@ jobs: ;; esac - set -x - echo "FROM $IMG" > Dockerfile - echo "ADD make-$EXT-packages.sh /usr/bin/" >> Dockerfile - echo "CMD make-$EXT-packages.sh" >> Dockerfile - - cp .circleci/make-$EXT-packages.sh . - docker build -t docker_img . - docker run --rm -it -e PARAM_DIST=$(echo "<< parameters.platform >>" | cut -d: -f1) -e PARAM_RELEASE=$(echo "<< parameters.platform >>" | cut -d: -f2) -v$(pwd):/varnish-cache docker_img + docker run \ + --rm \ + -it \ + -e PARAM_DIST=$(echo "<< parameters.platform >>" | cut -d: -f1) \ + -e PARAM_RELEASE=$(echo "<< parameters.platform >>" | cut -d: -f2) \ + -v$(pwd):/varnish-cache \ + $IMG \ + /varnish-cache/.circleci/make-$EXT-packages.sh - run: name: List created packages command: find ./packages -type f From dridi.boukelmoune at gmail.com Tue Feb 15 07:11:06 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 15 Feb 2022 07:11:06 +0000 (UTC) Subject: [master] eee7eb057 circleci: Isolate centos-specific setup Message-ID: <20220215071106.04FB297A36@lists.varnish-cache.org> commit eee7eb0577d811e85bf88785a3e417c0124a86c2 Author: Guillaume Quintard Date: Wed Feb 2 22:19:15 2022 -0800 circleci: Isolate centos-specific setup Not all RPM-based distributions are EPEL consumers. Better diff with the --ignore-all-space option. diff --git a/.circleci/make-rpm-packages.sh b/.circleci/make-rpm-packages.sh index 56acdad05..63b5ae4a8 100755 --- a/.circleci/make-rpm-packages.sh +++ b/.circleci/make-rpm-packages.sh @@ -13,13 +13,12 @@ elif [ -z "$PARAM_DIST" ]; then exit 1 fi -yum install -y epel-release - if [ "$PARAM_DIST" = centos ]; then - if [ "$PARAM_RELEASE" = 8 ]; then - dnf install -y 'dnf-command(config-manager)' - yum config-manager --set-enabled powertools - fi + if [ "$PARAM_RELEASE" = 8 ]; then + dnf install -y 'dnf-command(config-manager)' + yum config-manager --set-enabled powertools + fi + yum install -y epel-release fi yum install -y rpm-build yum-utils From dridi.boukelmoune at gmail.com Tue Feb 15 07:11:06 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 15 Feb 2022 07:11:06 +0000 (UTC) Subject: [master] b0bb88c31 circleci: Bump the docker version Message-ID: <20220215071106.1E01097A3A@lists.varnish-cache.org> commit b0bb88c31551701bb759f2906759ecf6ba8ca503 Author: Guillaume Quintard Date: Mon Feb 14 15:35:47 2022 +0100 circleci: Bump the docker version Presumably, to run images with fairly recent software? diff --git a/.circleci/config.yml b/.circleci/config.yml index 2f4e303e5..8262a1cc5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -208,7 +208,7 @@ jobs: working_directory: /workspace steps: - setup_remote_docker: - version: 20.10.6 + version: 20.10.11 - run: name: Install docker command: yum install -y docker From dridi.boukelmoune at gmail.com Tue Feb 15 07:11:06 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 15 Feb 2022 07:11:06 +0000 (UTC) Subject: [master] 51f122561 circleci: Add Fedora (latest and rawhide) jobs Message-ID: <20220215071106.3646497A3E@lists.varnish-cache.org> commit 51f122561e4a72571a62da2711ccd7e04ac38fd2 Author: Guillaume Quintard Date: Mon Feb 14 15:41:02 2022 +0100 circleci: Add Fedora (latest and rawhide) jobs But only fedora:latest has a packaging job. Better diff with the --ignore-all-space option. diff --git a/.circleci/config.yml b/.circleci/config.yml index 8262a1cc5..fcac45566 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -160,8 +160,8 @@ jobs: mkdir -p packages case "<< parameters.platform >>" in debian:*|ubuntu:*) EXT=deb ;; - centos:*) EXT=rpm ;; - alpine:*) EXT=apk ;; + centos:*|fedora:*) EXT=rpm ;; + alpine:*) EXT=apk ;; *) echo "unrecognized platform: << parameters.platform >>" exit 1 @@ -219,16 +219,18 @@ jobs: docker create --name workspace -v /workspace << parameters.dist >>:<< parameters.release >> /bin/true docker cp /workspace workspace:/ docker run --volumes-from workspace -w /workspace << parameters.dist >>:<< parameters.release >> sh -c ' - if [ << parameters.dist >> = centos ]; then - if [ << parameters.release >> = 8 ]; then - dnf install -y "dnf-command(config-manager)" - yum config-manager --set-enabled powertools - yum install -y diffutils python3-sphinx - else - yum install -y python-sphinx + if [ << parameters.dist >> = centos -o << parameters.dist >> = fedora ]; then + yum groupinstall -y "Development Tools" + if [ << parameters.dist >> = centos ]; then + if [ << parameters.release >> = 8 ]; then + dnf install -y "dnf-command(config-manager)" + yum config-manager --set-enabled powertools + yum install -y diffutils + fi + yum install -y epel-release fi - yum install -y epel-release yum install -y \ + cpio \ automake \ git \ jemalloc-devel \ @@ -238,6 +240,7 @@ jobs: make \ pcre2-devel \ python3 \ + /usr/bin/sphinx-build \ sudo elif [ << parameters.dist >> = debian -o << parameters.dist >> = ubuntu ]; then export DEBIAN_FRONTEND=noninteractive @@ -296,7 +299,7 @@ jobs: if [ << parameters.dist >> = archlinux ]; then useradd varnish - elif [ << parameters.dist >> = centos ]; then + elif [ << parameters.dist >> = centos -o << parameters.dist >> = fedora ]; then adduser varnish else adduser --disabled-password --gecos "" varnish @@ -350,6 +353,14 @@ workflows: name: distcheck_centos_8 dist: centos release: "8" + - distcheck: + name: distcheck_fedora_latest + dist: fedora + release: latest + - distcheck: + name: distcheck_fedora_rawhide + dist: fedora + release: rawhide - distcheck: name: distcheck_debian_buster dist: debian @@ -395,6 +406,7 @@ workflows: - debian:stretch - centos:7 - centos:8 + - fedora:latest - alpine:3 rclass: - arm.medium From dridi.boukelmoune at gmail.com Tue Feb 15 07:11:06 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 15 Feb 2022 07:11:06 +0000 (UTC) Subject: [master] 5fe5bf6ac circleci: Move centos:8 jobs to centos:stream Message-ID: <20220215071106.5085897A46@lists.varnish-cache.org> commit 5fe5bf6acee90f4f4c0dc20b3c2e76c9b843efd4 Author: Dridi Boukelmoune Date: Mon Feb 14 15:48:49 2022 +0100 circleci: Move centos:8 jobs to centos:stream We grab the image from Red Hat's quay.io image repository, which is done with the addition of an optional prefix parameter for distcheck jobs and a hardcoded hack for packaging jobs. To make this work, the aarch64 packaging jobs had to be generalized to less specific "arm64" images. diff --git a/.circleci/config.yml b/.circleci/config.yml index fcac45566..9eb09b793 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -167,13 +167,14 @@ jobs: exit 1 esac + case "<< parameters.platform >>" in + centos:stream) REPO=quay.io/centos/ ;; + *) REPO= ;; + esac + case "<< parameters.rclass >>" in - arm.*) - IMG=arm64v8/<< parameters.platform >> - ;; - *) - IMG=<< parameters.platform >> - ;; + arm.*) ARCH=arm64 ;; + *) ARCH=amd64 ;; esac docker run \ @@ -182,7 +183,8 @@ jobs: -e PARAM_DIST=$(echo "<< parameters.platform >>" | cut -d: -f1) \ -e PARAM_RELEASE=$(echo "<< parameters.platform >>" | cut -d: -f2) \ -v$(pwd):/varnish-cache \ - $IMG \ + --platform linux/$ARCH \ + ${REPO}<< parameters.platform >> \ /varnish-cache/.circleci/make-$EXT-packages.sh - run: name: List created packages @@ -193,6 +195,10 @@ jobs: - "packages" distcheck: parameters: + prefix: + description: the container image repository + type: string + default: "" dist: description: the Linux distribution (debian|ubuntu) type: string @@ -216,13 +222,13 @@ jobs: - run: name: Extract and distcheck command: | - docker create --name workspace -v /workspace << parameters.dist >>:<< parameters.release >> /bin/true + docker create --name workspace -v /workspace << parameters.prefix >><< parameters.dist >>:<< parameters.release >> /bin/true docker cp /workspace workspace:/ - docker run --volumes-from workspace -w /workspace << parameters.dist >>:<< parameters.release >> sh -c ' + docker run --volumes-from workspace -w /workspace << parameters.prefix >><< parameters.dist >>:<< parameters.release >> sh -c ' if [ << parameters.dist >> = centos -o << parameters.dist >> = fedora ]; then yum groupinstall -y "Development Tools" if [ << parameters.dist >> = centos ]; then - if [ << parameters.release >> = 8 ]; then + if [ << parameters.release >> = stream ]; then dnf install -y "dnf-command(config-manager)" yum config-manager --set-enabled powertools yum install -y diffutils @@ -350,9 +356,10 @@ workflows: dist: centos release: "7" - distcheck: - name: distcheck_centos_8 + name: distcheck_centos_stream + prefix: quay.io/centos/ dist: centos - release: "8" + release: stream - distcheck: name: distcheck_fedora_latest dist: fedora @@ -405,7 +412,7 @@ workflows: - debian:buster - debian:stretch - centos:7 - - centos:8 + - centos:stream - fedora:latest - alpine:3 rclass: diff --git a/.circleci/make-rpm-packages.sh b/.circleci/make-rpm-packages.sh index 63b5ae4a8..40c883d98 100755 --- a/.circleci/make-rpm-packages.sh +++ b/.circleci/make-rpm-packages.sh @@ -6,7 +6,7 @@ echo "PARAM_RELEASE: $PARAM_RELEASE" echo "PARAM_DIST: $PARAM_DIST" if [ -z "$PARAM_RELEASE" ]; then - echo "Env variable PARAM_RELEASE is not set! For example PARAM_RELEASE=8, for CentOS 8" + echo "Env variable PARAM_RELEASE is not set! For example PARAM_RELEASE=stream, for CentOS stream" exit 1 elif [ -z "$PARAM_DIST" ]; then echo "Env variable PARAM_DIST is not set! For example PARAM_DIST=centos" @@ -14,7 +14,7 @@ elif [ -z "$PARAM_DIST" ]; then fi if [ "$PARAM_DIST" = centos ]; then - if [ "$PARAM_RELEASE" = 8 ]; then + if [ "$PARAM_RELEASE" = stream ]; then dnf install -y 'dnf-command(config-manager)' yum config-manager --set-enabled powertools fi From dridi.boukelmoune at gmail.com Tue Feb 15 07:11:06 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 15 Feb 2022 07:11:06 +0000 (UTC) Subject: [master] 09af98e72 circleci: Run bionic builds in a 32bit image Message-ID: <20220215071106.6AACC97A4E@lists.varnish-cache.org> commit 09af98e72825063550c2179b2d4d5f9f957140d1 Author: Dridi Boukelmoune Date: Mon Feb 14 17:21:30 2022 +0100 circleci: Run bionic builds in a 32bit image Closes #3702 diff --git a/.circleci/config.yml b/.circleci/config.yml index 9eb09b793..13b9e8cfe 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -196,7 +196,7 @@ jobs: distcheck: parameters: prefix: - description: the container image repository + description: the container image prefix (repository or architecture) type: string default: "" dist: @@ -375,9 +375,9 @@ workflows: extra_conf: --enable-asan --enable-ubsan --enable-workspace-emulator - distcheck: name: distcheck_ubuntu_bionic + prefix: i386/ dist: ubuntu release: bionic - extra_conf: CFLAGS='-g -O2 -m32' - distcheck: name: distcheck_alpine dist: alpine From dridi.boukelmoune at gmail.com Tue Feb 15 08:50:06 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 15 Feb 2022 08:50:06 +0000 (UTC) Subject: [master] 99607ac7d circleci: Update packages on archlinux Message-ID: <20220215085006.D40C1A0724@lists.varnish-cache.org> commit 99607ac7dea29baad6fb8b485a28471834fc4cf7 Author: Dridi Boukelmoune Date: Tue Feb 15 08:46:45 2022 +0100 circleci: Update packages on archlinux We see linking failures sometimes, so hopefully that solves those. diff --git a/.circleci/config.yml b/.circleci/config.yml index 13b9e8cfe..776a13cd2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -289,7 +289,8 @@ jobs: tar \ sudo elif [ << parameters.dist >> = archlinux ]; then - pacman -Sy --noconfirm \ + pacman -Syu --noconfirm + pacman -S --noconfirm \ ca-certificates \ cpio \ git \ From dridi.boukelmoune at gmail.com Wed Feb 16 10:35:05 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 16 Feb 2022 10:35:05 +0000 (UTC) Subject: [master] 7e6d4caa6 circleci: Fold pacman commands Message-ID: <20220216103505.D56E3A7B8F@lists.varnish-cache.org> commit 7e6d4caa63c28e10f4586b709050c011b4ab15bb Author: Dridi Boukelmoune Date: Wed Feb 16 11:33:01 2022 +0100 circleci: Fold pacman commands Suggested by @gquintard. diff --git a/.circleci/config.yml b/.circleci/config.yml index 776a13cd2..9707e08f1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -289,8 +289,7 @@ jobs: tar \ sudo elif [ << parameters.dist >> = archlinux ]; then - pacman -Syu --noconfirm - pacman -S --noconfirm \ + pacman -Syu --noconfirm \ ca-certificates \ cpio \ git \ From phk at FreeBSD.org Wed Feb 16 14:18:05 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 16 Feb 2022 14:18:05 +0000 (UTC) Subject: [master] a810eb842 Refactor argv processing. Message-ID: <20220216141805.9E24EAE150@lists.varnish-cache.org> commit a810eb842c5f0ac46ecaeb4984135539df1dde2e Author: Poul-Henning Kamp Date: Wed Feb 16 14:15:59 2022 +0000 Refactor argv processing. Create a general list for holding "args to be dealt with later" and use it for pretty much everything in that class. Side-effect: Multiple -T, -M and -P options are supported now. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 4f65216ce..b49bebb09 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -50,7 +50,6 @@ #include "hash/hash_slinger.h" #include "libvcc.h" -#include "vav.h" #include "vcli_serve.h" #include "vend.h" #include "vev.h" @@ -73,16 +72,10 @@ struct VSC_mgt *VSC_C_mgt; static int I_fd = -1; static char *workdir; -static struct vpf_fh *pfh1 = NULL; -static struct vpf_fh *pfh2 = NULL; - static struct vfil_path *vcl_path = NULL; -static VTAILQ_HEAD(,f_arg) f_args = VTAILQ_HEAD_INITIALIZER(f_args); static const char opt_spec[] = "?a:b:Cdf:Fh:i:I:j:l:M:n:P:p:r:S:s:T:t:VW:x:"; -int optreset; // Some has it, some doesn't. Cheaper than auto* - /*--------------------------------------------------------------------*/ static void @@ -175,6 +168,46 @@ usage(void) /*--------------------------------------------------------------------*/ +struct arg_list { + unsigned magic; +#define ARG_LIST_MAGIC 0x7b0d1bc4 + char arg[2]; + char *val; + VTAILQ_ENTRY(arg_list) list; + void *priv; +}; + +static VTAILQ_HEAD(, arg_list) arglist = VTAILQ_HEAD_INITIALIZER(arglist); + +static struct arg_list * +arg_list_add(const char arg, const char *val) +{ + struct arg_list *alp; + + ALLOC_OBJ(alp, ARG_LIST_MAGIC); + AN(alp); + alp->arg[0] = arg; + alp->arg[1] = '\0'; + REPLACE(alp->val, val); + VTAILQ_INSERT_TAIL(&arglist, alp, list); + return (alp); +} + +static unsigned +arg_list_count(const char *arg) +{ + unsigned retval = 0; + struct arg_list *alp; + + VTAILQ_FOREACH(alp, &arglist, list) { + if (!strcmp(alp->arg, arg)) + retval++; + } + return (retval); +} + +/*--------------------------------------------------------------------*/ + static void cli_check(const struct cli *cli) { @@ -252,7 +285,6 @@ mgt_Cflag_atexit(void) if (getpid() != heritage.mgt_pid) return; VJ_rmdir("vmod_cache"); - VJ_unlink("_.pid"); (void)chdir("/"); VJ_rmdir(workdir); } @@ -411,10 +443,9 @@ struct f_arg { #define F_ARG_MAGIC 0x840649a8 char *farg; char *src; - VTAILQ_ENTRY(f_arg) list; }; -static void +static struct f_arg * mgt_f_read(const char *fn) { struct f_arg *fa; @@ -431,7 +462,7 @@ mgt_f_read(const char *fn) free(fa->farg); fa->farg = fnp; fa->src = f; - VTAILQ_INSERT_TAIL(&f_args, fa, list); + return (fa); } static void @@ -457,35 +488,34 @@ mgt_b_conv(const char *b_arg) fa->src = strdup(VSB_data(vsb)); AN(fa->src); VSB_destroy(&vsb); - VTAILQ_INSERT_TAIL(&f_args, fa, list); + AZ(arg_list_count("f")); + arg_list_add('f', "")->priv = fa; } static int -mgt_process_f_args(struct cli *cli, unsigned C_flag) +mgt_process_f_arg(struct cli *cli, unsigned C_flag, void **fap) { int retval = 0; struct f_arg *fa; - - while (!VTAILQ_EMPTY(&f_args)) { - fa = VTAILQ_FIRST(&f_args); - CHECK_OBJ_NOTNULL(fa, F_ARG_MAGIC); - VTAILQ_REMOVE(&f_args, fa, list); - mgt_vcl_startup(cli, fa->src, - VTAILQ_EMPTY(&f_args) ? "boot" : NULL, fa->farg, C_flag); - if (C_flag) { - if (cli->result != CLIS_OK && - cli->result != CLIS_TRUNCATED) - retval = 2; - AZ(VSB_finish(cli->sb)); - fprintf(stderr, "%s\n", VSB_data(cli->sb)); - VSB_clear(cli->sb); - } else { - cli_check(cli); - } - free(fa->farg); - free(fa->src); - FREE_OBJ(fa); + const char *name = NULL; + + TAKE_OBJ_NOTNULL(fa, fap, F_ARG_MAGIC); + if (arg_list_count("f") == 1) + name = "boot"; + mgt_vcl_startup(cli, fa->src, name, fa->farg, C_flag); + if (C_flag) { + if (cli->result != CLIS_OK && + cli->result != CLIS_TRUNCATED) + retval = 2; + AZ(VSB_finish(cli->sb)); + fprintf(stderr, "%s\n", VSB_data(cli->sb)); + VSB_clear(cli->sb); + } else { + cli_check(cli); } + free(fa->farg); + free(fa->src); + FREE_OBJ(fa); return (retval); } @@ -543,21 +573,15 @@ main(int argc, char * const *argv) { int o, eric_fd = -1; unsigned C_flag = 0; - unsigned f_flag = 0; unsigned F_flag = 0; const char *b_arg = NULL; const char *i_arg = NULL; const char *j_arg = NULL; const char *h_arg = "critbit"; - const char *M_arg = NULL; const char *n_arg = NULL; - const char *P_arg = NULL; const char *S_arg = NULL; const char *s_arg = "default,100m"; const char *W_arg = NULL; - int s_arg_given = 0; - int novcl = 0; - const char *T_arg = "localhost:0"; char *p; struct cli cli[1]; const char *err; @@ -565,6 +589,8 @@ main(int argc, char * const *argv) struct sigaction sac; struct vev *e; pid_t pid; + struct arg_list *alp; + int first_arg = 1; if (argc == 2 && !strcmp(argv[1], "--optstring")) { printf("%s\n", opt_spec); @@ -581,35 +607,22 @@ main(int argc, char * const *argv) mgt_initialize(cli); - /* Check if first argument is a special flag */ - - o = getopt(argc, argv, opt_spec); - switch (o) { - case 'x': - if (argc != 3) - ARGV_ERR("Too many arguments for -x\n"); - mgt_x_arg(optarg); - exit(0); - case 'V': - if (argc != 2) - ARGV_ERR("Too many arguments for -V\n"); - VCS_Message("varnishd"); - exit(0); - default: - break; - } - - /* First pass over arguments to determine overall configuration */ - - do { + for (; (o = getopt(argc, argv, opt_spec)) != -1; first_arg = 0) { switch (o) { - case '?': - usage(); - exit(2); case 'V': + if (!first_arg) + ARGV_ERR("-V must be the first argument\n"); + if (argc != 2) + ARGV_ERR("Too many arguments for -V\n"); + VCS_Message("varnishd"); + exit(0); case 'x': - ARGV_ERR("-%c must be the first argument\n", o); - break; + if (!first_arg) + ARGV_ERR("-x must be the first argument\n"); + if (argc != 3) + ARGV_ERR("Too many arguments for -x\n"); + mgt_x_arg(optarg); + exit(0); case 'b': b_arg = optarg; break; @@ -619,31 +632,60 @@ main(int argc, char * const *argv) case 'd': d_flag++; break; - case 'f': - f_flag = 1; - break; case 'F': F_flag = 1; break; case 'j': j_arg = optarg; break; - default: + case 'h': + h_arg = optarg; + break; + case 'i': + i_arg = optarg; + break; + case 'l': + arg_list_add('p', "vsl_space")->priv = optarg; + break; + case 'n': + n_arg = optarg; + break; + case 'S': + S_arg = optarg; + break; + case 't': + arg_list_add('p', "default_ttl")->priv = optarg; + break; + case 'W': + W_arg = optarg; + break; + case 'a': + case 'f': + case 'I': + case 'p': + case 'P': + case 'M': + case 'r': + case 's': + case 'T': + (void)arg_list_add(o, optarg); break; + default: + usage(); + exit(2); } - o = getopt(argc, argv, opt_spec); - } while (o != -1); + } if (argc != optind) ARGV_ERR("Too many arguments (%s...)\n", argv[optind]); - if (b_arg != NULL && f_flag) + if (b_arg != NULL && arg_list_count("f")) ARGV_ERR("Only one of -b or -f can be specified\n"); if (d_flag && F_flag) ARGV_ERR("Only one of -d or -F can be specified\n"); - if (C_flag && b_arg == NULL && !f_flag) + if (C_flag && b_arg == NULL && !arg_list_count("f")) ARGV_ERR("-C needs either -b or -f \n"); if (d_flag && C_flag) @@ -652,12 +694,18 @@ main(int argc, char * const *argv) if (F_flag && C_flag) ARGV_ERR("-F makes no sense with -C\n"); - if (!d_flag && b_arg == NULL && !f_flag) + if (!d_flag && b_arg == NULL && !arg_list_count("f")) ARGV_ERR("Neither -b nor -f given. (use -f '' to override)\n"); + if (arg_list_count("I") > 1) + ARGV_ERR("\tOnly one -I allowed\n"); + if (d_flag || F_flag) complain_to_stderr = 1; + if (!arg_list_count("T")) + (void)arg_list_add('T', "localhost:0"); + /* * Start out by closing all unwanted file descriptors we might * have inherited from sloppy process control daemons. @@ -694,101 +742,46 @@ main(int argc, char * const *argv) if (b_arg != NULL) mgt_b_conv(b_arg); - optind = 1; - optreset = 1; - while ((o = getopt(argc, argv, opt_spec)) != -1) { - switch (o) { - case 'C': - case 'd': - case 'F': - case 'j': - /* Handled in first pass */ - break; + /* Process delayed arguments */ + VTAILQ_FOREACH(alp, &arglist, list) { + switch(alp->arg[0]) { case 'a': - MAC_Arg(optarg); - break; - case 'b': - /* already dealt with */ + MAC_Arg(alp->val); break; case 'f': - if (*optarg == '\0') - novcl = 1; - else - mgt_f_read(optarg); - break; - case 'h': - h_arg = optarg; - break; - case 'i': - i_arg = optarg; + if (*alp->val != '\0') + alp->priv = mgt_f_read(alp->val); break; case 'I': - if (I_fd >= 0) - ARGV_ERR("\tOnly one -I allowed\n"); VJ_master(JAIL_MASTER_FILE); - I_fd = open(optarg, O_RDONLY); + I_fd = open(alp->val, O_RDONLY); if (I_fd < 0) ARGV_ERR("\tCan't open %s: %s\n", - optarg, VAS_errtxt(errno)); + alp->val, VAS_errtxt(errno)); VJ_master(JAIL_MASTER_LOW); break; - case 'l': - MCF_ParamSet(cli, "vsl_space", optarg); - cli_check(cli); - break; - case 'M': - M_arg = optarg; - break; - case 'n': - n_arg = optarg; - break; - case 'P': - P_arg = optarg; - break; case 'p': - p = strchr(optarg, '='); - if (p == NULL) - ARGV_ERR("\t-p lacks '='\n"); - AN(p); - *p++ = '\0'; - MCF_ParamSet(cli, optarg, p); - *--p = '='; - cli_check(cli); + if (alp->priv) { + MCF_ParamSet(cli, alp->val, alp->priv); + } else { + p = strchr(alp->val, '='); + if (p == NULL) + ARGV_ERR("\t-p lacks '='\n"); + AN(p); + *p++ = '\0'; + MCF_ParamSet(cli, alp->val, p); + } break; case 'r': - MCF_ParamProtect(cli, optarg); - cli_check(cli); - break; - case 'S': - S_arg = optarg; + MCF_ParamProtect(cli, alp->val); break; case 's': - s_arg_given = 1; - STV_Config(optarg); - break; - case 'T': - if (!strcmp(optarg, "none")) - T_arg = NULL; - else - T_arg = optarg; - break; - case 't': - MCF_ParamSet(cli, "default_ttl", optarg); - break; - case 'W': - W_arg = optarg; + STV_Config(alp->val); break; default: - WRONG("Error in argument parsing"); + break; } - } - assert(argc == optind); - - /* XXX: we can have multiple CLI actions above, is this enough ? */ - if (cli[0].result != CLIS_OK) { - AZ(VSB_finish(cli[0].sb)); - ARGV_ERR("Failed parameter creation:\n%s\n", - VSB_data(cli[0].sb)); + cli_check(cli); } VCLS_SetLimit(mgt_cls, &mgt_param.cli_limit); @@ -839,13 +832,8 @@ main(int argc, char * const *argv) if (C_flag) AZ(atexit(mgt_Cflag_atexit)); - pfh1 = create_pid_file(&pid, "%s/_.pid", workdir); - - if (P_arg) - pfh2 = create_pid_file(&pid, "%s", P_arg); - /* If no -s argument specified, process default -s argument */ - if (!s_arg_given) + if (!arg_list_count("s")) STV_Config(s_arg); /* Configure Transient storage, if user did not */ @@ -853,10 +841,23 @@ main(int argc, char * const *argv) mgt_vcl_init(); - u = mgt_process_f_args(cli, C_flag); + u = 0; + VTAILQ_FOREACH(alp, &arglist, list) { + if (!strcmp(alp->arg, "f") && alp->priv != NULL) + u |= mgt_process_f_arg(cli, C_flag, &alp->priv); + } if (C_flag) exit(u); + VTAILQ_FOREACH(alp, &arglist, list) { + if (!strcmp(alp->arg, "P")) + alp->priv = create_pid_file(&pid, "%s", alp->val); + } + + /* Implict -P argument */ + alp = arg_list_add('P', NULL); + alp->priv = create_pid_file(&pid, "%s/_.pid", workdir); + if (VTAILQ_EMPTY(&heritage.socks)) MAC_Arg(":80\0"); // XXX: extra NUL for FlexeLint @@ -871,10 +872,14 @@ main(int argc, char * const *argv) mgt_SHM_static_alloc(i_arg, strlen(i_arg) + 1L, "Arg", "-i"); VSC_C_mgt = VSC_mgt_New(NULL, NULL, ""); - if (M_arg != NULL) - mgt_cli_master(M_arg); - if (T_arg != NULL) - mgt_cli_telnet(T_arg); + VTAILQ_FOREACH(alp, &arglist, list) { + if (!strcmp(alp->arg, "M")) + mgt_cli_master(alp->val); + else if (!strcmp(alp->arg, "T") && strcmp(alp->val, "none")) + mgt_cli_telnet(alp->val); + else if (!strcmp(alp->arg, "P")) + VPF_Write(alp->priv); + } AZ(VSB_finish(vident)); @@ -882,10 +887,6 @@ main(int argc, char * const *argv) S_arg = make_secret(workdir); AN(S_arg); - VPF_Write(pfh1); - if (pfh2 != NULL) - VPF_Write(pfh2); - MGT_Complain(C_DEBUG, "Version: %s", VCS_String("V")); MGT_Complain(C_DEBUG, "Platform: %s", VSB_data(vident) + 1); @@ -918,7 +919,7 @@ main(int argc, char * const *argv) assert(I_fd == -1); err = mgt_has_vcl(); - if (!d_flag && err != NULL && !novcl) + if (!d_flag && err != NULL && !arg_list_count("f")) MGT_Complain(C_ERR, "%s", err); if (err == NULL && !d_flag) @@ -967,8 +968,9 @@ main(int argc, char * const *argv) MGT_Complain(C_INFO, "manager dies"); mgt_cli_close_all(); VEV_Destroy(&mgt_evb); - VPF_Remove(pfh1); - if (pfh2 != NULL) - VPF_Remove(pfh2); + VTAILQ_FOREACH(alp, &arglist, list) { + if (!strcmp(alp->arg, "P")) + VPF_Remove(alp->priv); + } exit(exit_status); } From dridi.boukelmoune at gmail.com Mon Feb 21 10:23:05 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 21 Feb 2022 10:23:05 +0000 (UTC) Subject: [master] bbc31a5ea vep: Extract src attr parsing to its own function Message-ID: <20220221102305.6B7D0BE100@lists.varnish-cache.org> commit bbc31a5ea9e6a1617eddc7efc4a6d2ca1d01bee9 Author: Dridi Boukelmoune Date: Fri Dec 31 15:06:54 2021 +0100 vep: Extract src attr parsing to its own function diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 0bda28c84..7e0458556 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -429,6 +429,37 @@ vep_do_remove(struct vep_state *vep, enum dowhat what) /*--------------------------------------------------------------------- */ +static void +include_attr_src(struct vep_state *vep) +{ + const char *p; + + if (vep->include_src != NULL) { + vep_error(vep, + "ESI 1.0 " + "has multiple src= attributes"); + vep->state = VEP_TAGERROR; + VSB_destroy(&vep->attr_vsb); + VSB_destroy(&vep->include_src); + return; + } + for (p = VSB_data(vep->attr_vsb); *p != '\0'; p++) + if (vct_islws(*p)) + break; + if (*p != '\0') { + vep_error(vep, + "ESI 1.0 " + "has whitespace in src= attribute"); + vep->state = VEP_TAGERROR; + VSB_destroy(&vep->attr_vsb); + if (vep->include_src != NULL) + VSB_destroy(&vep->include_src); + return; + } + vep->include_src = vep->attr_vsb; + vep->attr_vsb = NULL; +} + static void v_matchproto_() vep_do_include(struct vep_state *vep, enum dowhat what) { @@ -439,31 +470,11 @@ vep_do_include(struct vep_state *vep, enum dowhat what) if (what == DO_ATTR) { Debug("ATTR (%s) (%s)\n", vep->match_hit->match, VSB_data(vep->attr_vsb)); - if (vep->include_src != NULL) { - vep_error(vep, - "ESI 1.0 " - "has multiple src= attributes"); - vep->state = VEP_TAGERROR; - VSB_destroy(&vep->attr_vsb); - VSB_destroy(&vep->include_src); + if (!strcmp("src=", vep->match_hit->match)) { + include_attr_src(vep); return; } - for (p = VSB_data(vep->attr_vsb); *p != '\0'; p++) - if (vct_islws(*p)) - break; - if (*p != '\0') { - vep_error(vep, - "ESI 1.0 " - "has whitespace in src= attribute"); - vep->state = VEP_TAGERROR; - VSB_destroy(&vep->attr_vsb); - if (vep->include_src != NULL) - VSB_destroy(&vep->include_src); - return; - } - vep->include_src = vep->attr_vsb; - vep->attr_vsb = NULL; - return; + WRONG("Unhandled attribute"); } assert(what == DO_TAG); if (!vep->emptytag) From dridi.boukelmoune at gmail.com Mon Feb 21 10:23:05 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 21 Feb 2022 10:23:05 +0000 (UTC) Subject: [master] 26097fb09 esi: Implement Message-ID: <20220221102305.915C2BE104@lists.varnish-cache.org> commit 26097fb091496f79ef9a38b22e3639735fb39280 Author: Dridi Boukelmoune Date: Fri Dec 31 15:31:14 2021 +0100 esi: Implement This changes the default behavior of includes, matching the ESI language specification. The onerror attribute seems to only accept one value, so in its absence a failed ESI fragment delivery aborts the top request delivery. This new behavior requires the esi_include_onerror feature flag to be raised to take effect. In addition, it breaks the ESI object attribute format for persisted caches. diff --git a/bin/varnishd/cache/cache_esi.h b/bin/varnishd/cache/cache_esi.h index 1e5777b50..58eb85ed1 100644 --- a/bin/varnishd/cache/cache_esi.h +++ b/bin/varnishd/cache/cache_esi.h @@ -39,7 +39,8 @@ #define VEC_S1 (0x60 + 1) #define VEC_S2 (0x60 + 2) #define VEC_S8 (0x60 + 8) -#define VEC_INCL 'I' +#define VEC_INCL_ABRT 'I' +#define VEC_INCL_CONT 'i' typedef ssize_t vep_callback_t(struct vfp_ctx *, void *priv, ssize_t l, enum vgz_flag flg); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index fb63fb12f..ac40a77b7 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -65,6 +65,7 @@ struct ecx { ssize_t l; int isgzip; int woken; + int abrt; struct req *preq; struct ecx *pecx; @@ -378,7 +379,11 @@ ved_vdp_esi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv, Debug("SKIP1(%d)\n", (int)ecx->l); ecx->state = 4; break; - case VEC_INCL: + case VEC_INCL_ABRT: + ecx->abrt = + FEATURE(FEATURE_ESI_INCLUDE_ONERROR); + /* FALLTHROUGH */ + case VEC_INCL_CONT: ecx->p++; q = (void*)strchr((const char*)ecx->p, '\0'); AN(q); @@ -905,4 +910,9 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody) req->doclose = SC_REM_CLOSE; req->acct.resp_bodybytes += VDP_Close(req->vdc); + + if (i && ecx->abrt) { + req->top->topreq->vdc->retval = -1; + req->top->topreq->doclose = req->doclose; + } } diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 7e0458556..2716c60b2 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -114,6 +114,7 @@ struct vep_state { dostuff_f *dostuff; struct vsb *include_src; + unsigned include_continue; unsigned nm_skip; unsigned nm_verbatim; @@ -181,6 +182,7 @@ static struct vep_match vep_match_esi[] = { static struct vep_match vep_match_attr_include[] = { { "src=", &VEP_ATTRGETVAL }, + { "onerror=", &VEP_ATTRGETVAL }, { NULL, &VEP_SKIPATTR } }; @@ -460,11 +462,20 @@ include_attr_src(struct vep_state *vep) vep->attr_vsb = NULL; } +static void +include_attr_onerror(struct vep_state *vep) +{ + + vep->include_continue = !strcmp("continue", VSB_data(vep->attr_vsb)); + VSB_destroy(&vep->attr_vsb); +} + static void v_matchproto_() vep_do_include(struct vep_state *vep, enum dowhat what) { const char *p, *q, *h; ssize_t l; + char incl; Debug("DO_INCLUDE(%d)\n", what); if (what == DO_ATTR) { @@ -474,6 +485,10 @@ vep_do_include(struct vep_state *vep, enum dowhat what) include_attr_src(vep); return; } + if (!strcmp("onerror=", vep->match_hit->match)) { + include_attr_onerror(vep); + return; + } WRONG("Unhandled attribute"); } assert(what == DO_TAG); @@ -499,6 +514,8 @@ vep_do_include(struct vep_state *vep, enum dowhat what) l = VSB_len(vep->include_src); h = 0; + incl = vep->include_continue ? VEC_INCL_CONT : VEC_INCL_ABRT; + if (l > 7 && !memcmp(p, "http://", 7)) { h = p + 7; p = strchr(h, '/'); @@ -511,7 +528,7 @@ vep_do_include(struct vep_state *vep, enum dowhat what) return; } Debug("HOST <%.*s> PATH <%s>\n", (int)(p-h),h, p); - VSB_printf(vep->vsb, "%c", VEC_INCL); + VSB_printf(vep->vsb, "%c", incl); VSB_printf(vep->vsb, "Host: %.*s%c", (int)(p-h), h, 0); } else if (l > 8 && !memcmp(p, "https://", 8)) { if (!FEATURE(FEATURE_ESI_IGNORE_HTTPS)) { @@ -534,13 +551,13 @@ vep_do_include(struct vep_state *vep, enum dowhat what) VSB_destroy(&vep->include_src); return; } - VSB_printf(vep->vsb, "%c", VEC_INCL); + VSB_printf(vep->vsb, "%c", incl); VSB_printf(vep->vsb, "Host: %.*s%c", (int)(p-h), h, 0); } else if (*p == '/') { - VSB_printf(vep->vsb, "%c", VEC_INCL); + VSB_printf(vep->vsb, "%c", incl); VSB_printf(vep->vsb, "%c", 0); } else { - VSB_printf(vep->vsb, "%c", VEC_INCL); + VSB_printf(vep->vsb, "%c", incl); VSB_printf(vep->vsb, "%c", 0); /* Look for the last / before a '?' */ h = NULL; @@ -574,6 +591,7 @@ vep_do_include(struct vep_state *vep, enum dowhat what) #undef R VSB_printf(vep->vsb, "%c", 0); VSB_destroy(&vep->include_src); + vep->include_continue = 0; } /*--------------------------------------------------------------------- diff --git a/bin/varnishtest/tests/e00035.vtc b/bin/varnishtest/tests/e00035.vtc new file mode 100644 index 000000000..0fc59d749 --- /dev/null +++ b/bin/varnishtest/tests/e00035.vtc @@ -0,0 +1,50 @@ +varnishtest "ESI fragment fetch fail" + +server s1 { + rxreq + expect req.url == "/abort" + txresp -hdr {surrogate-control: content="ESI/1.0"} \ + -body {before after} + + rxreq + expect req.url == "/fail" + txresp -hdr "content-length: 100" -nolen + delay 0.1 +} -start + +varnish v1 -cliok "param.set feature +esi_disable_xml_check" +varnish v1 -cliok "param.set feature +esi_include_onerror" +varnish v1 -vcl+backend { + sub vcl_backend_response { + set beresp.do_esi = beresp.http.surrogate-control ~ "ESI/1.0"; + unset beresp.http.surrogate-control; + } +} -start + +client c1 { + txreq -url "/abort" + non_fatal + rxresp + expect resp.body == "before " +} -run + +server s1 -wait + +server s1 { + rxreq + expect req.url == "/continue" + txresp -hdr {surrogate-control: content="ESI/1.0"} \ + -body {before after} + + rxreq + expect req.url == "/fail" + txresp -hdr "content-length: 100" -nolen + delay 0.1 +} -start + +client c1 { + fatal + txreq -url "/continue" + rxresp + expect resp.body == "before after" +} -run diff --git a/include/tbl/feature_bits.h b/include/tbl/feature_bits.h index d51b22cef..68ae39839 100644 --- a/include/tbl/feature_bits.h +++ b/include/tbl/feature_bits.h @@ -70,6 +70,10 @@ FEATURE_BIT(ESI_REMOVE_BOM, esi_remove_bom, "Ignore UTF-8 BOM in ESI bodies." ) +FEATURE_BIT(ESI_INCLUDE_ONERROR, esi_include_onerror, + "Parse the onerror attribute of tags." +) + FEATURE_BIT(WAIT_SILO, wait_silo, "Wait for persistent silos to completely load before serving requests." ) From dridi.boukelmoune at gmail.com Mon Feb 21 10:23:05 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 21 Feb 2022 10:23:05 +0000 (UTC) Subject: [master] a8449faff esi: Harmonize VEC_* constants Message-ID: <20220221102305.ABF44BE10D@lists.varnish-cache.org> commit a8449faff23a3c29d19781998fa5f2ee7ce110af Author: Dridi Boukelmoune Date: Mon Feb 21 08:13:40 2022 +0100 esi: Harmonize VEC_* constants diff --git a/bin/varnishd/cache/cache_esi.h b/bin/varnishd/cache/cache_esi.h index 58eb85ed1..bfe72ac33 100644 --- a/bin/varnishd/cache/cache_esi.h +++ b/bin/varnishd/cache/cache_esi.h @@ -39,8 +39,8 @@ #define VEC_S1 (0x60 + 1) #define VEC_S2 (0x60 + 2) #define VEC_S8 (0x60 + 8) -#define VEC_INCL_ABRT 'I' -#define VEC_INCL_CONT 'i' +#define VEC_IA (0x40 + 9) +#define VEC_IC (0x60 + 9) typedef ssize_t vep_callback_t(struct vfp_ctx *, void *priv, ssize_t l, enum vgz_flag flg); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index ac40a77b7..b214e9e94 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -379,11 +379,11 @@ ved_vdp_esi_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv, Debug("SKIP1(%d)\n", (int)ecx->l); ecx->state = 4; break; - case VEC_INCL_ABRT: + case VEC_IA: ecx->abrt = FEATURE(FEATURE_ESI_INCLUDE_ONERROR); /* FALLTHROUGH */ - case VEC_INCL_CONT: + case VEC_IC: ecx->p++; q = (void*)strchr((const char*)ecx->p, '\0'); AN(q); diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 2716c60b2..70835f07f 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -514,7 +514,7 @@ vep_do_include(struct vep_state *vep, enum dowhat what) l = VSB_len(vep->include_src); h = 0; - incl = vep->include_continue ? VEC_INCL_CONT : VEC_INCL_ABRT; + incl = vep->include_continue ? VEC_IC : VEC_IA; if (l > 7 && !memcmp(p, "http://", 7)) { h = p + 7; From dridi.boukelmoune at gmail.com Mon Feb 21 14:32:06 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 21 Feb 2022 14:32:06 +0000 (UTC) Subject: [master] a6afbd76e param: Streamline the bits parameters typedefs Message-ID: <20220221143206.66E9760E13@lists.varnish-cache.org> commit a6afbd76e69b5833427b8056a8cdf438806fd386 Author: Dridi Boukelmoune Date: Tue Jan 11 10:20:07 2022 +0100 param: Streamline the bits parameters typedefs diff --git a/bin/varnishd/common/common_param.h b/bin/varnishd/common/common_param.h index 5cdd35eea..abdfd6bab 100644 --- a/bin/varnishd/common/common_param.h +++ b/bin/varnishd/common/common_param.h @@ -71,10 +71,12 @@ struct poolparam { vtim_dur max_age; }; +#define PARAM_BITMAP(name, len) typedef uint8_t name[(len + 7)>>3] -typedef uint8_t vsl_mask_t[256>>3]; -typedef uint8_t debug_t[(DBG_Reserved+7)>>3]; -typedef uint8_t feature_t[(FEATURE_Reserved+7)>>3]; +PARAM_BITMAP(vsl_mask_t, 256); +PARAM_BITMAP(debug_t, DBG_Reserved); +PARAM_BITMAP(feature_t, FEATURE_Reserved); +#undef PARAM_BITMAP struct params { From dridi.boukelmoune at gmail.com Mon Feb 21 14:32:06 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 21 Feb 2022 14:32:06 +0000 (UTC) Subject: [master] bba8fc0ca param: New experimental parameter Message-ID: <20220221143206.879B260E16@lists.varnish-cache.org> commit bba8fc0ca6102a515e8794dac7a26cde541f4933 Author: Dridi Boukelmoune Date: Tue Jan 11 10:37:48 2022 +0100 param: New experimental parameter This parameter should ease the introduction of features that may later be removed without being considered a breaking change. For features that get promoted to either being always present or behind the feature param, it sends a clear signal regarding when we consider a feature ready for production. This could have been useful for HTTP/2 support for example. The first experimental feature is the ability to drop thread pools, which was behind the debug param. Having EXPERIMENTAL in the code takes a lot of real estate, but exp is already established as short for expiry. diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index 6c77d5840..ba68a2c64 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -197,7 +197,7 @@ pool_poolherder(void *priv) continue; } } else if (nwq > cache_param->wthread_pools && - DO_DEBUG(DBG_DROP_POOLS)) { + EXPERIMENTAL(EXPERIMENTAL_DROP_POOLS)) { Lck_Lock(&pool_mtx); pp = VTAILQ_FIRST(&pools); CHECK_OBJ_NOTNULL(pp, POOL_MAGIC); diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index b3a4b5ad4..096856bf1 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -570,6 +570,7 @@ void SMP_Ready(void); #endif #define FEATURE(x) COM_FEATURE(cache_param->feature_bits, x) +#define EXPERIMENTAL(x) COM_EXPERIMENTAL(cache_param->experimental_bits, x) #define DO_DEBUG(x) COM_DO_DEBUG(cache_param->debug_bits, x) #define DSL(debug_bit, id, ...) \ diff --git a/bin/varnishd/common/common_param.h b/bin/varnishd/common/common_param.h index abdfd6bab..89df97f91 100644 --- a/bin/varnishd/common/common_param.h +++ b/bin/varnishd/common/common_param.h @@ -52,6 +52,18 @@ COM_DO_DEBUG(const volatile uint8_t *p, enum debug_bits x) return (p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7))); } +enum experimental_bits { +#define EXPERIMENTAL_BIT(U, l, d) EXPERIMENTAL_##U, +#include "tbl/experimental_bits.h" + EXPERIMENTAL_Reserved +}; + +static inline int +COM_EXPERIMENTAL(const volatile uint8_t *p, enum experimental_bits x) +{ + return (p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7))); +} + enum feature_bits { #define FEATURE_BIT(U, l, d) FEATURE_##U, #include "tbl/feature_bits.h" @@ -64,7 +76,6 @@ COM_FEATURE(const volatile uint8_t *p, enum feature_bits x) return (p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7))); } - struct poolparam { unsigned min_pool; unsigned max_pool; @@ -75,6 +86,7 @@ struct poolparam { PARAM_BITMAP(vsl_mask_t, 256); PARAM_BITMAP(debug_t, DBG_Reserved); +PARAM_BITMAP(experimental_t, EXPERIMENTAL_Reserved); PARAM_BITMAP(feature_t, FEATURE_Reserved); #undef PARAM_BITMAP @@ -114,5 +126,6 @@ struct params { vsl_mask_t vsl_mask; debug_t debug_bits; + experimental_t experimental_bits; feature_t feature_bits; }; diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 9065d9eaa..5df9f5fff 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -244,5 +244,6 @@ extern const char *mgt_vmod_path; #error "Keep pthreads out of in manager process" #endif -#define MGT_FEATURE(x) COM_FEATURE(mgt_param.feature_bits, x) -#define MGT_DO_DEBUG(x) COM_DO_DEBUG(mgt_param.debug_bits, x) +#define MGT_FEATURE(x) COM_FEATURE(mgt_param.feature_bits, x) +#define MGT_EXPERIMENTAL(x) COM_EXPERIMENTAL(mgt_param.experimental_bits, x) +#define MGT_DO_DEBUG(x) COM_DO_DEBUG(mgt_param.debug_bits, x) diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c index 89d1a1aa3..5151d9598 100644 --- a/bin/varnishd/mgt/mgt_param_bits.c +++ b/bin/varnishd/mgt/mgt_param_bits.c @@ -204,6 +204,51 @@ tweak_debug(struct vsb *vsb, const struct parspec *par, const char *arg) return (0); } +/*-------------------------------------------------------------------- + * The experimental parameter + */ + +static const char * const experimental_tags[] = { +# define EXPERIMENTAL_BIT(U, l, d) [EXPERIMENTAL_##U] = #l, +# include "tbl/experimental_bits.h" + NULL +}; + +static int v_matchproto_(tweak_t) +tweak_experimental(struct vsb *vsb, const struct parspec *par, const char *arg) +{ + const char *s; + unsigned j; + (void)par; + + if (arg != NULL && arg != JSON_FMT) { + if (!strcmp(arg, "none")) { + memset(mgt_param.experimental_bits, + 0, sizeof mgt_param.experimental_bits); + } else { + return (bit_tweak(vsb, mgt_param.experimental_bits, + EXPERIMENTAL_Reserved, arg, experimental_tags, + "experimental bit", "+")); + } + } else { + if (arg == JSON_FMT) + VSB_putc(vsb, '"'); + s = ""; + for (j = 0; j < (unsigned)EXPERIMENTAL_Reserved; j++) { + if (bit(mgt_param.experimental_bits, j, BTST)) { + VSB_printf(vsb, "%s+%s", s, + experimental_tags[j]); + s = ","; + } + } + if (*s == '\0') + VSB_cat(vsb, "none"); + if (arg == JSON_FMT) + VSB_putc(vsb, '"'); + } + return (0); +} + /*-------------------------------------------------------------------- * The feature parameter */ @@ -273,7 +318,15 @@ struct parspec VSL_parspec[] = { "Use +/- prefix to set/reset individual bits:" #define DEBUG_BIT(U, l, d) "\n\t" #l "\t" d #include "tbl/debug_bits.h" -#undef DEBUG_BIT + }, + { "experimental", tweak_experimental, NULL, + NULL, NULL, "none", + NULL, + "Enable/Disable experimental features.\n" + "\tnone\tDisable all experimental features\n\n" + "Use +/- prefix to set/reset individual bits:" +#define EXPERIMENTAL_BIT(U, l, d) "\n\t" #l "\t" d +#include "tbl/experimental_bits.h" }, { "feature", tweak_feature, NULL, NULL, NULL, "default", @@ -284,7 +337,6 @@ struct parspec VSL_parspec[] = { "Use +/- prefix to enable/disable individual feature:" #define FEATURE_BIT(U, l, d) "\n\t" #l "\t" d #include "tbl/feature_bits.h" -#undef FEATURE_BIT }, { NULL, NULL, NULL } }; diff --git a/bin/varnishtest/tests/c00080.vtc b/bin/varnishtest/tests/c00080.vtc index 5a50fffcb..e4e151848 100644 --- a/bin/varnishtest/tests/c00080.vtc +++ b/bin/varnishtest/tests/c00080.vtc @@ -9,7 +9,7 @@ server s1 { varnish v1 -vcl+backend {} -start -varnish v1 -cliok "param.set debug +drop_pools" +varnish v1 -cliok "param.set experimental +drop_pools" varnish v1 -cliok "param.set debug +slow_acceptor" varnish v1 -cliok "param.set thread_pools 1" @@ -40,7 +40,7 @@ server s1 { varnish v2 -arg "-Wpoll" -vcl+backend {} -start -varnish v2 -cliok "param.set debug +drop_pools" +varnish v2 -cliok "param.set experimental +drop_pools" varnish v2 -cliok "param.set debug +slow_acceptor" varnish v2 -cliok "param.set thread_pools 1" diff --git a/include/Makefile.am b/include/Makefile.am index 62395ce2a..6ab8a8f5e 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -13,6 +13,7 @@ nobase_pkginclude_HEADERS = \ tbl/body_status.h \ tbl/cli_cmds.h \ tbl/debug_bits.h \ + tbl/experimental_bits.h \ tbl/feature_bits.h \ tbl/h2_error.h \ tbl/h2_frames.h \ diff --git a/include/tbl/debug_bits.h b/include/tbl/debug_bits.h index 6002cecd9..0e60d2547 100644 --- a/include/tbl/debug_bits.h +++ b/include/tbl/debug_bits.h @@ -45,7 +45,6 @@ DEBUG_BIT(FLUSH_HEAD, flush_head, "Flush after http1 head") DEBUG_BIT(VTC_MODE, vtc_mode, "Varnishtest Mode") DEBUG_BIT(WITNESS, witness, "Emit WITNESS lock records") DEBUG_BIT(VSM_KEEP, vsm_keep, "Keep the VSM file on restart") -DEBUG_BIT(DROP_POOLS, drop_pools, "Drop thread pools (testing)") DEBUG_BIT(SLOW_ACCEPTOR, slow_acceptor, "Slow down Acceptor") DEBUG_BIT(H2_NOCHECK, h2_nocheck, "Disable various H2 checks") DEBUG_BIT(VMOD_SO_KEEP, vmod_so_keep, "Keep copied VMOD libraries") diff --git a/include/tbl/experimental_bits.h b/include/tbl/experimental_bits.h new file mode 100644 index 000000000..ba1ff2e79 --- /dev/null +++ b/include/tbl/experimental_bits.h @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 2022 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. + * + * Fields in the experimental parameter + * + */ + +/*lint -save -e525 -e539 */ + +EXPERIMENTAL_BIT(DROP_POOLS, drop_pools, "Drop thread pools") +#undef EXPERIMENTAL_BIT + +/*lint -restore */ diff --git a/include/tbl/params.h b/include/tbl/params.h index 596429518..348b75a06 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -1736,6 +1736,23 @@ PARAM( " vtc_mode Varnishtest Mode" ) +/* actual location mgt_param_bits.c*/ +/* see tbl/experimental_bits.h */ +PARAM( + /* name */ experimental, + /* type */ experimental, + /* min */ NULL, + /* max */ NULL, + /* def */ NULL, + /* units */ NULL, + /* descr */ + "Enable/Disable experimental features.\n" + " none Disable all experimental features\n" + "\n" + "Use +/- prefix to set/reset individual bits:\n" + " drop_pools Drop thread pools\n" +) + /* actual location mgt_param_bits.c*/ /* See tbl/feature_bits.h */ PARAM( From dridi.boukelmoune at gmail.com Mon Feb 21 14:32:06 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 21 Feb 2022 14:32:06 +0000 (UTC) Subject: [master] d8ba06a52 tweak: A char is enough for bits signs Message-ID: <20220221143206.A37ED60E1A@lists.varnish-cache.org> commit d8ba06a5260ce5b5eb4b0c86f97ccaf946f15a99 Author: Dridi Boukelmoune Date: Tue Jan 11 17:14:54 2022 +0100 tweak: A char is enough for bits signs diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c index 5151d9598..35d3856ca 100644 --- a/bin/varnishd/mgt/mgt_param_bits.c +++ b/bin/varnishd/mgt/mgt_param_bits.c @@ -64,7 +64,7 @@ bit(uint8_t *p, unsigned no, enum bit_do act) static int bit_tweak(struct vsb *vsb, uint8_t *p, unsigned l, const char *arg, - const char * const *tags, const char *desc, const char *sign) + const char * const *tags, const char *desc, char sign) { int i, n; unsigned j; @@ -94,7 +94,7 @@ bit_tweak(struct vsb *vsb, uint8_t *p, unsigned l, const char *arg, return (-1); } assert(j < l); - if (s[0] == *sign) + if (s[0] == sign) (void)bit(p, j, BSET); else (void)bit(p, j, BCLR); @@ -141,7 +141,7 @@ tweak_vsl_mask(struct vsb *vsb, const struct parspec *par, const char *arg) (void)bit(mgt_param.vsl_mask, SLT_ExpKill, BSET); } else { return (bit_tweak(vsb, mgt_param.vsl_mask, - SLT__Reserved, arg, VSL_tags, "VSL tag", "-")); + SLT__Reserved, arg, VSL_tags, "VSL tag", '-')); } } else { if (arg == JSON_FMT) @@ -184,7 +184,7 @@ tweak_debug(struct vsb *vsb, const struct parspec *par, const char *arg) 0, sizeof mgt_param.debug_bits); } else { return (bit_tweak(vsb, mgt_param.debug_bits, - DBG_Reserved, arg, debug_tags, "debug bit", "+")); + DBG_Reserved, arg, debug_tags, "debug bit", '+')); } } else { if (arg == JSON_FMT) @@ -228,7 +228,7 @@ tweak_experimental(struct vsb *vsb, const struct parspec *par, const char *arg) } else { return (bit_tweak(vsb, mgt_param.experimental_bits, EXPERIMENTAL_Reserved, arg, experimental_tags, - "experimental bit", "+")); + "experimental bit", '+')); } } else { if (arg == JSON_FMT) @@ -278,7 +278,7 @@ tweak_feature(struct vsb *vsb, const struct parspec *par, const char *arg) } else { return (bit_tweak(vsb, mgt_param.feature_bits, FEATURE_Reserved, arg, feature_tags, - "feature bit", "+")); + "feature bit", '+')); } } else { if (arg == JSON_FMT) From dridi.boukelmoune at gmail.com Mon Feb 21 14:32:06 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 21 Feb 2022 14:32:06 +0000 (UTC) Subject: [master] 43de8c9f7 tweak: Manage bits parameters "default" separately Message-ID: <20220221143206.C0CF760E1E@lists.varnish-cache.org> commit 43de8c9f726295f795e5019b35319ca30462949c Author: Dridi Boukelmoune Date: Tue Jan 11 17:38:33 2022 +0100 tweak: Manage bits parameters "default" separately diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c index 35d3856ca..4b236a53a 100644 --- a/bin/varnishd/mgt/mgt_param_bits.c +++ b/bin/varnishd/mgt/mgt_param_bits.c @@ -120,29 +120,29 @@ tweak_vsl_mask(struct vsb *vsb, const struct parspec *par, const char *arg) const char *s; (void)par; + if (arg != NULL && !strcmp(arg, "default")) { + memset(mgt_param.vsl_mask, 0, sizeof mgt_param.vsl_mask); + (void)bit(mgt_param.vsl_mask, SLT_VCL_trace, BSET); + (void)bit(mgt_param.vsl_mask, SLT_WorkThread, BSET); + (void)bit(mgt_param.vsl_mask, SLT_Hash, BSET); + (void)bit(mgt_param.vsl_mask, SLT_VfpAcct, BSET); + (void)bit(mgt_param.vsl_mask, SLT_VdpAcct, BSET); + (void)bit(mgt_param.vsl_mask, SLT_H2TxBody, BSET); + (void)bit(mgt_param.vsl_mask, SLT_H2TxHdr, BSET); + (void)bit(mgt_param.vsl_mask, SLT_H2RxBody, BSET); + (void)bit(mgt_param.vsl_mask, SLT_H2RxHdr, BSET); + (void)bit(mgt_param.vsl_mask, SLT_ObjHeader, BSET); + (void)bit(mgt_param.vsl_mask, SLT_ObjProtocol, BSET); + (void)bit(mgt_param.vsl_mask, SLT_ObjReason, BSET); + (void)bit(mgt_param.vsl_mask, SLT_ObjStatus, BSET); + (void)bit(mgt_param.vsl_mask, SLT_Debug, BSET); + (void)bit(mgt_param.vsl_mask, SLT_ExpKill, BSET); + return (0); + } + if (arg != NULL && arg != JSON_FMT) { - if (!strcmp(arg, "default")) { - memset(mgt_param.vsl_mask, - 0, sizeof mgt_param.vsl_mask); - (void)bit(mgt_param.vsl_mask, SLT_VCL_trace, BSET); - (void)bit(mgt_param.vsl_mask, SLT_WorkThread, BSET); - (void)bit(mgt_param.vsl_mask, SLT_Hash, BSET); - (void)bit(mgt_param.vsl_mask, SLT_VfpAcct, BSET); - (void)bit(mgt_param.vsl_mask, SLT_VdpAcct, BSET); - (void)bit(mgt_param.vsl_mask, SLT_H2TxBody, BSET); - (void)bit(mgt_param.vsl_mask, SLT_H2TxHdr, BSET); - (void)bit(mgt_param.vsl_mask, SLT_H2RxBody, BSET); - (void)bit(mgt_param.vsl_mask, SLT_H2RxHdr, BSET); - (void)bit(mgt_param.vsl_mask, SLT_ObjHeader, BSET); - (void)bit(mgt_param.vsl_mask, SLT_ObjProtocol, BSET); - (void)bit(mgt_param.vsl_mask, SLT_ObjReason, BSET); - (void)bit(mgt_param.vsl_mask, SLT_ObjStatus, BSET); - (void)bit(mgt_param.vsl_mask, SLT_Debug, BSET); - (void)bit(mgt_param.vsl_mask, SLT_ExpKill, BSET); - } else { - return (bit_tweak(vsb, mgt_param.vsl_mask, - SLT__Reserved, arg, VSL_tags, "VSL tag", '-')); - } + return (bit_tweak(vsb, mgt_param.vsl_mask, + SLT__Reserved, arg, VSL_tags, "VSL tag", '-')); } else { if (arg == JSON_FMT) VSB_putc(vsb, '"'); @@ -266,13 +266,16 @@ tweak_feature(struct vsb *vsb, const struct parspec *par, const char *arg) unsigned j; (void)par; + if (arg != NULL && !strcmp(arg, "default")) { + memset(mgt_param.feature_bits, 0, + sizeof mgt_param.feature_bits); + (void)bit(mgt_param.feature_bits, + FEATURE_VALIDATE_HEADERS, BSET); + return (0); + } + if (arg != NULL && arg != JSON_FMT) { - if (!strcmp(arg, "default")) { - memset(mgt_param.feature_bits, - 0, sizeof mgt_param.feature_bits); - (void)bit(mgt_param.feature_bits, - FEATURE_VALIDATE_HEADERS, BSET); - } else if (!strcmp(arg, "none")) { + if (!strcmp(arg, "none")) { memset(mgt_param.feature_bits, 0, sizeof mgt_param.feature_bits); } else { From dridi.boukelmoune at gmail.com Mon Feb 21 14:32:06 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 21 Feb 2022 14:32:06 +0000 (UTC) Subject: [master] 81feeb7e8 tweak: Generalize bits tweaking Message-ID: <20220221143206.D932E60E22@lists.varnish-cache.org> commit 81feeb7e8652392d4f9ac60079db6fe9f08451fa Author: Dridi Boukelmoune Date: Tue Jan 11 18:03:33 2022 +0100 tweak: Generalize bits tweaking diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c index 4b236a53a..54198516e 100644 --- a/bin/varnishd/mgt/mgt_param_bits.c +++ b/bin/varnishd/mgt/mgt_param_bits.c @@ -104,6 +104,42 @@ bit_tweak(struct vsb *vsb, uint8_t *p, unsigned l, const char *arg, } +/*-------------------------------------------------------------------- + */ + +static int +tweak_generic_bits(struct vsb *vsb, const struct parspec *par, const char *arg, + uint8_t *p, unsigned l, const char * const *tags, const char *desc, + char sign) +{ + const char *s; + unsigned j; + + (void)par; + + if (arg != NULL && arg != JSON_FMT) { + if (sign == '+' && !strcmp(arg, "none")) + memset(p, 0, l >> 3); + else + return (bit_tweak(vsb, p, l, arg, tags, desc, sign)); + } else { + if (arg == JSON_FMT) + VSB_putc(vsb, '"'); + s = ""; + for (j = 0; j < l; j++) { + if (bit(p, j, BTST)) { + VSB_printf(vsb, "%s%c%s", s, sign, tags[j]); + s = ","; + } + } + if (*s == '\0') + VSB_cat(vsb, sign == '+' ? "none" : "(all enabled)"); + if (arg == JSON_FMT) + VSB_putc(vsb, '"'); + } + return (0); +} + /*-------------------------------------------------------------------- * The vsl_mask parameter */ @@ -116,9 +152,6 @@ static const char * const VSL_tags[256] = { static int v_matchproto_(tweak_t) tweak_vsl_mask(struct vsb *vsb, const struct parspec *par, const char *arg) { - unsigned j; - const char *s; - (void)par; if (arg != NULL && !strcmp(arg, "default")) { memset(mgt_param.vsl_mask, 0, sizeof mgt_param.vsl_mask); @@ -140,25 +173,8 @@ tweak_vsl_mask(struct vsb *vsb, const struct parspec *par, const char *arg) return (0); } - if (arg != NULL && arg != JSON_FMT) { - return (bit_tweak(vsb, mgt_param.vsl_mask, - SLT__Reserved, arg, VSL_tags, "VSL tag", '-')); - } else { - if (arg == JSON_FMT) - VSB_putc(vsb, '"'); - s = ""; - for (j = 0; j < (unsigned)SLT__Reserved; j++) { - if (bit(mgt_param.vsl_mask, j, BTST)) { - VSB_printf(vsb, "%s-%s", s, VSL_tags[j]); - s = ","; - } - } - if (*s == '\0') - VSB_cat(vsb, "(all enabled)"); - if (arg == JSON_FMT) - VSB_putc(vsb, '"'); - } - return (0); + return (tweak_generic_bits(vsb, par, arg, mgt_param.vsl_mask, + SLT__Reserved, VSL_tags, "VSL tag", '-')); } /*-------------------------------------------------------------------- @@ -174,34 +190,9 @@ static const char * const debug_tags[] = { static int v_matchproto_(tweak_t) tweak_debug(struct vsb *vsb, const struct parspec *par, const char *arg) { - const char *s; - unsigned j; - (void)par; - if (arg != NULL && arg != JSON_FMT) { - if (!strcmp(arg, "none")) { - memset(mgt_param.debug_bits, - 0, sizeof mgt_param.debug_bits); - } else { - return (bit_tweak(vsb, mgt_param.debug_bits, - DBG_Reserved, arg, debug_tags, "debug bit", '+')); - } - } else { - if (arg == JSON_FMT) - VSB_putc(vsb, '"'); - s = ""; - for (j = 0; j < (unsigned)DBG_Reserved; j++) { - if (bit(mgt_param.debug_bits, j, BTST)) { - VSB_printf(vsb, "%s+%s", s, debug_tags[j]); - s = ","; - } - } - if (*s == '\0') - VSB_cat(vsb, "none"); - if (arg == JSON_FMT) - VSB_putc(vsb, '"'); - } - return (0); + return (tweak_generic_bits(vsb, par, arg, mgt_param.debug_bits, + DBG_Reserved, debug_tags, "debug bit", '+')); } /*-------------------------------------------------------------------- @@ -217,36 +208,9 @@ static const char * const experimental_tags[] = { static int v_matchproto_(tweak_t) tweak_experimental(struct vsb *vsb, const struct parspec *par, const char *arg) { - const char *s; - unsigned j; - (void)par; - if (arg != NULL && arg != JSON_FMT) { - if (!strcmp(arg, "none")) { - memset(mgt_param.experimental_bits, - 0, sizeof mgt_param.experimental_bits); - } else { - return (bit_tweak(vsb, mgt_param.experimental_bits, - EXPERIMENTAL_Reserved, arg, experimental_tags, - "experimental bit", '+')); - } - } else { - if (arg == JSON_FMT) - VSB_putc(vsb, '"'); - s = ""; - for (j = 0; j < (unsigned)EXPERIMENTAL_Reserved; j++) { - if (bit(mgt_param.experimental_bits, j, BTST)) { - VSB_printf(vsb, "%s+%s", s, - experimental_tags[j]); - s = ","; - } - } - if (*s == '\0') - VSB_cat(vsb, "none"); - if (arg == JSON_FMT) - VSB_putc(vsb, '"'); - } - return (0); + return (tweak_generic_bits(vsb, par, arg, mgt_param.experimental_bits, + EXPERIMENTAL_Reserved, experimental_tags, "experimental bit", '+')); } /*-------------------------------------------------------------------- @@ -262,9 +226,6 @@ static const char * const feature_tags[] = { static int v_matchproto_(tweak_t) tweak_feature(struct vsb *vsb, const struct parspec *par, const char *arg) { - const char *s; - unsigned j; - (void)par; if (arg != NULL && !strcmp(arg, "default")) { memset(mgt_param.feature_bits, 0, @@ -274,31 +235,8 @@ tweak_feature(struct vsb *vsb, const struct parspec *par, const char *arg) return (0); } - if (arg != NULL && arg != JSON_FMT) { - if (!strcmp(arg, "none")) { - memset(mgt_param.feature_bits, - 0, sizeof mgt_param.feature_bits); - } else { - return (bit_tweak(vsb, mgt_param.feature_bits, - FEATURE_Reserved, arg, feature_tags, - "feature bit", '+')); - } - } else { - if (arg == JSON_FMT) - VSB_putc(vsb, '"'); - s = ""; - for (j = 0; j < (unsigned)FEATURE_Reserved; j++) { - if (bit(mgt_param.feature_bits, j, BTST)) { - VSB_printf(vsb, "%s+%s", s, feature_tags[j]); - s = ","; - } - } - if (*s == '\0') - VSB_cat(vsb, "none"); - if (arg == JSON_FMT) - VSB_putc(vsb, '"'); - } - return (0); + return (tweak_generic_bits(vsb, par, arg, mgt_param.feature_bits, + FEATURE_Reserved, feature_tags, "feature bit", '+')); } /*-------------------------------------------------------------------- From dridi.boukelmoune at gmail.com Mon Feb 21 14:32:06 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 21 Feb 2022 14:32:06 +0000 (UTC) Subject: [master] 20863c9b1 tweak: Simplify default bits parameters Message-ID: <20220221143206.F325360E26@lists.varnish-cache.org> commit 20863c9b166cf0171f577047f9e4125d728bd48f Author: Dridi Boukelmoune Date: Tue Jan 11 18:09:55 2022 +0100 tweak: Simplify default bits parameters Instead of manually setting the default bits, give the parameters specs actual default values and centralize the special handling of the "default" argument. diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c index 54198516e..02f5e1463 100644 --- a/bin/varnishd/mgt/mgt_param_bits.c +++ b/bin/varnishd/mgt/mgt_param_bits.c @@ -115,7 +115,12 @@ tweak_generic_bits(struct vsb *vsb, const struct parspec *par, const char *arg, const char *s; unsigned j; - (void)par; + if (arg != NULL && !strcmp(arg, "default") && + strcmp(par->def, "none")) { + memset(p, 0, l >> 3); + return (tweak_generic_bits(vsb, par, par->def, p, l, tags, + desc, sign)); + } if (arg != NULL && arg != JSON_FMT) { if (sign == '+' && !strcmp(arg, "none")) @@ -153,26 +158,6 @@ static int v_matchproto_(tweak_t) tweak_vsl_mask(struct vsb *vsb, const struct parspec *par, const char *arg) { - if (arg != NULL && !strcmp(arg, "default")) { - memset(mgt_param.vsl_mask, 0, sizeof mgt_param.vsl_mask); - (void)bit(mgt_param.vsl_mask, SLT_VCL_trace, BSET); - (void)bit(mgt_param.vsl_mask, SLT_WorkThread, BSET); - (void)bit(mgt_param.vsl_mask, SLT_Hash, BSET); - (void)bit(mgt_param.vsl_mask, SLT_VfpAcct, BSET); - (void)bit(mgt_param.vsl_mask, SLT_VdpAcct, BSET); - (void)bit(mgt_param.vsl_mask, SLT_H2TxBody, BSET); - (void)bit(mgt_param.vsl_mask, SLT_H2TxHdr, BSET); - (void)bit(mgt_param.vsl_mask, SLT_H2RxBody, BSET); - (void)bit(mgt_param.vsl_mask, SLT_H2RxHdr, BSET); - (void)bit(mgt_param.vsl_mask, SLT_ObjHeader, BSET); - (void)bit(mgt_param.vsl_mask, SLT_ObjProtocol, BSET); - (void)bit(mgt_param.vsl_mask, SLT_ObjReason, BSET); - (void)bit(mgt_param.vsl_mask, SLT_ObjStatus, BSET); - (void)bit(mgt_param.vsl_mask, SLT_Debug, BSET); - (void)bit(mgt_param.vsl_mask, SLT_ExpKill, BSET); - return (0); - } - return (tweak_generic_bits(vsb, par, arg, mgt_param.vsl_mask, SLT__Reserved, VSL_tags, "VSL tag", '-')); } @@ -227,14 +212,6 @@ static int v_matchproto_(tweak_t) tweak_feature(struct vsb *vsb, const struct parspec *par, const char *arg) { - if (arg != NULL && !strcmp(arg, "default")) { - memset(mgt_param.feature_bits, 0, - sizeof mgt_param.feature_bits); - (void)bit(mgt_param.feature_bits, - FEATURE_VALIDATE_HEADERS, BSET); - return (0); - } - return (tweak_generic_bits(vsb, par, arg, mgt_param.feature_bits, FEATURE_Reserved, feature_tags, "feature bit", '+')); } @@ -245,14 +222,32 @@ tweak_feature(struct vsb *vsb, const struct parspec *par, const char *arg) struct parspec VSL_parspec[] = { { "vsl_mask", tweak_vsl_mask, NULL, - NULL, NULL, "default", + NULL, NULL, + /* default */ + "-Debug," + "-ExpKill," + "-H2RxBody," + "-H2RxHdr," + "-H2TxBody," + "-H2TxHdr," + "-Hash," + "-ObjHeader," + "-ObjProtocol," + "-ObjReason," + "-ObjStatus," + "-VCL_trace," + "-VdpAcct," + "-VfpAcct," + "-WorkThread", NULL, "Mask individual VSL messages from being logged.\n" "\tdefault\tSet default value\n" "\nUse +/- prefix in front of VSL tag name to unmask/mask " "individual VSL messages." }, { "debug", tweak_debug, NULL, - NULL, NULL, "none", + NULL, NULL, + /* default */ + "none", NULL, "Enable/Disable various kinds of debugging.\n" "\tnone\tDisable all debugging\n\n" @@ -261,7 +256,9 @@ struct parspec VSL_parspec[] = { #include "tbl/debug_bits.h" }, { "experimental", tweak_experimental, NULL, - NULL, NULL, "none", + NULL, NULL, + /* default */ + "none", NULL, "Enable/Disable experimental features.\n" "\tnone\tDisable all experimental features\n\n" @@ -270,7 +267,9 @@ struct parspec VSL_parspec[] = { #include "tbl/experimental_bits.h" }, { "feature", tweak_feature, NULL, - NULL, NULL, "default", + NULL, NULL, + /* default */ + "+validate_headers", NULL, "Enable/Disable various minor features.\n" "\tdefault\tSet default value\n" From dridi.boukelmoune at gmail.com Tue Feb 22 14:03:05 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 22 Feb 2022 14:03:05 +0000 (UTC) Subject: [master] 006f3ec4d param: Rename conflicting EXPERIMENTAL macros Message-ID: <20220222140305.09CCF64D68@lists.varnish-cache.org> commit 006f3ec4d2271641f20a5005aa7533bba3d11752 Author: Dridi Boukelmoune Date: Tue Feb 22 14:59:36 2022 +0100 param: Rename conflicting EXPERIMENTAL macros There was already a macro called EXPERIMENTAL, so it clashes with the new set of EXPERIMENTAL* macros. Anything directly referring to the parameter keeps the experimental prefix, otherwise, experiment. Spotted by Flexelint. diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index ba68a2c64..6d854c127 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -197,7 +197,7 @@ pool_poolherder(void *priv) continue; } } else if (nwq > cache_param->wthread_pools && - EXPERIMENTAL(EXPERIMENTAL_DROP_POOLS)) { + EXPERIMENT(EXPERIMENT_DROP_POOLS)) { Lck_Lock(&pool_mtx); pp = VTAILQ_FIRST(&pools); CHECK_OBJ_NOTNULL(pp, POOL_MAGIC); diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index 096856bf1..f5c377448 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -570,7 +570,7 @@ void SMP_Ready(void); #endif #define FEATURE(x) COM_FEATURE(cache_param->feature_bits, x) -#define EXPERIMENTAL(x) COM_EXPERIMENTAL(cache_param->experimental_bits, x) +#define EXPERIMENT(x) COM_EXPERIMENT(cache_param->experimental_bits, x) #define DO_DEBUG(x) COM_DO_DEBUG(cache_param->debug_bits, x) #define DSL(debug_bit, id, ...) \ diff --git a/bin/varnishd/common/common_param.h b/bin/varnishd/common/common_param.h index 89df97f91..201bfd381 100644 --- a/bin/varnishd/common/common_param.h +++ b/bin/varnishd/common/common_param.h @@ -53,13 +53,13 @@ COM_DO_DEBUG(const volatile uint8_t *p, enum debug_bits x) } enum experimental_bits { -#define EXPERIMENTAL_BIT(U, l, d) EXPERIMENTAL_##U, +#define EXPERIMENTAL_BIT(U, l, d) EXPERIMENT_##U, #include "tbl/experimental_bits.h" - EXPERIMENTAL_Reserved + EXPERIMENT_Reserved }; static inline int -COM_EXPERIMENTAL(const volatile uint8_t *p, enum experimental_bits x) +COM_EXPERIMENT(const volatile uint8_t *p, enum experimental_bits x) { return (p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7))); } @@ -86,7 +86,7 @@ struct poolparam { PARAM_BITMAP(vsl_mask_t, 256); PARAM_BITMAP(debug_t, DBG_Reserved); -PARAM_BITMAP(experimental_t, EXPERIMENTAL_Reserved); +PARAM_BITMAP(experimental_t, EXPERIMENT_Reserved); PARAM_BITMAP(feature_t, FEATURE_Reserved); #undef PARAM_BITMAP diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 5df9f5fff..9853f51a5 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -245,5 +245,5 @@ extern const char *mgt_vmod_path; #endif #define MGT_FEATURE(x) COM_FEATURE(mgt_param.feature_bits, x) -#define MGT_EXPERIMENTAL(x) COM_EXPERIMENTAL(mgt_param.experimental_bits, x) +#define MGT_EXPERIMENT(x) COM_EXPERIMENT(mgt_param.experimental_bits, x) #define MGT_DO_DEBUG(x) COM_DO_DEBUG(mgt_param.debug_bits, x) diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c index 02f5e1463..bec9625b4 100644 --- a/bin/varnishd/mgt/mgt_param_bits.c +++ b/bin/varnishd/mgt/mgt_param_bits.c @@ -185,7 +185,7 @@ tweak_debug(struct vsb *vsb, const struct parspec *par, const char *arg) */ static const char * const experimental_tags[] = { -# define EXPERIMENTAL_BIT(U, l, d) [EXPERIMENTAL_##U] = #l, +# define EXPERIMENTAL_BIT(U, l, d) [EXPERIMENT_##U] = #l, # include "tbl/experimental_bits.h" NULL }; @@ -195,7 +195,7 @@ tweak_experimental(struct vsb *vsb, const struct parspec *par, const char *arg) { return (tweak_generic_bits(vsb, par, arg, mgt_param.experimental_bits, - EXPERIMENTAL_Reserved, experimental_tags, "experimental bit", '+')); + EXPERIMENT_Reserved, experimental_tags, "experimental bit", '+')); } /*-------------------------------------------------------------------- From dridi.boukelmoune at gmail.com Tue Feb 22 15:12:05 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 22 Feb 2022 15:12:05 +0000 (UTC) Subject: [master] 3b6b1124f vcc: New SYM_ALIAS kind for deprecated symbols Message-ID: <20220222151205.D5629920A2@lists.varnish-cache.org> commit 3b6b1124fcae042b81aca6c9597ae53a240e1732 Author: Dridi Boukelmoune Date: Fri Jan 7 09:42:19 2022 +0100 vcc: New SYM_ALIAS kind for deprecated symbols Aliases are a new strictly internal kind of symbols with zero runtime cost. They resolve implicitly to the destination symbol, even when they are created. This should facilitate renaming things in the future. One thing we could do is to have libvcc warn about deprecated aliases (subject to a new vcc_err_alias parameter too) to make this visible not just in the documentation. diff --git a/include/tbl/symbol_kind.h b/include/tbl/symbol_kind.h index 40dfbfdd8..c1f29fa98 100644 --- a/include/tbl/symbol_kind.h +++ b/include/tbl/symbol_kind.h @@ -33,6 +33,7 @@ VCC_KIND(NONE, none) VCC_KIND(RESERVED, reserved) +VCC_KIND(ALIAS, alias) VCC_KIND(ACL, acl) VCC_KIND(ACTION, action) VCC_KIND(BACKEND, backend) diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index 76b2cab73..1663ba92d 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -384,6 +384,7 @@ vcc_kind_t VCC_HandleKind(vcc_type_t fmt); void VCC_PrintCName(struct vsb *vsb, const char *b, const char *e); struct symbol *VCC_MkSym(struct vcc *tl, const char *b, vcc_ns_t, vcc_kind_t, int, int); +struct symbol *VCC_MkSymAlias(struct vcc *tl, const char *, const char *); struct symxref { const char *name; }; extern const struct symxref XREF_NONE[1]; diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c index 34736072b..1478509ed 100644 --- a/lib/libvcc/vcc_symb.c +++ b/lib/libvcc/vcc_symb.c @@ -320,6 +320,14 @@ VCC_SymbolGet(struct vcc *tl, vcc_ns_t ns, vcc_kind_t kind, break; tn = tn1; } + if (sym != NULL && sym->kind == SYM_ALIAS) { + assert(ns == SYM_MAIN); + st = vcc_symtab_str(tl->syms[ns->id], sym->eval_priv, NULL, ID); + AN(st); + st2 = st; + sym = vcc_sym_in_tab(tl, st, SYM_NONE, sym->lorev, sym->hirev); + AN(sym); + } if (sym != NULL && sym->kind == SYM_VMOD && e->partial) e = SYMTAB_EXISTING; if (sym != NULL && e->partial) { @@ -450,6 +458,29 @@ VCC_MkSym(struct vcc *tl, const char *b, vcc_ns_t ns, vcc_kind_t kind, return (sym); } +struct symbol * +VCC_MkSymAlias(struct vcc *tl, const char *alias, const char *name) +{ + struct symbol *sym_alias, *sym; + struct symtab *st; + + AN(tl); + AN(alias); + AN(name); + + st = vcc_symtab_str(tl->syms[SYM_MAIN->id], name, NULL, ID); + AN(st); + sym = vcc_sym_in_tab(tl, st, SYM_NONE, VCL_LOW, VCL_HIGH); + AN(sym); + assert(sym->kind != SYM_ALIAS); + sym_alias = VCC_MkSym(tl, alias, SYM_MAIN, SYM_ALIAS, sym->lorev, + sym->hirev); + AN(sym_alias); + sym_alias->eval_priv = strdup(name); + AN(sym_alias->eval_priv); + return (sym); +} + static void vcc_walksymbols(struct vcc *tl, const struct symtab *root, symwalk_f *func, vcc_kind_t kind) From dridi.boukelmoune at gmail.com Tue Feb 22 15:12:06 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 22 Feb 2022 15:12:06 +0000 (UTC) Subject: [master] 10d386c6c vcc: Allow aliases among VCL variables Message-ID: <20220222151206.0F6C2920A5@lists.varnish-cache.org> commit 10d386c6c2a259432b7d8d14fa4384cdb2520873 Author: Dridi Boukelmoune Date: Fri Jan 7 09:52:24 2022 +0100 vcc: Allow aliases among VCL variables The script expects aliases to be defined like this in the RST docs: my.alias ``VCL <= 4.1`` Type: DEPRECATED Alias of: something.else A little description is still necessary. There is no DEPRECATED type in addition to the SYM_ALIAS kind, this is a purely cosmetic suggestion. Deprecated aliases should probably have a high VCL version limit like in the example above, generate.py doesn't enforce it so far. diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index c50194348..94b0252fe 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -169,18 +169,22 @@ def varproto(s): varprotos[s] = True class vardef(object): - def __init__(self, nam, typ, rd, wr, wu, vlo, vhi): + def __init__(self, nam, typ, rd, wr, wu, al, vlo, vhi): self.nam = nam self.typ = typ self.rd = rd self.wr = wr self.uns = wu + self.al = al self.vlo = vlo self.vhi = vhi - self.emit() + if al is None: + self.emit_var() + else: + self.emit_alias() - def emit(self): + def emit_var(self): fh.write("\n") fo.write("\n") cnam = self.nam.replace(".", "_") @@ -234,6 +238,11 @@ class vardef(object): restrict(fo, self.uns) fo.write(";\n") + def emit_alias(self): + var_aliases.append("\tsym = VCC_MkSymAlias(tl, \"%s\", \"%s\");\n" % + (self.nam, self.al)) + var_aliases.append("\tAN(sym);\n") + def parse_vcl(x): vlo, vhi = (0, 99) x = x.split() @@ -260,6 +269,7 @@ def parse_var(ln): vr = [] vw = [] vu = [] + va = None while True: l = ln.pop(0) if l == "": @@ -281,9 +291,12 @@ def parse_var(ln): for i in j[2:]: vu.append(i.strip(",.")) continue + if j[0] == "Alias" and j[1] == "of:": + va = j[2] + continue break if vn[:8] != "storage.": - vardef(vn, vt, vr, vw, vu, vlo, vhi) + vardef(vn, vt, vr, vw, vu, va, vlo, vhi) def parse_var_doc(fn): l = [] @@ -755,7 +768,10 @@ vcc_Var_Init(struct vcc *tl) struct symbol *sym; """) +var_aliases = [] parse_var_doc(join(srcroot, "doc/sphinx/reference/vcl_var.rst")) +for al in var_aliases: + fo.write(al) fo.write("}\n") for i in stv_variables: From dridi.boukelmoune at gmail.com Tue Feb 22 15:12:06 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 22 Feb 2022 15:12:06 +0000 (UTC) Subject: [master] ceb88d2e0 vcc: New $Alias stanza for VMODs Message-ID: <20220222151206.4850F920AC@lists.varnish-cache.org> commit ceb88d2e0134907eb9bf160c67db1f4e422d241f Author: Dridi Boukelmoune Date: Tue Feb 22 10:24:32 2022 +0100 vcc: New $Alias stanza for VMODs It is now possible to rename a symbol from a VMOD without breaking existing code until the VMOD author decides to remove the deprecated alias. The VCC file syntax is simply: $Alias [Optional description] $Alias <.alias> [Optional description] The alias can only apply to a $Function or $Method. The generated RST looks like this for a method: ALIAS x.() ------------------------ Deprecated alias for ``x.()``. [Optional description] It looks the same for a function without the $Object prefix. Aliases don't have a reference label for sphinx docs, the goal is not to make them prominent, but rather to have the ability to move them to a manual section for deprecated symbols at the end of the document. diff --git a/bin/varnishtest/tests/r01332.vtc b/bin/varnishtest/tests/r01332.vtc index 1f6616737..eea01c990 100644 --- a/bin/varnishtest/tests/r01332.vtc +++ b/bin/varnishtest/tests/r01332.vtc @@ -15,6 +15,7 @@ varnish v1 -vcl+backend { sub vcl_deliver { objx.enum(martin); set resp.http.foo = objx.foo(""); + set resp.http.bar = objx.bar(""); } } -start @@ -23,4 +24,5 @@ client c1 { rxresp expect resp.status == 200 expect resp.http.foo == "BOO" + expect resp.http.bar == "BOO" } -run diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index 2b5ec5959..9c5be1234 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -76,6 +76,38 @@ vcc_path_dlopen(void *priv, const char *fn) static void vcc_VmodObject(struct vcc *tl, struct symbol *sym); static void vcc_VmodSymbols(struct vcc *tl, const struct symbol *sym); +static void +alias_sym(struct vcc *tl, const struct symbol *psym, const struct vjsn_val *v) +{ + char *alias = NULL, *func = NULL; + struct symbol *sym; + struct vsb *buf; + + buf = VSB_new_auto(); + AN(buf); + + VCC_SymName(buf, psym); + VSB_printf(buf, ".%s", v->value); + AZ(VSB_finish(buf)); + REPLACE(alias, VSB_data(buf)); + + v = VTAILQ_NEXT(v, list); + assert(vjsn_is_string(v)); + + VSB_clear(buf); + VCC_SymName(buf, psym); + VSB_printf(buf, ".%s", v->value); + AZ(VSB_finish(buf)); + REPLACE(func, VSB_data(buf)); + + sym = VCC_MkSymAlias(tl, alias, func); + AN(sym); + assert(sym->kind == SYM_FUNC || sym->kind == SYM_METHOD); + VSB_destroy(&buf); + free(alias); + free(func); +} + static void func_sym(struct vcc *tl, vcc_kind_t kind, const struct symbol *psym, const struct vjsn_val *v) @@ -83,10 +115,14 @@ func_sym(struct vcc *tl, vcc_kind_t kind, const struct symbol *psym, struct symbol *sym; struct vsb *buf; + if (kind == SYM_ALIAS) { + alias_sym(tl, psym, v); + return; + } + buf = VSB_new_auto(); AN(buf); - VSB_clear(buf); VCC_SymName(buf, psym); VSB_printf(buf, ".%s", v->value); AZ(VSB_finish(buf)); @@ -158,6 +194,7 @@ vcc_json_always(struct vcc *tl, const struct vjsn *vj, const char *vmod_name) vv2->value, vmod_name); VSB_printf(ifp->event, "%s(ctx, &vmod_priv_%s, ev)", vv2->value, vmod_name); + } else if (!strcmp(vv2->value, "$ALIAS")) { } else if (!strcmp(vv2->value, "$FUNC")) { } else if (!strcmp(vv2->value, "$OBJ")) { } else { @@ -237,6 +274,7 @@ vcc_vmod_kind(const char *type) VMOD_KIND("$OBJ", SYM_OBJECT); VMOD_KIND("$METHOD", SYM_METHOD); VMOD_KIND("$FUNC", SYM_FUNC); + VMOD_KIND("$ALIAS", SYM_ALIAS); #undef VMOD_KIND return (SYM_NONE); } diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 0eb77c527..5be4d4665 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -835,6 +835,53 @@ class MethodStanza(Stanza): self.proto.jsonproto(jl[-1], self.proto.cname()) +class AliasStanza(Stanza): + + ''' $Alias ALIAS SYMBOL ''' + + def find_symbol(self, tbl, name): + for sym in tbl: + if sym.proto is None: + continue; + if sym.proto.name == name: + return sym + err("Symbol '%s' not found\n" % name, warn=False) + + def parse(self): + if len(self.toks) != 3: + err("Syntax error, expected: $Alias \n", warn=False) + if not re.match('^\.?[a-zA-Z_][a-zA-Z0-9_]*$', self.toks[1]): + err("%s(): Illegal C-name\n" % self.toks[1], warn=False) + if self.toks[1][0] == '.': + if not re.match('^[a-zA-Z_][a-zA-Z0-9_]*\.[a-zA-Z_][a-zA-Z0-9_]*$', + self.toks[2]): + err("Syntax error, expected: $Alias <.alias> \n", + warn=False) + obj_name = self.toks[2].split('.')[0] + obj = self.find_symbol(self.vcc.contents, obj_name) + self.find_symbol(obj.methods, self.toks[2]) + self.sym_alias = "%s%s" % (obj_name, self.toks[1]) + self.doc_alias = "x%s" % self.sym_alias + self.sym_name = self.toks[2] + self.doc_name = "x%s" % self.toks[2] + else: + self.find_symbol(self.vcc.contents, self.toks[2]) + self.sym_alias = self.toks[1] + self.doc_alias = self.toks[1] + self.sym_name = self.toks[2] + self.doc_name = self.toks[2] + self.vcc.contents.append(self) + + def rsthead(self, fo, unused_man): + write_rst_hdr(fo, "ALIAS %s()" % self.doc_alias, "-") + fo.write("\nDeprecated alias for ``%s()``." % self.doc_name) + if len(self.doc) > 0: + fo.write("\n\n") + + def json(self, jl): + jl.append(["$ALIAS", self.sym_alias, self.sym_name]) + + ####################################################################### DISPATCH = { @@ -846,6 +893,7 @@ DISPATCH = { "Object": ObjectStanza, "Method": MethodStanza, "Synopsis": SynopsisStanza, + "Alias": AliasStanza, } diff --git a/vmod/vmod_debug.vcc b/vmod/vmod_debug.vcc index b3ff9ac4d..2fb67e8ab 100644 --- a/vmod/vmod_debug.vcc +++ b/vmod/vmod_debug.vcc @@ -374,3 +374,10 @@ $Object caller(SUB) $Method VOID .call() $Method SUB .xsub() + +DEPRECATED +========== + +$Alias .bar obj.foo + +Bar was wrong, it was definitely foo. From dridi.boukelmoune at gmail.com Tue Feb 22 15:12:06 2022 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 22 Feb 2022 15:12:06 +0000 (UTC) Subject: [master] ddb8f3268 vmod_cookie: Rename format_rfc1123() to format_date() Message-ID: <20220222151206.75CD4920AF@lists.varnish-cache.org> commit ddb8f3268882b3d57c223618330740ec94f18ccc Author: Dridi Boukelmoune Date: Fri Jan 7 09:58:16 2022 +0100 vmod_cookie: Rename format_rfc1123() to format_date() This was supposed to happen before the first release including the VMOD but it got OBE at the time. diff --git a/vmod/vmod_cookie.c b/vmod/vmod_cookie.c index a0f47c74b..f70f6ee4a 100644 --- a/vmod/vmod_cookie.c +++ b/vmod/vmod_cookie.c @@ -451,7 +451,7 @@ vmod_get_string(VRT_CTX, struct vmod_priv *priv) } VCL_STRING -vmod_format_rfc1123(VRT_CTX, VCL_TIME ts, VCL_DURATION duration) +vmod_format_date(VRT_CTX, VCL_TIME ts, VCL_DURATION duration) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); diff --git a/vmod/vmod_cookie.vcc b/vmod/vmod_cookie.vcc index 913240f1b..e92e11e5e 100644 --- a/vmod/vmod_cookie.vcc +++ b/vmod/vmod_cookie.vcc @@ -132,7 +132,7 @@ Example:: -$Function STRING format_rfc1123(TIME now, DURATION timedelta) +$Function STRING format_date(TIME now, DURATION timedelta) Get a RFC1123 formatted date string suitable for inclusion in a Set-Cookie response header. @@ -145,7 +145,7 @@ Example:: sub vcl_deliver { # Set a userid cookie on the client that lives for 5 minutes. set resp.http.Set-Cookie = "userid=" + req.http.userid + - "; Expires=" + cookie.format_rfc1123(now, 5m) + "; httpOnly"; + "; Expires=" + cookie.format_date(now, 5m) + "; httpOnly"; } $Function STRING get(PRIV_TASK, STRING cookiename) @@ -254,3 +254,8 @@ Example:: cookie.set("cookie1", "value1"); std.log("cookie1 value is: " + cookie.get("cookie1")); } + +DEPRECATED +========== + +$Alias format_rfc1123 format_date From nils.goroll at uplex.de Wed Feb 23 10:14:08 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 23 Feb 2022 10:14:08 +0000 (UTC) Subject: [master] c7104e3e1 Revert "Fix a newly introduced lifetime violation" Message-ID: <20220223101408.9A22D940E@lists.varnish-cache.org> commit c7104e3e11889b7fb27af5daa7c2adfb27430d4d Author: Nils Goroll Date: Wed Feb 23 10:37:54 2022 +0100 Revert "Fix a newly introduced lifetime violation" The fix did work, but the explanation was wrong. This reverts commit a6c1306494bab1d95fc7dd571089b80336922a1c. diff --git a/vmod/vmod_vtc.c b/vmod/vmod_vtc.c index 06bab4bcd..143e5e7ce 100644 --- a/vmod/vmod_vtc.c +++ b/vmod/vmod_vtc.c @@ -443,6 +443,7 @@ vsl_line(VRT_CTX, char *str) { VCL_INT id; VCL_ENUM side; + VCL_STRANDS s; const char *tag, *delim = " \t\r\n"; char *e, *save; @@ -474,9 +475,11 @@ vsl_line(VRT_CTX, char *str) str = strtok_r(NULL, "\r\n", &save); if (str == NULL) - vmod_vsl(ctx, id, tag, side, vrt_null_strands); + s = vrt_null_strands; else - vmod_vsl(ctx, id, tag, side, TOSTRAND(str)); + s = TOSTRAND(str); + + vmod_vsl(ctx, id, tag, side, s); } VCL_VOID From nils.goroll at uplex.de Wed Feb 23 10:14:08 2022 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 23 Feb 2022 10:14:08 +0000 (UTC) Subject: [master] 1157dfdc6 Respect TOSTRAND() lifetime Message-ID: <20220223101408.B57389411@lists.varnish-cache.org> commit 1157dfdc61211b95375a3ed10f076f2d7875439c Author: Nils Goroll Date: Wed Feb 23 11:07:06 2022 +0100 Respect TOSTRAND() lifetime In a different context, I questioned my understanding of C object lifetimes and learned that I had given the wrong explanation for why TOSTRAND() was used wrongly in 0c96fc6597c3ba6da057bb43acb7f677e6b776f8: TOSTRAND() creates a compound literal whose lifetime is the enclosing block. Thus, the error was unrelated to temporary lifetime, but rather that the compound literal was assigned in the if-block, but used outside it. Ref: https://stackoverflow.com/questions/71225472/more-questions-on-the-c11-temporary-lifetime-rule-and-undefined-behaviour/71226049#71226049 diff --git a/vmod/vmod_vtc.c b/vmod/vmod_vtc.c index 143e5e7ce..636bdc275 100644 --- a/vmod/vmod_vtc.c +++ b/vmod/vmod_vtc.c @@ -474,10 +474,9 @@ vsl_line(VRT_CTX, char *str) return; str = strtok_r(NULL, "\r\n", &save); + s = TOSTRAND(str); if (str == NULL) s = vrt_null_strands; - else - s = TOSTRAND(str); vmod_vsl(ctx, id, tag, side, s); } From phk at FreeBSD.org Mon Feb 28 09:46:07 2022 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 28 Feb 2022 09:46:07 +0000 (UTC) Subject: [master] 6225c0aff Add the foundation of the "VEXT" mechanism Message-ID: <20220228094608.0F13B9BD92@lists.varnish-cache.org> commit 6225c0aff722828944d5bd6c13aa0a62a0c5836b Author: Poul-Henning Kamp Date: Mon Feb 28 09:45:27 2022 +0000 Add the foundation of the "VEXT" mechanism diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 94ba2f436..8e8d6b117 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -57,6 +57,7 @@ varnishd_SOURCES = \ cache/cache_ws_common.c \ common/common_vsc.c \ common/common_vsmw.c \ + common/common_vext.c \ hash/hash_classic.c \ hash/hash_critbit.c \ hash/hash_simple_list.c \ diff --git a/bin/varnishd/common/common_vext.c b/bin/varnishd/common/common_vext.c new file mode 100644 index 000000000..1c1e1ee38 --- /dev/null +++ b/bin/varnishd/common/common_vext.c @@ -0,0 +1,163 @@ +/*- + * Copyright (c) 2022 Varnish Software AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * 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. + * + * Loadable extensions + */ + +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "vdef.h" +#include "vas.h" +#include "miniobj.h" +#include "vav.h" +#include "vqueue.h" +#include "vrnd.h" +#include "vsb.h" + +#include "heritage.h" + +struct vext { + unsigned magic; +#define VEXT_MAGIC 0xd5063ef6 + VTAILQ_ENTRY(vext) list; + + char **argv; + int fd; + struct vsb *vsb; + void *dlptr; +}; + +static VTAILQ_HEAD(,vext) vext_list = + VTAILQ_HEAD_INITIALIZER(vext_list); + +void +vext_argument(const char *arg) +{ + struct vext *vp; + + fprintf(stderr, "EEE <%s>\n", arg); + ALLOC_OBJ(vp, VEXT_MAGIC); + AN(vp); + vp->argv = VAV_Parse(arg, NULL, ARGV_COMMA); + AN(vp->argv); + if (vp->argv[0] != NULL) + ARGV_ERR("\tParse failure in argument: %s\n\t%s\n", + arg, vp->argv[0]); + VTAILQ_INSERT_TAIL(&vext_list, vp, list); + fprintf(stderr, "eee <%s>\n", vp->argv[1]); + vp->fd = open(vp->argv[1], O_RDONLY); + if (vp->fd < 0) + ARGV_ERR("\tCannot open %s\n\t%s\n", + vp->argv[1], strerror(errno)); +} + +void +vext_copyin(struct vsb *vident) +{ + struct vext *vp; + const char *p; + int i, fdo; + unsigned u; + char buf[BUFSIZ]; + ssize_t sz, szw; + + VTAILQ_FOREACH(vp, &vext_list, list) { + if (vp->vsb == NULL) { + vp->vsb = VSB_new_auto(); + AN(vp->vsb); + } + VSB_clear(vp->vsb); + p = strrchr(vp->argv[1], '/'); + if (p != NULL) + p++; + else + p = vp->argv[0]; + VSB_printf(vident, ",-E%s", p); + VSB_printf(vp->vsb, "vext_cache/%s,", p); + for (i = 0; i < 8; i++) { + AZ(VRND_RandomCrypto(&u, sizeof u)); + u %= 26; + VSB_printf(vp->vsb, "%c", 'a' + (char)u); + } + VSB_printf(vp->vsb, ".so"); + AZ(VSB_finish(vp->vsb)); + fprintf(stderr, "ee2 %s\n", VSB_data(vp->vsb)); + fdo = open(VSB_data(vp->vsb), O_WRONLY|O_CREAT|O_EXCL, 0700); + xxxassert(fdo >= 0); + AZ(lseek(vp->fd, 0, SEEK_SET)); + do { + sz = read(vp->fd, buf, sizeof buf); + if (sz > 0) { + szw = write(fdo, buf, sz); + xxxassert(szw == sz); + } + } while (sz > 0); + closefd(&fdo); + closefd(&vp->fd); + } +} + +void +vext_load(void) +{ + struct vext *vp; + + VTAILQ_FOREACH(vp, &vext_list, list) { + vp->dlptr = dlopen( + VSB_data(vp->vsb), + RTLD_NOW | RTLD_GLOBAL + ); + if (vp->dlptr == NULL) { + XXXAN(vp->dlptr); + } + fprintf(stderr, "Loaded -E %s\n", VSB_data(vp->vsb)); + } +} + +void +vext_cleanup(void) +{ + struct vext *vp; + + VTAILQ_FOREACH(vp, &vext_list, list) { + fprintf(stderr, "ee3 %s\n", VSB_data(vp->vsb)); + if (vp->vsb != NULL && VSB_len(vp->vsb) > 0) { + XXXAZ(unlink(VSB_data(vp->vsb))); + VSB_clear(vp->vsb); + } + } +} diff --git a/bin/varnishd/common/heritage.h b/bin/varnishd/common/heritage.h index 8244f8046..af312b265 100644 --- a/bin/varnishd/common/heritage.h +++ b/bin/varnishd/common/heritage.h @@ -129,3 +129,9 @@ extern vsm_lock_f *vsc_unlock; extern vsm_lock_f *vsmw_lock; extern vsm_lock_f *vsmw_unlock; +/* common/common_vext.c */ + +void vext_argument(const char *); +void vext_copyin(struct vsb *); +void vext_load(void); +void vext_cleanup(void); diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 17c80cf67..7a218fc42 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -378,6 +378,8 @@ mgt_launch_child(struct cli *cli) heritage.cls = mgt_cls; heritage.ident = VSB_data(vident) + 1; + vext_load(); + VJ_subproc(JAIL_SUBPROC_WORKER); heritage.proc_vsmw = VSMW_New(heritage.vsm_fd, 0640, "_.index"); @@ -385,7 +387,7 @@ mgt_launch_child(struct cli *cli) /* * We pass these two params because child_main needs them - * Well before it has found its own param struct. + * well before it has found its own param struct. */ child_main(mgt_param.sigsegv_handler, mgt_param.wthread_stacksize); diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index b49bebb09..cc09cb06f 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -74,7 +74,7 @@ static char *workdir; static struct vfil_path *vcl_path = NULL; -static const char opt_spec[] = "?a:b:Cdf:Fh:i:I:j:l:M:n:P:p:r:S:s:T:t:VW:x:"; +static const char opt_spec[] = "?a:b:CdE:f:Fh:i:I:j:l:M:n:P:p:r:S:s:T:t:VW:x:"; /*--------------------------------------------------------------------*/ @@ -123,6 +123,7 @@ usage(void) printf(FMT, "-P file", "PID file"); printf(FMT, "-i identity", "Identity of varnish instance"); printf(FMT, "-I clifile", "Initialization CLI commands"); + printf(FMT, "-E extension", "Load extension"); printf("\nTuning options:\n"); @@ -284,7 +285,9 @@ mgt_Cflag_atexit(void) /* Only master process */ if (getpid() != heritage.mgt_pid) return; + vext_cleanup(); VJ_rmdir("vmod_cache"); + VJ_rmdir("vext_cache"); (void)chdir("/"); VJ_rmdir(workdir); } @@ -660,6 +663,7 @@ main(int argc, char * const *argv) W_arg = optarg; break; case 'a': + case 'E': case 'f': case 'I': case 'p': @@ -752,6 +756,9 @@ main(int argc, char * const *argv) if (*alp->val != '\0') alp->priv = mgt_f_read(alp->val); break; + case 'E': + vext_argument(alp->val); + break; case 'I': VJ_master(JAIL_MASTER_FILE); I_fd = open(alp->val, O_RDONLY); @@ -821,6 +828,7 @@ main(int argc, char * const *argv) VJ_master(JAIL_MASTER_SYSTEM); AZ(system("rm -rf vmod_cache")); + AZ(system("rm -rf vext_cache")); VJ_master(JAIL_MASTER_LOW); if (VJ_make_subdir("vmod_cache", "VMOD cache", NULL)) { @@ -829,6 +837,13 @@ main(int argc, char * const *argv) workdir, VAS_errtxt(errno)); } + if (arg_list_count("E") && + VJ_make_subdir("vext_cache", "VMOD cache", NULL)) { + ARGV_ERR( + "Cannot create vmod directory (%s/vext_cache): %s\n", + workdir, VAS_errtxt(errno)); + } + if (C_flag) AZ(atexit(mgt_Cflag_atexit)); @@ -881,6 +896,8 @@ main(int argc, char * const *argv) VPF_Write(alp->priv); } + vext_copyin(vident); + AZ(VSB_finish(vident)); if (S_arg == NULL) @@ -968,6 +985,10 @@ main(int argc, char * const *argv) MGT_Complain(C_INFO, "manager dies"); mgt_cli_close_all(); VEV_Destroy(&mgt_evb); + VJ_master(JAIL_MASTER_SYSTEM); + vext_cleanup(); + (void)rmdir("vext_cache"); + VJ_master(JAIL_MASTER_LOW); VTAILQ_FOREACH(alp, &arglist, list) { if (!strcmp(alp->arg, "P")) VPF_Remove(alp->priv);