probelabs/goreplay · error

setsockopt packet_version: %v

Error message

setsockopt packet_version: %v

What it means

NewSocket's setsockopt to enable TPACKET_V2 on the AF_PACKET socket failed (old kernel, restricted environment/namespace); the fd is closed and the wrapped errno is returned, so memory-mapped capture can't be set up.

Source

Thrown at internal/capture/sock_linux.go:82

	}

	// sock create
	fd, err := unix.Socket(unix.AF_PACKET, unix.SOCK_RAW, int(ETHALL))
	if err != nil {
		return nil, err
	}
	sock := &SockRaw{
		fd:          fd,
		ifindex:     ifi.Index,
		snaplen:     FRAMESIZE,
		pollTimeout: ^uintptr(0),
	}

	// set packet version
	err = unix.SetsockoptInt(fd, unix.SOL_PACKET, unix.PACKET_VERSION, unix.TPACKET_V2)
	if err != nil {
		unix.Close(fd)
		return nil, fmt.Errorf("setsockopt packet_version: %v", err)
	}

	// bind to interface
	addr := unix.RawSockaddrLinklayer{
		Family:   unix.AF_PACKET,
		Protocol: ETHALL,
		Ifindex:  int32(ifi.Index),
	}
	_, _, e := unix.Syscall(
		unix.SYS_BIND,
		uintptr(fd),
		uintptr(unsafe.Pointer(&addr)),
		uintptr(unix.SizeofSockaddrLinklayer),
	)
	if e != 0 {
		unix.Close(fd)
		return nil, e
	}

View on GitHub (pinned to 251e45abd2)

Solutions

  1. Run on a kernel supporting TPACKET_V2 (>= 2.6.27)
  2. Check seccomp/apparmor/container restrictions blocking setsockopt
  3. Ensure the process has CAP_NET_RAW; fall back to pcap capture if not
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/capture/sock_linux.go:82 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/81896bfc38bfa7a8. Report an issue: GitHub.