Skip to content

Commit db9a1d2

Browse files
Avoid adding loopback interface (ip link add) when setting nat zone on loopback interface (sonic-net#1411)
* Avoid adding loopback interface (ip link add) when nat zone is set on loopback interface Signed-off-by: Akhilesh Samineni <[email protected]>
1 parent 2267071 commit db9a1d2

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

cfgmgr/intfmgr.cpp

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

427427
if (is_lo)
428428
{
429-
addLoopbackIntf(alias);
429+
if (m_loopbackIntfList.find(alias) == m_loopbackIntfList.end())
430+
{
431+
addLoopbackIntf(alias);
432+
m_loopbackIntfList.insert(alias);
433+
SWSS_LOG_INFO("Added %s loopback interface", alias.c_str());
434+
}
430435
}
431436
else
432437
{
@@ -540,6 +545,7 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
540545
if (is_lo)
541546
{
542547
delLoopbackIntf(alias);
548+
m_loopbackIntfList.erase(alias);
543549
}
544550

545551
if (!subIntfAlias.empty())

cfgmgr/intfmgr.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,21 @@ 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);
2829
void setIntfMac(const std::string &alias, const std::string &macAddr);
29-
30+
3031
bool doIntfGeneralTask(const std::vector<std::string>& keys, std::vector<FieldValueTuple> data, const std::string& op);
3132
bool doIntfAddrTask(const std::vector<std::string>& keys, const std::vector<FieldValueTuple>& data, const std::string& op);
3233
void doTask(Consumer &consumer);
33-
34+
3435
bool isIntfStateOk(const std::string &alias);
3536
bool isIntfCreated(const std::string &alias);
3637
bool isIntfChangeVrf(const std::string &alias, const std::string &vrfName);
3738
int getIntfIpCount(const std::string &alias);
38-
39+
3940
void addLoopbackIntf(const std::string &alias);
4041
void delLoopbackIntf(const std::string &alias);
4142
void flushLoopbackIntfs(void);

0 commit comments

Comments
 (0)