Commit Graph

236 Commits (324c679a41ba7e5448092a0e5b1ca7e06adb78e2)

Author SHA1 Message Date
Rafael Ortiz d8d311738c
aya: support both bpf_map_def layout variants
Libbpf and iproute2 use two slightly different `bpf_map_def` layouts. This change implements support for loading both.

Refs: #10, #14
3 years ago
Alessandro Decina 5f0ff1698a aya: netlink: tc: use ptr::read_unaligned instead of deferencing a potentially unaligned ptr 3 years ago
Alessandro Decina 7f2ceaf12e aya: netlink: port TC code to using new nlattr utils 3 years ago
Alessandro Decina d9b5ab575f aya: netlink: refactor nlattr writing code 3 years ago
Alessandro Decina c240a2c733 aya: netlink: introduce NestedAttrs builder and switch XDP to it
NestedAttrs is a safe interface for writing nlattrs. This is the first
step towards making the netlink code safer and easier to maintain.
3 years ago
Alessandro Decina bb595c4e69 aya: refactor program section parsing
This renames aya::obj::ProgramKind to aya::obj::ProgramSection and moves
all the program section parsing to ProgramSection::from_str.
3 years ago
Alessandro Decina 0188622580 aya: fix tracepoint prefix in a couple more places 3 years ago
Alessandro Decina a0151dd485 aya: fix trace point section name
Trace points have prefix "tracepoint" not "trace_point".
3 years ago
Alessandro Decina 521ef09463
Merge pull request #4 from seanyoung/doctest
Fix doctest and run them during CI
3 years ago
Alessandro Decina d70e291580 (cargo-release) version 0.10.2 3 years ago
Alessandro Decina fee71b42f1 aya: tc: fix QdiscRequest layout 3 years ago
Sean Young 1196ba1dcc Fix doctest and run them during CI
Signed-off-by: Sean Young <sean@mess.org>
3 years ago
Sean Young b49ba69d09 Add support for lirc programs
Signed-off-by: Sean Young <sean@mess.org>
3 years ago
Alessandro Decina 304abfbfeb (cargo-release) version 0.10.1 3 years ago
LOU Xun f1fc30411d
Fix Bpf::load_file when BTF doesn't exist 3 years ago
Alessandro Decina 94b5e2e4e6 Copy readme into aya/ 3 years ago
Alessandro Decina 7694bacf04 aya: add more fields to Cargo.toml 3 years ago
Alessandro Decina be0b7bbd83 Doc fixes 3 years ago
Alessandro Decina 9f7b017d5d aya: bump version to 0.10 3 years ago
Alessandro Decina 768640dd46 aya: add doc aliases for maps and programs 3 years ago
Alessandro Decina 293e66af65 More docs 3 years ago
Alessandro Decina ad58e171ff aya: refactor tc code a bit and add docs 3 years ago
Alessandro Decina 11e21e83be More docs 3 years ago
Alessandro Decina 6c7df27bd0 More doc fixes 3 years ago
Alessandro Decina 28158e6028 aya: improve async perf map docs 3 years ago
Alessandro Decina 6ecf7dabf3 aya: tweak PerfEventArray docs 3 years ago
Alessandro Decina 6772595f3e aya: ProgramArray: more doc fixes 3 years ago
Alessandro Decina 4bde0c54bd aya: ProgramArray: tweak docs 3 years ago
Alessandro Decina 2cda5dbbe7 aya: implement ProgramFd for CgroupSkb 3 years ago
Alessandro Decina 2d7b9b2e90 aya: fix CgroupSkb docs 3 years ago
Alessandro Decina 08a68faf8a aya: programs: add support for BPF_PROG_TYPE_CGROUP_SKB programs 3 years ago
Alessandro Decina fb3e2f7f9d aya: programs: fix detaching programs attached with bpf_prog_attach 3 years ago
Alessandro Decina 665802594c aya: programs: fix syscall name in errors 3 years ago
Alessandro Decina 81a0b61164 aya: handle reordered functions
LLVM will split .text into .text.hot .text.unlikely etc and move the
content around in order to improve locality. We need to parse all the
text sections or relocations can potentially fail.
3 years ago
Alessandro Decina b92b1e18a9 aya: improve call relocation error messages 3 years ago
Alessandro Decina 20b2d4c77d aya: BpfError: set the #[source] attribute for RelocationErrors 3 years ago
Arnabjyoti Kalita 6974d349e8
programs: add support for attaching and detaching TC programs
This change adds support for attaching TC programs directly from aya, without
having to use iproute2/tc.
3 years ago
Alessandro Decina 31f8d71604 aya: add support for Stack and Queue maps 3 years ago
Alessandro Decina 40b7da6655 aya: add id and pinning fields to bpf_map_def 3 years ago
Alessandro Decina dc4e020f29 aya: netlink: improve error messages 3 years ago
Alessandro Decina 5effc972ac aya: add support for BPF_PROG_TYPE_SCHED_CLS programs 3 years ago
Alessandro Decina 4222b140ec aya: perf_map: fix bug when max_entries=0
When a perf map has max_entries=0, max_entries is dynamically set at
load time to the number of possible cpus as reported by
/sys/devices/system/cpu/possible.

