{"record":{"id":"3450325ed282aaa3","repo":"OpenNHP/opennhp","slug":"unsupported-map-type-d","errorCode":null,"errorMessage":"unsupported map type: %d","messagePattern":"unsupported map type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nhp/utils/ebpf/ebpf.go","lineNumber":459,"sourceCode":"\tcase MapTypeSrcPortList:\n\t\t//base the map port_list\n\t\terr = AddEbpfRuleForSrcDestPortList(params.SrcIP, params.DstPortStart, params.DstPortEnd, TtlSec64)\n\t\tif err != nil {\n\t\t\tlog.Error(\"failed add ebpf src: %s dst port start: %d dst port end: %d\", params.SrcIP, params.DstPortStart, params.DstPortEnd)\n\t\t\treturn err\n\t\t}\n\n\tcase MapTypeProtocolPort:\n\t\t//base the map protocol_port\n\t\tdstPort := uint16(params.DstPort)\n\t\terr = AddEbpfRuleForProtocolPort(protocol, dstPort, TtlSec64)\n\t\tif err != nil {\n\t\t\tlog.Error(\"failed add ebpf protocol: %s dst port: %d\", params.Protocol, params.DstPort)\n\t\t\treturn err\n\t\t}\n\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported map type: %d\", mapType)\n\t}\n\n\treturn nil\n}\n\n// Parse the IP address\nfunc parseIP(ipStr string) (uint32, error) {\n\tip := net.ParseIP(ipStr)\n\tif ip == nil {\n\t\tlog.Error(\"invalid IP address: %s\", ipStr)\n\t\treturn 0, fmt.Errorf(\"invalid IP address: %s\", ipStr)\n\t}\n\tip = ip.To4()\n\tif ip == nil {\n\t\tlog.Error(\"only IPv4 addresses are supported: %s\", ipStr)\n\t\treturn 0, fmt.Errorf(\"only IPv4 addresses are supported: %s\", ipStr)\n\t}\n\treturn binary.LittleEndian.Uint32(ip), nil","sourceCodeStart":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/nhp/utils/ebpf/ebpf.go#L441-L477","documentation":"EbpfRuleAdd dispatches on the mapType argument to select the eBPF map update function (whitelist and related types are handled in preceding switch cases). A mapType integer that matches none of the supported constants falls into the default branch and is rejected with \"unsupported map type: %d\", protecting the eBPF maps from being updated via an undefined type.","triggerScenarios":"Calling EbpfRuleAdd (directly or via HandleAccessControl) with a mapType constant the build does not define, a hardcoded integer instead of the exported MapType* constants, or a map type from a newer/older version mismatch between the calling component and the ebpf package.","commonSituations":"Passing a raw int like 3 instead of utils.MapTypeWhitelist; two components compiled against different versions where map-type constants were renumbered; a typo'd constant or an eBPF feature not compiled in (no `make ebpf`).","solutions":["Use the exported constants (e.g. utils.MapTypeWhitelist) instead of raw integers for mapType","Check the constants defined in nhp/utils/ebpf and use one of the supported values","Rebuild both the caller and the ebpf package from the same source revision to avoid constant mismatches","Ensure eBPF support was actually built (make ebpf) if a map type is gated behind ebpf compilation"],"exampleFix":"// before\nutils.EbpfRuleAdd(3, params, ttl) // error: unsupported map type: 3\n// after\nutils.EbpfRuleAdd(utils.MapTypeWhitelist, params, ttl)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func ok(t int) bool { return t == utils.MapTypeWhitelist }","tryCatchPattern":null,"preventionTips":["Use exported constants only"],"tags":["go","ebpf","enum","validation"],"backgroundTag":"unsupported-enum-value","analyzedSha":"6e04ca5ff03222a699c24205cd4bf8fee9af7ffe","analyzedAt":"2026-09-07T15:44:59.941Z","contentChangedAt":"2026-09-07T15:44:59.941Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}