mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-11 13:18:53 +00:00
prober: remove per-packet DERP pub key copying overheads (#14658)
Updates tailscale/corp#25883 Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user