diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2019-08-06 16:58:13 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2019-08-06 16:58:13 +0200 |
commit | ef113c6f725349a2ab52f3cbef18403f82c84134 (patch) | |
tree | da3ff7453dbb76cf5cf0290135483171842a0b38 /filter | |
parent | e2b530aa729f9c5973e498b45dd6f55ab669d1ac (diff) |
Filter: Allow to use sets in path masks
Diffstat (limited to 'filter')
-rw-r--r-- | filter/config.Y | 4 | ||||
-rw-r--r-- | filter/test.conf | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/filter/config.Y b/filter/config.Y index 8171a7c2..a67a72a8 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -801,6 +801,10 @@ bgp_path: bgp_path_tail: NUM bgp_path_tail { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_PATH_MASK_ITEM, .val.pmi = { .asn = $1, .kind = PM_ASN, }, }); $$->next = $2; } | NUM DDOT NUM bgp_path_tail { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_PATH_MASK_ITEM, .val.pmi = { .from = $1, .to = $3, .kind = PM_ASN_RANGE }, }); $$->next = $4; } + | '[' set_items ']' bgp_path_tail { + if ($2->from.type != T_INT) cf_error("Only integer sets allowed in path mask"); + $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_PATH_MASK_ITEM, .val.pmi = { .set = build_tree($2), .kind = PM_ASN_SET }, }); $$->next = $4; + } | '*' bgp_path_tail { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_PATH_MASK_ITEM, .val.pmi = { .kind = PM_ASTERISK }, }); $$->next = $2; } | '?' bgp_path_tail { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_PATH_MASK_ITEM, .val.pmi = { .kind = PM_QUESTION }, }); $$->next = $2; } | bgp_path_expr bgp_path_tail { $$ = $1; $$->next = $2; } diff --git a/filter/test.conf b/filter/test.conf index 9abd76f3..04074965 100644 --- a/filter/test.conf +++ b/filter/test.conf @@ -626,6 +626,7 @@ bgppath p2; bt_assert(p2 !~ [8, ten..(2*ten)]); bt_assert(p2 ~ [= * 4 3 * 1 =]); bt_assert(p2 ~ [= (3+2) (2*2) 3 2 1 =]); + bt_assert(p2 ~ [= 5 [2, 4, 6] 3 [1..2] 1 =]); bt_assert(p2 ~ mkpath(5, 4)); bt_assert(p2.len = 5); |