Commit Graph

55 Commits (263f115fdcd7a257757d4da64ee26380ead31b7b)

Author SHA1 Message Date
Tamir Duberstein 8250a09bc0 Add rustfmt to CI
Tamir Duberstein 5811d6ff56 Replace xtask builds with build scripts
Adapt https://github.com/aya-rs/aya/commit/3d463a3 and subsequent work
to the template. This has worked very well for us in the main project,
and our users should get the same hotness.

Note that xtask is still used for running, as it is in the main project.
Tamir Duberstein 4da4bf4729 Run clippy in CI
Install Rust stable *after* nightly so that the default is stable.
Tamir Duberstein ee45752006 Move dependencies to workspace
Add "{{project-name}}-ebpf" to workspace. Update various cargo configs
to match main aya repo.
Xiaobo Liu d889dd373b Upgrade aya version
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
Xiaobo Liu 44c1f66b7e ebpf: merge rust-analyzer settings
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
catalin-h a006355e62
lsp: support rust-analyzer on helix editor ()
This patch allows the helix editor to correctly initialize the
rust-analyzer when opening a source file from {{project-name}}-ebpf.

To find the Cargo.toml the helix editor must be launched from
the {{project-name}}-ebpf directory or provide the workspace path
as follows:

hx -w <path to {{project-name}}-ebpf> [relative path in {{project-name}}-ebpf]

The patch was tested using helix version 23.10.
Chris Pick d9ce1b7169 ebpf: use TC_ACT_PIPE in classifier
Demonstrate using the correct constant instead of a magic number.
Michal Rostecki f642921fee chore: Use `aya`, `aya-ebpf` and `aya-log` from crates.io
pdliyan 628e6a4f81 Fix unchanged Bpf reference. Would check sock_map latter.
pdliyan bc61bdeeba Rename aya-bpf to aya-ebpf.
pdliyan dce5317f2c Rename aya-bpf to aya-ebpf.
Dave Tucker bccd6d3cb6 ebpf: Don't use name in macros
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Tamir Duberstein afdb45341f Remove branch specifications
The branch should be dictated by the repository.
Dmitry Savintsev 347d37c914 minor space fix for VSCode toml formatting
Signed-off-by: Dmitry Savintsev <dsavints@gmail.com>
Michal Rostecki 11f406414e Unpin Rust nightly
The issues with core::sync::atomic got fixed.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Dmitry Savintsev 8cd95c42ea adjust spacing to avoid VSCode changes on save
Signed-off-by: Dmitry Savintsev <dsavints@gmail.com>
Luca BRUNO 554702e63d
cargo-generate: add perf_event
This adds `perf_event` program type as a template entry.
The new entry comes with a skeleton example which register
scheduled events on each CPU at 1 HZ, triggered by the kernel
(based on clock ticks). The corresponding BPF logic logs each
event, and can identify kernel tasks from userland processes.
Michal Rostecki 3fdfd8b200 rust-toolchain: Add a comment about rust-src
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Josh Taylor 35d480a341 Add rust-src to components
arctic-alpaca 5af9b38bd6
Pin nightly version in -ebpf
Michal Rostecki 70475f3b2a Add raw_tracepoint program type
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Michal Rostecki 379b23b1b4 ebpf: Stop using `unsafe` for the whole function
Users should opt in into `unsafe` when performing particular unsafe
actions (accesing raw pointers, interacting with maps etc.), but
assuming that the whole eBPF program code is unsafe is quite an
exaggeration.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Michal Rostecki 0c4b89b497 ebpf: Change `static mut` to `static` in map declaration
Maps are using UnsafeCell for interior mutability, therefore `static
mut` is not needed anymore.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Michal Rostecki 1ecc829b4f classifier: Use the new `TcContext` struct
That new context type exposes `data` and `data_end` fields for direct
access to the packet payload.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Michal Rostecki f462b301f4 ebpf: Update git repository URL for aya-log
aya-log was moved to the main aya repository, the old one is archived.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Tatsuyuki Ishi c15f1d34de
Fix trailing comma in ebpf/.vscode/settings.json
Kenjiro Nakayama 8621ea7d5f Add cgroup_sockopt template for BPF_PROG_TYPE_CGROUP_SOCKOPT
Kenjiro Nakayama 3bf8e87b3e Add cgroup_sysctl template for BPF_PROG_TYPE_CGROUP_SYSCTL
Since https://github.com/aya-rs/aya/pull/256 supports `BPF_PROG_TYPE_CGROUP_SYSCTL`,
this patch adds cgroup_sysctl template.
Dave Tucker 807131b955
Merge pull request from nak3/add-socket-filter
Add template for socket_filter program type
Michal Rostecki 0ea4a7eb04 Add aya-log
This change adds aya-log and example log messsages to all eBPF
programs.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Michal Rostecki 04584fe9c5 ebpf: Make the dev target identical to release
eBPF programs cannot be debugged and those ones built with the default
dev profile are often annoying the verifier. Therefore it doesn't make
sense to compile not optimized eBPF objects.

