Skip to content

Commit c03d639

Browse files
kcudniklguohan
authored andcommitted
Add more information on failed map sizes (sonic-net#416)
1 parent 29f1e3c commit c03d639

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

syncd/syncd_applyview.cpp

+34-1
Original file line numberDiff line numberDiff line change
@@ -6888,6 +6888,36 @@ void checkAsicVsDatabaseConsistency(
68886888
}
68896889
}
68906890

6891+
void checkMap(
6892+
_In_ const ObjectIdMap& firstR2V,
6893+
_In_ const char* firstR2Vname,
6894+
_In_ const ObjectIdMap& firstV2R,
6895+
_In_ const char * firstV2Rname,
6896+
_In_ const ObjectIdMap& secondR2V,
6897+
_In_ const char* secondR2Vname,
6898+
_In_ const ObjectIdMap& secondV2R,
6899+
_In_ const char *secondV2Rname)
6900+
{
6901+
SWSS_LOG_ENTER();
6902+
6903+
for (auto it: firstR2V)
6904+
{
6905+
sai_object_id_t r = it.first;
6906+
sai_object_id_t v = it.second;
6907+
6908+
if (firstV2R.find(v) == firstV2R.end())
6909+
SWSS_LOG_ERROR("%s (0x%lx:0x%lx) is missing from %s", firstR2Vname, r, v, firstV2Rname);
6910+
else if (firstV2R.at(v) != r)
6911+
SWSS_LOG_ERROR("mismatch on %s (0x%lx:0x%lx) vs %s (0x%lx:0x%lx)", firstR2Vname, r, v, firstV2Rname, v, firstV2R.at(v));
6912+
6913+
if (secondR2V.find(r) == secondR2V.end())
6914+
SWSS_LOG_ERROR("%s (0x%lx:0x%lx) is missing from %s", firstR2Vname, r, v, secondR2Vname);
6915+
else if (secondV2R.find(secondR2V.at(r)) == secondV2R.end())
6916+
SWSS_LOG_ERROR("%s (0x%lx:0x%lx) is missing from %s", firstR2Vname, r, secondR2V.at(r), secondV2Rname);
6917+
}
6918+
}
6919+
6920+
68916921
sai_status_t syncdApplyView()
68926922
{
68936923
SWSS_LOG_ENTER();
@@ -7053,9 +7083,12 @@ sai_status_t syncdApplyView()
70537083
(current.vidToRid.size() != temp.vidToRid.size()))
70547084
{
70557085
/*
7056-
* TODO for debug we need to display differences
7086+
* Check all possible differences.
70577087
*/
70587088

7089+
checkMap(current.ridToVid, "current R2V", current.vidToRid, "current V2R", temp.ridToVid, "temp R2V", temp.vidToRid, "temp V2R");
7090+
checkMap(temp.ridToVid, "temp R2V", temp.vidToRid, "temp V2R", current.ridToVid, "current R2V", current.vidToRid, "current V2R");
7091+
70597092
SWSS_LOG_THROW("wrong number of vid/rid items in map, forgot to translate? R2V: %zu:%zu, V2R: %zu:%zu, FIXME",
70607093
current.ridToVid.size(),
70617094
temp.ridToVid.size(),

0 commit comments

Comments
 (0)