{"record":{"id":"b1512f9df7d2c699","repo":"lima-vm/lima","slug":"unsupported-protocol-d","errorCode":null,"errorMessage":"unsupported protocol: %d","messagePattern":"unsupported protocol: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/guestagent/sockets/sockets_linux.go","lineNumber":53,"sourceCode":"func query(conn *netlink.Conn, family, proto int) ([]netlink.Message, error) {\n\treq := buildInetDiagReqV2(family, proto)\n\tmsg := netlink.Message{\n\t\tHeader: netlink.Header{\n\t\t\tType:  unix.SOCK_DIAG_BY_FAMILY,\n\t\t\tFlags: netlink.Request | netlink.Dump,\n\t\t},\n\t\tData: req,\n\t}\n\tmsgs, err := conn.Execute(msg)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn msgs, nil\n}\n\nfunc parseMessages(msgs []netlink.Message, proto int) ([]Socket, error) {\n\tif proto != unix.IPPROTO_TCP && proto != unix.IPPROTO_UDP {\n\t\treturn nil, fmt.Errorf(\"unsupported protocol: %d\", proto)\n\t}\n\tvar sockets []Socket\n\tfor _, m := range msgs {\n\t\tdata := m.Data\n\t\t// inet_diag_msg minimum size ~72 bytes (4 + 48 + 20)\n\t\tif len(data) < 72 {\n\t\t\tcontinue\n\t\t}\n\t\tfamily := int(data[0])\n\t\tstate := data[1]\n\t\t// data[2] timer, data[3] retrans (ignored here)\n\t\t// id begins at offset 4:\n\t\t// sport (2B, big-endian), dport (2B, big-endian)\n\t\tsport := binary.BigEndian.Uint16(data[4:6])\n\n\t\tsrc := data[8:24] // 16 bytes\n\n\t\tvar localIP net.IP","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/guestagent/sockets/sockets_linux.go#L35-L71","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Call List only with unix.IPPROTO_TCP or unix.IPPROTO_UDP.","If a new protocol is needed, add a corresponding inet_diag request builder and branch in parseMessages.","Check that the protocol constant passed is not accidentally zeroed/unset."],"exampleFix":"// before\nlist, err := l.List(0) // unsupported\n// after\nlist, err := l.List(unix.IPPROTO_TCP)","handlingStrategy":"validation","validationCode":"// validate protocol before calling the lister\nfunc validProto(p int) bool { return p == unix.IPPROTO_TCP || p == unix.IPPROTO_UDP }\nif !validProto(proto) {\n\treturn nil, fmt.Errorf(\"caller bug: protocol %d not TCP/UDP\", proto)\n}","typeGuard":null,"tryCatchPattern":"sockets, err := lister.List(proto)\nif err != nil {\n\tif strings.Contains(err.Error(), \"unsupported protocol\") {\n\t\tlog.WithField(\"proto\", proto).Error(\"protocol constant bug in caller\")\n\t}\n\treturn err\n}","preventionTips":["Only pass the unix.IPPROTO_TCP / unix.IPPROTO_UDP constants.","Avoid computed/uninitialized protocol values.","Extend parseMessages explicitly when adding a new protocol.","Cover each supported protocol in unit tests."],"tags":["guestagent","netlink","sockets","linux"],"backgroundTag":"unsupported-protocol","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}