Commit Graph

475 Commits (9ca0af1a79f7d18f577f4c2727e08a7e1be1ab90)

Author SHA1 Message Date
Tamir Duberstein ff86f1385c
Remove dependency on bpftool in integration tests 1 year ago
Dave Tucker 47f764c191 aya: Make Features part of the public API
This commit adds a new probe for bpf_attach_cookie, which would be used
to implement USDT probes. Since USDT probes aren't currently supported,
we this triggers a dead_code warning in clippy.

There are cases where exposing FEATURES - our lazy static - is actually
helpful to users of the library. For example, they may wish to choose to
load a different version of their bytecode based on current features.
Or, in the case of an orchestrator like bpfd, we might want to allow
users to describe which features their program needs and return nice
error message is one or more nodes in their cluster doesn't support the
necessary feature set.

To do this without breaking the API, we make all the internal members of
the `Features` and `BtfFeatures` structs private, and add accessors for
them. We then add a `features()` API to avoid leaking the
lazy_static.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Alessandro Decina 76d35d10ce
Merge pull request #526 from dave-tucker/trie
aya: Remove iter_key from LPM Trie API
1 year ago
Dave Tucker 00c480d2f9 aya: Remove iter_key from LPM Trie API
Based on the discussion in Discord we've decided to drop the
iter_key() API for LPM Trie. According to the kernel self-tests and
experimentation done in Aya, providing a key into bpf_map_get_next_id
will either:

- If key is an EXACT match, proceed iterating through all keys in the
trie from this point
- If key is NOT an EXACT match, proceed iterating through all keys in
the trie starting at the leftmost entry.

An API in Aya could be crafted that gets the LPM match + less specific
matches for a prefix using these semantics BUT it would only apply to
userspace. Therefore we've opted out of fixing this.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
ajwerner 65d10f9ffc aya: replace os::unix::prelude with os::fd 1 year ago
Mary 77cce840f7
Update aya/src/bpf.rs
Co-authored-by: Alessandro Decina <alessandro.d@gmail.com>
1 year ago
Mary 93435fc854 aya: allow global value to be optional
This allow to not error out when a global symbol is missing from the object.
1 year ago
Federico Ponzi 987e8489d0 aya-utils: add syscall_prefix and syscall_fnname_add_prefix
These two functions are needed because kernel symbols representing
syscalls have architecture-specific prefixes.

These are the equivalent of bcc's get_syscall_fnname and
get_syscall_prefix.

Solves: #534
1 year ago
Mary 49c6f5d122 aya: Fix uprobe support on 4.16 and lower
Fix uprobe support on Ubuntu 18.04.
1 year ago
Mary 8e9f395eab aya: Add support for old ld.so.cache format
This fix uprobe support on Debian 10. (and possibly others)
This implement support to parse the original libc5 format.
1 year ago
Alexis (Poliorcetics) Bourget 243986c1da fix: Relax unnecessarily strict atomic ordering on probe event_alias 1 year ago
Mary e9be3d9023 aya: Make probe event_alias unique
This fixes issues when trying to attach the same kernel function multiple times on 4.17 and lower (possibly upper too?)
1 year ago
Alessandro Decina 3a9a54fd9b
Merge pull request #602 from marysaka/fix/btf-reloc-all-functions
aya: Apply BTF relocations to all functions
1 year ago
Kenjiro Nakayama afb4aa1c66 Add a few tweak a code to fix libbpf's API change. 1 year ago
William Batista 3d1013d729 Fixed a typo in the per_cpu_hashmap documentation 1 year ago
Hanaasagi 0e4aec475f fix(lint): remove useless `any` `all` in cfg. 1 year ago
Mary 591e21267a aya: Do not create data maps on kernel without global data support
Fix map creation failure when a BPF have a data section on older
kernel. (< 5.2)

