Mailing List Archive

[master] 75b25921b param: Introduce the notion of PCRE parameters
commit 75b25921b2061852478a94e88789df6a34e8a835
Author: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Date: Wed Oct 21 17:46:55 2020 +0200

param: Introduce the notion of PCRE parameters

Unlike string or VCC parameters they are inherited, but their definition
is not as straightforward as simple parameters. They also need to be
guarded by PARAM_ALL because inside struct params they are groupped in a
dedicated struct vre_limits, and there is no need for disruption in that
area.

Refs #3250

diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c
index 5b295208b..f911aff20 100644
--- a/bin/varnishd/mgt/mgt_param_tbl.c
+++ b/bin/varnishd/mgt/mgt_param_tbl.c
@@ -34,39 +34,11 @@
#include <stdio.h>

#include "mgt/mgt.h"
-
#include "mgt/mgt_param.h"

-
struct parspec mgt_parspec[] = {
#define PARAM_ALL
#define PARAM(ty, nm, ...) { #nm, __VA_ARGS__ },
#include "tbl/params.h"
-
- { "pcre_match_limit", tweak_uint,
- &mgt_param.vre_limits.match,
- "1", NULL, "10000",
- NULL,
- "The limit for the number of calls to the internal match()"
- " function in pcre_exec().\n\n"
- "(See: PCRE_EXTRA_MATCH_LIMIT in pcre docs.)\n\n"
- "This parameter limits how much CPU time"
- " regular expression matching can soak up." },
- { "pcre_match_limit_recursion", tweak_uint,
- &mgt_param.vre_limits.match_recursion,
- "1", NULL, "20",
- NULL,
- "The recursion depth-limit for the internal match() function"
- " in a pcre_exec().\n\n"
- "(See: PCRE_EXTRA_MATCH_LIMIT_RECURSION in pcre docs.)\n\n"
- "This puts an upper limit on the amount of stack used"
- " by PCRE for certain classes of regular expressions.\n\n"
- "We have set the default value low in order to"
- " prevent crashes, at the cost of possible regexp"
- " matching failures.\n\n"
- "Matching failures will show up in the log as VCL_Error"
- " messages with regexp errors -27 or -21.\n\n"
- "Testcase r01576 can be useful when tuning this parameter." },
-
{ NULL, NULL, NULL }
};
diff --git a/include/tbl/params.h b/include/tbl/params.h
index 139565924..c3292b92b 100644
--- a/include/tbl/params.h
+++ b/include/tbl/params.h
@@ -1349,7 +1349,48 @@ PARAM_VCC(
"Allow 'import ... from ...'."
)

+/*--------------------------------------------------------------------
+ * PCRE parameters
+ */
+
+# define PARAM_PCRE(nm, pv, min, def, descr) \
+ PARAM(, nm, tweak_uint, &mgt_param.vre_limits.pv, \
+ min, NULL, def, NULL, descr)
+
+PARAM_PCRE(
+ /* name */ pcre_match_limit,
+ /* priv */ match,
+ /* min */ "1",
+ /* def */ "10000",
+ /* descr */
+ "The limit for the number of calls to the internal match()"
+ " function in pcre_exec().\n\n"
+ "(See: PCRE_EXTRA_MATCH_LIMIT in pcre docs.)\n\n"
+ "This parameter limits how much CPU time"
+ " regular expression matching can soak up."
+)
+
+PARAM_PCRE(
+ /* name */ pcre_match_limit_recursion,
+ /* priv */ match_recursion,
+ /* min */ "1",
+ /* def */ "20",
+ /* descr */
+ "The recursion depth-limit for the internal match() function"
+ " in a pcre_exec().\n\n"
+ "(See: PCRE_EXTRA_MATCH_LIMIT_RECURSION in pcre docs.)\n\n"
+ "This puts an upper limit on the amount of stack used"
+ " by PCRE for certain classes of regular expressions.\n\n"
+ "We have set the default value low in order to"
+ " prevent crashes, at the cost of possible regexp"
+ " matching failures.\n\n"
+ "Matching failures will show up in the log as VCL_Error"
+ " messages with regexp errors -27 or -21.\n\n"
+ "Testcase r01576 can be useful when tuning this parameter."
+)
+
# undef PARAM_ALL
+# undef PARAM_PCRE
# undef PARAM_STRING
# undef PARAM_VCC
#endif /* defined(PARAM_ALL) */
@@ -1408,32 +1449,6 @@ PARAM(
" esi_remove_bom Remove UTF-8 BOM"
)

-/* actual location mgt_param_tbl.c */
-PARAM(
- /* name */ pcre_match_limit,
- /* type */ uint,
- /* min */ "1",
- /* max */ NULL,
- /* def */ "1.000",
- /* units */ NULL,
- /* descr */
- "The limit for the number of internal matching function calls in "
- "a pcre_exec() execution."
-)
-
-/* actual location mgt_param_tbl.c */
-PARAM(
- /* name */ pcre_match_limit_recursion,
- /* type */ uint,
- /* min */ "1",
- /* max */ NULL,
- /* def */ "1.000",
- /* units */ NULL,
- /* descr */
- "The limit for the number of internal matching function "
- "recursions in a pcre_exec() execution."
-)
-
/* actual location mgt_pool.c */
PARAM(
/* name */ thread_pool_add_delay,
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit