This moves the path dependencies back into the per-crate Cargo.toml.
It is required such that the release tooling can correctly calculate
which version constraints require changing when we perform a release.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
This allows for inheritance of common fields from the workspace root.
The following fields have been made common:
- authors
- license
- repository
- homepage
- edition
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
`Option<NonZeroUsize>` is guaranteed to have the same size as `usize`,
which is not guarnateed for `Result`. This is a minor optimization, but
also results in simpler code.
This feature is equivalent to async_tokio || async_std; removing it
avoids warnings emitted during `cargo hack check --feature-powerset`
where async is selected without either of the other features.
Use cargo hack to ensure clippy runs on the powerset of features.
Having separate format hints and tokens per IP address family is
unnecessary, since they are represented by different types and we handle
format hints for each type separately. So we can just have one format
hint.
Also, we should be consistent with the format strings grammar in
Rust[0]. The `type` token, which is mapped to formatting traits, usually
consists of one letter[1] (and optional `?` for `Debug` trait, but that
doesn't matter for us). It shouldn't consist of multiple letters. Our
`:ipv4` and `:ipv6` tokens were clearly breaking that convention, so we
should rather switch to something with one letter - hence `:i`.
[0] https://doc.rust-lang.org/std/fmt/#syntax
[1] https://doc.rust-lang.org/std/fmt/#formatting-traits
- Replace all `#[repr(usize)]` with `#[repr(u8)]`; this saves
3*(sizeof(word)-1) bytes per log message.
- Encode payload length as u16 rather than usize; this saves
sizeof(word)-1 bytes per log message. This is safe because the maximum
size of a log message is less than (1 << 16 - 1).
This changes `level` to a require field in every log message. It was
already always present, but was treated as optional when reading.
Previously `struct TagLenValue` was defined in both aya-log and
aya-log-common where the former implemented reading and the latter
writing; the reading logic doesn't need the struct, so remove it.
Keeping the `Pod` implementations and optional dependency on aya in
aya-log-common breaks the clippy checks (which are made on the entire
workspace).
The reason is that when different crates inside the workspace have the
same dependency with different features, that dependency is built only
once with the sum of features needed by all crates. It's **not** being
built separately with different feature sets.
That's why, before this change, aya-log-common was built once for the
entire workspace with `userspace` feature enabled. That made importing
aya-log-ebpf inside integration-ebpf impossible. The aya-log-common
build, with `userspace` feature enabled, was pulling std as a
dependency. Therefore, importing aya-log-ebpf inside integration-ebpf
resulted in including std and errors like:
```
error[E0152]: found duplicate lang item `panic_impl`
--> test/integration-ebpf/src/log.rs:23:1
|
23 | fn panic(_info: &core::panic::PanicInfo) -> ! {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: the lang item is first defined in crate `std` (which `aya` depends on)
```
This change fixes the problem by removing the `userspace` feature from
aya-log-common and moving the `Pod` implementations to aya-log.
Add `{:mac}` (for lower-case hex representation) and `{:MAC}` (for
upper-case hex representation) format hints for the `[u8; 6]` type,
which is the standard one in Linux to store physical addresses in.
Tested with: https://github.com/vadorovsky/aya-examples/tree/main/xdp-mac
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
switch map() and map_mut() from returning a
`Result` to an `Option` since it's just getting
a value from a Hashmap, and to stay in line with
the Programs API.
Remove `MapError::MapNotFound`
Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
Build completing tests passing
Refactor the Map API to better align
with the aya programs API. Specifically
remove all internal locking mechanisms
and custom Deref/DerefMut implementations.
They are replaced with a Map enum
and AsRef/AsMut implementations.
All Try_From implementations have been moved
to standardized enums, with a slightly
special one for PerfEventArray's.
Also cleanup/fix all associated tests and
documentation.
Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
Miri took issue about using slice::from_raw_parts without checking for
alignment. Instead, we can simply convert to a [u8;16] into a [u16;8] by
iterating in chunks of 2 and bitshifting (remembering that these arrays
are in network-endian order).
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
This change adds optional display hints:
* `{:x}`, `{:X}` - for hex representation of numbers
* `{:ipv4}`, `{:IPv4}` - for IPv4 addresses
* `{:ipv6}`, `{:IPv6}` - for IPv6 addresses
It also gets rid of dyn-fmt and instead comes with our own parser
implementation.
Tested on: https://github.com/vadorovsky/aya-examples/tree/main/tc
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
This commit moves the aya-log projects from the subtree and adds them to
the main cargo workspace. It also brings the BPF crates into the
workspace and moves the macro crates up a level since they aren't BPF
code.
Miri was disabled for aya-bpf as the previous config wasn't actually
checking anything.
CI, clippy, fmt and release configurations have all been adjusted
appropriately.
CI was not properly running for other supported arches which was also
ixed here.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
Change 821ba0b243fd removed the `size > buf.len()` check, which was a
mistake, because we might write to a subslice of the whole buffer, so
then `buf` can be lower than `LOG_BUF_CAPACITY`.
This change compares `size` with `min::(buf.len(), LOG_BUF_CAPACITY)`
instead.
Fixes: 821ba0b243fd ("Ensure log buffer bounds")
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
This change adds checks in `TagLenValue.write()` to ensure that the size
of written data doesn't exceed the buffer size.
Verifier in recent kernel versions requires the bound to be a constant
value, so using `buf.len()` does not work.
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
This moves a large chunk of code from ebpf to shared so we can re-use
write_record_header and write_record_message and friends so that we
can write test cases to ensure that logs are properly formatted
given certain input.
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
eBPF verifier rejects programs which are not checking the bounds of the
log buffer before writing any arguments. This change ensures that
written log arguments.
In practice, it means that doing this kind of checks is not going to be
needed in eBPF program code anymore:
33a1aee2ea/echo-ebpf/src/main.rs (L47)
Tested on:
876f8b4551
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>