Commit Graph

227 Commits (3aa274597236e8c9938e3626346e2d23119e7ed6)

Author SHA1 Message Date
Nimrod Shneor c6e66d8080 Fix #128: Add support for BPF_MAP_TYPE_LPM_TRIE map 4 years ago
Alessandro Decina 6a91fdf5a7
Merge pull request #157 from dave-tucker/doc-aya
aya: document the public api
4 years ago
Alessandro Decina 4e9bc32a3d aya: maps: rename from_pinned() to open_pinned() 4 years ago
Dave Tucker bca01580e7 aya: document the public api
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
4 years ago
Dave Tucker 65a0b83205 Mark .rodata maps as readonly and freeze on load
This commit marks .rodata maps as BPF_F_RDONLY_PROG when loaded to
prevent a BPF program mutating them.

Initial map data is populated by the loader using the new
`BpfLoader::set_global()` API. The loader will mark
is marked as frozen using bpf_map_freeze to prevent map data
being changed from userspace.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
4 years ago
Thia Wyrod 18970369e2
aya: Remove unnecessary unsafe markers on map iteration.
Map iteration can yield stale keys and values by virtue of sharing a
data structure with BPF programs which can modify it. However, all
accesses remain perfectly safe and will not cause memory corruption or
data races.
4 years ago
Alessandro Decina 07a6016ebb
Merge pull request #120 from eero-thia/thia/dedup
aya: eliminate name duplication in maps and programs.
4 years ago
Thia Wyrod f56dd0a70b
aya: eliminate name duplication in maps and programs.
Map and ProgramData objects had unnecessarily cloned strings for their
names, despite them being just as easily available to external users via
bpf.maps() and bpf.programs().
4 years ago
Thia Wyrod daa7ea6d0d
aya: remove unnecessary usage of &dyn trait in favor of impl trait.
This should improve performance in most situations by eliminating
unnecessary fat pointer indirection.
4 years ago
Thia Wyrod 1584bc47bd
aya: close file descriptors on Map drop. 4 years ago
William Findlay 27d803b634
aya/maps: improve map errors to be more descriptive 4 years ago
Dave Tucker dc4b928ec5 miri: Disable Stacked Borrows and skip some tests
The perf_buffer code fails due to stacked borrows, skip this for now.
munmap isn't supported by miri.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
4 years ago
Dave Tucker 9426f36f79 Implement Pinning For Programs and Maps
This commit adds 2 new methods to aya::sys
- bpf_pin_object
- bpf_get_object

Which allow the pinning and retrieval of programs/maps to bpffs.

It adds a `Program.pin` API, such that a loaded program can be pinned.
For map pinning, the user must ensure the `pinning u32` in the
`bpf_map_def` is set to 1, maps will be pinned using a new builder API.

BpfLoader::new().map_pin_path("/sys/fs/bpf/myapp").load_file("myapp.o")

This will pin all maps whose definition requests pinning to path + name.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
4 years ago
Markus Stange c39dff6025 Add support for PerfEvent programs. 4 years ago
Alessandro Decina 0878c4505a aya: fix clippy warnings 4 years ago
Simone Margaritelli 8311abfdcb
added support for armv7-unknown-linux-gnueabi and armv7-unknown-linux-gnueabihf
* new: added support for armv7-unknown-linux-gnueabi (closes alessandrod/aya/issues/22)

* fix: replaced custom type defintions with proper libc types

* fix: fixed pointless parameter binding

