probelabs/goreplay · error

setsockopt packet_rx_ring: %v

Error message

setsockopt packet_rx_ring: %v

What it means

NewSocket failed creating the PACKET_RX_RING shared-memory ring via setsockopt (usually ENOMEM or insufficient privileges/no hugepage support); the fd is closed and the errno is wrapped, so the memory-mapped receive path cannot be established.

Source

Thrown at internal/capture/sock_linux.go:112

		uintptr(unsafe.Pointer(&addr)),
		uintptr(unix.SizeofSockaddrLinklayer),
	)
	if e != 0 {
		unix.Close(fd)
		return nil, e
	}

	// create shared-memory ring buffer
	tp := &unix.TpacketReq{
		Block_size: BLOCKSIZE,
		Block_nr:   BLOCKNR,
		Frame_size: FRAMESIZE,
		Frame_nr:   FRAMENR,
	}
	err = unix.SetsockoptTpacketReq(sock.fd, unix.SOL_PACKET, unix.PACKET_RX_RING, tp)
	if err != nil {
		unix.Close(fd)
		return nil, fmt.Errorf("setsockopt packet_rx_ring: %v", err)
	}
	sock.buf, err = unix.Mmap(
		sock.fd,
		0,
		BLOCKSIZE*BLOCKNR,
		unix.PROT_READ|unix.PROT_WRITE,
		unix.MAP_SHARED|MAPHUGE2MB,
	)
	if err != nil {
		unix.Close(fd)
		return nil, fmt.Errorf("socket mmap error: %v", err)
	}
	return sock, nil
}

// ReadPacketData implements gopacket.PacketDataSource.
func (sock *SockRaw) ReadPacketData() (buf []byte, ci gopacket.CaptureInfo, err error) {
	sock.mu.Lock()

View on GitHub (pinned to 251e45abd2)

Solutions

  1. Free memory or reduce ring size (BLOCKSIZE/BLOCKNR) if ENOMEM
  2. Verify hugepage (2MB) availability for the MAPHUGE2MB mapping
  3. Run with CAP_NET_RAW and check container resource limits
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/capture/sock_linux.go:112 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/66dfef157dc43007. Report an issue: GitHub.