diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2018-08-10 11:13:02 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2018-08-10 11:13:02 +0000 |
commit | 478b147334e004b5a6ce52db7c7dd924f55fa05c (patch) | |
tree | ac975287a1755316e9fcb619e89afa9d2ea8465b /usr.sbin/bgpd | |
parent | 5076b9bd3d5cd5fe2172961dae0f611187b1bbad (diff) |
Make the AS_SET handling for source-as even simpler. It is enough to only
extract the rightmost AS of a segment if the segment is not an AS_SET.
Then if we hit the final segment as will contain the last aggregator AS.
This fixes a possible issue with a path like 1 2 3 { 4 5 } { 6 7 } which
should match for source-as 3.
OK benno@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/util.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/usr.sbin/bgpd/util.c b/usr.sbin/bgpd/util.c index c62e7e15af2..dabf6eb331d 100644 --- a/usr.sbin/bgpd/util.c +++ b/usr.sbin/bgpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.29 2018/08/09 21:12:33 claudio Exp $ */ +/* $OpenBSD: util.c,v 1.30 2018/08/10 11:13:01 claudio Exp $ */ /* * Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org> @@ -334,7 +334,7 @@ aspath_match(void *data, u_int16_t len, struct filter_as *f, u_int32_t match) int final; u_int16_t seg_size; u_int8_t i, seg_len; - u_int32_t as = 0, preas; + u_int32_t as = 0; if (f->type == AS_EMPTY) { if (len == 0) @@ -360,18 +360,18 @@ aspath_match(void *data, u_int16_t len, struct filter_as *f, u_int32_t match) final = (len == seg_size); - /* just check the rightmost AS */ if (f->type == AS_SOURCE) { - /* keep previous AS in case an AS_SET is rightmost */ - preas = as; - as = aspath_extract(seg, seg_len - 1); + /* + * Just extract the rightmost AS + * but if that segment is an AS_SET then the rightmost + * AS of a previous non AS_SET segment should be used. + * Because of that simply skip AS_SET segments. + */ + if (seg[0] != AS_SET) + as = aspath_extract(seg, seg_len - 1); /* not yet in the final segment */ if (!final) continue; - if (seg[0] == AS_SET) - /* use aggregator AS per rfc6472 */ - if (preas) - as = preas; if (as_compare(f, as, match)) return (1); else |