Commit Graph

530 Commits (b039ac524e2ba732f48f1117f14eb9c69299e6a5)
 

Author SHA1 Message Date
Dave Tucker b039ac524e
Merge pull request #249 from alessandrod/new-links
aya: rework links
3 years ago
Dave Tucker e2ebd85d5c
Merge pull request #250 from vadorovsky/aya-gen-disable-debug
aya-gen: Disable Debug derive for BTF types
3 years ago
Michal Rostecki bd336acb02 aya-gen: Disable Debug derive for BTF types
It's a workaround for the upstream bindgen issue:

https://github.com/rust-lang/rust-bindgen/issues/2083

tl;dr: Rust nightly complains about #[repr(packed)] structs deriving
Debug without Copy.

It needs to be fixed properly upstream, but for now we have to disable
Debug derive here.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
3 years ago
Alessandro Decina 69cc844bbf
Merge pull request #248 from dave-tucker/map_sec
bpf: Maps live in maps section
3 years ago
Dave Tucker f12c0269d0 bpf: Maps live in maps section
This forces all maps to the maps section so we remain compatible with
libbpf. This requires #181 to avoid breaking userspace.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina cb57d10d25 aya: rework links
Remove LinkRef and remove the Rc<RefCell<_>> that was used to store
type-erased link values in ProgramData. Among other things, this allows
`Bpf` to be `Send`, which makes it easier to use it with async runtimes.

Change the link API to:

    let link_id = prog.attach(...)?;
    ...
    prog.detach(link_id)?;

Link ids are strongly typed, so it's impossible to eg:

    let link_id = uprobe.attach(...)?;
    xdp.detach(link_id);

As it would result in a compile time error.

Links are still stored inside ProgramData, and unless detached
explicitly, they are automatically detached when the parent program gets
dropped.
3 years ago
Alessandro Decina 5472ac0354
Merge pull request #181 from dave-tucker/multimap
aya: Support multiple maps in map sections
3 years ago
Dave Tucker f357be7db4 aya: Support multiple maps in map sections
This commit uses the symbol table to discover all maps inside an ELF
section. Instead of doing what libbpf does - divide the section data
in to equal sized chunks - we read in to section data using the
symbol address and offset, thus allowing us to support definitions
of varying lengths.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 2e494a1a29
Merge pull request #247 from nak3:fix-typo
Fix tiny typo
3 years ago
Kenjiro Nakayama 80913c04f3 Fix minor typo 3 years ago
Alessandro Decina 7d08783b18
Merge pull request #245 from alessandrod/memcpy
ebpf: add fallback memcpy
3 years ago
Alessandro Decina 29d539751a ebpf: add fallback memcpy
Add simplest possible memcpy that the verifier should never trip on
3 years ago
Alessandro Decina a1d4499967
Merge pull request #243 from alessandrod/perf-reserve
aya: perf_buffer: call BytesMut::reserve() internally
3 years ago
Alessandro Decina ad1636d2e7 aya: perf_buffer: call BytesMut::reserve() internally
This changes PerfBuffer::read_events() to call BytesMut::reserve()
internally, and deprecates PerfBufferError::MoreSpaceNeeded.

This makes for a more ergonomic API, and allows for a more idiomatic
usage of BytesMut. For example consider:

    let mut buffers = vec![BytesMut::with_capacity(N), ...];
    loop {
        let events = oob_cpu_buf.read_events(&mut buffers).unwrap();
        for buf in &mut buffers[..events.read] {
            let sub: Bytes = buf.split_off(n).into();
            process_sub_buf(sub);
        }
        ...
    }

This is a common way to process perf bufs, where a sub buffer is split
off from the original buffer and then processed. In the next iteration
of the loop when it's time to read again, two things can happen:

- if processing of the sub buffer is complete and `sub` has been
dropped, read_events() will call buf.reserve(sample_size) and hit a fast
path in BytesMut that will just restore the original capacity of the
buffer (assuming sample_size <= N).

- if processing of the sub buffer hasn't ended (eg the buffer has been
stored or is being processed in another thread),
buf.reserve(sample_size) will actually allocate the new memory required
to read the sample.

