[master] d31b1ff11 param: Tweak all bits parameters with all or none

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Tue Feb 18 09:46:16 UTC 2025


commit d31b1ff114d84c94a40e18c7f72ecc9665e6b3ba
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Tue Feb 4 13:37:34 2025 +0100

    param: Tweak all bits parameters with all or none
    
    Until now, only one of the two magic keywords was allowed, depending on
    the sign. In order to allow the counterparts, the rendering side of the
    value needs to ignore bits without a tag, which can happen for bits
    after the last bit once rounded up to 8bit groups. In the vsl_mask case,
    there are also holes in VSL tags that were maintained for file format
    compatibility.
    
    Co-authored-by: Nils Goroll <nils.goroll at uplex.de>

diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c
index 51c3766d5..d3e753f1f 100644
--- a/bin/varnishd/mgt/mgt_param_tweak.c
+++ b/bin/varnishd/mgt/mgt_param_tweak.c
@@ -652,6 +652,13 @@ bit_clear(uint8_t *p, unsigned l)
 	memset(p, 0, ((size_t)l + 7) >> 3);
 }
 
+static inline void
+bit_set(uint8_t *p, unsigned l)
+{
+
+	memset(p, 255, ((size_t)l + 7) >> 3);
+}
+
 /*--------------------------------------------------------------------
  */
 
@@ -676,10 +683,18 @@ bit_tweak(struct vsb *vsb, uint8_t *p, unsigned l, const char *arg,
 			bit_clear(p, l);
 			continue;
 		}
+		if (sign == '+' && !strcmp(s, "all")) {
+			bit_set(p, l);
+			continue;
+		}
 		if (sign == '-' && !strcmp(s, "all")) {
 			bit_clear(p, l);
 			continue;
 		}
+		if (sign == '-' && !strcmp(s, "none")) {
+			bit_set(p, l);
+			continue;
+		}
 		if (*s != '-' && *s != '+') {
 			VSB_printf(vsb, "Missing '+' or '-' (%s)\n", s);
 			VAV_Free(av);
@@ -726,6 +741,8 @@ tweak_generic_bits(struct vsb *vsb, const struct parspec *par, const char *arg,
 
 	all = 1;
 	for (j = 0; all && j < l; j++) {
+		if (tags[j] == NULL)
+			continue;
 		if (!bit(p, j, BTST))
 			all = 0;
 	}
@@ -737,6 +754,8 @@ tweak_generic_bits(struct vsb *vsb, const struct parspec *par, const char *arg,
 	else
 		VSB_cat(vsb, sign == '+' ? "none" : "all");
 	for (j = 0; !all && j < l; j++) {
+		if (tags[j] == NULL)
+			continue;
 		if (bit(p, j, BTST))
 			VSB_printf(vsb, ",%c%s", sign, tags[j]);
 	}
diff --git a/bin/varnishtest/tests/c00054.vtc b/bin/varnishtest/tests/c00054.vtc
index 0ee1c2674..b66639779 100644
--- a/bin/varnishtest/tests/c00054.vtc
+++ b/bin/varnishtest/tests/c00054.vtc
@@ -9,6 +9,8 @@ varnish v1 -cliok "param.set vsl_mask +WorkThread,+TTL,+Hash"
 varnish v1 -cliok "param.show vsl_mask"
 
 varnish v1 -cliexpect {"value": "none"} "param.set -j feature none"
+varnish v1 -cliexpect {"value": "all"} "param.set -j feature all"
+varnish v1 -cliexpect {"value": "none"} "param.set -j vsl_mask none"
 varnish v1 -cliexpect {"value": "all"} "param.set -j vsl_mask all"
 varnish v1 -cliexpect {"value": "all(,-\w+)+"} "param.reset -j vsl_mask"
 


More information about the varnish-commit mailing list