From ea138f568606a9bd07909d6aa5da216f4853b6ef Mon Sep 17 00:00:00 2001 From: Don Slice Date: Wed, 11 Aug 2021 08:45:23 -0400 Subject: [PATCH] bgpd: Stop prepending peer-as if self-originated and lastas configured Problem seen where if "set aspath-prepend last-as" configured and applied outbound, we prepend the peer's asn which causes our self- originated routes to be denied. Signed-off-by: Don Slice (cherry picked from commit 6ba0adacd25349a0b5088d7e64106a859031f150) --- bgpd/bgp_routemap.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index fc5b52b777..22df4ee7fd 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -1939,9 +1939,8 @@ route_set_aspath_prepend(void *rule, const struct prefix *prefix, void *object) aspath_prepend(aspath, new); } else { as_t as = aspath_leftmost(new); - if (!as) - as = path->peer->as; - new = aspath_add_seq_n(new, as, (uintptr_t)rule); + if (as) + new = aspath_add_seq_n(new, as, (uintptr_t)rule); } path->attr->aspath = new; @@ -4915,7 +4914,7 @@ DEFUN_YANG (set_aspath_prepend_lastas, SET_STR "Transform BGP AS_PATH attribute\n" "Prepend to the as-path\n" - "Use the peer's AS-number\n" + "Use the last AS-number in the as-path\n" "Number of times to insert\n") { int idx_num = 4; -- 2.39.5