[master] cf5a9f7b8 param: New vcc_feature bits parameter

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Jun 27 13:38:06 UTC 2022


commit cf5a9f7b8630c1e207d875d0e61750d80f9665f8
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Tue May 31 08:12:43 2022 +0200

    param: New vcc_feature bits parameter
    
    It currently has no effect besides showing up in the CLI.
    
    Refs #3269

diff --git a/bin/varnishd/common/common_param.h b/bin/varnishd/common/common_param.h
index 4a34dfa4f..14debcca7 100644
--- a/bin/varnishd/common/common_param.h
+++ b/bin/varnishd/common/common_param.h
@@ -76,6 +76,18 @@ COM_FEATURE(const volatile uint8_t *p, enum feature_bits x)
 	return (p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7)));
 }
 
+enum vcc_feature_bits {
+#define VCC_FEATURE_BIT(U, l, d) VCC_FEATURE_##U,
+#include "tbl/vcc_feature_bits.h"
+       VCC_FEATURE_Reserved
+};
+
+static inline int
+COM_VCC_FEATURE(const volatile uint8_t *p, enum vcc_feature_bits x)
+{
+	return (p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7)));
+}
+
 struct poolparam {
 	unsigned		min_pool;
 	unsigned		max_pool;
@@ -88,6 +100,7 @@ PARAM_BITMAP(vsl_mask_t,	256);
 PARAM_BITMAP(debug_t,		DBG_Reserved);
 PARAM_BITMAP(experimental_t,	EXPERIMENT_Reserved);
 PARAM_BITMAP(feature_t,		FEATURE_Reserved);
+PARAM_BITMAP(vcc_feature_t,	VCC_FEATURE_Reserved);
 #undef PARAM_BITMAP
 
 struct params {
@@ -104,6 +117,7 @@ struct params {
 #define ptyp_thread_pool_min	unsigned
 #define ptyp_timeout		vtim_dur
 #define ptyp_uint		unsigned
+#define ptyp_vcc_feature	vcc_feature_t
 #define ptyp_vsl_buffer		unsigned
 #define ptyp_vsl_mask		vsl_mask_t
 #define ptyp_vsl_reclen		unsigned
diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index 61eafbd83..d067aff42 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -247,3 +247,4 @@ extern const char *mgt_vmod_path;
 #define MGT_FEATURE(x)		COM_FEATURE(mgt_param.feature_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)
+#define MGT_VCC_FEATURE(x)	COM_VCC_FEATURE(mgt_param.vcc_feature_bits, x)
diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h
index f95e965fd..35c9c2076 100644
--- a/bin/varnishd/mgt/mgt_param.h
+++ b/bin/varnishd/mgt/mgt_param.h
@@ -84,6 +84,7 @@ tweak_t tweak_thread_pool_min;
 tweak_t tweak_thread_pool_max;
 tweak_t tweak_timeout;
 tweak_t tweak_uint;
+tweak_t tweak_vcc_feature;
 tweak_t tweak_vsl_buffer;
 tweak_t tweak_vsl_mask;
 tweak_t tweak_vsl_reclen;
diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c
index 342f3c0e9..42fb802b4 100644
--- a/bin/varnishd/mgt/mgt_param_tweak.c
+++ b/bin/varnishd/mgt/mgt_param_tweak.c
@@ -762,3 +762,21 @@ tweak_feature(struct vsb *vsb, const struct parspec *par, const char *arg)
 	return (tweak_generic_bits(vsb, par, arg, mgt_param.feature_bits,
 	    FEATURE_Reserved, feature_tags, "feature bit", '+'));
 }
+
+/*--------------------------------------------------------------------
+ * The vcc_feature parameter
+ */
+
+static const char * const vcc_feature_tags[] = {
+#  define VCC_FEATURE_BIT(U, l, d) [VCC_FEATURE_##U] = #l,
+#  include "tbl/vcc_feature_bits.h"
+       NULL
+};
+
+int v_matchproto_(tweak_t)
+tweak_vcc_feature(struct vsb *vsb, const struct parspec *par, const char *arg)
+{
+
+	return (tweak_generic_bits(vsb, par, arg, mgt_param.vcc_feature_bits,
+	    VCC_FEATURE_Reserved, vcc_feature_tags, "vcc_feature bit", '+'));
+}
diff --git a/include/Makefile.am b/include/Makefile.am
index 6ab8a8f5e..7b7b6b116 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -32,6 +32,7 @@ nobase_pkginclude_HEADERS = \
 	tbl/sess_attr.h \
 	tbl/sess_close.h \
 	tbl/symbol_kind.h \
+	tbl/vcc_feature_bits.h \
 	tbl/vcl_returns.h \
 	tbl/vcl_states.h \
 	tbl/vhd_fsm.h \
diff --git a/include/tbl/params.h b/include/tbl/params.h
index b53cbc478..1cccb1df1 100644
--- a/include/tbl/params.h
+++ b/include/tbl/params.h
@@ -1785,6 +1785,24 @@ PARAM_BITS(
 #endif
 PARAM_POST
 
+PARAM_PRE
+PARAM_BITS(
+	/* name */	vcc_feature,
+	/* fld */	vcc_feature_bits,
+	/* def */
+	"+err_unref,"
+	"+unsafe_path",
+	/* descr */
+	"Enable/Disable various VCC behaviors.\n"
+	"\tdefault\tSet default value\n"
+	"\tnone\tDisable all behaviors.\n\n"
+	"Use +/- prefix to enable/disable individual behavior:")
+#ifdef PARAM_ALL
+#  define VCC_FEATURE_BIT(U, l, d) "\n\t" #l "\t" d
+#  include "tbl/vcc_feature_bits.h"
+#endif
+PARAM_POST
+
 PARAM_PRE
 PARAM_BITS(
 	/* name */	vsl_mask,
diff --git a/include/tbl/vcc_feature_bits.h b/include/tbl/vcc_feature_bits.h
new file mode 100644
index 000000000..850e37078
--- /dev/null
+++ b/include/tbl/vcc_feature_bits.h
@@ -0,0 +1,50 @@
+/*-
+ * Copyright (c) 2022 Varnish Software AS
+ * All rights reserved.
+ *
+ * Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
+ *
+ * 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 vcc parameter
+ *
+ */
+
+/*lint -save -e525 -e539 */
+
+VCC_FEATURE_BIT(ERR_UNREF,		err_unref,
+    "Unreferenced VCL objects result in error."
+)
+
+VCC_FEATURE_BIT(ALLOW_INLINE_C,		allow_inline_c,
+    "Allow inline C code in VCL."
+)
+
+VCC_FEATURE_BIT(UNSAFE_PATH,		unsafe_path,
+    "Allow '/' in vmod & include paths. Allow 'import ... from ...'."
+)
+
+#undef VCC_FEATURE_BIT
+
+/*lint -restore */


More information about the varnish-commit mailing list