From: claudio Date: Fri, 10 Aug 2018 11:13:01 +0000 (+0000) Subject: Make the AS_SET handling for source-as even simpler. It is enough to only X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=ff470c9366e6549ab6c1edb978ab78b937b43e62;p=openbsd 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@ --- 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 @@ -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