Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions fboss/agent/SwSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,20 @@ void SwSwitch::initialConfigApplied(
sendNeighborSolicitationForConfiguredInterfaces("warm boot");
sendArpRequestForConfiguredInterfaces("warm boot");

// After warmboot completes, immediately synchronize hardware stats to
// software cache (hwSwitchStats_). This ensures that tests reading stats
// immediately after warmboot get correct values instead of stale cached
// data. The background stats thread normally updates cache every 1 second,
// but tests may read stats within milliseconds of warmboot completing.

try {
XLOG(DBG2) << "Warm boot: synchronizing hardware stats to software cache";
updateStats();
XLOG(DBG2) << "Warm boot: stats synchronization completed";
} catch (const std::exception& ex) {
XLOG(ERR) << "Warm boot: stats synchronization failed: " << ex.what();
}

if (flags_ & SwitchFlags::PUBLISH_STATS) {
stats()->switchConfiguredMs(
duration_cast<std::chrono::milliseconds>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class AgentQueuePerHostL2Test : public AgentHwTest {
auto ttlCounterName = utility::getQueuePerHostTtlCounterName();

auto statBefore = utility::getAclInOutPackets(getSw(), ttlCounterName);
XLOG(DBG2) << "ACL counter '" << ttlCounterName
<< "' statBefore = " << statBefore;

std::map<int, int64_t> beforeQueueOutPkts;
for (const auto& queueId : utility::kQueuePerhostQueueIds()) {
Expand Down Expand Up @@ -132,6 +134,10 @@ class AgentQueuePerHostL2Test : public AgentHwTest {
auto statAfter =
utility::getAclInOutPackets(this->getSw(), ttlCounterName);

XLOG(DBG2) << "ACL counter '" << ttlCounterName
<< "' statBefore = " << statBefore
<< ", statAfter = " << statAfter
<< ", delta = " << (statAfter - statBefore);
/*
* counts ttl >= 128 packet only
* but L2 traffic (so TTL is not decremented, and thus looped back
Expand Down
Loading