Repository navigation
Require a sustained run before recording a route flap - #174
Merged
Merged
Conversation
Flap detection compared cumulative response counts with a margin of 2. On a per-packet balanced hop those counts take turns leading, so route changes accumulated on hops already marked E; and a genuine change was only recorded once the new responder outnumbered the old one's whole history. A responder now needs 5 consecutive responses to become, or replace, the hop's stable responder, and no change is recorded while the hop's responses were split per-packet before the new run began (the E test). The ! marker is no longer hidden when E is shown, so a recorded change stays visible.
With E and ! able to appear together, the widest marker string is now " E!~^+" (6 columns), but the auto host width still reserved 5, so a hostname at the column limit was truncated by one character. Derive the reserve from build_hop_indicators with every marker set.
The guard judges per-packet balancing on the hop's whole history, so a later move back after a genuine change, weighted balancing near 70%, and warm-up on an evenly balanced hop are not handled. Say so in KNOWN_ISSUES, soften the --help wording, and tighten the CHANGELOG entry.
This was referenced Nov 14, 2026
# Conflicts: # CHANGELOG.md
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.
Symptom
On a hop where a router balances per packet,
!route-change history kept growing even though the hop was already classified as per-packet ECMP (E). A simulated 600-round run with responders chosen 50/50 at random recorded 9 route changes. The opposite failure also existed: after 200 rounds on one router, 20 rounds on a new one recorded no change at all.Strict round-robin (A, B, A, B...) did not reproduce on master. Its cumulative counts never differ by 2. The false alarms need the random interleaving a real balancer shows once other traffic shares it.
Root cause
record_response_detecting_flaps_with_extensionsswitched its tracked primary when another responder's cumulative count led by 2. Under random per-packet balancing the count difference is a random walk that keeps crossing zero, so the tracked primary flipped repeatedly. A real change was only seen once the new responder outnumbered the old one's whole history. The main table hid!behindE, which masked the false alarms, but the hop detail view and JSON export still carried them. It also hid real changes: after a genuine move, the cumulative split can drop below 70% for a long time.Fix
FLAP_CONFIRM_RESPONSES(5) times in a row to become the hop's stable responder or to replace it. Blips and alternation never qualify. A real change is recorded 5 rounds after it happens, however long the old path was in use.Euses, applied to the history before the run, so the new path's own responses can't hide it, and without the 8-response minimum, so warm-up balancing is covered too. The tracked primary still moves, so later changes compare against the current path.MIN_RESPONSES_FOR_FLAPand the margin are gone; a change now needs at least 10 responses anyway.!is no longer suppressed byE. Both can show on a hop where a recorded genuine change later made the split look balanced.E!~^+, 6 columns, derived frombuild_hop_indicators). It reserved 5 before, which truncated a hostname by one character onceEand!could appear together.--help, and a KNOWN_ISSUES.md "By Design" entry: path changes on an already per-packet balanced hop are not flagged, weighted balancing at or above 70% can still record a change after 5 minority replies in a row, a move back after a genuine change is missed once the combined history falls below 70% (for example 100 rounds on A, 100 on B, then back to A), and an evenly balanced hop can record one change during warm-up.Tests
test_route_flap_per_packet_balancing_never_flaps: 2- and 3-way round-robin plus a deterministic 50/50 random sequence (asserts the hop isPerPacketand has no route changes). Fails on master (9 flaps).test_route_flap_genuine_change_records_one_flap: 200 x A then 20 x B gives exactly one A to B change at response 205; 5 x A then 10 x B also gives one. Fails on master (0 flaps).test_route_flap_brief_blip_does_not_flap: 20 x A, 4 x B, 20 x A gives no change (passes on master too).E!.widest_indicator_set_fits_host_column: renders a hop with every marker and checks the hostname is followed byE!~^+untruncated. Fails with the old+ 5reserve (core1.example.n… E!~^+).Gates:
cargo fmt --check,cargo clippy --all-targets -- -D warnings(with and without default features) andcargo testall pass.Behavior across balancing patterns
A model of the old and new rules over 2000 random 600-round sequences per row (flaps per run, then share of runs with any flap):
Weighted splits near 70% are the one case that records more flaps than before. That is documented in KNOWN_ISSUES.md.
Not verified
No live check. The change is confined to hop state, and replay runs the same function. I did not build the fake per-packet router harness because the unit tests reproduce both failures directly. Replaying an old recording now uses the new rules, so its route-change history can differ from what was shown live.