This change fixes a bug where instead of setting max_entries to the
number of possible cpus, we were setting it to the cpu index of the last
possible cpu.
3 years ago
Alessandro Decina 3b7ffd0048 aya: update generated bindings
Update generated bindings with kernel headers from libbpf 4ccc1f0
3 years ago
Alessandro Decina 30d2b25f11 aya: xdp: fix detaching on kernels older than 5.7
XDP_FLAGS_REPLACE was added in 5.7. Now for kernels >= 5.7 whenever we
detach an XDP program we pass along the program fd we expect to be
detaching. For older kernels, we just detach whatever is attached, which
is not great but it's the way the API worked pre XDP_FLAGS_REPLACE.
3 years ago
Alessandro Decina 607cf68a69 aya: xdp: set flags when attaching with netlink 3 years ago
Alessandro Decina bb7728a2c5 aya: fix BpfError display strings 3 years ago
Alessandro Decina 9e12c9324c aya: fix warnings 3 years ago
Alessandro Decina 9a24f20e6f aya: programs: rework load_program() retry code a bit 3 years ago
Alessandro Decina 144175434f aya: programs: add support for SkMsg programs 3 years ago
Alessandro Decina dad300c88b aya: maps: add SockHash 3 years ago
Alessandro Decina ca4b3bfc04 aya: add support for SockOps programs 4 years ago
Alessandro Decina b57cace941 aya: add support BPF_PROG_TYPE_SK_SKB programs and SockMaps 4 years ago
Alessandro Decina b6cd813af5 aya: fix program array key size 4 years ago
Alessandro Decina 0b3e532d7a aya: small doc fixes 4 years ago
Alessandro Decina 79f1b385a5 aya: more docs 4 years ago
Alessandro Decina 683a58ea6d aya: consolidate errors into ProgramError::SyscallError 4 years ago
Alessandro Decina ae863bc663 aya: split aya::programs::probe into ::kprobe and ::uprobe & add docs 4 years ago
Alessandro Decina d9634ae945 aya: add maps::StackTraceMap
Map type for BPF_MAP_TYPE_STACK_TRACE.
4 years ago
Alessandro Decina 67c9cc0359 aya: add util::kernel_symbols()
kernel_symbols() can be used to load /proc/kallsyms in a BTreeMap.
Useful for looking up symbols from stack addresses.
4 years ago
Alessandro Decina 2cdb10e7f2 aya: add bpf_map_lookup_elem_ptr 4 years ago
Alessandro Decina ad6d0596ab aya: tweak docs 4 years ago
Alessandro Decina f464279740 aya: rename ProgramArray::unset to ProgramArray::clear_index 4 years ago
Alessandro Decina 9ad2a5e72d aya: rename ProgramArray::keys to ProgramArray::indices 4 years ago
Alessandro Decina b0364f76ab aya: maps: add PerCpuArray 4 years ago
Alessandro Decina 74d5f17559 aya: rework IterableMap and ProgramArray
Make MapKeys not use IterableMap. Leave only ProgramArray::get,
ProgramArray::set and ProgramArray::unset exposed as the other syscalls
don't work consistently for program arrays.
4 years ago
Alessandro Decina aa3a30d196 aya: PerCpuKernelMem doesn't need to be public 4 years ago
Alessandro Decina 1746bbf5b8 aya: add aya::maps::Array 4 years ago
Alessandro Decina c3b902137b aya: add aya::maps::array and move ProgramArray under it 4 years ago
Alessandro Decina 6cec8be564 aya: hash_map: add doc aliases for HASH and LRU_HASH 4 years ago
Alessandro Decina 7a989b43b9 aya: per_cpu_hash_map: add support for BPF_MAP_TYPE_LRU_PERCPU_HASH 4 years ago
Alessandro Decina 635dcd44b9 aya: maps: introduce MapError::KeyNotFound
Change get() from -> Result<Option<V>, MapError> to -> Result<V,
MapError> where MapError::KeyNotFound is returned instead of Ok(None) to
signify that the key is not present.
4 years ago
Alessandro Decina fd142e467c aya: rename MapError::NotFound to MapError::MapNotFound 4 years ago
Alessandro Decina 3a5b289163 aya: add PerCpuHashMap 4 years ago
Alessandro Decina d5098c9e57 aya: move hash_map.rs to hash_map/hash_map.rs 4 years ago
Alessandro Decina 6a12a48f03 aya: hash_map: factor out common hash code
This is in preparation of adding new hash map types
4 years ago
Alessandro Decina ac83273da8 aya: fix warnings 4 years ago
Alessandro Decina 46e0a2ede4 aya: don't export VerifierLog 4 years ago
Alessandro Decina 7c6ae76975 aya: HashMap: add support for LRU maps 4 years ago
Alessandro Decina 04fde46855 aya: more docs 4 years ago
Alessandro Decina eea27f52f3 aya: tweak docs 4 years ago
Alessandro Decina 5aa9cb12ad aya: rename perf map and add docs
Rename the perf_map module to just perf, and rename PerfMap to
PerfEventArray.
4 years ago
Alessandro Decina d94bfde295 aya: maps: add docs and make the hash_map and program_array modules public 4 years ago
Alessandro Decina ce3f83acb1 aya: add HashMap docs 4 years ago
Alessandro Decina e28da8812e aya: make HashMap::new private 4 years ago
Alessandro Decina 24f7c37158 aya: add ProgramArray docs 4 years ago
Alessandro Decina 3fddc8165c aya: make ProgramArray::new private 4 years ago
Alessandro Decina 6682a5ff39 aya: remove pop()
lookup_and_delete_elem is only supported for QUEUE and STACK maps at the
moment.
4 years ago
Alessandro Decina 1bbbf616b6 aya: add some docs for the crate and `Bpf` 4 years ago
Alessandro Decina 563ce46118 aya: maps: group syscall errors into MapError::SyscallError 4 years ago
Alessandro Decina f9554d6db5 aya: fix bindings for PERF_EVENT_IOC_{ENABLE|DISABLE|SET_BPF} 4 years ago
Alessandro Decina a92bfebf50 aya: remove TryInto magic from program()/program_mut() too
For programs it's actually useful being able to get the underlying
Program enum, for example when iterating/loading all the programs
4 years ago
Alessandro Decina 42e0a659b2 aya: remove TryInto cleverness from map() and map_mut()
Require callers to call try_into() explicitly. It's more characters, but
it's easier to understand/document.

