Skip to content

routing.New() panics on non-Linux — check/wait/monitor crash on macOS/Windows/BSD #34

Description

@dolph

What breaks

router.go:47 calls routing.New() from github.com/google/gopacket/routing. The upstream package is Linux-only and provides a stub for every other GOOS:

// gopacket/routing/other.go
// +build !linux

func New() (Router, error) {
    panic("router only implemented in linux")
}

Result: the binary will go build and start on macOS / Windows / FreeBSD, but the first destination check unrecoverably crashes the process with:

panic: router only implemented in linux

This is hit by every subcommand that does network work — check, wait, waitfor, monitor — via Destination.Check()GetRoute() in destinations.go:168. There's no recover() anywhere, so the whole process dies on the first non-localhost destination.

Why this matters

  • go build ./... succeeds on every platform, so a macOS/Windows contributor's local ./build.sh (or go install) produces an apparently-working binary that fatally crashes the moment it's used.
  • The README and CLI advertise no platform restrictions.

Suggested fixes (any one)

  1. Declare Linux-only at the module level. Add //go:build linux to router.go (and a router_other.go stub that returns a no-op Route with the destination IP, no gateway, no source iface) so the rest of the tool degrades gracefully on other platforms. The existing code in destinations.go:168-171 already tolerates GetRoute() returning an error.

  2. Fail with a clear error rather than a panic. Wrap the call:

    func GetRoute(ip net.IP) (route *Route, err error) {
        defer func() {
            if r := recover(); r != nil {
                err = fmt.Errorf("routing not supported on %s", runtime.GOOS)
            }
        }()
        ...
    }

    This at least lets check/wait/monitor continue without route metadata on non-Linux.

  3. Declare Linux-only and refuse to build on other platforms. Add //go:build linux to connectivity.go (the package main) so go build cleanly fails on macOS/Windows with a build error instead of producing a crashing binary.

Option (3) is the cleanest given how Linux-centric the rest of the design is (/etc/connectivity.yml, statsd-via-UDP defaults, the release pipeline already only builds linux/amd64 per #26). Combined with a README note this gives users an honest experience.

Related: this is broader than #26 (single-arch release): the issue is whether the code works on other platforms, not whether binaries are built for them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions