From e8bc64e308586b6502090da2775af84cd760ed0d Mon Sep 17 00:00:00 2001 From: Jan Maria Matejka Date: Wed, 28 Feb 2018 16:57:50 +0100 Subject: 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. --- nest/a-path.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'nest') diff --git a/nest/a-path.c b/nest/a-path.c index b453f702..0272c6d7 100644 --- a/nest/a-path.c +++ b/nest/a-path.c @@ -535,8 +535,7 @@ as_path_match(struct adata *path, struct f_path_mask *mask) val2 = val = mask->val; goto step; case PM_ASN_EXPR: - val2 = val = f_eval_asn((struct f_inst *) mask->val); - goto step; + ASSERT(0); case PM_ASN_RANGE: val = mask->val; val2 = mask->val2; -- cgit v1.2.3