Also introduce MapError::NotFound instead of returning Result<Option<_>>.
4 years ago
Alessandro Decina d3482c063c aya: fix some badly completed match arms 4 years ago
Alessandro Decina ee05f9d949 aya: fix verifier log handling 4 years ago
Alessandro Decina 92b4ed2664 aya: add support for function calls 4 years ago
Alessandro Decina 8b0eee317d aya: section: collecting relocations can't fail anymore 4 years ago
Alessandro Decina 318c16cea3 aya: obj: rename symbol_table to symbols_by_index 4 years ago
Alessandro Decina 286e117fe0 aya: add Program::name() and make ::prog_type() public 4 years ago
Alessandro Decina 0199e4b297 aya: bpf: Add Bpf::programs() 4 years ago
Alessandro Decina dcb5121985 aya: bpf: remove lifetime param from previous signature 4 years ago
Alessandro Decina ed53f7470b aya: maps: add Map::name() and Map::map_type() 4 years ago
Alessandro Decina 0a493baed6 aya: add Bpf::maps() to get all the maps 4 years ago
Alessandro Decina 29f2d9b2d9 aya: switch to rustified enums 4 years ago
Alessandro Decina 59ed237343 aya: generate code with xtask 4 years ago
Alessandro Decina 8327ffbb8d xdp: xdp BPF_LINK_CREATE was added in 5.9 4 years ago
Alessandro Decina 1e779c520a aya: obj: implement sane defaults for license and kernel version
Default to license=GPL and kernel_version=any
4 years ago
Alessandro Decina f11df77f85 aya: implement missing bit of retprobes 4 years ago
Alessandro Decina b7369d2763 aya: sys: fix warning 4 years ago
Alessandro Decina 82bcef3790 aya: rename gen-bindings to gen-bindings.sh 4 years ago
Alessandro Decina 245cd46bab aya: tweak error display 4 years ago
Alessandro Decina 3e8a279a59 Fix build with musl 4 years ago
Alessandro Decina 68a633fe51 perf_map: support max_entries=0
When a PerfMap has max_entries=0, set max_entries to the number of
available CPUs.
4 years ago
Alessandro Decina f56c32b46b util: add possible_cpus() 4 years ago
Alessandro Decina a3ab2eff57 Format fixes 4 years ago
Alessandro Decina 0cf5d17e38 deps: enable only the std feature for the futures crate 4 years ago
Alessandro Decina 3abe9bb859 Fix RawFd import paths 4 years ago
Alessandro Decina 2cec04c578 bpf: add explicit BTF argument to the load API
Add a `target_btf: Option<Btf>` argument to Bpf::load. None can be
passed to indicate to skip BTF relocation, for example for kernels that
don't support it. Some(btf) can be used to pass BTF parsed with
Btf::from_sys_fs() or Btf::parse/parse_file.

