prober: remove DERP pub key copying overheads in qd and non-tun measures (#14659)
Some checks are pending
checklocks / checklocks (push) Waiting to run
CodeQL / Analyze (go) (push) Waiting to run
Dockerfile build / deploy (push) Waiting to run
CI / race-root-integration (1/4) (push) Waiting to run
CI / race-root-integration (2/4) (push) Waiting to run
CI / race-root-integration (3/4) (push) Waiting to run
CI / race-root-integration (4/4) (push) Waiting to run
CI / test (-coverprofile=/tmp/coverage.out, amd64) (push) Waiting to run
CI / test (-race, amd64, 1/3) (push) Waiting to run
CI / test (-race, amd64, 2/3) (push) Waiting to run
CI / test (-race, amd64, 3/3) (push) Waiting to run
CI / test (386) (push) Waiting to run
CI / windows (push) Waiting to run
CI / privileged (push) Waiting to run
CI / vm (push) Waiting to run
CI / race-build (push) Waiting to run
CI / cross (386, linux) (push) Waiting to run
CI / cross (amd64, darwin) (push) Waiting to run
CI / cross (amd64, freebsd) (push) Waiting to run
CI / cross (amd64, openbsd) (push) Waiting to run
CI / cross (amd64, windows) (push) Waiting to run
CI / cross (arm, 5, linux) (push) Waiting to run
CI / cross (arm, 7, linux) (push) Waiting to run
CI / cross (arm64, darwin) (push) Waiting to run
CI / cross (arm64, linux) (push) Waiting to run
CI / cross (arm64, windows) (push) Waiting to run
CI / cross (loong64, linux) (push) Waiting to run
CI / ios (push) Waiting to run
CI / crossmin (amd64, illumos) (push) Waiting to run
CI / crossmin (amd64, plan9) (push) Waiting to run
CI / crossmin (amd64, solaris) (push) Waiting to run
CI / crossmin (ppc64, aix) (push) Waiting to run
CI / android (push) Waiting to run
CI / wasm (push) Waiting to run
CI / tailscale_go (push) Waiting to run
CI / fuzz (push) Waiting to run
CI / depaware (push) Waiting to run
CI / go_generate (push) Waiting to run
CI / go_mod_tidy (push) Waiting to run
CI / licenses (push) Waiting to run
CI / staticcheck (386, windows) (push) Waiting to run
CI / staticcheck (amd64, darwin) (push) Waiting to run
CI / staticcheck (amd64, linux) (push) Waiting to run
CI / staticcheck (amd64, windows) (push) Waiting to run
CI / notify_slack (push) Blocked by required conditions
CI / check_mergeability (push) Blocked by required conditions

Updates tailscale/corp#25883

Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
Jordan Whited 2025-01-15 16:28:49 -08:00 committed by GitHub
parent 84b0379dd5
commit 00bd906797
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -431,6 +431,7 @@ type txRecord struct {
t := time.NewTicker(time.Second / time.Duration(packetsPerSecond))
defer t.Stop()
toDERPPubKey := toc.SelfPublicKey()
seq := uint64(0)
for {
select {
@ -446,7 +447,7 @@ type txRecord struct {
txRecordsMu.Unlock()
binary.BigEndian.PutUint64(pkt, seq)
seq++
if err := fromc.Send(toc.SelfPublicKey(), pkt); err != nil {
if err := fromc.Send(toDERPPubKey, pkt); err != nil {
sendErrC <- fmt.Errorf("sending packet %w", err)
return
}
@ -460,6 +461,7 @@ type txRecord struct {
go func() {
defer wg.Done()
defer close(recvFinishedC) // to break out of 'select' below.
fromDERPPubKey := fromc.SelfPublicKey()
for {
m, err := toc.Recv()
if err != nil {
@ -469,7 +471,7 @@ type txRecord struct {
switch v := m.(type) {
case derp.ReceivedPacket:
now := time.Now()
if v.Source != fromc.SelfPublicKey() {
if v.Source != fromDERPPubKey {
recvFinishedC <- fmt.Errorf("got data packet from unexpected source, %v", v.Source)
return
}
@ -767,9 +769,10 @@ func runDerpProbeNodePair(ctx context.Context, from, to *tailcfg.DERPNode, fromc
// Send the packets.
sendc := make(chan error, 1)
go func() {
toDERPPubKey := toc.SelfPublicKey()
for idx, pkt := range pkts {
inFlight.AcquireContext(ctx)
if err := fromc.Send(toc.SelfPublicKey(), pkt); err != nil {
if err := fromc.Send(toDERPPubKey, pkt); err != nil {
sendc <- fmt.Errorf("sending packet %d: %w", idx, err)
return
}
@ -781,6 +784,7 @@ func runDerpProbeNodePair(ctx context.Context, from, to *tailcfg.DERPNode, fromc
go func() {
defer close(recvc) // to break out of 'select' below.
idx := 0
fromDERPPubKey := fromc.SelfPublicKey()
for {
m, err := toc.Recv()
if err != nil {
@ -790,7 +794,7 @@ func runDerpProbeNodePair(ctx context.Context, from, to *tailcfg.DERPNode, fromc
switch v := m.(type) {
case derp.ReceivedPacket:
inFlight.Release()
if v.Source != fromc.SelfPublicKey() {
if v.Source != fromDERPPubKey {
recvc <- fmt.Errorf("got data packet %d from unexpected source, %v", idx, v.Source)
return
}
@ -925,7 +929,7 @@ func derpProbeBandwidthTUN(ctx context.Context, transferTimeSeconds, totalBytesT
destinationAddrBytes := destinationAddr.AsSlice()
scratch := make([]byte, 4)
toPubDERPKey := toc.SelfPublicKey()
toDERPPubKey := toc.SelfPublicKey()
for {
n, err := dev.Read(bufs, sizes, tunStartOffset)
if err != nil {
@ -954,7 +958,7 @@ func derpProbeBandwidthTUN(ctx context.Context, transferTimeSeconds, totalBytesT
copy(pkt[12:16], pkt[16:20])
copy(pkt[16:20], scratch)
if err := fromc.Send(toPubDERPKey, pkt); err != nil {
if err := fromc.Send(toDERPPubKey, pkt); err != nil {
tunReadErrC <- err
return
}