diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index d404309..317e9f8 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -926,14 +926,14 @@ aspath_firstas_check (struct aspath *asp return 0; } -/* AS path loop check. If aspath contains asno then return 1. */ +/* AS path loop check. If aspath contains asno then return >= 1. */ int aspath_loop_check (struct aspath *aspath, as_t asno) { struct assegment *seg; int count = 0; - if ( (aspath == NULL) || (aspath->segments) ) + if ( (aspath == NULL) || (aspath->segments == NULL) ) return 0; seg = aspath->segments; @@ -1363,7 +1363,7 @@ aspath_str2aspath (const char *str) { enum as_token token = as_token_unknown; u_short as_type; - u_short asno = NULL; + u_short asno = 0; struct aspath *aspath; int needtype; diff --git a/tests/aspath_test.c b/tests/aspath_test.c index 5d510cc..1d28dbe 100644 --- a/tests/aspath_test.c +++ b/tests/aspath_test.c @@ -76,7 +76,7 @@ static struct test_segment { 10, { "8482 51457 {5204}", "8482 51457 {5204}", - 3, 0, NOT_ALL_PRIVATE, 5204, 51457, 8482}, + 3, 0, NOT_ALL_PRIVATE, 5204, 51456, 8482}, }, { /* 4 */ "seqset2", @@ -618,8 +618,8 @@ validate (struct aspath *as, const struc } /* loop, private and first as checks */ - if (aspath_loop_check (as, sp->does_loop) - || aspath_loop_check (as, sp->doesnt_loop) + if ((sp->does_loop && aspath_loop_check (as, sp->does_loop) == 0) + || (sp->doesnt_loop && aspath_loop_check (as, sp->doesnt_loop) != 0) || (aspath_private_as_check (as) != sp->private_as) || (aspath_firstas_check (as,sp->first) && sp->first == 0))