slackhq/nebula · warning

unsupported sock type: %T

Error message

unsupported sock type: %T

What it means

LocalAddr converts a unix.Sockaddr returned by getsockname into a netip.AddrPort; if the kernel returns a sockaddr type it does not handle (anything other than SockaddrInet4 or SockaddrInet6), it returns this error including the Go type. This should be practically unreachable on Linux and indicates an unexpected kernel/golang.org/x/sys behavior.

Source

Thrown at udp/udp_linux.go:173

	return unix.GetsockoptInt(u.sysFd, unix.SOL_SOCKET, unix.SO_SNDBUF)
}

func (u *StdConn) GetSoMark() (int, error) {
	return unix.GetsockoptInt(u.sysFd, unix.SOL_SOCKET, unix.SO_MARK)
}

func (u *StdConn) LocalAddr() (netip.AddrPort, error) {
	sa, err := unix.Getsockname(u.sysFd)
	if err != nil {
		return netip.AddrPort{}, err
	}
	switch sa := sa.(type) {
	case *unix.SockaddrInet4:
		return netip.AddrPortFrom(netip.AddrFrom4(sa.Addr), uint16(sa.Port)), nil
	case *unix.SockaddrInet6:
		return netip.AddrPortFrom(netip.AddrFrom16(sa.Addr), uint16(sa.Port)), nil
	default:
		return netip.AddrPort{}, fmt.Errorf("unsupported sock type: %T", sa)
	}
}

// recvmmsg does one blocking recvmmsg (MSG_WAITFORONE), reading up to len(msgs) datagrams.
func (u *StdConn) recvmmsg(msgs []rawMessage) (int, error) {
	r, _, errno := unix.Syscall6(
		unix.SYS_RECVMMSG,
		uintptr(u.sysFd),
		uintptr(unsafe.Pointer(&msgs[0])),
		uintptr(len(msgs)),
		unix.MSG_WAITFORONE,
		0,
		0,
	)
	if errno != 0 {
		if u.closed.Load() {
			return 0, net.ErrClosed
		}

View on GitHub (pinned to dd8f660c0a)

Solutions

  1. Confirm the socket fd was created as AF_INET/AF_INET6 by udp.NewListener and not modified
  2. Upgrade golang.org/x/sys to a current version and rebuild
  3. File a bug with the Go kernel socktype printed in the error (%T) if it occurs on stock code
  4. As a workaround, cache the AddrPort from listener setup instead of querying LocalAddr at runtime
Defensive patterns

Strategy: try-catch

Try / catch

ap, err := u.LocalAddr()
if err != nil {
    if strings.HasPrefix(err.Error(), "unsupported sock type") {
        // fall back to the AddrPort captured at listener creation
        ap = configuredListenAddr
    }
    log.Warn("LocalAddr failed", "err", err)
}

Prevention

When it happens

Trigger: Calling StdConn.LocalAddr() when unix.Getsockname returns a sockaddr type other than *unix.SockaddrInet4 or *unix.SockaddrInet6 (e.g. an AF_UNIX or unexpected family).

Common situations: Very old or patched x/sys/unix versions surfacing a different concrete sockaddr type; running code modified to create non-INET sockets; upstream bug reports of impossible states.

Related errors


AI-assisted analysis of slackhq/nebula@dd8f660c0a (2026-09-03). Data as JSON: /api/errors/459a7dd8c5e44b14. Report an issue: GitHub.