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.
3 years ago
Alessandro Decina
98b36b23bc
Merge pull request #116 from eero-thia/thia/close
...
aya: close file descriptors on Map drop.
3 years ago
Alessandro Decina
2955ca1d1f
Merge pull request #121 from eero-thia/thia/programs_mut
...
aya: programs_mut iterator to complement programs.
3 years ago
Thia Wyrod
c7f8db9a0b
aya: programs_mut iterator to complement programs.
3 years ago
Thia Wyrod
1584bc47bd
aya: close file descriptors on Map drop.
3 years ago
Thia Wyrod
f8f17a09fb
aya: expand include_bytes_aligned to accept expressions.
...
This allows one to this macro with literal expressions involving macros
such as concat! and env!.
3 years ago
Alessandro Decina
6db30fad9c
Merge pull request #108 from deverton/kprobe-debugfs
...
Support k/uprobes on older kernels.
3 years ago
Dan Everton
0e84610976
Refactoring after feedback.
3 years ago
Rust Plumber
761cb79fe3
aya: fix test warnings ( #111 )
3 years ago
Dan Everton
606c3267c4
Support pid filtering in debugfs
3 years ago
Dan Everton
1dc75542b4
Handle probe entry offsets
3 years ago
Dan Everton
4e6aeb2e69
Merge branch 'main' into kprobe-debugfs
3 years ago
Dan Everton
3dff6e8555
Updates based on feedback
3 years ago
Dan Everton
4277205e9d
Use current kernel version as default if not specified
...
When a BPF program doesn't specify the target kernel version, the
most compatible option is to set the program kernel version to match
the currently running kernel.
3 years ago
Dan Everton
42c9737d47
Functional detach of debugfs probes.
3 years ago
Dan Everton
a4faabcf93
Fix event_alias comparison when looking in event list
3 years ago
Dan Everton
84fa2197ec
Don't duplicate perf_attach code and formatting
3 years ago
Dan Everton
d0321bd1ee
Attempt auto detach of probe for debugfs
3 years ago
Dan Everton
34aa790a91
Support k/uprobes on older kernels.
...
Prior to kernel 4.17 probes were attached via debugfs and this patch
attempts to make that work.
Tested on kernel 4.14.
3 years ago
Dan Everton
07e3824aa4
chore: formatting
3 years ago
Dan Everton
49f6a8e819
Stub `kernel_version` for tests
3 years ago
Dan Everton
d966881e46
Fix lint issues
3 years ago
Dan Everton
fc0861105a
fix: make maps compatible with kernel <= 4.14
...
In kernel 4.15 and additional parameter was added to allow maps to have
names but using this breaks on older kernels.
This change makes it so the name is only added on kernels 4.15 and
newer.
3 years ago
Alessandro Decina
182182d840
(cargo-release) version 0.10.6
3 years ago
Dave Tucker
352e54b724
obj: fix name parsing for sk_skb sections
...
This commit fixes name parsing of sk_skb sections such that both named
and unnamed variants will work correctly.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
alessandrod
4a7f47d93a
Update libbpf to 16dfb4ffe4aed03fafc00e0557b1ce1310a09731
3 years ago
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
4 years ago
Alessandro Decina
66a12ffcf7
aya: programs: tweak LircMode2::query doc.
4 years ago
Alessandro Decina
8c03ba052a
aya: netlink: fix clippy lint
4 years ago
Sean Young
81e07e9661
Implement query for lirc programs ( #32 )
...
Signed-off-by: Sean Young <sean@mess.org>
4 years ago
Alessandro Decina
fa2cbe2f82
aya: fix clippy warnings
4 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.
4 years ago
Alessandro Decina
0a9d02140a
aya: netlink: fix alignment when writing attributes
4 years ago
Alessandro Decina
abb199e6f4
aya: netlink: fix handling of multipart messages
4 years ago
Alessandro Decina
9185f32f6f
aya: tc: clean up netlink code a bit
4 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 )
4 years ago
Alessandro Decina
d996a88de4
aya: fix formatting
4 years ago
Alessandro Decina
0878c4505a
aya: fix clippy warnings
4 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.
4 years ago
Alessandro Decina
b657930a3e
aya: don't error out parsing padded map sections
...
Fixes #28
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
Alessandro Decina
9c8e78b7d4
aya: tc: make qdisc_add_clsact return io::Error
4 years ago
Alessandro Decina
122a5306e7
aya, aya-bpf-bindings: regenerate bindings
4 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.
4 years ago
Arnabjyoti Kalita
35f15f70e0
aya: add minimum kernel version for each map and program type ( #18 )
4 years ago
Alessandro Decina
bb15e82c1d
aya: add missing load() in kprobe example
...
Fixes #17
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
Alessandro Decina
5f0ff1698a
aya: netlink: tc: use ptr::read_unaligned instead of deferencing a potentially unaligned ptr
4 years ago
Alessandro Decina
7f2ceaf12e
aya: netlink: port TC code to using new nlattr utils
4 years ago
Alessandro Decina
d9b5ab575f
aya: netlink: refactor nlattr writing code
4 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.
4 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.
4 years ago
Alessandro Decina
0188622580
aya: fix tracepoint prefix in a couple more places
4 years ago
Alessandro Decina
a0151dd485
aya: fix trace point section name
...
Trace points have prefix "tracepoint" not "trace_point".
4 years ago
Alessandro Decina
521ef09463
Merge pull request #4 from seanyoung/doctest
...
Fix doctest and run them during CI
4 years ago
Alessandro Decina
d70e291580
(cargo-release) version 0.10.2
4 years ago
Alessandro Decina
fee71b42f1
aya: tc: fix QdiscRequest layout
4 years ago
Sean Young
1196ba1dcc
Fix doctest and run them during CI
...
Signed-off-by: Sean Young <sean@mess.org>
4 years ago
Sean Young
b49ba69d09
Add support for lirc programs
...
Signed-off-by: Sean Young <sean@mess.org>
4 years ago
Alessandro Decina
304abfbfeb
(cargo-release) version 0.10.1
4 years ago
LOU Xun
f1fc30411d
Fix Bpf::load_file when BTF doesn't exist
4 years ago
Alessandro Decina
94b5e2e4e6
Copy readme into aya/
4 years ago
Alessandro Decina
7694bacf04
aya: add more fields to Cargo.toml
4 years ago
Alessandro Decina
be0b7bbd83
Doc fixes
4 years ago
Alessandro Decina
9f7b017d5d
aya: bump version to 0.10
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
ad58e171ff
aya: refactor tc code a bit and add 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
2cda5dbbe7
aya: implement ProgramFd for CgroupSkb
4 years ago
Alessandro Decina
2d7b9b2e90
aya: fix CgroupSkb docs
4 years ago
Alessandro Decina
08a68faf8a
aya: programs: add support for BPF_PROG_TYPE_CGROUP_SKB programs
4 years ago
Alessandro Decina
fb3e2f7f9d
aya: programs: fix detaching programs attached with bpf_prog_attach
4 years ago
Alessandro Decina
665802594c
aya: programs: fix syscall name in errors
4 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.
4 years ago
Alessandro Decina
b92b1e18a9
aya: improve call relocation error messages
4 years ago
Alessandro Decina
20b2d4c77d
aya: BpfError: set the #[source] attribute for RelocationErrors
4 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.
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
dc4e020f29
aya: netlink: improve error messages
4 years ago
Alessandro Decina
5effc972ac
aya: add support for BPF_PROG_TYPE_SCHED_CLS programs
4 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.
4 years ago
Alessandro Decina
3b7ffd0048
aya: update generated bindings
...
Update generated bindings with kernel headers from libbpf 4ccc1f0
4 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.
4 years ago
Alessandro Decina
607cf68a69
aya: xdp: set flags when attaching with netlink
4 years ago
Alessandro Decina
bb7728a2c5
aya: fix BpfError display strings
4 years ago
Alessandro Decina
9e12c9324c
aya: fix warnings
4 years ago
Alessandro Decina
9a24f20e6f
aya: programs: rework load_program() retry code a bit
4 years ago
Alessandro Decina
144175434f
aya: programs: add support for SkMsg programs
4 years ago
Alessandro Decina
dad300c88b
aya: maps: add SockHash
4 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