From 8f3c6151b4ff11d98a20f6f9919723f0fb719161 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Fri, 4 Mar 2022 02:01:34 +0100 Subject: Nest: Cleanups in as_path_filter() Use struct f_val as a common argument for as_path_filter(), as suggested by Alexander Zubkov. That allows to use NULL sets as valid arguments. --- nest/a-path.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'nest/a-path.c') diff --git a/nest/a-path.c b/nest/a-path.c index 2e34a3d1..d5b01635 100644 --- a/nest/a-path.c +++ b/nest/a-path.c @@ -602,8 +602,10 @@ as_path_match_set(const struct adata *path, const struct f_tree *set) } const struct adata * -as_path_filter(struct linpool *pool, const struct adata *path, const struct f_tree *set, u32 key, int pos) +as_path_filter(struct linpool *pool, const struct adata *path, const struct f_val *set, int pos) { + ASSERT((set->type == T_SET) || (set->type == T_INT)); + if (!path) return NULL; @@ -629,13 +631,13 @@ as_path_filter(struct linpool *pool, const struct adata *path, const struct f_tr u32 as = get_as(p); int match; - if (set) + if (set->type == T_SET) { struct f_val v = {T_INT, .val.i = as}; - match = !!find_tree(set, &v); + match = !!find_tree(set->val.t, &v); } - else - match = (as == key); + else /* T_INT */ + match = (as == set->val.i); if (match == pos) { -- cgit v1.2.3 From cb339a30677901f2c248de08ff535cf0a9efab3d Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Mon, 14 Mar 2022 20:36:20 +0100 Subject: Filter: Implement for loops For loops allow to iterate over elements in compound data like BGP paths or community lists. The syntax is: for [ ] in do --- doc/bird.sgml | 26 ++++++++++++---- filter/config.Y | 21 ++++++++++++- filter/data.c | 1 + filter/f-inst.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ filter/test.conf | 40 +++++++++++++++++++++++- nest/a-path.c | 29 ++++++++++++++++++ nest/a-set.c | 48 +++++++++++++++++++++++++++++ nest/attrs.h | 4 +++ 8 files changed, 254 insertions(+), 8 deletions(-) (limited to 'nest/a-path.c') diff --git a/doc/bird.sgml b/doc/bird.sgml index f933128c..89b1541c 100644 --- a/doc/bird.sgml +++ b/doc/bird.sgml @@ -1683,7 +1683,8 @@ prefix and an ASN as arguments. Control structures