aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2021-01-09 19:19:04 +0900
committerKazuki Yamaguchi <k@rhe.jp>2022-12-21 21:17:11 +0900
commit7a1561979f1d4597df8919d611efc43e27eda25a (patch)
treefaa0c444aef168c9c11bc9707cf7075a8af66fa6
parent2b7643e1f8ecb0bd4cf9af4183b4fd53b655d19c (diff)
downloadbird-ky/filter-fix-constant-expression.tar.gz
Filter: Fix dynamic expression inside compile-time constantky/filter-fix-constant-expression
Is this the correct way to do that??? I don't get how the three outputs are used, yet.
-rw-r--r--filter/f-inst.c1
-rw-r--r--filter/filter.c1
-rw-r--r--filter/filter.h1
3 files changed, 3 insertions, 0 deletions
diff --git a/filter/f-inst.c b/filter/f-inst.c
index 9a3a22ab..66c658fd 100644
--- a/filter/f-inst.c
+++ b/filter/f-inst.c
@@ -531,6 +531,7 @@
INST(FI_VAR_GET, 0, 1) {
SYMBOL;
NEVER_CONSTANT;
+ if (fs->flags & FF_CONSTANT) runtime("Variable reference in constant expression");
RESULT_TYPE(sym->class & 0xff);
RESULT_VAL(fstk->vstk[curline.vbase + sym->offset]);
}
diff --git a/filter/filter.c b/filter/filter.c
index 20a380dc..95ca546f 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -384,6 +384,7 @@ f_eval_int(const struct f_line *expr)
filter_state = (struct filter_state) {
.stack = &filter_stack,
.pool = cfg_mem,
+ .flags = FF_CONSTANT,
};
struct f_val val;
diff --git a/filter/filter.h b/filter/filter.h
index 26c1037b..c6ecffbd 100644
--- a/filter/filter.h
+++ b/filter/filter.h
@@ -69,6 +69,7 @@ void filters_dump_all(void);
#define FILTER_UNDEF ((struct filter *) 2) /* Used in BGP */
#define FF_SILENT 2 /* Silent filter execution */
+#define FF_CONSTANT 4 /* Require constant return */
/* Custom route attributes */
struct custom_attribute {