prober: remove per-packet DERP pub key copying overheads (#14658)

Updates tailscale/corp#25883

Signed-off-by: Jordan Whited <jordan@tailscale.com>
pull/14659/head
Jordan Whited 11 months ago committed by GitHub
parent 0481042738
commit 84b0379dd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -925,6 +925,7 @@ func derpProbeBandwidthTUN(ctx context.Context, transferTimeSeconds, totalBytesT
destinationAddrBytes := destinationAddr.AsSlice()
scratch := make([]byte, 4)
toPubDERPKey := toc.SelfPublicKey()
for {
n, err := dev.Read(bufs, sizes, tunStartOffset)
if err != nil {
@ -953,7 +954,7 @@ func derpProbeBandwidthTUN(ctx context.Context, transferTimeSeconds, totalBytesT
copy(pkt[12:16], pkt[16:20])
copy(pkt[16:20], scratch)
if err := fromc.Send(toc.SelfPublicKey(), pkt); err != nil {
if err := fromc.Send(toPubDERPKey, pkt); err != nil {
tunReadErrC <- err
return
}
@ -971,6 +972,7 @@ func derpProbeBandwidthTUN(ctx context.Context, transferTimeSeconds, totalBytesT
buf := make([]byte, mtu+tunStartOffset)
bufs := make([][]byte, 1)
fromDERPPubKey := fromc.SelfPublicKey()
for {
m, err := toc.Recv()
if err != nil {
@ -979,7 +981,7 @@ func derpProbeBandwidthTUN(ctx context.Context, transferTimeSeconds, totalBytesT
}
switch v := m.(type) {
case derp.ReceivedPacket:
if v.Source != fromc.SelfPublicKey() {
if v.Source != fromDERPPubKey {
recvErrC <- fmt.Errorf("got data packet from unexpected source, %v", v.Source)
return
}

Loading…
Cancel
Save