However, we still want to let people to use the dev profile, especially
in the future when we want to get rid of xtask by using cargo binary
dependencies[0]. The trick is to have no real difference between dev and
release profile in eBPF.

This change doesn't affect the userspace part which still is going to
contain debug symbols when built with dev profile.

[0] https://rust-lang.github.io/rfcs/3028-cargo-binary-dependencies.html

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
Michal Rostecki ec1910fffd Revert "Use release profile for eBPF programs by default"
This reverts commit ad9b8ee8dc.
Marcus Weiner 220aa73093
Use HTTPS url for git dependency
Dmitry Savintsev aa3b2a4407 use edition 2021
Kenjiro Nakayama 8dcda393c4 Add template for socket_filter program type
This patch adds template for socket_filter.
e.g.

```sh
cargo generate --path ~/dev/aya-template \
         --name my-test \
	 -d program_type=socket_filter
```
Michal Rostecki ad9b8ee8dc Use release profile for eBPF programs by default
This change removes the differentiation between release and dev profiles
for eBPF programs. There is no way eBPF programs can be debugged and
building them with dev profile just makes them slower and often unable
to be verified. They should be always built with the release profile.

After this change, `cargo xtask build-ebpf` is going to build eBPF
programs with release profile. And the userspace program is going to
include eBPF program bytes from target/release/. Regardless of which
profile is being used in the userspace program.

`cargo xtask build-ebpf` has the --profile argument which can be
optionally used (i.e. for user-defined profiles), but by default the
value of that option is `release`.

Signed-off-by: Michal Rostecki <mrostecki@opensuse.org>
Michal Rostecki e1fb8024a6 fentry/fexit: Add template for fentry/fexit programs
Signed-off-by: Michal Rostecki <mrostecki@opensuse.org>
William Findlay d4a4f33902
ebpf: use new SkBuffContext instead of SkSkbContext
William Findlay 3f082e713e
tp_btf: add template for tp_btf programs
William Findlay 7ffb47cc6b
template: add a new template for LSM programs
William Findlay 87e5676648
ebpf: Add rust-analyzer settings for coc.nvim
Mirrors the settings for vscode introduced in e81a33e

Signed-off-by: William Findlay <william@williamfindlay.com>
Alessandro Decina ffa931552e ebpf: use core::hint::unreachable_unchecked()
unreachable!() can panic when debug assertions is on, and we don't want
that inside a panic handler
Dave Tucker c07fea5fbf ebpf: Add rust toolchain override
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Dave Tucker e81a33efcb ebpf: Add rust-analyzer settings for vscode
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Alessandro Decina 7baf4f5688 Sleep while waiting for SIGINT
Alessandro Decina 6d30972fdb ebpf: set debug = 1 to avoid a potential segfault in LLVM
Alessandro Decina dcf738cd46 Switch git urls to aya-rs
Dave Tucker 566934ccb6
Merge pull request from aya-rs/skel
Use cargo-generate conditionals to provide skeletons for all supported program types
Dave Tucker 60badbcc73
Merge pull request from alessandrod/cargo-toml-target
ebpf: set target and enable -Z build-std in .cargo/config.toml