Repository navigation
[Nexthop][bugfix] Preserve accumulated port counters across admin disable/enable - #1732
Open
vvasavada-nexthop wants to merge 1 commit into
Open
vvasavada-nexthop wants to merge 1 commit into
vvasavada-nexthop wants to merge 1 commit into
Conversation
Contributor
Author
|
/autorebase |
Signed-off-by: Vishrant Vasavada <vvasavada@nexthop.ai>
rabbit-nexthop
force-pushed
the
preserve-accumulated-port-counters
branch
from
November 20, 2026 00:55
4b710a7 to
5b53f98
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-submission checklist
pip install -r requirements-dev.txt && pre-commit installpre-commit runSummary
An admin down/up of a port (
fboss2 bounce interface, orfboss2 set port <p> state disablethenenable) silently zeroes that port's Input Discards. Input Errors, bytes and packets keep counting through the flap.Root cause.
SaiPortManagerdrops a port'sHwPortFb303Statsentry when the port is admin-disabled and creates a fresh one when it is re-enabled. Most port counters are read from the ASIC as cumulative values, so a fresh entry picks them up again on the first poll. A few counters are summed in software instead:inDiscards_: the agent adds up changes ininDiscardsRaw_.Fix.
HwPortStatsin a newdisabledPortStats_map. Only ports that have been polled at least once are saved.HwPortFb303Statsfrom the saved copy. The next poll then measures the change against the saved raw value, so discards that happened while the port was down are counted too. The summed counters stay monotonic, consistent with the hardware ones.clearStats()andclearInterfacePhyCounters()also zero the saved copy. Otherwise an explicit clear of a disabled port would be undone on re-enable.removePort()drops the saved copy.Disabled ports still don't export counters, and removing and re-creating a port (lane/speed change) still starts from fresh stats.
Test Plan
New tests in
PortManagerAccumulatedStatsTest:preservedAcrossDisableEnable: seedsinDiscards_=1000andfecCorrectableErrors=20, then disablesand re-enables the port and polls. Checks that both values survive.
clearWhileDisabled: runsclearStats/clearInterfacePhyCounterswhile the port is disabled, thenre-enables it. Checks that both counters read 0.
Run:
./switch_test --gtest_filter='PortManagerAccumulatedStatsTest.*:PortManagerTest.*'With the fix:
Without the fix (only the SaiPortManager changes reverted), both new tests fail.
inDiscards_reads -1right after re-enable and 0 after the first poll, which reproduces the crow235 signature: