Skip to content

Commit f2e4d25

Browse files
authored
Fix for 2053, Fix IPv6 BGP multipath-relax peer-type. (sonic-net#2062)
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.
1 parent baa7476 commit f2e4d25

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

cfgmgr/intfmgr.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ IntfMgr::IntfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c
6767
setWarmReplayDoneState();
6868
}
6969
}
70+
71+
string swtype;
72+
Table cfgDeviceMetaDataTable(cfgDb, CFG_DEVICE_METADATA_TABLE_NAME);
73+
if(cfgDeviceMetaDataTable.hget("localhost", "switch_type", swtype))
74+
{
75+
mySwitchType = swtype;
76+
}
7077
}
7178

7279
void IntfMgr::setIntfIp(const string &alias, const string &opCmd,
@@ -86,9 +93,23 @@ void IntfMgr::setIntfIp(const string &alias, const string &opCmd,
8693
}
8794
else
8895
{
96+
string metric = "";
97+
// Kernel adds connected route with default metric of 256. But the metric is not
98+
// communicated to frr unless the ip address is added with explicit metric
99+
// In voq system, We need the static route to the remote neighbor and connected
100+
// route to have the same metric to enable BGP to choose paths from routes learned
101+
// via eBGP and iBGP over the internal inband port be part of same ecmp group.
102+
// For v4 both the metrics (connected and static) are default 0 so we do not need
103+
// to set the metric explicitly.
104+
if(mySwitchType == "voq")
105+
{
106+
metric = " metric 256";
107+
}
108+
89109
(prefixLen < 127) ?
90-
(cmd << IP_CMD << " -6 address " << shellquote(opCmd) << " " << shellquote(ipPrefixStr) << " broadcast " << shellquote(broadcastIpStr) << " dev " << shellquote(alias)) :
91-
(cmd << IP_CMD << " -6 address " << shellquote(opCmd) << " " << shellquote(ipPrefixStr) << " dev " << shellquote(alias));
110+
(cmd << IP_CMD << " -6 address " << shellquote(opCmd) << " " << shellquote(ipPrefixStr) << " broadcast " << shellquote(broadcastIpStr) <<
111+
" dev " << shellquote(alias) << metric) :
112+
(cmd << IP_CMD << " -6 address " << shellquote(opCmd) << " " << shellquote(ipPrefixStr) << " dev " << shellquote(alias) << metric);
92113
}
93114

94115
int ret = swss::exec(cmd.str(), res);

cfgmgr/intfmgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class IntfMgr : public Orch
3737
std::set<std::string> m_loopbackIntfList;
3838
std::set<std::string> m_pendingReplayIntfList;
3939
std::set<std::string> m_ipv6LinkLocalModeList;
40+
std::string mySwitchType;
4041

4142
void setIntfIp(const std::string &alias, const std::string &opCmd, const IpPrefix &ipPrefix);
4243
void setIntfVrf(const std::string &alias, const std::string &vrfName);

cfgmgr/nbrmgr.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,12 @@ bool NbrMgr::addKernelRoute(string odev, IpAddress ip_addr)
509509
}
510510
else
511511
{
512-
cmd = string("") + IP_CMD + " -6 route add " + ip_str + "/128 dev " + odev;
512+
// In voq system, We need the static route to the remote neighbor and connected
513+
// route to have the same metric to enable BGP to choose paths from routes learned
514+
// via eBGP and iBGP over the internal inband port be part of same ecmp group.
515+
// For v4 both the metrics (connected and static) are default 0 so we do not need
516+
// to set the metric explicitly.
517+
cmd = string("") + IP_CMD + " -6 route add " + ip_str + "/128 dev " + odev + " metric 256";
513518
SWSS_LOG_NOTICE("IPv6 Route Add cmd: %s",cmd.c_str());
514519
}
515520

0 commit comments

Comments
 (0)