Tamir Duberstein
4fef255823
disallow (some) as conversions
...
See https://rust-lang.github.io/rust-clippy/master/#/as_conversions .
1 year ago
Michal Rostecki
33baf7ef22
aya-bpf/maps: Add `get_ptr` and `get_mut_ptr` methods to Array
...
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Ricky Han
fbfbedb6a8
cargo fmt
2 years ago
Ricky Han
e9ec257328
Add test case
2 years ago
Hengqi Chen
e12e8a9ded
aya-bpf/maps: Create LPMTrie with BPF_F_NO_PREALLOC
...
The Linux kernel requires BPF_F_NO_PREALLOC on creating LPMTrie ([0]).
Add BPF_F_NO_PREALLOC flag in LPMTrie constructor.
Closes #332 .
[0]: https://github.com/torvalds/linux/blob/9e6b19a66d9b/kernel/bpf/lpm_trie.c#L551
Signed-off-by: Hengqi Chen <chenhengqi@outlook.com>
2 years ago
Gabi
14bad9ba92
aya-bpf: minor fix lpm_trie::key docs
2 years ago
Dave Tucker
6ab7148731
bpf: Only use never type with rust nightly
...
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Michal Rostecki
ee15fbbbc5
bpf: Use `then_some` instead of `then(|| [...])`
...
This change fixes the `unnecessary_lazy_evaluations` clippy warning.
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
tirex
741c35f555
Restore previous check for bpf_get_stackid
2 years ago
tirex
42c4d5c3af
Temporary change return value condition to avoid problems with possibly (not aware) cast from int to long
2 years ago
tirex
5b1a3ed866
Fix return value for map removing/deleting
2 years ago
Tatsuyuki Ishi
5e24cf7a29
bpf: Remove unnecessary Sync bound on PerCpuArray<T>
2 years ago
Alessandro Decina
82cd3e695a
ebpf: PerCpuArray: remove get_mut() and add get_ptr() and get_ptr_mut()
...
get_mut() wasn't sound as it allowed creating multiple mutable
references.
2 years ago
Tatsuyuki Ishi
41c6b56142
bpf: Replace map types to use &self, remove HashMap::get_mut
...
The bpf_map_defs are now wrapped with UnsafeCell, which also happens to
provide a cozy way to get a *mut pointer. An UnsafeCell isn't strictly
required as the struct fields are practically opaque to us, but using an
UnsafeCell follows the general best practices against miscompilation and
also prevents some obvious errors.
HashMap::get_mut was removed because the idea is completely unsound.
Previous users should wrap their data with UnsafeCell instead or use
atomics.
Closes: https://github.com/aya-rs/aya/issues/233
2 years ago
Alessandro Decina
16337001e4
Merge pull request #286 from nak3/add-BPF_MAP_TYPE_BLOOM_FILTER
...
Add support for BPF_MAP_TYPE_BLOOM_FILTER
2 years ago
Kenjiro Nakayama
c5d5695a71
Add missing BPF_MAP_TYPE_STACK in BPF code
...
Currently BPF_MAP_TYPE_STACK is supported by user code (`aya/src/maps/stack.rs`),
but it does not support the BPF_MAP_TYPE_STACK BPF code.
This patch fixes it.
2 years ago
Dave Tucker
74704c3b28
bpf: Support BPF_PROG_TYPE_SK_LOOKUP
...
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Kenjiro Nakayama
c4262f793d
Add support for BPF_MAP_TYPE_BLOOM_FILTER
...
This patch adds support for `BPF_MAP_TYPE_BLOOM_FILTER`.
2 years ago
Dave Tucker
4a32e7d985
clippy: fix new lints on nightly
...
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina
ecd6a6e96b
bpf: hash_map: add get_mut() method
3 years ago
Nimrod Shneor
d0b6daa091
Add LPMTrie Map to aya-bpf for BPF programs
3 years ago
William Findlay
df26fd94a7
bpf/program_array: use never type, add unsafe flag, and document safety
3 years ago
William Findlay
ff14493751
bpf/maps: implement ProgramArray
...
This PR implements the ProgramArray map type in aya-bpf. Includes a convenient tail_call
method that wraps the bpf_tail_call helper.
3 years ago
Thia Wyrod
b655cf973f
aya-bpf: remove unnecessary unsafe markers on map functions.
...
Map lookup and deletion can yield stale keys and values by virtue of
sharing a data structure with userspace programs and other BPF programs
which can modify it. However, all accesses remain perfectly safe and will
not cause memory corruption or data races.
3 years ago
Alessandro Decina
8043451973
bpf: re-export Lru hash maps from aya_bpf::maps
3 years ago
Alessandro Decina
c0f695c4b6
bpf: Add LruHashMap and LruPerCpuHashMap
3 years ago
Dave Tucker
8a6fe4a640
bpf: Rename SkSkbContext to SkBuffContext
...
This is necessary since the context is used in many other program types
and not just in SK_SKB programs.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker
2a8ba55b7e
bpf: Implement redirect for skbs on sockmap/sockhash
...
This implements redirect_skb and renames redirect to redirect_msg
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina
4116442cda
bpf: PerfEventByteArray: remove unused import
3 years ago
Alessandro Decina
0220a4192c
bpf: add PerfEventByteArray
...
Similar to PerfEventArray but allows to output variable length byte
slices
3 years ago
Alessandro Decina
23a70382b2
bpf: PerfEventArray: tweak output API
3 years ago
Alessandro Decina
ea91fe08d3
bpf: rename PerfMap to PerfEventArray
3 years ago
Dave Tucker
69041954cb
bpf: Added pinned constructor to maps
...
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina
269be03a89
bpf: add PerCpuArray
3 years ago
Alessandro Decina
a68ff47246
aya-bpf, aya-bpf-bindings: fix clippy lints
3 years ago
Tw
55ba0538f2
bpf: add support for tracepoint program ( #29 )
...
This patch add initial support for tracepoint program type.
Hope you enjoy.
Signed-off-by: Tw <wei.tan@intel.com>
3 years ago
Tw
d1b7b024dc
bpf: fix a minor bug due to stackid allocation
...
The type casting introduces an allocation, this will cause compiling failure when linking final bpf target.
So remove this casting to fix this issue.
BTW, the following is the failure I met:
= note: 07:24:12 [ERROR] fatal error: "unable to allocate function return #1"
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0. Running pass 'Function Pass Manager' on module 'trace_bpf-001a275b17e9eb12'.
1. Running pass 'BPF DAG->DAG Pattern Instruction Selection' on function '@_ZN7aya_bpf4maps11stack_trace10StackTrace11get_stackid17h32b649bc3780c0aaE'
Signed-off-by: Tw <wei.tan@intel.com>
3 years ago
Tw
fd20bd5e23
bpf: add support for STACK_TRACE map
...
This path support initial support for BPF_MAP_TYPE_STACK_TRACE.
Signed-off-by: Tw <wei.tan@intel.com>
3 years ago
Alessandro Decina
122a5306e7
aya, aya-bpf-bindings: regenerate bindings
3 years ago
Alessandro Decina
8cd669ca9a
xtask: fix include paths for kernel headers bundled with libbpf
3 years ago
Alessandro Decina
67d35cc1d3
bpf: fix PerfMap::output() API when appending context data
...
map.output(&ctx, &data, nr_bytes) can be used to append nr_bytes from
the current context to the &data event.
3 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.
3 years ago
Alessandro Decina
240c65507b
bpf: add HashMap::remove()
3 years ago
Alessandro Decina
696ae6079c
bpf: Add HashMap::pinned API
4 years ago
Alessandro Decina
bf4892d0db
bpf: add support for Queue and SockMap maps
4 years ago
Alessandro Decina
575e85c412
bpf: add id and pinning fields to bpf_map_def
4 years ago
Alessandro Decina
ab8d512b60
bpf: add HashMap::insert
4 years ago
Alessandro Decina
4febbc3fae
bpf: perf_map: fix type error
4 years ago
Alessandro Decina
8e6f447e9b
bpf: sk_skb: add helper methods
...
This adds support for skb_store_bytes, skb_load_bytes and
l4_csum_replace to SkSkbContext.
4 years ago
Alessandro Decina
1b314ded2f
bpf: add SockHash::redirect
4 years ago