XDP (eXpress Data Path) support for high-performance packet processing
XDP (eXpress Data Path) support for high-performance packet processing
(attach-xdp ifname prog-fd & flags)Attach XDP program to a network interface.
Parameters:
Returns the interface index.
Example: (attach-xdp "eth0" prog-fd [:drv-mode])
Attach XDP program to a network interface.
Parameters:
- ifname: Interface name (e.g., "eth0") or interface index (integer)
- prog-fd: BPF program file descriptor
- flags: XDP attachment flags (optional, defaults to :drv-mode)
:update-if-noexist - Only attach if no XDP program exists
:skb-mode - Generic XDP (slower, kernel mode)
:drv-mode - Native XDP (driver mode, fastest)
:hw-mode - Hardware offload mode
:replace - Replace existing program
Returns the interface index.
Example:
(attach-xdp "eth0" prog-fd [:drv-mode])(detach-xdp ifname & flags)Detach XDP program from a network interface.
Parameters:
Example: (detach-xdp "eth0")
Detach XDP program from a network interface. Parameters: - ifname: Interface name (e.g., "eth0") or interface index (integer) - flags: XDP detachment flags (optional, should match attachment flags) Example: (detach-xdp "eth0")
(interface-index->name ifindex)Get network interface name from index.
Example: (interface-index->name 2) => "eth0"
Get network interface name from index. Example: (interface-index->name 2) => "eth0"
(interface-name->index ifname)Get network interface index from name.
Example: (interface-name->index "eth0") => 2
Get network interface index from name. Example: (interface-name->index "eth0") => 2
(load-xdp-from-file path section-name & options)Load XDP program from ELF file.
Parameters:
Returns program file descriptor.
Example: (load-xdp-from-file "filter.o" "xdp" {:prog-name "xdp_filter"})
Load XDP program from ELF file.
Parameters:
- path: Path to ELF file containing XDP program
- section-name: ELF section name (default "xdp")
- options: Additional options passed to load-xdp-program
Returns program file descriptor.
Example:
(load-xdp-from-file "filter.o" "xdp" {:prog-name "xdp_filter"})(load-xdp-program bytecode
&
{:keys [prog-name license log-level log-size]
:or {license "GPL" log-level 0 log-size 0}})Load XDP program from bytecode.
Parameters:
Returns program file descriptor.
Example: (load-xdp-program bytecode {:prog-name "xdp_filter" :license "GPL"})
Load XDP program from bytecode.
Parameters:
- bytecode: BPF bytecode (byte array or vector of instruction maps)
- options: Map of options:
- :prog-name - Program name (optional)
- :license - License string (default "GPL")
- :log-level - Verifier log level (default 0)
- :log-size - Log buffer size (default 0)
Returns program file descriptor.
Example:
(load-xdp-program bytecode {:prog-name "xdp_filter" :license "GPL"})(with-xdp [binding attach-expr] & body)Attach XDP program to interface and ensure detachment after use.
Example: (with-xdp [ifindex (attach-xdp "eth0" prog-fd [:drv-mode])] ;; XDP program is active (do-packet-processing))
Attach XDP program to interface and ensure detachment after use.
Example:
(with-xdp [ifindex (attach-xdp "eth0" prog-fd [:drv-mode])]
;; XDP program is active
(do-packet-processing))(with-xdp-program [prog-binding bytecode options iface-binding ifname flags]
&
body)Load XDP program, attach to interface, and ensure cleanup.
Example: (with-xdp-program [prog-fd bytecode {:prog-name "xdp_filter"} ifindex "eth0" [:drv-mode]] ;; XDP program is loaded and attached (process-packets))
Load XDP program, attach to interface, and ensure cleanup.
Example:
(with-xdp-program [prog-fd bytecode {:prog-name "xdp_filter"}
ifindex "eth0" [:drv-mode]]
;; XDP program is loaded and attached
(process-packets))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 |