From 6eb36d9eaf9310ebf9a94ebf886951266bc22c25 Mon Sep 17 00:00:00 2001 From: anilkpan <64167306+anilkpan@users.noreply.github.com> Date: Sun, 27 Dec 2020 12:45:17 -0800 Subject: [PATCH] vlanmgr changes related to EVPN VxLan warmboot (#1460) vlanmgr changes related to EVPN VxLan warmboot --- cfgmgr/vlanmgr.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++- cfgmgr/vlanmgr.h | 5 ++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/cfgmgr/vlanmgr.cpp b/cfgmgr/vlanmgr.cpp index 4570374cb4..a79aa844f2 100644 --- a/cfgmgr/vlanmgr.cpp +++ b/cfgmgr/vlanmgr.cpp @@ -29,12 +29,34 @@ VlanMgr::VlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, c m_stateVlanTable(stateDb, STATE_VLAN_TABLE_NAME), m_stateVlanMemberTable(stateDb, STATE_VLAN_MEMBER_TABLE_NAME), m_appVlanTableProducer(appDb, APP_VLAN_TABLE_NAME), - m_appVlanMemberTableProducer(appDb, APP_VLAN_MEMBER_TABLE_NAME) + m_appVlanMemberTableProducer(appDb, APP_VLAN_MEMBER_TABLE_NAME), + replayDone(false) { SWSS_LOG_ENTER(); if (WarmStart::isWarmStart()) { + vector vlanKeys, vlanMemberKeys; + + /* cache all vlan and vlan member config */ + m_cfgVlanTable.getKeys(vlanKeys); + m_cfgVlanMemberTable.getKeys(vlanMemberKeys); + for (auto k : vlanKeys) + { + m_vlanReplay.insert(k); + } + for (auto k : vlanMemberKeys) + { + m_vlanMemberReplay.insert(k); + } + if (m_vlanReplay.empty()) + { + replayDone = true; + WarmStart::setWarmStartState("vlanmgrd", WarmStart::REPLAYED); + SWSS_LOG_NOTICE("vlanmgr warmstart state set to REPLAYED"); + WarmStart::setWarmStartState("vlanmgrd", WarmStart::RECONCILED); + SWSS_LOG_NOTICE("vlanmgr warmstart state set to RECONCILED"); + } const std::string cmds = std::string("") + IP_CMD + " link show " + DOT1Q_BRIDGE_NAME + " 2>/dev/null"; @@ -298,6 +320,7 @@ void VlanMgr::doVlanTask(Consumer &consumer) if (isVlanStateOk(key) && m_vlans.find(key) == m_vlans.end()) { m_vlans.insert(key); + m_vlanReplay.erase(kfvKey(t)); it = consumer.m_toSync.erase(it); SWSS_LOG_DEBUG("%s already created", kfvKey(t).c_str()); continue; @@ -308,6 +331,7 @@ void VlanMgr::doVlanTask(Consumer &consumer) { addHostVlan(vlan_id); } + m_vlanReplay.erase(kfvKey(t)); /* set up host env .... */ for (auto i : kfvFieldsValues(t)) @@ -394,6 +418,16 @@ void VlanMgr::doVlanTask(Consumer &consumer) it = consumer.m_toSync.erase(it); } } + if (!replayDone && m_vlanReplay.empty() && + m_vlanMemberReplay.empty() && + WarmStart::isWarmStart()) + { + replayDone = true; + WarmStart::setWarmStartState("vlanmgrd", WarmStart::REPLAYED); + SWSS_LOG_NOTICE("vlanmgr warmstart state set to REPLAYED"); + WarmStart::setWarmStartState("vlanmgrd", WarmStart::RECONCILED); + SWSS_LOG_NOTICE("vlanmgr warmstart state set to RECONCILED"); + } } bool VlanMgr::isMemberStateOk(const string &alias) @@ -536,6 +570,7 @@ void VlanMgr::doVlanMemberTask(Consumer &consumer) if (isVlanMemberStateOk(kfvKey(t))) { SWSS_LOG_DEBUG("%s already set", kfvKey(t).c_str()); + m_vlanMemberReplay.erase(kfvKey(t)); it = consumer.m_toSync.erase(it); continue; } @@ -577,6 +612,8 @@ void VlanMgr::doVlanMemberTask(Consumer &consumer) FieldValueTuple s("state", "ok"); fvVector.push_back(s); m_stateVlanMemberTable.set(kfvKey(t), fvVector); + + m_vlanMemberReplay.erase(kfvKey(t)); } } else if (op == DEL_COMMAND) @@ -603,6 +640,16 @@ void VlanMgr::doVlanMemberTask(Consumer &consumer) /* Other than the case of member port/lag is not ready, no retry will be performed */ it = consumer.m_toSync.erase(it); } + if (!replayDone && m_vlanMemberReplay.empty() && + WarmStart::isWarmStart()) + { + replayDone = true; + WarmStart::setWarmStartState("vlanmgrd", WarmStart::REPLAYED); + SWSS_LOG_NOTICE("vlanmgr warmstart state set to REPLAYED"); + WarmStart::setWarmStartState("vlanmgrd", WarmStart::RECONCILED); + SWSS_LOG_NOTICE("vlanmgr warmstart state set to RECONCILED"); + + } } void VlanMgr::doTask(Consumer &consumer) diff --git a/cfgmgr/vlanmgr.h b/cfgmgr/vlanmgr.h index 7c2f0c68b1..8cf467f41c 100644 --- a/cfgmgr/vlanmgr.h +++ b/cfgmgr/vlanmgr.h @@ -23,7 +23,10 @@ class VlanMgr : public Orch Table m_statePortTable, m_stateLagTable; Table m_stateVlanTable, m_stateVlanMemberTable; std::set m_vlans; - + std::set m_vlanReplay; + std::set m_vlanMemberReplay; + bool replayDone; + void doTask(Consumer &consumer); void doVlanTask(Consumer &consumer); void doVlanMemberTask(Consumer &consumer);