[master] fb02b2993 Fix vcl.show for labels

Martin Blix Grydeland martin at varnish-software.com
Mon Aug 5 11:06:08 UTC 2019


commit fb02b2993bedfbeac37b7cb488f35d285b971b52
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Fri Aug 2 13:28:36 2019 +0200

    Fix vcl.show for labels
    
    When executing vcl.show for labels, show the VCL the label points to
    instead of asserting.

diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index c50e44dd3..9adb3f431 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -876,6 +876,11 @@ vcl_cli_show(struct cli *cli, const char * const *av, void *priv)
 		return;
 	}
 	CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC);
+	if (vcl->label) {
+		vcl = vcl->label;
+		CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC);
+		AZ(vcl->label);
+	}
 	CHECK_OBJ_NOTNULL(vcl->conf, VCL_CONF_MAGIC);
 	if (verbose) {
 		for (i = 0; i < vcl->conf->nsrc; i++)
diff --git a/bin/varnishtest/tests/s00005.vtc b/bin/varnishtest/tests/s00005.vtc
index 0fa00990f..3ed6c0193 100644
--- a/bin/varnishtest/tests/s00005.vtc
+++ b/bin/varnishtest/tests/s00005.vtc
@@ -40,6 +40,8 @@ varnish v1 -cliok "vcl.label foo vcl2"
 varnish v1 -cliok "vcl.label bar vcl2"
 varnish v1 -cliok "vcl.list"
 varnish v1 -clijson "vcl.list -j"
+varnish v1 -cliok "vcl.show foo"
+varnish v1 -cliok "vcl.show -v bar"
 varnish v1 -clierr 300 "vcl.discard vcl2"
 varnish v1 -cliok "vcl.discard bar"
 varnish v1 -cliok "vcl.label foo vcl1"


More information about the varnish-commit mailing list