From 182940d4642b7cab0ca0621268350cb5aba5d50a Mon Sep 17 00:00:00 2001 From: Shuotian Cheng Date: Thu, 26 Sep 2019 16:11:22 -0700 Subject: [PATCH] [mirrororch]: Remove mirror session state after it is remvoed (#1066) Remove deprecated mirror session states in the state database Signed-off-by: Shu0t1an Cheng --- orchagent/mirrororch.cpp | 25 +++++++++++++++++-------- orchagent/mirrororch.h | 2 ++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/orchagent/mirrororch.cpp b/orchagent/mirrororch.cpp index fbb241d1b3a6..91b07aa81a98 100644 --- a/orchagent/mirrororch.cpp +++ b/orchagent/mirrororch.cpp @@ -113,17 +113,17 @@ bool MirrorOrch::bake() } } - if (!active) + if (active) { - continue; - } + SWSS_LOG_NOTICE("Found mirror session %s active before warm reboot", + key.c_str()); - SWSS_LOG_NOTICE("Found mirror session %s active before warm reboot", - key.c_str()); + // Recover saved active session's monitor port + m_recoverySessionMap.emplace( + key, monitor_port + state_db_key_delimiter + next_hop_ip); + } - // Recover saved active session's monitor port - m_recoverySessionMap.emplace( - key, monitor_port + state_db_key_delimiter + next_hop_ip); + removeSessionState(key); } return Orch::bake(); @@ -382,6 +382,8 @@ void MirrorOrch::deleteEntry(const string& name) m_policerOrch->decreaseRefCount(session.policer); } + removeSessionState(name); + m_syncdMirrors.erase(sessionIter); SWSS_LOG_NOTICE("Removed mirror session %s", name.c_str()); @@ -436,6 +438,13 @@ void MirrorOrch::setSessionState(const string& name, const MirrorEntry& session, m_mirrorTable.set(name, fvVector); } +void MirrorOrch::removeSessionState(const string& name) +{ + SWSS_LOG_ENTER(); + + m_mirrorTable.del(name); +} + bool MirrorOrch::getNeighborInfo(const string& name, MirrorEntry& session) { SWSS_LOG_ENTER(); diff --git a/orchagent/mirrororch.h b/orchagent/mirrororch.h index 4a5801df6f45..1635012a1805 100644 --- a/orchagent/mirrororch.h +++ b/orchagent/mirrororch.h @@ -108,6 +108,8 @@ class MirrorOrch : public Orch, public Observer, public Subject * attr is the field name will be stored, if empty then all fields will be stored */ void setSessionState(const std::string& name, const MirrorEntry& session, const std::string& attr = ""); + void removeSessionState(const std::string& name); + bool getNeighborInfo(const string&, MirrorEntry&); void updateNextHop(const NextHopUpdate&);