{"record":{"id":"449aeb9f74cc630d","repo":"OpenNHP/opennhp","slug":"ebpf-functionality-is-only-supported-on-linux-cur","errorCode":null,"errorMessage":"eBPF functionality is only supported on Linux, current platform is not Linux","messagePattern":"eBPF functionality is only supported on Linux, current platform is not Linux","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"endpoints/ac/ebpf/ebpf_other.go","lineNumber":13,"sourceCode":"//go:build !linux\n\npackage ebpf\n\nimport (\n\t// \"log\"\n\n\t\"fmt\"\n\n\t\"github.com/OpenNHP/opennhp/nhp/log\"\n)\n\nvar ErrEBPFSupportedOnlyOnLinux = fmt.Errorf(\"eBPF functionality is only supported on Linux, current platform is not Linux\")\nvar (\n\tDenyLogger *log.Logger\n\tAcLogger   *log.Logger\n)\n\nfunc EbpfEngineLoad(dirPath string, logLevel int, acId string) error {\n\tlog.Info(\"eBPF function must be compiled on Linux OS\")\n\treturn ErrEBPFSupportedOnlyOnLinux\n}\n\n// clean eBPF map file\nfunc CleanupBPFFiles() {\n\tlog.Info(\"ebpf func must be compile based linux os\")\n}\n","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/OpenNHP/opennhp/blob/6e04ca5ff03222a699c24205cd4bf8fee9af7ffe/endpoints/ac/ebpf/ebpf_other.go#L1-L28","documentation":"ErrEBPFSupportedOnlyOnLinux is a package-level sentinel error returned by EbpfEngineLoad and getBootTimeNanos in build-tag-guarded files (ebpf_other.go) compiled on non-Linux platforms. The eBPF/XDP deny-path engine depends on Linux kernel facilities (XDP programs, BPF maps, /proc boot time), so any attempt to use it elsewhere fails immediately with this error.","triggerScenarios":"Calling endpoints/ac/ebpf.EbpfEngineLoad (or nhp/utils/ebpf getBootTimeNanos) on a darwin/windows build, or when the file was compiled without the Linux build tag; also returned when AC FilterMode is FilterMode_EBPFXDP on a non-Linux host.","commonSituations":"Developer builds nhp-ac on macOS for local dev with filter_mode=ebpf_xdp in config.toml; CI runner on non-Linux OS exercises the eBPF code path; cross-compilation produces a stub build.","solutions":["Run nhp-ac on Linux (kernel >= the version required by cilium/ebpf) with root/CAP_BPF+CAP_NET_ADMIN","Set filter_mode = 0 (FilterMode_IPTABLES) in the AC config on non-Linux platforms","Guard code with runtime.GOOS == \"linux\" before selecting the eBPF engine","Ensure the eBPF object files were compiled (make ebpf requires clang) if on Linux but still hitting the stub"],"exampleFix":"// before\nif a.config.FilterMode == FilterMode_EBPFXDP {\n    err := ebpf.EbpfEngineLoad(...)\n// after\nif a.config.FilterMode == FilterMode_EBPFXDP {\n    if runtime.GOOS != \"linux\" {\n        log.Warn(\"eBPF unsupported on %s, falling back to iptables\", runtime.GOOS)\n        a.config.FilterMode = FilterMode_IPTABLES\n    } else if err := ebpf.EbpfEngineLoad(...); err != nil { ... }","handlingStrategy":"validation","validationCode":"if runtime.GOOS != \"linux\" {\n\treturn fmt.Errorf(\"eBPF requires Linux, got %s\", runtime.GOOS)\n}\nif ! capabilityHasCAPBPF() { ... }","typeGuard":null,"tryCatchPattern":"if err := ebpf.EbpfEngineLoad(dir, lvl, id); err != nil {\n\tif errors.Is(err, ebpf.ErrEBPFSupportedOnlyOnLinux) {\n\t\tlog.Warn(\"falling back to iptables filter mode\")\n\t\tconf.FilterMode = ac.FilterMode_IPTABLES\n\t}\n}","preventionTips":["Set filter_mode=iptables on non-Linux dev machines","Gate eBPF paths on runtime.GOOS and build tags","Document kernel/capability requirements (root or CAP_BPF/CAP_NET_ADMIN)"],"tags":["ebpf","linux","platform","xdp"],"backgroundTag":"unsupported-platform","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"}