From 9ccd1baa966ab5ed86f97a737f97969a7b1bc96b Mon Sep 17 00:00:00 2001 From: Nikhil Bansal Date: Thu, 20 Dec 2018 09:35:07 +0530 Subject: [PATCH] Adding default as_path for 2 byte asn neighbor With 4 byte asn changes, by default as_path with 4 byte asn was being added. It should be as_path with 2 byte asn if the peer does not support 4 byte asn. Change-Id: Ic1cf113613a36615797cb985b1a3f4199e2fd663 Closes-Bug: #218663 --- src/bgp/bgp_table.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bgp/bgp_table.cc b/src/bgp/bgp_table.cc index 6f1b39f5eac..b86dc47100c 100644 --- a/src/bgp/bgp_table.cc +++ b/src/bgp/bgp_table.cc @@ -25,9 +25,7 @@ #include "bgp/tunnel_encap/tunnel_encap.h" #include "net/community_type.h" -using std::map; using std::make_pair; -using std::ostringstream; using std::string; class BgpTable::DeleteActor : public LifetimeActor { @@ -586,10 +584,14 @@ UpdateInfo *BgpTable::GetUpdateInfo(RibOut *ribout, BgpRoute *route, // then generate a Nil AsPath i.e. one with 0 length. No need // to modify the AsPath if it already exists since this is an // iBGP RibOut. - if (clone->aspath_4byte() == NULL) { + if (ribout->as4_supported() && !clone->aspath_4byte()) { AsPath4ByteSpec as_path; clone->set_aspath_4byte(&as_path); } + if (!ribout->as4_supported() && !clone->as_path()) { + AsPathSpec as_path; + clone->set_as_path(&as_path); + } } else if (ribout->peer_type() == BgpProto::EBGP) { // Don't advertise routes from non-master instances if there's // no nexthop. The ribout has to be for bgpaas-clients because