Files
tailscale/net/tstun/wrap_injection_errno_test.go
James Tucker c606e83fb2 net/tstun,feature/conn25: make ErrInjectionQueueFull detectable as ENOBUFS
Export ErrInjectionQueueFull, returned by TryInjectOutbound when a full
injection queue forced a packet drop, and define it to wrap
syscall.ENOBUFS on platforms that define that errno. Callers can now
test for buffer exhaustion generically with errors.Is(err,
syscall.ENOBUFS) instead of knowing about tstun's error type. plan9 and
tamago have no ENOBUFS in their syscall packages, so there the error is
a plain sentinel; code that must build on those platforms (or on all
platforms, like feature/conn25) can still match the exported sentinel.

Also stop conn25 from logging queue-full TSMP rejections: those drops
are expected under saturation and are already counted as reason="queue_full"
in the outbound usermetric.

Signed-off-by: James Tucker <[email protected]>
2026-10-13 15:55:43 -07:00

21 lines
529 B
Go

// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause
//go:build !plan9 && !tamago
package tstun
import (
"errors"
"syscall"
"testing"
)
// ErrInjectionQueueFull must match the platform ENOBUFS errno, so callers
// can test for buffer exhaustion without knowing this package's type.
func TestErrInjectionQueueFullMatchesENOBUFS(t *testing.T) {
if !errors.Is(ErrInjectionQueueFull, syscall.ENOBUFS) {
t.Errorf("errors.Is(ErrInjectionQueueFull, syscall.ENOBUFS) = false, want true")
}
}