From bce5f8ad33896e8b837ef7813c371182342390bc Mon Sep 17 00:00:00 2001 From: claudio Date: Fri, 10 Aug 2018 11:15:53 +0000 Subject: [PATCH] Another place where we should handle AS_SET better. aspath_lenmatch() should count through AS_SET boundaries, in other words the path 1 2 3 { 4 3 5 } 3 3 7 has an as-seq count of 4, before it was just 2. OK benno@ --- usr.sbin/bgpd/rde_attr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/usr.sbin/bgpd/rde_attr.c b/usr.sbin/bgpd/rde_attr.c index 54f8b82e4bf..6f7a94e2425 100644 --- a/usr.sbin/bgpd/rde_attr.c +++ b/usr.sbin/bgpd/rde_attr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_attr.c,v 1.108 2018/08/09 12:21:03 claudio Exp $ */ +/* $OpenBSD: rde_attr.c,v 1.109 2018/08/10 11:15:53 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker @@ -922,7 +922,7 @@ aspath_lenmatch(struct aspath *a, enum aslen_spec type, u_int aslen) u_int32_t as, lastas = 0; u_int count = 0; u_int16_t len, seg_size; - u_int8_t i, seg_len; + u_int8_t i, seg_len, seg_type; if (type == ASLEN_MAX) { if (aslen < aspath_count(a->data, a->len)) @@ -934,15 +934,19 @@ aspath_lenmatch(struct aspath *a, enum aslen_spec type, u_int aslen) /* type == ASLEN_SEQ */ seg = a->data; for (len = a->len; len > 0; len -= seg_size, seg += seg_size) { + seg_type = seg[0]; seg_len = seg[1]; seg_size = 2 + sizeof(u_int32_t) * seg_len; + for (i = 0; i < seg_len; i++) { - /* what should we do with AS_SET? */ as = aspath_extract(seg, i); if (as == lastas) { if (aslen < ++count) return (1); + } else if (seg_type == AS_SET) { + /* AS path 3 { 4 3 7 } 3 will have count = 3 */ + continue; } else count = 1; lastas = as; -- 2.20.1