conn,device: eval conn.PeerAwareEndpoint per-packet
Peer.SetEndpointFromPacket is not called per-packet. It is guaranteed to be called at least once per packet batch. Updates tailscale/corp#30042 Updates tailscale/corp#20732 Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
parent
4064566eca
commit
1d0488a3d7
3 changed files with 6 additions and 6 deletions
|
|
@ -109,8 +109,9 @@ type InitiationAwareEndpoint interface {
|
||||||
// to learn the identification WireGuard can derive from the session
|
// to learn the identification WireGuard can derive from the session
|
||||||
// or handshake.
|
// or handshake.
|
||||||
//
|
//
|
||||||
// wireguard-go never installs a [PeerAwareEndpoint] as the [Endpoint] for a
|
// A [PeerAwareEndpoint] may be installed as the [conn.Endpoint] following
|
||||||
// [Peer].
|
// successful decryption unless endpoint roaming has been disabled for
|
||||||
|
// the peer.
|
||||||
type PeerAwareEndpoint interface {
|
type PeerAwareEndpoint interface {
|
||||||
// FromPeer is called at least once per successfully Cryptokey Routing ID'd
|
// FromPeer is called at least once per successfully Cryptokey Routing ID'd
|
||||||
// [ReceiveFunc] packets batch for a given node key. wireguard-go will
|
// [ReceiveFunc] packets batch for a given node key. wireguard-go will
|
||||||
|
|
|
||||||
|
|
@ -282,10 +282,6 @@ func (peer *Peer) Stop() {
|
||||||
func (peer *Peer) SetEndpointFromPacket(endpoint conn.Endpoint) {
|
func (peer *Peer) SetEndpointFromPacket(endpoint conn.Endpoint) {
|
||||||
peer.endpoint.Lock()
|
peer.endpoint.Lock()
|
||||||
defer peer.endpoint.Unlock()
|
defer peer.endpoint.Unlock()
|
||||||
if ep, ok := endpoint.(conn.PeerAwareEndpoint); ok {
|
|
||||||
ep.FromPeer(peer.handshake.remoteStatic)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if peer.endpoint.disableRoaming {
|
if peer.endpoint.disableRoaming {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -460,6 +460,9 @@ func (peer *Peer) RoutineSequentialReceiver(maxBatchSize int) {
|
||||||
peer.timersHandshakeComplete()
|
peer.timersHandshakeComplete()
|
||||||
peer.SendStagedPackets()
|
peer.SendStagedPackets()
|
||||||
}
|
}
|
||||||
|
if ep, ok := elem.endpoint.(conn.PeerAwareEndpoint); ok {
|
||||||
|
ep.FromPeer(peer.handshake.remoteStatic)
|
||||||
|
}
|
||||||
rxBytesLen += uint64(len(elem.packet) + MinMessageSize)
|
rxBytesLen += uint64(len(elem.packet) + MinMessageSize)
|
||||||
|
|
||||||
if len(elem.packet) == 0 {
|
if len(elem.packet) == 0 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue