Skip to content

Commit 182940d

Browse files
authored
[mirrororch]: Remove mirror session state after it is remvoed (#1066)
Remove deprecated mirror session states in the state database Signed-off-by: Shu0t1an Cheng <[email protected]>
1 parent d823dd1 commit 182940d

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

orchagent/mirrororch.cpp

+17-8
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,17 @@ bool MirrorOrch::bake()
113113
}
114114
}
115115

116-
if (!active)
116+
if (active)
117117
{
118-
continue;
119-
}
118+
SWSS_LOG_NOTICE("Found mirror session %s active before warm reboot",
119+
key.c_str());
120120

121-
SWSS_LOG_NOTICE("Found mirror session %s active before warm reboot",
122-
key.c_str());
121+
// Recover saved active session's monitor port
122+
m_recoverySessionMap.emplace(
123+
key, monitor_port + state_db_key_delimiter + next_hop_ip);
124+
}
123125

124-
// Recover saved active session's monitor port
125-
m_recoverySessionMap.emplace(
126-
key, monitor_port + state_db_key_delimiter + next_hop_ip);
126+
removeSessionState(key);
127127
}
128128

129129
return Orch::bake();
@@ -382,6 +382,8 @@ void MirrorOrch::deleteEntry(const string& name)
382382
m_policerOrch->decreaseRefCount(session.policer);
383383
}
384384

385+
removeSessionState(name);
386+
385387
m_syncdMirrors.erase(sessionIter);
386388

387389
SWSS_LOG_NOTICE("Removed mirror session %s", name.c_str());
@@ -436,6 +438,13 @@ void MirrorOrch::setSessionState(const string& name, const MirrorEntry& session,
436438
m_mirrorTable.set(name, fvVector);
437439
}
438440

441+
void MirrorOrch::removeSessionState(const string& name)
442+
{
443+
SWSS_LOG_ENTER();
444+
445+
m_mirrorTable.del(name);
446+
}
447+
439448
bool MirrorOrch::getNeighborInfo(const string& name, MirrorEntry& session)
440449
{
441450
SWSS_LOG_ENTER();

orchagent/mirrororch.h

+2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ class MirrorOrch : public Orch, public Observer, public Subject
108108
* attr is the field name will be stored, if empty then all fields will be stored
109109
*/
110110
void setSessionState(const std::string& name, const MirrorEntry& session, const std::string& attr = "");
111+
void removeSessionState(const std::string& name);
112+
111113
bool getNeighborInfo(const string&, MirrorEntry&);
112114

113115
void updateNextHop(const NextHopUpdate&);

0 commit comments

Comments
 (0)