summaryrefslogtreecommitdiffstats
path: root/filter
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2009-04-17 01:48:36 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2009-04-17 01:48:36 +0200
commitc8a6b9a3d199444fd45879dd5cc5ececd9624822 (patch)
tree1ada700f499ec771ea68873c87b51bc71b455a27 /filter
parent024c310b537abc3ddbac3054de71fd759d422824 (diff)
downloadbird-c8a6b9a3d199444fd45879dd5cc5ececd9624822.tar
bird-c8a6b9a3d199444fd45879dd5cc5ececd9624822.zip
Rewrite of buggy AS path matching.
Old AS path maching supposes thath AS number appears only once in AS path, but that is not true. It also contains some bugs related to AS path sets. New code does not use any assumptions about semantic structure of AS path. It is asymptotically slower than the old code, but on real paths it is not significant. It also allows '?' for matching one arbitrary AS number.
Diffstat (limited to 'filter')
-rw-r--r--filter/config.Y9
-rw-r--r--filter/filter.c6
2 files changed, 8 insertions, 7 deletions
diff --git a/filter/config.Y b/filter/config.Y
index b6a0f47..6d9b064 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -284,14 +284,15 @@ bgp_path:
;
bgp_path_tail1:
- NUM bgp_path_tail1 { $$ = cfg_alloc(sizeof(struct f_path_mask)); $$->next = $2; $$->val = $1; $$->any = 0; }
- | '*' bgp_path_tail1 { $$ = cfg_alloc(sizeof(struct f_path_mask)); $$->next = $2; $$->val = 0; $$->any = 1; }
+ NUM bgp_path_tail1 { $$ = cfg_alloc(sizeof(struct f_path_mask)); $$->next = $2; $$->kind = PM_ASN; $$->val = $1; }
+ | '*' bgp_path_tail1 { $$ = cfg_alloc(sizeof(struct f_path_mask)); $$->next = $2; $$->kind = PM_ASTERISK; $$->val = 0; }
+ | '?' bgp_path_tail1 { $$ = cfg_alloc(sizeof(struct f_path_mask)); $$->next = $2; $$->kind = PM_QUESTION; $$->val = 0; }
| { $$ = NULL; }
;
bgp_path_tail2:
- NUM bgp_path_tail2 { $$ = cfg_alloc(sizeof(struct f_path_mask)); $$->next = $2; $$->val = $1; $$->any = 0; }
- | '?' bgp_path_tail2 { $$ = cfg_alloc(sizeof(struct f_path_mask)); $$->next = $2; $$->val = 0; $$->any = 1; }
+ NUM bgp_path_tail2 { $$ = cfg_alloc(sizeof(struct f_path_mask)); $$->next = $2; $$->kind = PM_ASN; $$->val = $1; }
+ | '?' bgp_path_tail2 { $$ = cfg_alloc(sizeof(struct f_path_mask)); $$->next = $2; $$->kind = PM_ASTERISK; $$->val = 0; }
| { $$ = NULL; }
;
diff --git a/filter/filter.c b/filter/filter.c
index 2e13c75..313d2fa 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -82,10 +82,10 @@ pm_format(struct f_path_mask *p, byte *buf, unsigned int size)
return;
}
- if (p->any)
- buf += bsprintf(buf, " *");
- else
+ if (p->kind == PM_ASN)
buf += bsprintf(buf, " %u", p->val);
+ else
+ buf += bsprintf(buf, (p->kind == PM_ASTERISK) ? " *" : " ?");
p = p->next;
}