* new: added linker for armv7-unknown-linux-gnueabihf to cargo config
4 years ago
Arnabjyoti Kalita 35f15f70e0
aya: add minimum kernel version for each map and program type (#18) 4 years ago
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
4 years ago
Sean Young 1196ba1dcc Fix doctest and run them during CI
Signed-off-by: Sean Young <sean@mess.org>
4 years ago
Alessandro Decina be0b7bbd83 Doc fixes 4 years ago
Alessandro Decina 768640dd46 aya: add doc aliases for maps and programs 4 years ago
Alessandro Decina 293e66af65 More docs 4 years ago
Alessandro Decina 11e21e83be More docs 4 years ago
Alessandro Decina 6c7df27bd0 More doc fixes 4 years ago
Alessandro Decina 28158e6028 aya: improve async perf map docs 4 years ago
Alessandro Decina 6ecf7dabf3 aya: tweak PerfEventArray docs 4 years ago
Alessandro Decina 6772595f3e aya: ProgramArray: more doc fixes 4 years ago
Alessandro Decina 4bde0c54bd aya: ProgramArray: tweak docs 4 years ago
Alessandro Decina 31f8d71604 aya: add support for Stack and Queue maps 4 years ago
Alessandro Decina 40b7da6655 aya: add id and pinning fields to bpf_map_def 4 years ago
Alessandro Decina 9e12c9324c aya: fix warnings 5 years ago
Alessandro Decina dad300c88b aya: maps: add SockHash 5 years ago
Alessandro Decina b57cace941 aya: add support BPF_PROG_TYPE_SK_SKB programs and SockMaps 5 years ago
Alessandro Decina b6cd813af5 aya: fix program array key size 5 years ago
Alessandro Decina 0b3e532d7a aya: small doc fixes 5 years ago
Alessandro Decina d9634ae945 aya: add maps::StackTraceMap
Map type for BPF_MAP_TYPE_STACK_TRACE.
5 years ago
Alessandro Decina ad6d0596ab aya: tweak docs 5 years ago
Alessandro Decina f464279740 aya: rename ProgramArray::unset to ProgramArray::clear_index 5 years ago
Alessandro Decina 9ad2a5e72d aya: rename ProgramArray::keys to ProgramArray::indices 5 years ago
Alessandro Decina b0364f76ab aya: maps: add PerCpuArray 5 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.
5 years ago
Alessandro Decina aa3a30d196 aya: PerCpuKernelMem doesn't need to be public 5 years ago
Alessandro Decina 1746bbf5b8 aya: add aya::maps::Array 5 years ago
Alessandro Decina c3b902137b aya: add aya::maps::array and move ProgramArray under it 5 years ago
Alessandro Decina 6cec8be564 aya: hash_map: add doc aliases for HASH and LRU_HASH 5 years ago
Alessandro Decina 7a989b43b9 aya: per_cpu_hash_map: add support for BPF_MAP_TYPE_LRU_PERCPU_HASH 5 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.
5 years ago
Alessandro Decina fd142e467c aya: rename MapError::NotFound to MapError::MapNotFound 5 years ago
Alessandro Decina 3a5b289163 aya: add PerCpuHashMap 5 years ago
Alessandro Decina d5098c9e57 aya: move hash_map.rs to hash_map/hash_map.rs 5 years ago
Alessandro Decina 6a12a48f03 aya: hash_map: factor out common hash code
This is in preparation of adding new hash map types
5 years ago
Alessandro Decina 7c6ae76975 aya: HashMap: add support for LRU maps 5 years ago
Alessandro Decina 04fde46855 aya: more docs 5 years ago
Alessandro Decina eea27f52f3 aya: tweak docs 5 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.
5 years ago
Alessandro Decina d94bfde295 aya: maps: add docs and make the hash_map and program_array modules public 5 years ago
Alessandro Decina ce3f83acb1 aya: add HashMap docs 5 years ago
Alessandro Decina e28da8812e aya: make HashMap::new private 5 years ago
Alessandro Decina 24f7c37158 aya: add ProgramArray docs 5 years ago
Alessandro Decina 3fddc8165c aya: make ProgramArray::new private 5 years ago
Alessandro Decina 6682a5ff39 aya: remove pop()
lookup_and_delete_elem is only supported for QUEUE and STACK maps at the
moment.
5 years ago
Alessandro Decina 563ce46118 aya: maps: group syscall errors into MapError::SyscallError 5 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<_>>.
5 years ago
Alessandro Decina ed53f7470b aya: maps: add Map::name() and Map::map_type() 5 years ago
Alessandro Decina 29f2d9b2d9 aya: switch to rustified enums 5 years ago
Alessandro Decina a3ab2eff57 Format fixes 5 years ago
Alessandro Decina 3abe9bb859 Fix RawFd import paths 5 years ago
Alessandro Decina ba992a2414 maps: fail new() for high level wrappers if the underlying map hasn't been created 5 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()
5 years ago
Alessandro Decina 4be0c45305 perf_map: split in sub modules 5 years ago
Alessandro Decina 95a24c6f8b perf_map: implement AsRawFd 5 years ago
Alessandro Decina 5d6fe8bdf4 Add IOError variants to PerfMapError and PerfBufferError 5 years ago
Alessandro Decina b9be2f1a9b Make aya::maps::perf_map public 5 years ago
Alessandro Decina 160e0be6d6 Change the suffix of errors from *Failed to *Error 5 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.
5 years ago
Alessandro Decina d7c91efb2d Make online_cpus() util public 5 years ago
Alessandro Decina af8f769b50 Turn the project into a workspace, move code under aya/ 5 years ago