Skip to content

Fix peers always reported as online - #24

Open
letalvoj wants to merge 1 commit into
CamM2325:mainfrom
letalvoj:fix/peer-online
Open

Fix peers always reported as online#24
letalvoj wants to merge 1 commit into
CamM2325:mainfrom
letalvoj:fix/peer-online

Conversation

@letalvoj

Copy link
Copy Markdown

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant