From b91f75fe12d1bca3f13054605c4b1bf45c663995 Mon Sep 17 00:00:00 2001 From: kcudnik Date: Sun, 22 Aug 2021 13:16:35 +0200 Subject: [PATCH] [sairedis] Add warning on double switch id allocation --- lib/VirtualObjectIdManager.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/VirtualObjectIdManager.cpp b/lib/VirtualObjectIdManager.cpp index ad3031377a40..36543b0dff65 100644 --- a/lib/VirtualObjectIdManager.cpp +++ b/lib/VirtualObjectIdManager.cpp @@ -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);