Skip to content

Commit

Permalink
Fix for 2053, Fix IPv6 BGP multipath-relax peer-type. (sonic-net#2062)
Browse files Browse the repository at this point in the history
By default the metric for ipv6 static route is 1024. This makes it the
routes learned via the internal bgp sessions inferior to the Ebgp
routes. So make the metric 256 which make the static route metric same
as connected route metric.
  • Loading branch information
skbarista authored Feb 7, 2022
1 parent baa7476 commit f2e4d25
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
25 changes: 23 additions & 2 deletions cfgmgr/intfmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ IntfMgr::IntfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c
setWarmReplayDoneState();
}
}

string swtype;
Table cfgDeviceMetaDataTable(cfgDb, CFG_DEVICE_METADATA_TABLE_NAME);
if(cfgDeviceMetaDataTable.hget("localhost", "switch_type", swtype))
{
mySwitchType = swtype;
}
}

void IntfMgr::setIntfIp(const string &alias, const string &opCmd,
Expand All @@ -86,9 +93,23 @@ void IntfMgr::setIntfIp(const string &alias, const string &opCmd,
}
else
{
string metric = "";
// Kernel adds connected route with default metric of 256. But the metric is not
// communicated to frr unless the ip address is added with explicit metric
// In voq system, We need the static route to the remote neighbor and connected
// route to have the same metric to enable BGP to choose paths from routes learned
// via eBGP and iBGP over the internal inband port be part of same ecmp group.
// For v4 both the metrics (connected and static) are default 0 so we do not need
// to set the metric explicitly.
if(mySwitchType == "voq")
{
metric = " metric 256";
}

(prefixLen < 127) ?
(cmd << IP_CMD << " -6 address " << shellquote(opCmd) << " " << shellquote(ipPrefixStr) << " broadcast " << shellquote(broadcastIpStr) << " dev " << shellquote(alias)) :
(cmd << IP_CMD << " -6 address " << shellquote(opCmd) << " " << shellquote(ipPrefixStr) << " dev " << shellquote(alias));
(cmd << IP_CMD << " -6 address " << shellquote(opCmd) << " " << shellquote(ipPrefixStr) << " broadcast " << shellquote(broadcastIpStr) <<
" dev " << shellquote(alias) << metric) :
(cmd << IP_CMD << " -6 address " << shellquote(opCmd) << " " << shellquote(ipPrefixStr) << " dev " << shellquote(alias) << metric);
}

int ret = swss::exec(cmd.str(), res);
Expand Down
1 change: 1 addition & 0 deletions cfgmgr/intfmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class IntfMgr : public Orch
std::set<std::string> m_loopbackIntfList;
std::set<std::string> m_pendingReplayIntfList;
std::set<std::string> m_ipv6LinkLocalModeList;
std::string mySwitchType;

void setIntfIp(const std::string &alias, const std::string &opCmd, const IpPrefix &ipPrefix);
void setIntfVrf(const std::string &alias, const std::string &vrfName);
Expand Down
7 changes: 6 additions & 1 deletion cfgmgr/nbrmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,12 @@ bool NbrMgr::addKernelRoute(string odev, IpAddress ip_addr)
}
else
{
cmd = string("") + IP_CMD + " -6 route add " + ip_str + "/128 dev " + odev;
// In voq system, We need the static route to the remote neighbor and connected
// route to have the same metric to enable BGP to choose paths from routes learned
// via eBGP and iBGP over the internal inband port be part of same ecmp group.
// For v4 both the metrics (connected and static) are default 0 so we do not need
// to set the metric explicitly.
cmd = string("") + IP_CMD + " -6 route add " + ip_str + "/128 dev " + odev + " metric 256";
SWSS_LOG_NOTICE("IPv6 Route Add cmd: %s",cmd.c_str());
}

Expand Down

0 comments on commit f2e4d25

Please sign in to comment.