Commit Graph

585 Commits (ae612a0a1061ea65237b62a7d9fa1f2f583dff36)

Author SHA1 Message Date
Alessandro Decina b57cace941 aya: add support BPF_PROG_TYPE_SK_SKB programs and SockMaps
Alessandro Decina b6cd813af5 aya: fix program array key size
Alessandro Decina 0b3e532d7a aya: small doc fixes
Alessandro Decina 79f1b385a5 aya: more docs
Alessandro Decina 683a58ea6d aya: consolidate errors into ProgramError::SyscallError
Alessandro Decina ae863bc663 aya: split aya::programs::probe into ::kprobe and ::uprobe & add docs
Alessandro Decina d9634ae945 aya: add maps::StackTraceMap
Map type for BPF_MAP_TYPE_STACK_TRACE.
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.
Alessandro Decina 2cdb10e7f2 aya: add bpf_map_lookup_elem_ptr
Alessandro Decina ad6d0596ab aya: tweak docs
Alessandro Decina f464279740 aya: rename ProgramArray::unset to ProgramArray::clear_index
Alessandro Decina 9ad2a5e72d aya: rename ProgramArray::keys to ProgramArray::indices
Alessandro Decina b0364f76ab aya: maps: add PerCpuArray
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.
Alessandro Decina aa3a30d196 aya: PerCpuKernelMem doesn't need to be public
Alessandro Decina 1746bbf5b8 aya: add aya::maps::Array
Alessandro Decina c3b902137b aya: add aya::maps::array and move ProgramArray under it
Alessandro Decina 6cec8be564 aya: hash_map: add doc aliases for HASH and LRU_HASH
Alessandro Decina 7a989b43b9 aya: per_cpu_hash_map: add support for BPF_MAP_TYPE_LRU_PERCPU_HASH
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.
Alessandro Decina fd142e467c aya: rename MapError::NotFound to MapError::MapNotFound
Alessandro Decina 3a5b289163 aya: add PerCpuHashMap
Alessandro Decina d5098c9e57 aya: move hash_map.rs to hash_map/hash_map.rs
Alessandro Decina 6a12a48f03 aya: hash_map: factor out common hash code
This is in preparation of adding new hash map types
Alessandro Decina ac83273da8 aya: fix warnings
Alessandro Decina 46e0a2ede4 aya: don't export VerifierLog
Alessandro Decina 7c6ae76975 aya: HashMap: add support for LRU maps
Alessandro Decina 04fde46855 aya: more docs
Alessandro Decina eea27f52f3 aya: tweak docs
Alessandro Decina 5aa9cb12ad aya: rename perf map and add docs
Rename the perf_map module to just perf, and rename PerfMap to
PerfEventArray.
Alessandro Decina d94bfde295 aya: maps: add docs and make the hash_map and program_array modules public
Alessandro Decina ce3f83acb1 aya: add HashMap docs
Alessandro Decina e28da8812e aya: make HashMap::new private
Alessandro Decina 24f7c37158 aya: add ProgramArray docs
Alessandro Decina 3fddc8165c aya: make ProgramArray::new private
Alessandro Decina 6682a5ff39 aya: remove pop()
lookup_and_delete_elem is only supported for QUEUE and STACK maps at the
moment.
Alessandro Decina 1bbbf616b6 aya: add some docs for the crate and `Bpf`
Alessandro Decina 563ce46118 aya: maps: group syscall errors into MapError::SyscallError
Alessandro Decina f9554d6db5 aya: fix bindings for PERF_EVENT_IOC_{ENABLE|DISABLE|SET_BPF}
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
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<_>>.
Alessandro Decina d3482c063c aya: fix some badly completed match arms
Alessandro Decina ee05f9d949 aya: fix verifier log handling
Alessandro Decina 92b4ed2664 aya: add support for function calls
Alessandro Decina 8b0eee317d aya: section: collecting relocations can't fail anymore
Alessandro Decina 318c16cea3 aya: obj: rename symbol_table to symbols_by_index
Alessandro Decina 286e117fe0 aya: add Program::name() and make ::prog_type() public
Alessandro Decina 0199e4b297 aya: bpf: Add Bpf::programs()
Alessandro Decina dcb5121985 aya: bpf: remove lifetime param from previous signature
Alessandro Decina ed53f7470b aya: maps: add Map::name() and Map::map_type()
Alessandro Decina 0a493baed6 aya: add Bpf::maps() to get all the maps
Alessandro Decina 29f2d9b2d9 aya: switch to rustified enums
Alessandro Decina 59ed237343 aya: generate code with xtask
Alessandro Decina 8327ffbb8d xdp: xdp BPF_LINK_CREATE was added in 5.9
Alessandro Decina 1e779c520a aya: obj: implement sane defaults for license and kernel version
Default to license=GPL and kernel_version=any
Alessandro Decina f11df77f85 aya: implement missing bit of retprobes
Alessandro Decina b7369d2763 aya: sys: fix warning
Alessandro Decina 82bcef3790 aya: rename gen-bindings to gen-bindings.sh
Alessandro Decina 245cd46bab aya: tweak error display
Alessandro Decina 3e8a279a59 Fix build with musl
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.
Alessandro Decina f56c32b46b util: add possible_cpus()
Alessandro Decina a3ab2eff57 Format fixes
Alessandro Decina 0cf5d17e38 deps: enable only the std feature for the futures crate
Alessandro Decina 3abe9bb859 Fix RawFd import paths
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.
Alessandro Decina 55d8bcf386 xdp: add support for attaching with custom xdp flags
Alessandro Decina d326038cf4 programs: rework ProgramError a bit
Move type specific errors to XdpError SocketFilterError etc.

Annotate all source errors with #[source]
Alessandro Decina f88ca1f1f1 programs: add internal API to create links
Alessandro Decina ba992a2414 maps: fail new() for high level wrappers if the underlying map hasn't been created
Alessandro Decina 873691d050 Trim deps a bit more
Alessandro Decina f1da541234 The futures crate is only needed when async is enabled
Alessandro Decina 14c98455a9 btf: remove unused methods
Alessandro Decina a5e19fc4ac Fix warnings
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()
Alessandro Decina 4be0c45305 perf_map: split in sub modules
Alessandro Decina 95a24c6f8b perf_map: implement AsRawFd
Alessandro Decina 5d6fe8bdf4 Add IOError variants to PerfMapError and PerfBufferError
Alessandro Decina b9be2f1a9b Make aya::maps::perf_map public
Alessandro Decina 160e0be6d6 Change the suffix of errors from *Failed to *Error
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.
Alessandro Decina d7c91efb2d Make online_cpus() util public
Alessandro Decina 2215e202f4 Generate arch specific bindings
Currently x86_64 and aarch64 are supported
Alessandro Decina 1de392964b Add src/generated/netlink_bindings.rs to repo
Alessandro Decina af8f769b50 Turn the project into a workspace, move code under aya/