Skip to content

Commit

Permalink
[sairedis] Add warning on double switch id allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik committed Aug 23, 2021
1 parent 518b93a commit b91f75f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/VirtualObjectIdManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,15 @@ sai_object_id_t VirtualObjectIdManager::allocateNewSwitchObjectId(
SWSS_LOG_THROW("switch index %u > %llu (max)", switchIndex, SAI_REDIS_SWITCH_INDEX_MAX);
}

if (m_switchIndexes.find(switchIndex) != m_switchIndexes.end())
{
// this could happen, if we first create switch with INIT=true, and
// then with INIT=false but we should have other way to not double call
// allocate to obtain existing switch ID, like from switch container

SWSS_LOG_WARN("switch index %u already allocated, double call to allocate!", switchIndex);
}

m_switchIndexes.insert(switchIndex);

sai_object_id_t objectId = constructObjectId(SAI_OBJECT_TYPE_SWITCH, switchIndex, switchIndex, m_globalContext);
Expand Down

0 comments on commit b91f75f

Please sign in to comment.