probelabs/goreplay · error

can't find matching interface

Error message

can't find matching interface

What it means

sock_linux NewSocket walks net.Interfaces() to find the kernel interface matching the pcap.Interface name; no match means the pcap interface list and the kernel's are out of sync (renamed, removed, or unexposed interface), so the socket is not created.

Source

Thrown at internal/capture/sock_linux.go:63

	loopIndex   int32  // this field must filled to avoid reading packet twice on a loopback device
}

// NewSocket returns new M'maped sock_raw on packet version 2.
func NewSocket(pifi pcap.Interface) (*SockRaw, error) {
	var ifi net.Interface

	infs, _ := net.Interfaces()
	found := false
	for _, i := range infs {
		if i.Name == pifi.Name {
			ifi = i
			found = true
			break
		}
	}

	if !found {
		return nil, fmt.Errorf("can't find matching interface")
	}

	// 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)

View on GitHub (pinned to 251e45abd2)

Solutions

  1. Confirm the interface name with 'ip link' right before starting gor
  2. Handle interfaces that disappear/rename dynamically (re-run discovery)
  3. Avoid passing virtual/pcap-only device names that net.Interfaces won't return
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/capture/sock_linux.go:63 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/34d3123afec06dbb. Report an issue: GitHub.