diff options
author | Jan Maria Matejka <mq@ucw.cz> | 2018-02-28 16:57:50 +0100 |
---|---|---|
committer | Jan Maria Matejka <mq@ucw.cz> | 2018-03-14 11:34:29 +0100 |
commit | e8bc64e308586b6502090da2775af84cd760ed0d (patch) | |
tree | fd111a1534336be4d3fa115ed6fd5688e6be43d3 /filter/filter.h | |
parent | 74bfd2f97c0a95b6fb73a67d9334e54a90695c58 (diff) |
Filter: make bgpmask literals real constructors
The bgpmask literals can include expressions. This is OK but they have
to be interpreted as soon as the code is run, not in the time the code
is used as value.
This led to strange behavior like rewriting bgpmasks when they shan't
be rewritten:
function mask_generator(int as)
{
return [= * as * =];
}
function another()
bgpmask m1;
bgpmask m2;
{
m1 = mask_generator(10);
m2 = mask_generator(20);
if (m1 == m2) {
print("strange"); # this would happen
}
}
Moreover, sending this to CLI would cause stack overflow and knock down the
whole BIRD, as soon as there is at least one route to execute the given
filter on.
show route filter bgpmask mmm; bgppath ppp; { ppp = +empty+; mmm = [= (ppp ~ mmm) =]; print(mmm); accept; }
The magic match operator (~) inside the bgpmask literal would try to
resolve mmm, which points to the same bgpmask so it would resolve
itself, call the magic match operator and vice versa.
After this patch, the bgpmask literal will get resolved as soon as it's
assigned to mmm and it also will return a type error as bool is not
convertible to ASN in BIRD.
Diffstat (limited to 'filter/filter.h')
-rw-r--r-- | filter/filter.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/filter/filter.h b/filter/filter.h index 1d0f389e..572459d8 100644 --- a/filter/filter.h +++ b/filter/filter.h @@ -27,6 +27,7 @@ F(FI_PAIR_CONSTRUCT, 'm', 'p') \ F(FI_EC_CONSTRUCT, 'm', 'c') \ F(FI_LC_CONSTRUCT, 'm', 'l') \ + F(FI_PATHMASK_CONSTRUCT, 'm', 'P') \ F(FI_NEQ, '!', '=') \ F(FI_EQ, '=', '=') \ F(FI_LT, 0, '<') \ @@ -196,7 +197,6 @@ int f_run(struct filter *filter, struct rte **rte, struct ea_list **tmp_attrs, s struct f_val f_eval_rte(struct f_inst *expr, struct rte **rte, struct linpool *tmp_pool); struct f_val f_eval(struct f_inst *expr, struct linpool *tmp_pool); uint f_eval_int(struct f_inst *expr); -u32 f_eval_asn(struct f_inst *expr); char *filter_name(struct filter *filter); int filter_same(struct filter *new, struct filter *old); |