probelabs/goreplay · error
expected %d snap length to be at least 0
Error message
expected %d snap length to be at least 0
What it means
SetSnapLen rejects a negative snaplen argument before touching the socket; snap length is a capture size bound and a negative value is invalid input (it is silently clamped to FRAMESIZE if too large, but negatives always fail).
Source
Thrown at internal/capture/sock_linux.go:189
func (sock *SockRaw) Close() (err error) {
sock.mu.Lock()
defer sock.mu.Unlock()
if sock.fd != -1 {
unix.Munmap(sock.buf)
sock.buf = nil
err = unix.Close(sock.fd)
sock.fd = -1
}
return
}
// SetSnapLen sets the maximum capture length to the given value.
// for this to take effects on the kernel level SetBPFilter should be called too.
func (sock *SockRaw) SetSnapLen(snap int) error {
sock.mu.Lock()
defer sock.mu.Unlock()
if snap < 0 {
return fmt.Errorf("expected %d snap length to be at least 0", snap)
}
if snap > FRAMESIZE {
snap = FRAMESIZE
}
sock.snaplen = snap
return nil
}
// SetTimeout sets poll wait timeout for the socket.
// negative value will block forever
func (sock *SockRaw) SetTimeout(t time.Duration) error {
sock.mu.Lock()
defer sock.mu.Unlock()
sock.pollTimeout = uintptr(t)
return nil
}
// GetSnapLen returns the maximum capture lengthView on GitHub (pinned to 251e45abd2)
Solutions
- Pass a non-negative snaplen >= 0
- Check the config computation that produced the snap value
- Clamp caller-side values before calling SetSnapLen
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/capture/sock_linux.go:189 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of probelabs/goreplay@251e45abd2 (2026-09-02).
Data as JSON: /api/errors/b46b663158ab8fa7.
Report an issue: GitHub.