Skip to content

Commit b91f75f

Browse files
committed
[sairedis] Add warning on double switch id allocation
1 parent 518b93a commit b91f75f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/VirtualObjectIdManager.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,15 @@ sai_object_id_t VirtualObjectIdManager::allocateNewSwitchObjectId(
279279
SWSS_LOG_THROW("switch index %u > %llu (max)", switchIndex, SAI_REDIS_SWITCH_INDEX_MAX);
280280
}
281281

282+
if (m_switchIndexes.find(switchIndex) != m_switchIndexes.end())
283+
{
284+
// this could happen, if we first create switch with INIT=true, and
285+
// then with INIT=false but we should have other way to not double call
286+
// allocate to obtain existing switch ID, like from switch container
287+
288+
SWSS_LOG_WARN("switch index %u already allocated, double call to allocate!", switchIndex);
289+
}
290+
282291
m_switchIndexes.insert(switchIndex);
283292

284293
sai_object_id_t objectId = constructObjectId(SAI_OBJECT_TYPE_SWITCH, switchIndex, switchIndex, m_globalContext);

0 commit comments

Comments
 (0)