| Crates.io | libxdp-sys |
| lib.rs | libxdp-sys |
| version | 0.2.3+1.5.6 |
| created_at | 2021-05-01 06:14:03.696836+00 |
| updated_at | 2025-10-09 14:09:28.699717+00 |
| description | Rust bindings for libxdp |
| homepage | https://github.com/chenhengqi/libxdp-sys |
| repository | https://github.com/chenhengqi/libxdp-sys |
| max_upload_size | |
| id | 391803 |
| size | 7,776,684 |
Rust FFI bindings for the libxdp C library, enabling safe and efficient interaction with XDP (eXpress Data Path) features from Rust.
libxdp-sys provides low-level, auto-generated Rust bindings to the libxdp C library. These bindings allow Rust programs to interact with XDP objects, manage XDP programs, and utilize advanced networking features exposed by libxdp.
This crate is intended for use as a building block for higher-level Rust libraries and applications that require direct access to XDP functionality. It is not a high-level API; instead, it exposes the raw C interface as closely as possible.
vendored featureuse_precompiled_bpf featureAdd libxdp-sys to your Cargo.toml:
[dependencies]
libxdp-sys = "0.2"
Enable optional features as needed:
[features]
vendored = ["libbpf-sys/vendored"]
vendored-libelf = ["libbpf-sys/vendored-libelf"]
use_precompiled_bpf = [] # Use precompiled BPF objects instead of building at compile time
If you enable the use_precompiled_bpf feature, the crate will use prebuilt BPF object files (found in src/prebuilt_ebpf) instead of compiling BPF code during the build process. This can speed up builds and improve reproducibility, especially in CI environments or when cross-compiling.
Example usage:
use libxdp_sys::*;
// Access a constant
let headroom = XDP_PACKET_HEADROOM;
// Use a struct and call a method
let insn = bpf_insn {
code: BPF_LD as u8,
_bitfield_align_1: [],
_bitfield_1: bpf_insn::new_bitfield_1(1, 2),
off: 0,
imm: 0,
};
let dst_reg = insn.dst_reg();
This crate uses a build.rs script to generate bindings at build time. For most users, enabling the vendored feature will build libbpf from source automatically.
Run integration tests with:
cargo test
libxdp-sys is dual-licensed under LGPL-2.1 or BSD-2-Clause, matching the upstream libxdp library.