Skip to content

Commit 40ff871

Browse files
Avoid adding loopback interface (ip link add) when setting nat zone on loopback interface (sonic-net#1434)
Signed-off-by: Akhilesh Samineni <[email protected]>
1 parent 4aa48d6 commit 40ff871

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

cfgmgr/intfmgr.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,12 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
495495

496496
if (is_lo)
497497
{
498-
addLoopbackIntf(alias);
498+
if (m_loopbackIntfList.find(alias) == m_loopbackIntfList.end())
499+
{
500+
addLoopbackIntf(alias);
501+
m_loopbackIntfList.insert(alias);
502+
SWSS_LOG_INFO("Added %s loopback interface", alias.c_str());
503+
}
499504
}
500505
else
501506
{
@@ -598,6 +603,7 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
598603
if (is_lo)
599604
{
600605
delLoopbackIntf(alias);
606+
m_loopbackIntfList.erase(alias);
601607
}
602608

603609
if (!subIntfAlias.empty())

cfgmgr/intfmgr.h

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class IntfMgr : public Orch
2222
Table m_statePortTable, m_stateLagTable, m_stateVlanTable, m_stateVrfTable, m_stateIntfTable;
2323

2424
std::set<std::string> m_subIntfList;
25+
std::set<std::string> m_loopbackIntfList;
2526

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

0 commit comments

Comments
 (0)