Commit Graph

1271 Commits (bf7fdff1cef28961f096d1c1e00181e0a0c2d14e)
 

Author SHA1 Message Date
Dave Tucker bf7fdff1ce aya: Find programs using the symbol table
This makes a few changes to the way that Aya reads the ELF object
files.

1. To find programs in a section, we use the symbols table. This allows
   for cases where multiple programs could appear in the same section.
2. When parsing our ELF file we build symbols_by_section_index as an
   optimization as we use it for legacy maps, BTF maps and now programs.

As a result of theses changes the "NAME" used in `bpf.prog_mut("NAME")`
is now ALWAYS the same as the function name in the eBPF code, making the
user experience more consistent.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Tamir Duberstein f705eabe66
Merge pull request #696 from Tuetuopay/tests-netns
test: add the possibility to run a test inside a network namespace
1 year ago
Dave Tucker 8778c4ca29
Merge pull request #695 from aya-rs/mergify/dave-tucker/config-update
ci(Mergify): configuration update
1 year ago
Dave Tucker 34d1d7a9d7 ci(Mergify): configuration update
This does 3 things:

- Automatically merges Dependabot PRs that pass CI
- Labels all PRs 🙏 which was previously done manually for the release note generation
- Assigns Alessandro to review any PR for which xtask/public-api/aya.txt has changed

Signed-off-by: Dave Tucker <datucker@redhat.com>
1 year ago
Tuetuopay c74813f8c5 test: add the possibility to run a test inside a network namespace
For tests that do networking operations, this allows to have a
clean-state network namespace and interfaces for each test. Mainly, this
avoids "device or resource busy" errors when reusing the loopback
interface across tests.
1 year ago
Tamir Duberstein e95f76a5b3
Merge pull request #699 from aya-rs/cache-again-god-damn-it
Misc testing improvements
1 year ago
Tamir Duberstein 8961be9526
Do not escape newlines on Err(LoadError).unwrap()
Wrap verifier logs in a newtype whose `Debug` impl emits unescaped
newlines. This improves ergonomics in tests where we `Result::unwrap()`
those load errors; when these fail today they emit the errors with
newlines escaped, making them incredibly difficult to read.
1 year ago
Tamir Duberstein 49cbb1366f
integration-test: rerun-if-changed=integration-ebpf
See code commentary for details.
1 year ago
Tamir Duberstein 13e83b24ee
Merge pull request #662 from nrxus/use-owned-fd-for-btf
Use `OwnedFd` for BTF's file descriptor
1 year ago
Andrés Medina ea96c29ccb aya: Use Arc<OwnedFd> when loading BTF fd
This fixes an existing file descriptor leak when there is BTF data in
the loaded object.

To avoid lifetime issues while having minimal impact to UX the
`OwnedFd` returned from the BPF_BTF_LOAD syscall will be wrapped in an
`Arc` and shared accross the programs and maps of the loaded BPF
file.
1 year ago
Andrés Medina 683a1cf2e4 aya: Make SysResult generic on Ok variant 1 year ago
Andrés Medina c63d9904f7 Replace std::os::unix::io for std::os::fd
This is just taking https://github.com/aya-rs/aya/pull/633 to its
logical conclusion. Because `std::os::fd` was only introduced as a
module in Rust v1.66.0 I have also updated the `Cargo.toml` of the
`aya` package to reflect the true MSRV. Note that this commit is *not*
the cause for this MSRV bump, that was done by a previous commit, this
commit is just making it explicit in the `Cargo.toml`
1 year ago
ajwerner 1bc9a1ad04
Merge pull request #697 from aya-rs/log-env-too
integration-test: Remove RUSTC from cargo-in-cargo
1 year ago
Tamir Duberstein d62ae98889
integration-test: Remove RUSTC from cargo-in-cargo
Fixes #686.
1 year ago
Tamir Duberstein f334cbd86e
Merge pull request #693 from aya-rs/public-diff-backwards
xtask: reverse public API diff direction
1 year ago
Tamir Duberstein 8d7545aff8
xtask: reverse public API diff direction
This is currently producing inverse diffs.
1 year ago
Dave Tucker 41fc87c2e6
Merge pull request #691 from aya-rs/public-api-followup
public api followup
1 year ago
Tamir Duberstein 321bda7539
public-api: simplify and improve output 1 year ago
Tamir Duberstein 06d6a3e7a6
vscode: exclude public-api fixtures from search 1 year ago
ajwerner 8e144a5c29
Merge pull request #661 from ajwerner/integration-tests-in-release
integration-tests: run in release also
1 year ago
Dave Tucker e30df50fb7
Merge pull request #682 from dave-tucker/public-api
xtask: Add cargo-public-api
1 year ago
Dave Tucker f833f1fc1d xtask: Add cargo-public-api
Adds cargo-public-api. This allows for public API changes to get caught
in CI, requiring new changes to be "blessed" by using:

  cargo xtask public-api --bless

