lima-vm/lima · error

unsupported protocol: %d

Error message

unsupported protocol: %d

What it means

parseMessages validates that the requested protocol is either TCP (6) or UDP (17) before decoding inet_diag netlink messages; any other protocol value is rejected. This is an internal guard in the guestagent socket-port scanner.

Source

Thrown at pkg/guestagent/sockets/sockets_linux.go:53

func query(conn *netlink.Conn, family, proto int) ([]netlink.Message, error) {
	req := buildInetDiagReqV2(family, proto)
	msg := netlink.Message{
		Header: netlink.Header{
			Type:  unix.SOCK_DIAG_BY_FAMILY,
			Flags: netlink.Request | netlink.Dump,
		},
		Data: req,
	}
	msgs, err := conn.Execute(msg)
	if err != nil {
		return nil, err
	}
	return msgs, nil
}

func parseMessages(msgs []netlink.Message, proto int) ([]Socket, error) {
	if proto != unix.IPPROTO_TCP && proto != unix.IPPROTO_UDP {
		return nil, fmt.Errorf("unsupported protocol: %d", proto)
	}
	var sockets []Socket
	for _, m := range msgs {
		data := m.Data
		// inet_diag_msg minimum size ~72 bytes (4 + 48 + 20)
		if len(data) < 72 {
			continue
		}
		family := int(data[0])
		state := data[1]
		// data[2] timer, data[3] retrans (ignored here)
		// id begins at offset 4:
		// sport (2B, big-endian), dport (2B, big-endian)
		sport := binary.BigEndian.Uint16(data[4:6])

		src := data[8:24] // 16 bytes

		var localIP net.IP

View on GitHub (pinned to dd909d0973)

Solutions

  1. Call List only with unix.IPPROTO_TCP or unix.IPPROTO_UDP.
  2. If a new protocol is needed, add a corresponding inet_diag request builder and branch in parseMessages.
  3. Check that the protocol constant passed is not accidentally zeroed/unset.

Example fix

// before
list, err := l.List(0) // unsupported
// after
list, err := l.List(unix.IPPROTO_TCP)
Defensive patterns

Strategy: validation

Validate before calling

// validate protocol before calling the lister
func validProto(p int) bool { return p == unix.IPPROTO_TCP || p == unix.IPPROTO_UDP }
if !validProto(proto) {
	return nil, fmt.Errorf("caller bug: protocol %d not TCP/UDP", proto)
}

Try / catch

sockets, err := lister.List(proto)
if err != nil {
	if strings.Contains(err.Error(), "unsupported protocol") {
		log.WithField("proto", proto).Error("protocol constant bug in caller")
	}
	return err
}

Prevention

When it happens

Trigger: parseMessages called from List (or tests) with a proto argument other than unix.IPPROTO_TCP or unix.IPPROTO_UDP — e.g. a caller passing 0 or an unsupported protocol constant.

Common situations: Code changes adding a new protocol (e.g. SCTP) without extending parseMessages; a caller passing the wrong constant; test scaffolding using an invented protocol number.

Related errors


AI-assisted analysis of lima-vm/lima@dd909d0973 (2026-09-01). Data as JSON: /api/errors/b1512f9df7d2c699. Report an issue: GitHub.