Accepted
BPF operations can fail in many ways:
Different error types require different handling:
All BPF errors are thrown as ex-info with structured data:
(throw (ex-info "BPF syscall failed"
{:type :bpf-error
:category :permission
:errno 1
:errno-keyword :eperm
:operation :prog-load
:details {...}}))
We define categories in clj-ebpf.errors:
:permission - CAP_BPF, CAP_SYS_ADMIN issues:verifier - Program rejected by verifier:resource - Resource limits exceeded:not-found - Map/program not found:invalid - Invalid arguments:system - Other system errors(errors/permission-error? e) ; Check if permission issue
(errors/verifier-error? e) ; Check if verifier rejection
(errors/resource-error? e) ; Check if resource limit
(errors/format-error e) ; Human-readable error message
(errors/suggest-fix e) ; Suggested remediation
For verifier errors, we capture and parse the verifier log:
(try
(load-program prog :xdp)
(catch Exception e
(when (errors/verifier-error? e)
(println (:verifier-log (ex-data e))))))
(try
(maps/create {:type :hash :key-size 4 :value-size 8 :max-entries 1000000})
(catch Exception e
(cond
(errors/permission-error? e)
(println "Need CAP_BPF capability")
(errors/resource-error? e)
(println "Reduce max-entries or increase limits")
:else
(throw e))))
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |