Skip to content

Commit 84b0379

Browse files
authored
prober: remove per-packet DERP pub key copying overheads (tailscale#14658)
Updates tailscale/corp#25883 Signed-off-by: Jordan Whited <[email protected]>
1 parent 0481042 commit 84b0379

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

prober/derp.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,6 +925,7 @@ func derpProbeBandwidthTUN(ctx context.Context, transferTimeSeconds, totalBytesT
925925

926926
destinationAddrBytes := destinationAddr.AsSlice()
927927
scratch := make([]byte, 4)
928+
toPubDERPKey := toc.SelfPublicKey()
928929
for {
929930
n, err := dev.Read(bufs, sizes, tunStartOffset)
930931
if err != nil {
@@ -953,7 +954,7 @@ func derpProbeBandwidthTUN(ctx context.Context, transferTimeSeconds, totalBytesT
953954
copy(pkt[12:16], pkt[16:20])
954955
copy(pkt[16:20], scratch)
955956

956-
if err := fromc.Send(toc.SelfPublicKey(), pkt); err != nil {
957+
if err := fromc.Send(toPubDERPKey, pkt); err != nil {
957958
tunReadErrC <- err
958959
return
959960
}
@@ -971,6 +972,7 @@ func derpProbeBandwidthTUN(ctx context.Context, transferTimeSeconds, totalBytesT
971972
buf := make([]byte, mtu+tunStartOffset)
972973
bufs := make([][]byte, 1)
973974

975+
fromDERPPubKey := fromc.SelfPublicKey()
974976
for {
975977
m, err := toc.Recv()
976978
if err != nil {
@@ -979,7 +981,7 @@ func derpProbeBandwidthTUN(ctx context.Context, transferTimeSeconds, totalBytesT
979981
}
980982
switch v := m.(type) {
981983
case derp.ReceivedPacket:
982-
if v.Source != fromc.SelfPublicKey() {
984+
if v.Source != fromDERPPubKey {
983985
recvErrC <- fmt.Errorf("got data packet from unexpected source, %v", v.Source)
984986
return
985987
}

0 commit comments

Comments
 (0)