Skip to content

Commit 58845ce

Browse files
authored
Add extra check for warm boot discovered RIDs (sonic-net#502)
* Add extra check for warm boot discovered RIDs * dump asic operations when rid2vid map missmatch
1 parent b4893ef commit 58845ce

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

syncd/syncd_applyview.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -7632,6 +7632,8 @@ sai_status_t syncdApplyView()
76327632
checkMap(current.ridToVid, "current R2V", current.vidToRid, "current V2R", temp.ridToVid, "temp R2V", temp.vidToRid, "temp V2R");
76337633
checkMap(temp.ridToVid, "temp R2V", temp.vidToRid, "temp V2R", current.ridToVid, "current R2V", current.vidToRid, "current V2R");
76347634

7635+
current.dumpVidToAsicOperatioId();
7636+
76357637
SWSS_LOG_THROW("wrong number of vid/rid items in map, forgot to translate? R2V: %zu:%zu, V2R: %zu:%zu, FIXME",
76367638
current.ridToVid.size(),
76377639
temp.ridToVid.size(),

syncd/syncd_hard_reinit.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,40 @@ void hardReinit()
12231223
checkAllIds();
12241224
}
12251225

1226+
void checkWarmBootDiscoveredRids(
1227+
_In_ std::shared_ptr<SaiSwitch> sw)
1228+
{
1229+
SWSS_LOG_ENTER();
1230+
1231+
/*
1232+
* After switch was created, rid discovery method was called, and all
1233+
* discovered RIDs should be present in current RID2VID map in redis
1234+
* database. If any RID is missing, then ether there is bug in vendor code,
1235+
* and after warm boot some RID values changed or we have a bug and forgot
1236+
* to put rid/vid pair to redis.
1237+
*
1238+
* Assumption here is that during warm boot ASIC state will not change.
1239+
*/
1240+
1241+
auto rid2vid = redisGetRidToVidMap();
1242+
bool success = true;
1243+
1244+
for (auto rid: sw->getDiscoveredRids())
1245+
{
1246+
if (rid2vid.find(rid) != rid2vid.end())
1247+
continue;
1248+
1249+
SWSS_LOG_ERROR("RID 0x%lx is missing from current RID2VID map after WARM boot!", rid);
1250+
1251+
success = false;
1252+
}
1253+
1254+
if (!success)
1255+
SWSS_LOG_THROW("FATAL, some discovered RIDs are not present in current RID2VID map, bug");
1256+
1257+
SWSS_LOG_NOTICE("all discovered RIDs are present in current RID2VID map");
1258+
}
1259+
12261260
void performWarmRestart()
12271261
{
12281262
SWSS_LOG_ENTER();
@@ -1329,5 +1363,7 @@ void performWarmRestart()
13291363

13301364
gSwitchId = g_switch_rid;
13311365

1366+
checkWarmBootDiscoveredRids(sw);
1367+
13321368
startDiagShell();
13331369
}

0 commit comments

Comments
 (0)