Commit Graph

188 Commits (3eb0fe3257502ffbb8ef6a60881babc6f4186f9b)

Author SHA1 Message Date
Tobias Klauser 2136f05461 aya: netlink: use NETLINK_EXT_ACK from libc crate
NETLINK_EXT_ACK is available since libc crate version 0.2.105, see
https://github.com/rust-lang/libc/releases/tag/0.2.105
3 years ago
William Findlay 1e6b1afbe4
aya/obj: fix incorrect section size for .bss 3 years ago
William Findlay 27d803b634
aya/maps: improve map errors to be more descriptive 3 years ago
William Findlay 6b6d4af932
aya/programs/lsm: pass Btf by reference instead of loading new Btf in Lsm::load 3 years ago
William Findlay 6539cbb555
aya/aya-bpf: implement btf tracepoint programs 3 years ago
Alessandro Decina 140005d9e3
Merge pull request #68 from vadorovsky/lsm
Add support for raw tracepoint and LSM programs
3 years ago
William Findlay 169478c863 Add support for raw tracepoint and LSM programs
This change adds support for the following program types:

* raw tracepoint
* LSM

Supporting LSM programs involved a necessity of supporting more
load_attrs for the BPF_PROG_LOAD operation, concretely:

* expected_attach_type - for LSM programs, it has always to be set to
  BPF_LSM_MAC
* attach_btf_obj_fd - it's often used to reference the file descriptor of
  program's BTF info, altough in case of LSM programs, it only has to
  contain the value 0, which means the vmlinux object file (usually
  /sys/kernel/btf/vmlinux)
* attach_btf_id - ID of the BTF object, which in case of LSM programs is
  the ID of the function (the LSM hook)

The example of LSM program using that functionality can be found here:

https://github.com/vadorovsky/aya-example-lsm

Fixes: #9
Signed-off-by: William Findlay <william@williamfindlay.com>
Signed-off-by: Michal Rostecki <mrostecki@opensuse.org>
3 years ago
William Findlay 99f6f9e14d
aya: fix include_bytes_aligned! macro to work in some corner cases
I found a corner case in my own development workflow that caused the existing macro to not
work properly. The following changes appear to fix things. Ideally, we could add some test
cases to CI to prevent regressions.  This would require creating a dedicated directory to
hold test cases so that we can "include" them at compile time.
3 years ago
Alessandro Decina a94774755f
Merge pull request #76 from willfindlay/load_include_bytes
aya: introduce include_bytes_aligned!() macro
3 years ago
William Findlay 4df4e9c14e
aya: introduce include_bytes_aligned!() macro
This is a helper macro that can be used to include bytes at compile-time that can then be
used in Bpf::load(). Unlike std's include_bytes!(), this macro also ensures that the
resulting byte array is correctly aligned so that it can be parsed as an ELF binary.

Signed-off-by: William Findlay <william@williamfindlay.com>
3 years ago
alessandrod 03e9935358 Bump libbpf to 92c1e61a605410b16d6330fdd4a7a4e03add86d4
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
dependabot[bot] c99dcfb9d3 build(deps): update object requirement from 0.26 to 0.27
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.26.0...0.27.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
Alessandro Decina 4152e8b1a4 (cargo-release) version 0.10.5 3 years ago
Alessandro Decina 59a1854a6b aya: fix call relocation bug
Take the section offset into account when looking up relocation entries
3 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>
3 years ago
Alessandro Decina 52c51895ba aya: fix clippy 3 years ago
Alessandro Decina 64e3fb4cc8 aya: improve docs a bit and make BpfLoader default to loading BTF if available 3 years ago
Alessandro Decina 5f8f18e3a1 aya: loader: take BTF info as reference
Allows sharing the same BTF info across many loaders
3 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>
3 years ago
Alessandro Decina a7f5b3775d (cargo-release) version 0.10.4 3 years ago
Dave Tucker a10a7b3bf2 bump obj to 0.26
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 98361a4c93 aya: minor PerfEvent API tweaks 3 years ago
Alessandro Decina b0a05e759e aya: run xtask codegen aya 3 years ago
Markus Stange c39dff6025 Add support for PerfEvent programs. 3 years ago
Alessandro Decina c56a6b16aa aya: only consider Text symbols as relocatable functions 3 years ago
Alessandro Decina d9fc0f484f aya: fix bug with nested call relocations
Use the correct offset when looking up relocation entries while doing
nested call relocations.
3 years ago
Dave Tucker e9bad0b61d Make Clippy Happy
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 9c27910f76 aya: update authors and repository link 3 years ago
Dave Tucker 8acb92d61c Remove docs. Update URLs to aya-rs
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 4e1ce2534c obj/btf: Fix size of Unknown variant
The size of Unknown should be ty_size, otherwise when it is encountered,
we never advance the cursor and it creates an infinite loop.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 569b8ca39e obj/btf: Add some tests for reading btf data
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 753a683704 btf: Add bindings for BTF_KIND_FLOAT
Fixes: #34

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina f30abca15e (cargo-release) version 0.10.3 3 years ago
Alessandro Decina 66a12ffcf7 aya: programs: tweak LircMode2::query doc. 3 years ago
Alessandro Decina 8c03ba052a aya: netlink: fix clippy lint 3 years ago
Sean Young 81e07e9661
Implement query for lirc programs (#32)
Signed-off-by: Sean Young <sean@mess.org>
3 years ago
Alessandro Decina fa2cbe2f82 aya: fix clippy warnings 3 years ago
Alessandro Decina c2a90c2c01 aya: tc: add qdisc_detach_program
qdisc_detach_program can be used to detach all the programs that have
the given name. It's useful when you want to detach programs that were
attached by some other process (eg. iproute2), or when you want to
detach programs that were previously left attached because the program
that attached them was killed.
3 years ago
Alessandro Decina 0a9d02140a aya: netlink: fix alignment when writing attributes 3 years ago
Alessandro Decina abb199e6f4 aya: netlink: fix handling of multipart messages 3 years ago
Alessandro Decina 9185f32f6f aya: tc: clean up netlink code a bit 3 years ago
Simone Margaritelli b4b019e447
fix: pass BTF object by reference in order to allow multiple eBPF programs to share it and save memory (closes #30). (#31) 3 years ago
Alessandro Decina d996a88de4 aya: fix formatting 3 years ago
Alessandro Decina 0878c4505a aya: fix clippy warnings 3 years ago
Alessandro Decina 21e01df242 aya: obj: improve parse_map_def tests
Add a test that checks that we handle ELF section padding correctly and
simplify the other tests.
3 years ago
Alessandro Decina b657930a3e aya: don't error out parsing padded map sections
Fixes #28
3 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
3 years ago
Alessandro Decina 9c8e78b7d4 aya: tc: make qdisc_add_clsact return io::Error 3 years ago
Alessandro Decina 122a5306e7 aya, aya-bpf-bindings: regenerate bindings 3 years ago
Alessandro Decina 08c71dfeb1 aya: kprobe: remove pid argument
Kprobes can only be attached globally. Per-pid logic needs to be
implemented on the BPF side with bpf_get_current_pid_tgid.
3 years ago