Commit Graph

1270 Commits (f705eabe667d4abdfd0b895de586cc4145319cf0)
 

Author SHA1 Message Date
Tamir Duberstein 728a25d9d9
vscode: check all targets
Now that building integration tests works out of the box, we can.
1 year ago
Tamir Duberstein 6ac1320707
integration-test: build "fake" by default
Use the environment variable AYA_BUILD_INTEGRATION_BPF to indicate to
the build script that it should *actually* build bpf, otherwise emitting
empty files.

This allows metadata builds to skip costly build steps without
sacrificing ergonomics; all compile-time tools such as cargo clippy work
out of the box.

Cargo even gives each of these builds (depending on the value of the
environment variable) its own cache key, so they do not invalidate each
other when the user alternates between metadata and real builds.

This allows the lint action to move out of the VM.
1 year ago
Tamir Duberstein 9086265ac0
xtask: reimplement build-integration-test
This command builds the integration test binaries and prints their paths
to stdout.
1 year ago
Tamir Duberstein c76d5a9950
integration-test: compile without touching disk 1 year ago
Tamir Duberstein 3d463a3610
integration-test: compile Rust probes using build.rs 1 year ago
Tamir Duberstein bc9f059d53
xtask: inline build_ebpf 1 year ago
Tamir Duberstein 8c61fc9ea6
integration-test: compile C probes using build.rs
- Add libbpf as a submodule. This prevents having to plumb its location
  around (which can't be passed to Cargo build scripts) and also
  controls the version against which codegen has run.
- Move bpf written in C to the integration-test crate and define
  constants for each probe.
- Remove magic; each C source file must be directly enumerated in the
  build script and in lib.rs.
1 year ago
Tamir Duberstein 6ca7d53733
Remove detritus
- rustfmt settings are hierarchical.
- integration-ebpf is always compiled at a distance with flags provided.
- .cargo/config.toml is not respected except at the root of the
  workspace[0].

[0] https://doc.rust-lang.org/cargo/reference/config.html#hierarchical-structure
1 year ago
Tamir Duberstein a840a17308
Merge pull request #648 from aya-rs/clippy-more
Clippy over tests and integration-ebpf
1 year ago
Tamir Duberstein 4fef255823
disallow (some) as conversions
See https://rust-lang.github.io/rust-clippy/master/#/as_conversions.
1 year ago
Tamir Duberstein e621a09181
Clippy over tests and integration-ebpf
Replace all `assert!(matches!(..))` with `assert_matches!(..)`.

Remove the now-unused build-integration-test xtask command whose logic
doesn't match that of the build-and-run command.
1 year ago
Tamir Duberstein 6e9aba55fe
Merge pull request #643 from aya-rs/procfs
Remove procfs dependency
1 year ago
Tamir Duberstein a1e0130387
Type-erase KernelVersion::current error 1 year ago
Tamir Duberstein 6bceb1c3da
Invert comparison
Incorrectly inverted in b611038d5b.
1 year ago
Tamir Duberstein 6e570f0f14
Rewrite kernel version logic
This restores and enhances the logic originally added in #579.
1 year ago
Tamir Duberstein cc2bc0acc1
Remove procfs dependency 1 year ago
Tamir Duberstein b5ebcb7cc5
Remove verifier log special case 1 year ago
Tamir Duberstein 4c0983bca9
Merge pull request #641 from aya-rs/logger-messages-plz
Miscellaneous fixes to allow running integration tests in bpf-linker
1 year ago
Tamir Duberstein b8252f46d9
Skip BPF_F_XDP_HAS_FRAGS tests on unsupported kernels 1 year ago
Tamir Duberstein 91a415f095
Skip relocation tests on unsupported kernels 1 year ago
Tamir Duberstein b45a5bb71b
Get verifier logs when loading programs 1 year ago
Tamir Duberstein 6b94b2080d
Hide details of VerifierLog
This type is really only used by one function.
1 year ago
Tamir Duberstein b0a4ab5f20
xtask: Standardize command logging
Don't run `cargo build --verbose`; it's too noisy.
1 year ago
Tamir Duberstein b611038d5b
Use procfs crate for kernel version parsing
This allows the logic to be shared between aya and the integration tests
without exposing additional public API surface.
1 year ago
Tamir Duberstein 7f25956aea
Add missing test annotation 1 year ago
Tamir Duberstein 32be47a23b
Merge pull request #642 from aya-rs/less-strings
aya: don't allocate static strings
1 year ago
Tamir Duberstein 27120b328a
aya: don't allocate static strings 1 year ago
Alessandro Decina c89c485bca
Merge pull request #627 from nak3/add-riscv
bpf: Add `pt_regs` handling in aya-bpf/args.rs for riscv64
1 year ago
Alessandro Decina ed70a47845
Merge pull request #640 from aya-rs/lossy-conversions
integration-test: Remove integration-test-macros
1 year ago
Tamir Duberstein e08c6471dd
Cargo.toml: suppress resolver warning on nightly
```
warning: some crates are on edition 2021 which defaults to `resolver = "2"`, but virtual workspaces default to `resolver = "1"`
```
1 year ago
Tamir Duberstein 9ca0af1a79
integration-test: Remove integration-test-macros
This doesn't add any value; use `cargo build --tests` with
`--message-format=json` instead; parse the output using `cargo_metadata`
to discover the location of the test binary.

Move test/integration-test/src/tests -> test/integration-test/tests to
conform to
https://doc.rust-lang.org/book/ch11-03-test-organization.html#integration-tests.
1 year ago
Tamir Duberstein ecc03ecfad
xtask: destructure 1 year ago
Tamir Duberstein de1fe1f5e1
xtask: Avoid lossy conversions, spurious vectors 1 year ago
Tamir Duberstein e93e3c4a55
Merge pull request #639 from aya-rs/test-no-bpftool
Remove dependency on bpftool in integration tests
1 year ago
Tamir Duberstein 25859e4e33
xtask: emit clang command on failure 1 year ago
Tamir Duberstein 7067db450a
xtask: Avoid lossy string conversion 1 year ago
Tamir Duberstein 5a2906a6c9
test,xtask: Replace lazy_static with OnceCell
This doesn't affect MSRV because this is testing code.
1 year ago
Tamir Duberstein ff86f1385c
Remove dependency on bpftool in integration tests 1 year ago
Mary 5c86b7ee95
Merge pull request #635 from marysaka/misc/aya-obj-enum-public
misc: aya-obj: Make it possible to externally assemble BtfEnum
1 year ago
Mary d9dfd94f29 misc: aya-obj: Make it possible to externally assemble BtfEnum 1 year ago
Alessandro Decina 4b8ffa40bb
Merge pull request #634 from alessandrod/str-helpers-asm-bounds
bpf: improve bpf_probe_read_kernel_str_bytes and bpf_probe_read_user_str_bytes
1 year ago
Alessandro Decina 11c227743d bpf: improve bpf_probe_read_kernel_str_bytes and bpf_probe_read_user_str_bytes
This change does a few things:

- it fixes a bug in the wrappers, where we were expecting the kernel to
  return len=1 for b"\0" where it instead returns 0 and doesn't write
  out the NULL terminator

- it makes the helpers more robust by hardcoding bound checks in
  assembly so that LLVM optimizations can't transform the checks in a
  way that the verifier can't understand.

- it adds integration tests
1 year ago
Dave Tucker bc0d02143f
Merge pull request #531 from dave-tucker/probe-cookie
aya: Make FEATURES public
1 year ago
Dave Tucker 47f764c191 aya: Make Features part of the public API
This commit adds a new probe for bpf_attach_cookie, which would be used
to implement USDT probes. Since USDT probes aren't currently supported,
we this triggers a dead_code warning in clippy.

There are cases where exposing FEATURES - our lazy static - is actually
helpful to users of the library. For example, they may wish to choose to
load a different version of their bytecode based on current features.
Or, in the case of an orchestrator like bpfd, we might want to allow
users to describe which features their program needs and return nice
error message is one or more nodes in their cluster doesn't support the
necessary feature set.

To do this without breaking the API, we make all the internal members of
the `Features` and `BtfFeatures` structs private, and add accessors for
them. We then add a `features()` API to avoid leaking the
lazy_static.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Alessandro Decina 76d35d10ce
Merge pull request #526 from dave-tucker/trie
aya: Remove iter_key from LPM Trie API
1 year ago
Dave Tucker 00c480d2f9 aya: Remove iter_key from LPM Trie API
Based on the discussion in Discord we've decided to drop the
iter_key() API for LPM Trie. According to the kernel self-tests and
experimentation done in Aya, providing a key into bpf_map_get_next_id
will either:

- If key is an EXACT match, proceed iterating through all keys in the
trie from this point
- If key is NOT an EXACT match, proceed iterating through all keys in
the trie starting at the leftmost entry.

An API in Aya could be crafted that gets the LPM match + less specific
matches for a prefix using these semantics BUT it would only apply to
userspace. Therefore we've opted out of fixing this.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
1 year ago
Tamir Duberstein 5c6bd55260
Merge pull request #633 from ajwerner/change-fd-import
aya: replace os::unix::prelude with os::fd
1 year ago
ajwerner 65d10f9ffc aya: replace os::unix::prelude with os::fd 1 year ago
Mary b2737d5b0d
Merge pull request #632 from marysaka/feat/global-data-optional
aya: allow global value to be optional
1 year ago
Mary 77cce840f7
Update aya/src/bpf.rs
Co-authored-by: Alessandro Decina <alessandro.d@gmail.com>
1 year ago