device: add priority message transmission around session establishment
Add SetPriorityMessageOnEstablishmentFunc, which registers a PeerPriorityMessageFunc callback invoked when a peer's session keypair is established or re-keyed for forward data transmission. The bytes it returns are transmitted to the peer as a transport message. The message is "priority" in two senses: it bypasses the staged packet queue entirely, so it cannot be evicted by TUN-sourced packets, and it is enqueued ahead of the keepalive/staged packets that follow keypair establishment. Updates tailscale/tailscale#20081 Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
parent
15b912c1c0
commit
7a66fbee4a
3 changed files with 100 additions and 1 deletions
|
|
@ -425,6 +425,7 @@ func (device *Device) RoutineHandshake(id int) {
|
|||
|
||||
peer.timersSessionDerived()
|
||||
peer.timersHandshakeComplete()
|
||||
peer.SendPriorityMessage()
|
||||
peer.SendKeepalive()
|
||||
}
|
||||
skip:
|
||||
|
|
@ -493,6 +494,7 @@ func (peer *Peer) processInboundContainer(elemsContainer *QueueInboundElementsCo
|
|||
if peer.ReceivedWithKeypair(elem.keypair) {
|
||||
peer.SetEndpointFromPacket(elem.endpoint)
|
||||
peer.timersHandshakeComplete()
|
||||
peer.SendPriorityMessage()
|
||||
peer.SendStagedPackets()
|
||||
}
|
||||
if ep, ok := elem.endpoint.(conn.PeerAwareEndpoint); ok {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue