[master] 4709fae3a Don't panic if you try to relabel a VCL with the same label.

Poul-Henning Kamp phk at FreeBSD.org
Wed Feb 13 13:06:10 UTC 2019


commit 4709fae3a703b5904a799b8aa1df2872e803219f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Feb 13 13:04:30 2019 +0000

    Don't panic if you try to relabel a VCL with the same label.
    
    Fixes #2834

diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index 7d8acb572..1a51ba07c 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -918,6 +918,13 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv)
 			VCLI_Out(cli, "%s is not a label", vpl->name);
 			return;
 		}
+		if (!VTAILQ_EMPTY(&vpl->dfrom) &&
+		    VTAILQ_FIRST(&vpl->dfrom)->to == vpt) {
+			VCLI_SetResult(cli, CLIS_PARAM);
+			VCLI_Out(cli, "VCL '%s' already has label '%s'",
+			    vpt->name, vpl->name);
+			return;
+		}
 		if (!VTAILQ_EMPTY(&vpt->dfrom) &&
 		    !VTAILQ_EMPTY(&vpl->dto)) {
 			VCLI_SetResult(cli, CLIS_PARAM);
diff --git a/bin/varnishtest/tests/c00077.vtc b/bin/varnishtest/tests/c00077.vtc
index 49ed76797..c32983893 100644
--- a/bin/varnishtest/tests/c00077.vtc
+++ b/bin/varnishtest/tests/c00077.vtc
@@ -13,6 +13,10 @@ varnish v1 -vcl+backend {
 
 varnish v1 -clierr 106 "vcl.label vcl.A vcl1"
 varnish v1 -cliok "vcl.label vclA vcl1"
+varnish v1 -clierr 106 "vcl.label vclA vcl1"
+varnish v1 -cliexpect {VCL 'vcl1' already has label 'vclA'} {
+	vcl.label vclA vcl1
+}
 
 varnish v1 -vcl+backend {
 	sub vcl_recv {


More information about the varnish-commit mailing list