If the BPF uses that section, relocation will fail accordingly and
report an error.
1 year ago
Mary 9e1109b3ce aya: Move program's functions to the same map 1 year ago
Tamir Duberstein ae8a95b0ee
build(deps): update bitflags requirement from 1.2.1 to 2.2.1
Updates the requirements on [bitflags](https://github.com/bitflags/bitflags) to permit the latest version.
- [Release notes](https://github.com/bitflags/bitflags/releases)
- [Changelog](https://github.com/bitflags/bitflags/blob/main/CHANGELOG.md)
- [Commits](https://github.com/bitflags/bitflags/compare/1.2.1...2.2.1)
1 year ago
vadorovsky deb054afa4
Merge pull request #577 from aya-rs/dependabot/cargo/object-0.31
build(deps): update object requirement from 0.30 to 0.31
1 year ago
Alessandro Decina 120b59dd2e
Merge pull request #545 from epompeii/lsm_sleepable
Add `BPF_F_SLEEPABLE` flag support to LSM
1 year ago
dependabot[bot] 4c78f7f1a0
build(deps): update object requirement from 0.30 to 0.31
Updates the requirements on [object](https://github.com/gimli-rs/object) to permit the latest version.
- [Release notes](https://github.com/gimli-rs/object/releases)
- [Changelog](https://github.com/gimli-rs/object/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gimli-rs/object/compare/0.30.0...0.31.0)

---
updated-dependencies:
- dependency-name: object
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
1 year ago
Alessandro Decina 45efa6384f
Merge pull request #586 from probulate/no-std-inversion
aya: flip feature "no_std" to feature "std"
1 year ago
Tamir Duberstein 33a0a2b604
aya: flip feature "no_std" to feature "std"
This fixes `cargo build --all-features` by sidestepping the feature
unification problem described in The Cargo Book[0].

Add `cargo hack --feature-powerset` to CI to enforce that this doesn't
regress (and that all combinations of features work).

Since error_in_core is nightly-only, use core-error and a fake std
module to allow aya-obj to build without std on stable.

[0] https://doc.rust-lang.org/cargo/reference/features.html#feature-unification
1 year ago
Everett Pompeii 1f2006bfde
Merge branch 'aya-rs:main' into lsm_sleepable 1 year ago
Dave Tucker ed14751c79
Merge pull request #525 from dave-tucker/borrow
aya: MapData should be Borrow, not AsRef
1 year ago
Mary 3aeeb8167b aya: Correctly set the kernel code version for Debian kernel
Fix BPF syscall failure related to the kernel code version.
1 year ago
Mary f1d891836e aya: Correctly set the kernel code version for Ubuntu kernel
Fix BPF syscall failure related to the kernel code version.
1 year ago
Mary 1132b6e01b aya: Add sanitize code for kernels without bpf_probe_read_kernel
Required for kernel before 5.5.

Also move Features to aya-obj.
1 year ago
Mary 7c25fe90a9 aya: Do not use unwrap with btf_fd in bpf_create_map
Fixes a crash when trying to create a map of type BPF_MAP_TYPE_PERCPU_ARRAY when btf_fd is None.

Tested on Ubuntu 18.04 (4.15.0-202-generic)
1 year ago
Alessandro Decina 93ac3e94bc aya: support relocations across multiple text sections + fixes
Fix R_BPF_64_64 text relocations in sections other than .text (for
instance .text.unlikely). Also fix misc bugs triggered by integration
tests.
1 year ago
Alessandro Decina 401ea5e848 aya, aya-obj: refactor map relocations
Clearly split the code between `.maps`, `maps` and data maps (bss, data,
rodata). Sprinkle comments.

Remove MapKind which was effectively only needed since we used to have
one variant - BpfSectionKind::Data - to represent all data maps. Instead
add explicit BpfSectionKind::{Data, Rodata, Bss} variants and match on
those when we initialize maps.
1 year ago
epompeii 85714d5cf3 review 2 years ago
epompeii 17f497ce42 program_section 2 years ago
Alessandro Decina b13070a342
Merge pull request #557 from drewvis/main
Add check for empty tracefs mounts
2 years ago
Alessandro Decina bcb2972a96 aya: make it possible to use set_global() with slices of Pod(s) 2 years ago
drewvis 8f64cf8cd5 Added code check comment 2 years ago
drewvis 3a2c0cd1dd Add check for empty tracefs mounts 2 years ago
Alessandro Decina 8ef00c4c63 Revert "aya: make it possible to use set_global() with slices of Pod(s)"
This reverts commit b614ffd603.
2 years ago
Alessandro Decina b614ffd603 aya: make it possible to use set_global() with slices of Pod(s) 2 years ago
Mikhail Trishchenkov ce60854934 Don't leak libc types 2 years ago
Mikhail Trishchenkov 896e3ab313 Fix formatting 2 years ago
Mikhail Trishchenkov 676b5cdc0d Rename method and fix comment 2 years ago
Mikhail Trishchenkov 2e3c1779be aya: Allow to attach XDP probe by interface index 2 years ago
Mary 94049ec661 aya: Fix MapData Clone implementation
The Clone implementation of MapData was previously not storing the
result of the dup operation.
2 years ago
Dave Tucker de4905a24b aya: Add loaded_programs() API to list all loaded programs
This uses a Programs iterator to yield all loaded bpf programs using
bpf_prog_get_next_id.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker b1a70fc6e4 aya: MapData should be Borrow, not AsRef
We don't ever do ref-to-ref conversion for MapData so Borrow should
suffice.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker ce79de7ff6 aya: Fix is_perf_link_supported
This was mistakenly comparing the exit code of the syscall, which is
always -1 and not the corresponding error-code. Added unit tests to
ensure we don't regress.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 7479c1dd6c aya: More discrete feature logging
Just use the Debug formatter vs. printing a message for each probe.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker d0b3d3b2fa aya: Enable bpf_link for perf_attach programs
This adds support for bpf_link to PerfEvent, Tracepoint, Kprobe and
Uprobe programs.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago