diff --git a/cfgmgr/intfmgr.cpp b/cfgmgr/intfmgr.cpp index 6fae70e7dab5..72e9123430c5 100644 --- a/cfgmgr/intfmgr.cpp +++ b/cfgmgr/intfmgr.cpp @@ -426,7 +426,12 @@ bool IntfMgr::doIntfGeneralTask(const vector& 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 { @@ -540,6 +545,7 @@ bool IntfMgr::doIntfGeneralTask(const vector& keys, if (is_lo) { delLoopbackIntf(alias); + m_loopbackIntfList.erase(alias); } if (!subIntfAlias.empty()) diff --git a/cfgmgr/intfmgr.h b/cfgmgr/intfmgr.h index 5a03a5a26d94..340c4cd04ab6 100644 --- a/cfgmgr/intfmgr.h +++ b/cfgmgr/intfmgr.h @@ -22,20 +22,21 @@ class IntfMgr : public Orch Table m_statePortTable, m_stateLagTable, m_stateVlanTable, m_stateVrfTable, m_stateIntfTable; std::set m_subIntfList; + std::set 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& keys, std::vector data, const std::string& op); bool doIntfAddrTask(const std::vector& keys, const std::vector& 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);