Commit Graph

1154 Commits (6e570f0f14e615ccd0eeb80dfb68f3674f6ee74a)
 

Author SHA1 Message Date
Kenjiro Nakayama 42baf1c074 Remove bpf_adj_room_mode 2 years ago
Kenjiro Nakayama 5d228695a4 Use map() 2 years ago
Alessandro Decina 8fd8816dfd
Merge pull request #261 from dave-tucker/cgroup_sock
Add Support for BPF_PROG_TYPE_CGROUP_SOCK_ADDR
2 years ago
Kenjiro Nakayama 200d42e414 xtask: Add `bpf_.*` instead of `bpf_map_.*` to allowed type
This patch replaces `bpf_map_.*` with `bpf_.*`.

Currently some types that are not used in helper functions are not generated for bindings - e.g. `bpf_sk_lookup`, `bpf_sockopt` and etc.
This patch replaces `bpf_map_.*` with `bpf_.*`.

Note, this PR does not include bindings files as it would be better to be created by auto script.
The missing bindings can be created by `cargo xtask codegen --libbpf-dir /<PATH_TO>/libbp`.
2 years ago
Dave Tucker 2bac924464 bpf: Add support for BPF_PROG_TYPE_CGROUP_SOCK_ADDR
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker af54b6c818 aya: Add BPF_PROG_TYPE_CGROUP_SOCK_ADDR
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Kenjiro Nakayama 29c10fafb7 Set attach type during load for BPF_PROG_TYPE_CGROUP_SKB
As per title, this patch sets `expected_attach_type` during load.
2 years ago
Alessandro Decina 41a27e3784
Merge pull request #260 from dave-tucker/netlify
Add Netlify Config and Update README
2 years ago
Dave Tucker 7e6530ff1e readme: Add unreleased docs link
This rearranges the README to use fancy badges!
And adds links to the docs published on netlify.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 713ea349fd docs: Add netlify.toml
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 5ff672d8a0
Merge pull request #259 from dave-tucker/xtask
xtask: Add docs build
2 years ago
Dave Tucker 8205bee930 xtask: Add docs build
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Kenjiro Nakayama f721021a0a
Add support for BPF_PROG_TYPE_CGROUP_SYSCTL (#256)
* Add support for BPF_PROG_TYPE_CGROUP_SYSCTL

This patch adds support for `BPF_PROG_TYPE_CGROUP_SYSCTL`.

* Parse unnamed macro

* Fix docs
2 years ago
Dave Tucker 2fca4aee4e
Merge pull request #253 from dave-tucker/forget
aya: Implement forget_link
2 years ago
Dave Tucker 8069ad14d0 aya: Implement forget_link
Fixes #51

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Alessandro Decina b9a544831c
Merge pull request #255 from NoneTirex/main
aya-bpf: Set skb_buff visbility to pub
2 years ago
tirex f1f7185dab Set skb_buff visbility to pub 2 years ago
Alessandro Decina e71e07f88e
Merge pull request #254 from dave-tucker/clippy
clippy: Fix lint against latest nightly
2 years ago
Dave Tucker cdaa3af5ae clippy: Fix lint against latest nightly
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 4afc5ea711
Merge pull request #252 from dave-tucker/multimap-relo
aya: Relocate maps using symbol_index
2 years ago
Dave Tucker d1f2215193 aya: Relocate maps using symbol_index
Since we support multiple maps in the same section, the section_index is
no longer a unique way to identify maps. This commit uses the symbol
index as the identifier, but falls back to section_index for rodata
and bss maps since we don't retrieve the symbol_index during parsing.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Alessandro Decina 4e57d1fe32 aya: revert version to 0.10.7
The world isn't ready to have pre-releases in git
2 years ago
Dave Tucker e1f448e6b7
Merge pull request #251 from aya-rs/codegen
Update libbpf to 3a4e26307d0f9b227e3ebd28b443a1a715e4e17d
2 years ago
dave-tucker d6ca3e1ae7 [codegen] Update libbpf to 3a4e26307d0f9b227e3ebd28b443a1a715e4e17dUpdate libbpf to 3a4e26307d0f9b227e3ebd28b443a1a715e4e17d
Files changed:\nM	aya/src/generated/linux_bindings_aarch64.rs
M	aya/src/generated/linux_bindings_armv7.rs
M	aya/src/generated/linux_bindings_x86_64.rs
M	bpf/aya-bpf-bindings/src/aarch64/bindings.rs
M	bpf/aya-bpf-bindings/src/aarch64/getters.rs
M	bpf/aya-bpf-bindings/src/aarch64/helpers.rs
M	bpf/aya-bpf-bindings/src/armv7/bindings.rs
M	bpf/aya-bpf-bindings/src/armv7/getters.rs
M	bpf/aya-bpf-bindings/src/armv7/helpers.rs
M	bpf/aya-bpf-bindings/src/x86_64/bindings.rs
M	bpf/aya-bpf-bindings/src/x86_64/getters.rs
M	bpf/aya-bpf-bindings/src/x86_64/helpers.rs
2 years ago
Dave Tucker b039ac524e
Merge pull request #249 from alessandrod/new-links
aya: rework links
2 years ago
Dave Tucker e2ebd85d5c
Merge pull request #250 from vadorovsky/aya-gen-disable-debug
aya-gen: Disable Debug derive for BTF types
2 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>
2 years ago
Alessandro Decina 69cc844bbf
Merge pull request #248 from dave-tucker/map_sec
bpf: Maps live in maps section
2 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>
2 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.
2 years ago
Alessandro Decina 5472ac0354
Merge pull request #181 from dave-tucker/multimap
aya: Support multiple maps in map sections
2 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>
2 years ago
Alessandro Decina 2e494a1a29
Merge pull request #247 from nak3:fix-typo
Fix tiny typo
2 years ago
Kenjiro Nakayama 80913c04f3 Fix minor typo 2 years ago
Alessandro Decina 7d08783b18
Merge pull request #245 from alessandrod/memcpy
ebpf: add fallback memcpy
2 years ago
Alessandro Decina 29d539751a ebpf: add fallback memcpy
Add simplest possible memcpy that the verifier should never trip on
2 years ago
Alessandro Decina a1d4499967
Merge pull request #243 from alessandrod/perf-reserve
aya: perf_buffer: call BytesMut::reserve() internally
2 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.
2 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