Skip to content

Commit

Permalink
Avoid adding loopback interface (ip link add) when setting nat zone o…
Browse files Browse the repository at this point in the history
…n 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]>
  • Loading branch information
AkhileshSamineni authored Aug 20, 2020
1 parent 2267071 commit db9a1d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 7 additions & 1 deletion cfgmgr/intfmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,12 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,

if (is_lo)
{
addLoopbackIntf(alias);
if (m_loopbackIntfList.find(alias) == m_loopbackIntfList.end())
{
addLoopbackIntf(alias);
m_loopbackIntfList.insert(alias);
SWSS_LOG_INFO("Added %s loopback interface", alias.c_str());
}
}
else
{
Expand Down Expand Up @@ -540,6 +545,7 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
if (is_lo)
{
delLoopbackIntf(alias);
m_loopbackIntfList.erase(alias);
}

if (!subIntfAlias.empty())
Expand Down
7 changes: 4 additions & 3 deletions cfgmgr/intfmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,21 @@ class IntfMgr : public Orch
Table m_statePortTable, m_stateLagTable, m_stateVlanTable, m_stateVrfTable, m_stateIntfTable;

std::set<std::string> m_subIntfList;
std::set<std::string> m_loopbackIntfList;

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

bool doIntfGeneralTask(const std::vector<std::string>& keys, std::vector<FieldValueTuple> data, const std::string& op);
bool doIntfAddrTask(const std::vector<std::string>& keys, const std::vector<FieldValueTuple>& data, const std::string& op);
void doTask(Consumer &consumer);

bool isIntfStateOk(const std::string &alias);
bool isIntfCreated(const std::string &alias);
bool isIntfChangeVrf(const std::string &alias, const std::string &vrfName);
int getIntfIpCount(const std::string &alias);

void addLoopbackIntf(const std::string &alias);
void delLoopbackIntf(const std::string &alias);
void flushLoopbackIntfs(void);
Expand Down

0 comments on commit db9a1d2

Please sign in to comment.