diff --git a/syncd/Syncd.cpp b/syncd/Syncd.cpp index f3fbab8cf507..9d40bf762a7e 100644 --- a/syncd/Syncd.cpp +++ b/syncd/Syncd.cpp @@ -538,7 +538,13 @@ sai_status_t Syncd::processClearStatsEvent( sai_object_meta_key_t metaKey; sai_deserialize_object_meta_key(key, metaKey); - m_translator->translateVidToRid(metaKey); + if (!m_translator->tryTranslateVidToRid(metaKey)) + { + SWSS_LOG_WARN("VID to RID translation failure: %s", key.c_str()); + sai_status_t status = SAI_STATUS_INVALID_OBJECT_ID; + m_getResponse->set(sai_serialize_status(status), {}, REDIS_ASIC_STATE_COMMAND_GETRESPONSE); + return status; + } auto info = sai_metadata_get_object_type_info(metaKey.objecttype); diff --git a/syncd/VirtualOidTranslator.cpp b/syncd/VirtualOidTranslator.cpp index a5796dbda7ed..3b45881ff6be 100644 --- a/syncd/VirtualOidTranslator.cpp +++ b/syncd/VirtualOidTranslator.cpp @@ -288,6 +288,23 @@ bool VirtualOidTranslator::tryTranslateVidToRid( } } +bool VirtualOidTranslator::tryTranslateVidToRid( + _Inout_ sai_object_meta_key_t &metaKey) +{ + SWSS_LOG_ENTER(); + + try + { + translateVidToRid(metaKey); + return true; + } + catch (const std::exception& e) + { + // message was logged already when throwing + return false; + } +} + void VirtualOidTranslator::translateVidToRid( _Inout_ sai_object_list_t &element) { diff --git a/syncd/VirtualOidTranslator.h b/syncd/VirtualOidTranslator.h index b666833c9da9..b996fc402118 100644 --- a/syncd/VirtualOidTranslator.h +++ b/syncd/VirtualOidTranslator.h @@ -86,6 +86,9 @@ namespace syncd void translateVidToRid( _Inout_ sai_object_meta_key_t &metaKey); + bool tryTranslateVidToRid( + _Inout_ sai_object_meta_key_t &metaKey); + void eraseRidAndVid( _In_ sai_object_id_t rid, _In_ sai_object_id_t vid);