OpenNHP/opennhp · error
unsupported map type
Error message
unsupported map type: %d
What it means
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.
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
Example fix
// before utils.EbpfRuleAdd(3, params, ttl) // error: unsupported map type: 3 // after utils.EbpfRuleAdd(utils.MapTypeWhitelist, params, ttl)
Defensive patterns
Strategy: type-guard
Type guard
func ok(t int) bool { return t == utils.MapTypeWhitelist } Prevention
- Use exported constants only
When it happens
Trigger: 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.
Common situations: 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`).
Related errors
- value is out of range for uint16
- unsupported protocol
- cluster instance # : must set either Host or Ip
- cluster instance # : invalid port
- AuthServiceId is required
AI-assisted analysis of OpenNHP/opennhp@6e04ca5ff0 (2026-09-07).
Data as JSON: /api/errors/3450325ed282aaa3.
Report an issue: GitHub.
Appendix: source
Thrown at nhp/utils/ebpf/ebpf.go:459
case MapTypeSrcPortList:
//base the map port_list
err = AddEbpfRuleForSrcDestPortList(params.SrcIP, params.DstPortStart, params.DstPortEnd, TtlSec64)
if err != nil {
log.Error("failed add ebpf src: %s dst port start: %d dst port end: %d", params.SrcIP, params.DstPortStart, params.DstPortEnd)
return err
}
case MapTypeProtocolPort:
//base the map protocol_port
dstPort := uint16(params.DstPort)
err = AddEbpfRuleForProtocolPort(protocol, dstPort, TtlSec64)
if err != nil {
log.Error("failed add ebpf protocol: %s dst port: %d", params.Protocol, params.DstPort)
return err
}
default:
return fmt.Errorf("unsupported map type: %d", mapType)
}
return nil
}
// Parse the IP address
func parseIP(ipStr string) (uint32, error) {
ip := net.ParseIP(ipStr)
if ip == nil {
log.Error("invalid IP address: %s", ipStr)
return 0, fmt.Errorf("invalid IP address: %s", ipStr)
}
ip = ip.To4()
if ip == nil {
log.Error("only IPv4 addresses are supported: %s", ipStr)
return 0, fmt.Errorf("only IPv4 addresses are supported: %s", ipStr)
}
return binary.LittleEndian.Uint32(ip), nilView on GitHub (pinned to 6e04ca5ff0)