In other words, calling buf.reserve(sample_size) inside read_events()
simplifies doing zero-copy processing of buffers in many cases.
3 years ago
Alessandro Decina f75d968657
Merge pull request #239 from nak3/pub-ops
aya-bpf: expose bpf_sock_ops of SockOpsContext
3 years ago
Alessandro Decina 5356e21b00
Merge pull request #240 from nak3/pub-sk-msg
aya-bpf: expose sk_msg_md of SkMsgContext
3 years ago
Kenjiro Nakayama 360560ec4e aya-bpf: expose sk_msg_md of SkMsgContext
This patch expose sk_msg_md of SkMsgContext.
3 years ago
Kenjiro Nakayama 6bc5a4d82d aya-bpf: expose bpf_sock_ops of SockOpsContext
This patch expose bpf_sock_ops of `SockOpsContext`.
3 years ago
Alessandro Decina f01497e021 (cargo-release) version 0.10.7 3 years ago
Alessandro Decina 37afde3fca aya-gen: fix lint error 3 years ago
Alessandro Decina 9a642d373f aya: fix lint errors 3 years ago
Alessandro Decina 5390fb1ee1
Merge pull request #187 from vadorovsky/sk-buff-socket-uid
bpf: sk_buff: Add get_socket_uid method to SkBuffContext
3 years ago
Alessandro Decina d690710337
Merge pull request #228 from nak3/fix-socket_filter
Fix socket_filter section match
3 years ago
Alessandro Decina 3dc9308c8e
Merge pull request #229 from dave-tucker/fix_cgroup_skb_attach_v2
aya: Fix Loading from cgroup/skb sections
3 years ago
Alessandro Decina 02c376ceb7
Merge pull request #224 from Tuetuopay/pod-arrays
aya: implement Pod for arrays of Pod types
3 years ago
Alessandro Decina 5269ab5b1c
Merge pull request #238 from vadorovsky/fix-doc-set-global
bpf: Improve documentation of set_global method
3 years ago
Michal Rostecki 7dd2e3d1f8 bpf: Improve documentation of set_global method
Use `static` instead of `const` and mention the necessity of using
`core::ptr::read_volatile`.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
3 years ago
Alessandro Decina 7fdf37ad51
Merge pull request #237 from hi120ki/fix-typo-fentry
fix typo in aya/src/programs/fentry.rs
3 years ago
Hi120ki ab462533c7 fix typo in aya/src/programs/fentry.rs 3 years ago
Michal Rostecki 34d74fcd3b bpf: sk_buff: Add get_socket_uid method to SkBuffContext
This change exposes the BPF helper bpf_socket_get_uid as a public method
of SkBuffContext, which allows to get the owner UID of the socket
associated to the sk_buff stored in the context.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
3 years ago
Alessandro Decina d3356398f5
Merge pull request #235 from alessandrod/hash-map-get-mut
bpf: hash_map: add get_mut() method
3 years ago
Alessandro Decina ecd6a6e96b bpf: hash_map: add get_mut() method 3 years ago
Kenjiro Nakayama 5725a97648 Fix unit test 3 years ago
Kenjiro Nakayama 9e41317ca6 Fix socket_filter section match
`BPF_PROG_TYPE_SOCKET_FILTER` program expands the sectionname's kind with `socket` not `socket_filter`.
So current eBPF program with socket filter always fails.

This patch fixes it.

Fix https://github.com/aya-rs/aya/issues/227
3 years ago
Alessandro Decina e0d818ff2d
Merge pull request #234 from xonatius/patch-1
Fix typo in README.md
3 years ago
Daniil Bondarev 49e998dc7e
Fix typo in aya/README.md 3 years ago
Daniil Bondarev ebb91f3c6f
Fix typo in README.md 3 years ago
Alessandro Decina 01fe3a6b5e
Merge pull request #231 from nimrodshn/bpf_lpm_trie
Add LPMTrie Map to aya-bpf for BPF programs
3 years ago
Nimrod Shneor d0b6daa091 Add LPMTrie Map to aya-bpf for BPF programs 3 years ago
Dave Tucker 5ee1321765 aya: Fix Loading from cgroup/skb sections
fa037a88e2 allowed for cgroup skb programs
that did not specify an attach direction to use the cgroup/skb section
name per the convention established in libbpf. It did not add the
necessary code to load programs from those sections which is added in
this commit

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Dave Tucker 00e34ec29c
Merge pull request #222 from aya-rs/dependabot/cargo/parking_lot-0.12.0
build(deps): update parking_lot requirement from 0.11.1 to 0.12.0
3 years ago
Tuetuopay 08211f6132 aya: implement Pod for arrays of Pod types
If a type is POD (meaning it can be converted to a byte array), then an
array of such type is POD.

Signed-off-by: Tuetuopay <tuetuopay@me.com>
3 years ago
Dave Tucker 5cfecbdd8e
Merge pull request #232 from dave-tucker/fix_docs
ci: lint: aya: Skip doctests with miri
3 years ago
Dave Tucker 3d820ee473 ci: lint: aya: Skip doctests with miri
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
Alessandro Decina 5421b71b5b
Merge pull request #230 from dave-tucker/fix_docs
ci: Fix aya-bpf workflow
3 years ago
Dave Tucker 1f047f0dbe ci: Fix aya-bpf workflow
This was testing the aya crate with the nightly toolchain which wasn't
what was intented

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
3 years ago
dependabot[bot] ab7eed2759
build(deps): update parking_lot requirement from 0.11.1 to 0.12.0
Updates the requirements on [parking_lot](https://github.com/Amanieu/parking_lot) to permit the latest version.
- [Release notes](https://github.com/Amanieu/parking_lot/releases)
- [Changelog](https://github.com/Amanieu/parking_lot/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Amanieu/parking_lot/compare/0.11.1...0.12.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
Alessandro Decina 2a18239346
Merge pull request #161 from nimrodshn/add_lpm_trie
Add support for BPF_MAP_TYPE_LPM_TRIE
3 years ago
Nimrod Shneor c6e66d8080 Fix #128: Add support for BPF_MAP_TYPE_LPM_TRIE map 3 years ago
Alessandro Decina 17a3959e87
Merge pull request #183 from dave-tucker/fix-image-build
ci: Fix image build workflow
3 years ago