From b592ad79c9bfa7540b5f8980b2b5d4d0228d2d30 Mon Sep 17 00:00:00 2001 From: Ann Pokora <44511240+qbdwlr@users.noreply.github.com> Date: Mon, 11 Oct 2021 11:00:39 -0400 Subject: [PATCH] [cfgmgr] Fix for STATE_DB Port check (#1936) *Updated checks for PORT entry in STATE_DB in portmgrd, teammgrd, and intfmgrd to additionally check for presence of "state" attribute. --- cfgmgr/intfmgr.cpp | 6 ++++++ cfgmgr/portmgr.cpp | 7 +++++++ cfgmgr/teammgr.cpp | 8 ++++++++ 3 files changed, 21 insertions(+) diff --git a/cfgmgr/intfmgr.cpp b/cfgmgr/intfmgr.cpp index 3e0ed862be..d0eaca21d9 100644 --- a/cfgmgr/intfmgr.cpp +++ b/cfgmgr/intfmgr.cpp @@ -9,6 +9,7 @@ #include "shellcmd.h" #include "macaddress.h" #include "warm_restart.h" +#include using namespace std; using namespace swss; @@ -438,6 +439,11 @@ bool IntfMgr::isIntfStateOk(const string &alias) } else if (m_statePortTable.get(alias, temp)) { + auto state_opt = swss::fvsGetValue(temp, "state", true); + if (!state_opt) + { + return false; + } SWSS_LOG_DEBUG("Port %s is ready", alias.c_str()); return true; } diff --git a/cfgmgr/portmgr.cpp b/cfgmgr/portmgr.cpp index 8fc43ca47f..b385a5096a 100644 --- a/cfgmgr/portmgr.cpp +++ b/cfgmgr/portmgr.cpp @@ -6,6 +6,7 @@ #include "portmgr.h" #include "exec.h" #include "shellcmd.h" +#include using namespace std; using namespace swss; @@ -87,6 +88,12 @@ bool PortMgr::isPortStateOk(const string &alias) if (m_statePortTable.get(alias, temp)) { + auto state_opt = swss::fvsGetValue(temp, "state", true); + if (!state_opt) + { + return false; + } + SWSS_LOG_INFO("Port %s is ready", alias.c_str()); return true; } diff --git a/cfgmgr/teammgr.cpp b/cfgmgr/teammgr.cpp index 89377e7e2d..b0e59c89a1 100644 --- a/cfgmgr/teammgr.cpp +++ b/cfgmgr/teammgr.cpp @@ -5,6 +5,7 @@ #include "tokenize.h" #include "warm_restart.h" #include "portmgr.h" +#include #include #include @@ -72,6 +73,13 @@ bool TeamMgr::isPortStateOk(const string &alias) return false; } + auto state_opt = swss::fvsGetValue(temp, "state", true); + if (!state_opt) + { + SWSS_LOG_INFO("Port %s is not ready", alias.c_str()); + return false; + } + return true; }