summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2018-08-10 11:15:54 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2018-08-10 11:15:54 +0000
commit50b4318a488a6b9edc7a76c97f402e1cde568361 (patch)
tree15bbf06e25559a0cf1cb607c7f6490fbf45b8b6d
parent478b147334e004b5a6ce52db7c7dd924f55fa05c (diff)
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@
-rw-r--r--usr.sbin/bgpd/rde_attr.c10
1 files 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 <claudio@openbsd.org>
@@ -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;