Skip to content

device: report whether a peer's session used a hybrid handshake - #145

Merged
nickkhyl merged 1 commit into
tailscalefrom
nickkhyl/hfs-status
Dec 4, 2026
Merged

nickkhyl merged 1 commit into
tailscalefrom
nickkhyl/hfs-status

Conversation

@nickkhyl

@nickkhyl nickkhyl commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Updates tailscale/tailscale#22853
Updates tailscale/corp#50068
Updates tailscale/corp#52622

Required by tailscale/tailscale#22868

@nickkhyl
nickkhyl requested a review from danderson December 3, 2026 18:16
@nickkhyl
nickkhyl force-pushed the nickkhyl/hfs-status branch from 48bfd68 to b4912f1 Compare December 3, 2026 19:57
Comment thread device/peer.go Outdated
Comment on lines +253 to +255
// SessionInfo returns information about the peer's current session
// and true if the session is usable, otherwise nil and false.
func (p *Peer) SessionInfo() (_ *PeerSessionInfo, ok bool) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, returning the session state as a struct instead of a bool makes more sense and helps us distinguish between "no usable session" and "a classic/non-hybrid-pq session" or extend the session info in the future, so I changed it in b4912f1.

@illotum illotum left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM aside of one nit

Comment thread device/peer.go Resolved
Comment thread device/peer.go Outdated
// SessionInfo returns information about the peer's current session
// and true if the session is usable, otherwise nil and false.
func (p *Peer) SessionInfo() (_ *PeerSessionInfo, ok bool) {
p.keypairs.RLock()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you can derive this more cheaply from:

p.sessionState.Lock()
established := p.sessionState.current == PeerSessionEstablished
p.sessionState.Unlock()

Please also keep the lock bounds shorter than a potential allocation. While preferrably the peersessioninfo struct doesn't escape in any current implementation, it may well in the future and so I would recommend avoiding holding the lock across an allocation boundary.

Comment thread device/peer.go Resolved

@raggi raggi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main change I would really like to see is the removal of the allocation inside the lock bound.

The design to push this through the existing peer state API is preferred but not manadatory, it's just weird to end up with two things so similarly named, covering so much the same kind of thing but happenign to be slightly different and dependent on each other.

Comment thread device/peer.go Outdated
// Hybrid is whether the session keys were derived
// from a hybrid post-quantum handshake,
// which gives the session hybrid forward secrecy.
Hybrid bool

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming we don't really care about backwards compatibility here, so if we e.g. change to a different form of hybrid handshake in the future, we're fine changing this to e.g. HybridV1 or something?

Comment thread device/peer.go Resolved
@nickkhyl
nickkhyl force-pushed the nickkhyl/hfs-status branch 2 times, most recently from 2632bdd to 0a64bd9 Compare December 3, 2026 22:43
@nickkhyl
nickkhyl force-pushed the nickkhyl/hfs-status branch from 0a64bd9 to 3c67285 Compare December 3, 2026 22:47
@nickkhyl

nickkhyl commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Reworked to return session info in the PeerSessionStateFunc callback. PTAL?

@raggi raggi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's pre-existing, but it feels weird that note is both a broadcaster and a recorder, and that's getting more vehement with the way that the bool passes through and that there's one write outside of note already (to sessionExpires).

Perhaps a future refactor should move the sessionState update to it's own call chain.

@nickkhyl
nickkhyl merged commit 5d2f71d into tailscale Dec 4, 2026
15 checks passed
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.

4 participants