Files
tailscale/net/tstun/wrap_injection_errno.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

25 lines
747 B
Go

// Copyright (c) Tailscale Inc & contributors
// SPDX-License-Identifier: BSD-3-Clause
//go:build !plan9 && !tamago
package tstun
import (
"fmt"
"syscall"
)
// ErrInjectionQueueFull is returned when a full injection queue forced a
// best-effort packet to be dropped rather than queued. It wraps
// syscall.ENOBUFS, the platform's "no buffer space available" errno, so
// callers can test for buffer exhaustion without knowing this package's
// type:
//
// errors.Is(err, syscall.ENOBUFS)
//
// Dropped packets are already counted as reason="queue_full" in the
// tailscaled_outbound_dropped_packets_total usermetric, so callers need not
// log this error.
var ErrInjectionQueueFull = fmt.Errorf("injection queue full: %w", syscall.ENOBUFS)