Skip to content

Commit

Permalink
Add more information on failed map sizes (sonic-net#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik authored and lguohan committed Feb 2, 2019
1 parent 29f1e3c commit c03d639
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion syncd/syncd_applyview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6888,6 +6888,36 @@ void checkAsicVsDatabaseConsistency(
}
}

void checkMap(
_In_ const ObjectIdMap& firstR2V,
_In_ const char* firstR2Vname,
_In_ const ObjectIdMap& firstV2R,
_In_ const char * firstV2Rname,
_In_ const ObjectIdMap& secondR2V,
_In_ const char* secondR2Vname,
_In_ const ObjectIdMap& secondV2R,
_In_ const char *secondV2Rname)
{
SWSS_LOG_ENTER();

for (auto it: firstR2V)
{
sai_object_id_t r = it.first;
sai_object_id_t v = it.second;

if (firstV2R.find(v) == firstV2R.end())
SWSS_LOG_ERROR("%s (0x%lx:0x%lx) is missing from %s", firstR2Vname, r, v, firstV2Rname);
else if (firstV2R.at(v) != r)
SWSS_LOG_ERROR("mismatch on %s (0x%lx:0x%lx) vs %s (0x%lx:0x%lx)", firstR2Vname, r, v, firstV2Rname, v, firstV2R.at(v));

if (secondR2V.find(r) == secondR2V.end())
SWSS_LOG_ERROR("%s (0x%lx:0x%lx) is missing from %s", firstR2Vname, r, v, secondR2Vname);
else if (secondV2R.find(secondR2V.at(r)) == secondV2R.end())
SWSS_LOG_ERROR("%s (0x%lx:0x%lx) is missing from %s", firstR2Vname, r, secondR2V.at(r), secondV2Rname);
}
}


sai_status_t syncdApplyView()
{
SWSS_LOG_ENTER();
Expand Down Expand Up @@ -7053,9 +7083,12 @@ sai_status_t syncdApplyView()
(current.vidToRid.size() != temp.vidToRid.size()))
{
/*
* TODO for debug we need to display differences
* Check all possible differences.
*/

checkMap(current.ridToVid, "current R2V", current.vidToRid, "current V2R", temp.ridToVid, "temp R2V", temp.vidToRid, "temp V2R");
checkMap(temp.ridToVid, "temp R2V", temp.vidToRid, "temp V2R", current.ridToVid, "current R2V", current.vidToRid, "current V2R");

SWSS_LOG_THROW("wrong number of vid/rid items in map, forgot to translate? R2V: %zu:%zu, V2R: %zu:%zu, FIXME",
current.ridToVid.size(),
temp.ridToVid.size(),
Expand Down

0 comments on commit c03d639

Please sign in to comment.