When this file is changed for aya, Alessandro will need to review the PR.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Andrew Werner 7575628d1b integration-tests: run in release also
In release, the trigger functions were being optimized out and the
tests did not work. Use core::hint::black_box to ensure that the
functions are not optimized out. Also, run these integration tests
in CI to ensure that we don't regress.
1 year ago
Tamir Duberstein 53d36a3fe0
Merge pull request #688 from aya-rs/get-fd-owned
sys: bpf_prog_get_fd_by_id returns OwnedFd
1 year ago
Tamir Duberstein eb80e6f37e
Merge pull request #689 from aya-rs/parallel-ci
github: parallel all the CI
1 year ago
Tamir Duberstein d6322d2da3
github: parallel all the CI
Human time is more precious than computer time.
1 year ago
Tamir Duberstein 76c78e3bf8
sys: bpf_prog_get_fd_by_id returns OwnedFd 1 year ago
Tamir Duberstein 51cd36378a
Merge pull request #687 from ajwerner/cargo-args
xtask: allow arbitrary flags to cargo build
1 year ago
Tamir Duberstein a6b1fb9a1e xtask: allow arbitrary flags to cargo build 1 year ago
Tamir Duberstein 5ebaf5f393
Merge pull request #683 from aya-rs/logs-wtf
Refactor log macro for readability
1 year ago
Dave Tucker 68174d7d73
Merge pull request #685 from aya-rs/dependabot/cargo/cargo_metadata-0.17.0
build(deps): update cargo_metadata requirement from 0.15.4 to 0.17.0
1 year ago
dependabot[bot] 4b6579e2f1
build(deps): update cargo_metadata requirement from 0.15.4 to 0.17.0
Updates the requirements on [cargo_metadata](https://github.com/oli-obk/cargo_metadata) to permit the latest version.
- [Release notes](https://github.com/oli-obk/cargo_metadata/releases)
- [Changelog](https://github.com/oli-obk/cargo_metadata/blob/main/CHANGELOG.md)
- [Commits](https://github.com/oli-obk/cargo_metadata/compare/0.15.4...0.15.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
1 year ago
vadorovsky aed74d5ab3
Merge pull request #669 from aya-rs/bpf-linker-hella-warnings
integration-test: shuttle linker logs to user
1 year ago
Tamir Duberstein b3db9161eb
Refactor log macro for readability
This happens to fix the miscompilation that occurs when bpf-linker is
moved to LLVM's new pass manager. A later commit will avoid the
miscompilation more convincingly.
1 year ago
Tamir Duberstein 74fc50bf7e
integration-test: shuttle stdio to user
Trampoline cargo-in-cargo stdio through cargo:warning to ensure the user
sees all the output.

Use bpf-linker from git in CI so we can see what's going on there.
1 year ago
Dave Tucker ec5ff01e41
Merge pull request #681 from aya-rs/fix-cargo-test
test: document cargo build scripts
1 year ago
Tamir Duberstein a84bd1a95d
test: document cargo build scripts 1 year ago
Tamir Duberstein 8cec4b25f9
Revert "integration-test: add to default-members"
This reverts commit 025c76780c.

Fixes #678.
1 year ago
Dave Tucker ff11c65734
Merge pull request #680 from dave-tucker/ci-cleanup
.github: Consolidate CI workflows into one
1 year ago
Dave Tucker 3b859ba70a ci: Bump ubunutu
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Dave Tucker cf0c866458 .github: Consolidate CI workflows into one
This gives a better view of the CI pipeline in Github.
Gives us control over what runs and when.
And finally, lets us check only a single status in mergify.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
vadorovsky f554d42105
Merge pull request #667 from vadorovsky/workspace-dependencies
cargo: Define dependencies on the workspace level
1 year ago
Mike Rostecki 96fa08bd82 cargo: Define dependencies on the workspace level
This way we will avoid version mismatches and make differences in
features across our crates clearer.
1 year ago
Tamir Duberstein 05e782abbf
Merge pull request #677 from aya-rs/ebpf-dep-better
rebuild ebpf on bpf-linker
1 year ago
Tamir Duberstein 6fc09ca07a
integration-test: build-dep on integration-ebpf
Remove the manual dependency tracking machinery in
integration-test/build.rs in favor of a build-dependency on
integration-ebpf. This required adding an empty lib.rs to create the
library target.

This allows integration-test/build.rs to be ignorant of bpf-linker.
Remove that in favor of the logic now in integration-ebpf.
1 year ago
Tamir Duberstein e276c07f73
integration-ebpf: invalidate on bpf-linker
Extract the symlink-to-bpf-linker logic from integration-test to xtask
and use it in a new build script in integration-ebpf, causing ebpf
probes to be rebuilt when bpf-linker changes. Previously bpf-linker
changes would rebuild integration-test, but not integration-ebpf,
resulting in stale tests.

Note that this still doesn't address the possibility that a new
bpf-linker is added to the PATH ahead of the cached one. Solving this in
the general case would require rebuild-if-changed-env=PATH *and*
rebuild-if-changed={every-directory-in-PATH} which would likely mean far
too much cache invalidation.
1 year ago
Tamir Duberstein 0168396604
integration-ebpf: add cargo config
Same reasoning as the one in bpf.
1 year ago
Tamir Duberstein 025c76780c
integration-test: add to default-members
This works now that build.rs does the right thing.

Update the `miri test` command in the lint job so it has the proper
exclusions; it is now in line with the invocations in the build-test job.
1 year ago
ajwerner b28d4c34ee
Merge pull request #674 from ajwerner/use-nightly-to-build-ebpf
test/integration-test: use +nightly for ebpf
1 year ago
Andrew Werner 97eb8afeac integration-test: use nightly toolchain with ebpf
The ebpf probes require a nightly compiler. Before this change, if you
ran `cargo xtask integration-test` with a stable compiler toolchain as
default, or you ran `cargo +stable xtask integration-test`, you would
have seen an error like the one below. This is now fixed by running the
cargo build command in the integration-ebpf directory and making sure
to clear the RUSTUP_TOOLCHAIN env var.

```
  --- stderr
  /home/ajwerner/src/github.com/aya-rs/aya/test/integration-test/bpf/ring_buf_sched_tracepoint.bpf.c:18:21: warning: declaration of 'struct switch_args' will not be visible outside of this function [-Wvisibility]
  int bpf_prog(struct switch_args* ctx)
                      ^
  1 warning generated.
  error: the `-Z` flag is only accepted on the nightly channel of Cargo, but this is the `stable` channel
  See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
  thread 'main' panicked at '"cargo" "build" "-p" "integration-ebpf" "-Z" "build-std=core" "--release" "--message-format=json" "--target" "bpfel-unknown-none" "--target-dir" "/home/ajwerner/src/github.com/aya-rs/aya/target/debug/build/integration-test-9bbcb3db5e9f8f57/out/integration-ebpf" exited
with status code 101:
  ', test/integration-test/build.rs:219:25
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: error while building userspace application

Caused by:
    Child { stdin: None, stdout: None, stderr: None, .. } exited with status code 101:
```
1 year ago