Finally, add a simpler Bpf::load_file(path) that uses from_sys_fs()
internally to simplify the common case.
4 years ago
Alessandro Decina 55d8bcf386 xdp: add support for attaching with custom xdp flags 4 years ago
Alessandro Decina d326038cf4 programs: rework ProgramError a bit
Move type specific errors to XdpError SocketFilterError etc.

Annotate all source errors with #[source]
4 years ago
Alessandro Decina f88ca1f1f1 programs: add internal API to create links 4 years ago
Alessandro Decina ba992a2414 maps: fail new() for high level wrappers if the underlying map hasn't been created 4 years ago
Alessandro Decina 873691d050 Trim deps a bit more 4 years ago
Alessandro Decina f1da541234 The futures crate is only needed when async is enabled 4 years ago
Alessandro Decina 14c98455a9 btf: remove unused methods 4 years ago
Alessandro Decina a5e19fc4ac Fix warnings 4 years ago
Alessandro Decina fdc4dad5ff maps: add AsyncPerfMap
When the async_tokio or async_std features are enabled, AsyncPerfMap
provides an async version of PerfMap which returns a future from
read_events()
4 years ago
Alessandro Decina 4be0c45305 perf_map: split in sub modules 4 years ago
Alessandro Decina 95a24c6f8b perf_map: implement AsRawFd 4 years ago
Alessandro Decina 5d6fe8bdf4 Add IOError variants to PerfMapError and PerfBufferError 4 years ago
Alessandro Decina b9be2f1a9b Make aya::maps::perf_map public 4 years ago
Alessandro Decina 160e0be6d6 Change the suffix of errors from *Failed to *Error 4 years ago
Alessandro Decina d4e282535b bpf, perf_map: make maps usable from multiple threads
Change PerfMap API so that individual buffers can be read from multiple
threads.

Change the way maps are stored in the `Bpf` struct from RefCell to a
custom RwLock.
4 years ago
Alessandro Decina d7c91efb2d Make online_cpus() util public 4 years ago
Alessandro Decina 2215e202f4 Generate arch specific bindings
Currently x86_64 and aarch64 are supported
4 years ago
Alessandro Decina 1de392964b Add src/generated/netlink_bindings.rs to repo 4 years ago
Alessandro Decina af8f769b50 Turn the project into a workspace, move code under aya/ 4 years ago