diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2009-04-17 01:48:36 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2009-04-17 01:48:36 +0200 |
commit | c8a6b9a3d199444fd45879dd5cc5ececd9624822 (patch) | |
tree | 1ada700f499ec771ea68873c87b51bc71b455a27 /filter | |
parent | 024c310b537abc3ddbac3054de71fd759d422824 (diff) |
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.Y | 9 | ||||
-rw-r--r-- | filter/filter.c | 6 |
2 files changed, 8 insertions, 7 deletions
diff --git a/filter/config.Y b/filter/config.Y index b6a0f470..6d9b064d 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 2e13c752..313d2fa7 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; } |