Fix peers always reported as online - #24
Open
letalvoj wants to merge 1 commit into
Open
Conversation
The device's peer list marked every peer online, including an iOS device that had been offline for 66 days — `tailscale status` on another node disagreed. The cause: the `online` flag returned by microlink_get_peer_info() was actually peer->active, and the peer-added callback hardcoded online=true. But `active` only tracks whether a peer holds a slot in the local WireGuard table — set when it is added, cleared when it is evicted — so any peer that could be reported at all was reported online. The real answer is already in MapResponse as Node.Online; it was being parsed and discarded. This keeps it on ml_peer_t alongside active (they answer different questions, and API callers want reachability, not table bookkeeping) and returns it. A missing Online counts as offline rather than assumed reachable, so NVS-cached peers also start offline until a MapResponse confirms them. Liveness changes then arrive incrementally as PeersChangedPatch entries on the long-poll stream, so those update Online too. A patch is partial, so online_valid separates "field absent, leave as-is" from "set to false" and an omitted field never clobbers a known value. Verified against a tailnet with one live and one long-offline peer: the device now matches `tailscale status`. The PeersChangedPatch path is implemented from the protocol but has not been observed firing.
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.
The device's peer list marked every peer online, including an iOS device that had been offline for 66 days —
tailscale statuson another node disagreed.The cause: the
onlineflag returned by microlink_get_peer_info() was actually peer->active, and the peer-added callback hardcoded online=true. Butactiveonly tracks whether a peer holds a slot in the local WireGuard table — set when it is added, cleared when it is evicted — so any peer that could be reported at all was reported online.The real answer is already in MapResponse as Node.Online; it was being parsed and discarded. This keeps it on ml_peer_t alongside active (they answer different questions, and API callers want reachability, not table bookkeeping) and returns it. A missing Online counts as offline rather than assumed reachable, so NVS-cached peers also start offline until a MapResponse confirms them.
Liveness changes then arrive incrementally as PeersChangedPatch entries on the long-poll stream, so those update Online too. A patch is partial, so online_valid separates "field absent, leave as-is" from "set to false" and an omitted field never clobbers a known value.
Verified against a tailnet with one live and one long-offline peer: the device now matches
tailscale status. The PeersChangedPatch path is implemented from the protocol but has not been observed firing.