Skip to content

Commit

Permalink
[mirrororch]: Remove mirror session state after it is remvoed (sonic-…
Browse files Browse the repository at this point in the history
…net#1066)

Remove deprecated mirror session states in the state database

Signed-off-by: Shu0t1an Cheng <shuche@microsoft.com>
  • Loading branch information
stcheng authored Sep 26, 2019
1 parent d823dd1 commit 182940d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 17 additions & 8 deletions orchagent/mirrororch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions orchagent/mirrororch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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&);
Expand Down

0 comments on commit 182940d

Please sign in to comment.