Commit Graph

794 Commits (90faac2a3a7ee4e416badacb9795bfac7abd8615)
 

Author SHA1 Message Date
Michal Rostecki 90faac2a3a aya-log: Add `*max_level_*` filter features
Add the following features for configuring the maximum log level
available:

* `max_level_off`
* `max_level_error`
* `max_level_warn`
* `max_level_info`
* `max_level_debug`
* `max_level_trace`
* `release_max_level_off`
* `release_max_level_error`
* `release_max_level_warn`
* `release_max_level_info`
* `release_max_level_debug`
* `release_max_level_trace`

Log invocations at disabled level will be skipped, which is especially
beneficial for eBPF programs which are not going to send unneceessary
logs through perf buffers.

Features with `release_` prefix are used only in release builds.

Those features have to applied on the userspace and eBPF crate
separately. The correct thing to do is to set them on the same level. In
case when userspace has higher maximum log level, it's not going to
recieve the logs beyond the filter in eBPF crate. In the opposite
situation, when eBPF crate has higher maximum level, it's going to waste
cycles on sending logs through perf buffer, while they are not going to
be displayed in the userspace.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Alessandro Decina a93a975cc6
Merge pull request #393 from aztecher/impl-set_max_entries
aya: add BpfLoader::set_max_entries
2 years ago
aztecher 2eccf1d57d aya: add BpfLoader::set_max_entries
Add BpfLoader::set_max_entries, which sets the max_entries for the
specified map, as the load-time option.
The max_entries set at map initialization in the ebpf component can be
overwritten by this method called on the userspace component.
If you want to set max_entries for multiple maps in an ebpf component,
you can do so by calling set_max_entries in the form of a method chain.

Fixes: #308
Refs: #292
2 years ago
Michal Rostecki 6eca4f5709
Merge pull request #394 from vadorovsky/clippy
Fix clippy warnings
2 years ago
Michal Rostecki 5a4b5ff8d8 Fix clippy warnings
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Dave Tucker e696389837
Merge pull request #391 from dave-tucker/fix-387
Consistently name Pin APIs as from_pin
2 years ago
Dave Tucker 5693fb9941 aya: Rename from_pinned and from_path to from_pin
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker de6fa98963 aya: Fix review comments from #387
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker eb26a6b116
Merge pull request #387 from astoycos/map-from-prog
Load static maps
2 years ago
Michal Rostecki 367ab20305
Merge pull request #390 from dave-tucker/clippy-up
clippy: Fix latest nightly lints
2 years ago
Dave Tucker b2924a3a26 aya-log: Make miri happy
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>
2 years ago
Dave Tucker a8eef00595 clippy: Fix latest nightly lints
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Andrew Stoycos 8a9cbf179f Add `from_pinned` and `from_fd` methods
Add `from_pinned` to allow loading BPF maps
from pinned points in the bpffs and
`from_fd` to allow loading BPF maps from
RawFds aquired via some other means eg
a unix socket.

These functions return an
aya::Map which has not been used previously
but will be the future abstraction once
all bpf maps are represented as an enum.

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
2 years ago
Dave Tucker 98e25ca5e6
Merge pull request #378 from dave-tucker/pin-fixes-again
aya: More pinning fixes
2 years ago
Dave Tucker 7c244e1f65 tests: Add integration test for pinning lifecycle
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 4ed587becc aya-tool: Fix clippy lints
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker f961cbb3d4 aya: Replace From<FdLink> for XdpLink with TryFrom
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 6af2053cf3 aya: Rename bpf_obj_get_info_by_id
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 23c0460ab3
Merge pull request #388 from dave-tucker/fedora-up
tests: Use Fedora 36
2 years ago
Alessandro Decina fe22b02108
Merge pull request #376 from conectado/verifier-log-level
Update `VerifierLogLevel` to use bitflags
2 years ago
Dave Tucker 1a9903d864 tests: Use Fedora 36
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
conectado 3bed2c2b94
aya: fix miss doc period 2 years ago
conectado c30ae6e001
aya: change variant names 2 years ago
Dave Tucker 4b5b9ab3d9 aya: More pinning fixes
This commit fixes a bug and adds some missing lifecycle APIs.

1. Adds PinnedLink::from_path to create a pinned link from bpffs
2. Adds From<PinnedLink> for FdLink to allow for ^ to be converted
3. Adds From<FdLink> for XdpLink

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 7b99a57330
Merge pull request #384 from aya-rs/codegen
Update libbpf to efd33720cdf4a0049323403df5daad0e9e894b3d
2 years ago
dave-tucker ed849ffd18 [codegen] Update libbpf to efd33720cdf4a0049323403df5daad0e9e894b3dUpdate libbpf to efd33720cdf4a0049323403df5daad0e9e894b3d
Files changed:\nM	aya/src/generated/linux_bindings_aarch64.rs
M	aya/src/generated/linux_bindings_armv7.rs
M	aya/src/generated/linux_bindings_riscv64.rs
M	aya/src/generated/linux_bindings_x86_64.rs
2 years ago
Dave Tucker aa16c7bc92
Merge pull request #383 from dave-tucker/oops-another-one
codgen: Add bpf_link_type
2 years ago
Dave Tucker bc088921b8 codgen: Add bpf_link_type
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Michal Rostecki 49c5a94aa0
Merge pull request #381 from aya-rs/codegen
Update libbpf to efd33720cdf4a0049323403df5daad0e9e894b3d
2 years ago
Michal Rostecki 306f83aab0
Merge pull request #352 from vadorovsky/tc-context
ebpf: Add TcContext for classifier programs
2 years ago
dave-tucker 8e96011c2d [codegen] Update libbpf to efd33720cdf4a0049323403df5daad0e9e894b3dUpdate libbpf to efd33720cdf4a0049323403df5daad0e9e894b3d
Files changed:\nM	aya/src/generated/btf_internal_bindings.rs
M	aya/src/generated/linux_bindings_aarch64.rs
M	aya/src/generated/linux_bindings_armv7.rs
M	aya/src/generated/linux_bindings_riscv64.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/helpers.rs
M	bpf/aya-bpf-bindings/src/armv7/bindings.rs
M	bpf/aya-bpf-bindings/src/armv7/helpers.rs
M	bpf/aya-bpf-bindings/src/riscv64/bindings.rs
M	bpf/aya-bpf-bindings/src/riscv64/helpers.rs
M	bpf/aya-bpf-bindings/src/x86_64/bindings.rs
M	bpf/aya-bpf-bindings/src/x86_64/helpers.rs
2 years ago
Dave Tucker 8ed77ebe1d
Merge pull request #380 from dave-tucker/info-structs
codegen: Add bpf_map_info and bpf_link_info
2 years ago
Dave Tucker a0641c15e4 codegen: Add bpf_map_info and bpf_link_info
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Michal Rostecki 895f96e971 ebpf: Add TcContext for classifier programs
This change separates the previous `SkBuffContext` into three structs:

* `SkBuff` which is a wrapper around `__sk_buff` which contains all
  possible methods operating on it.
* `SkBuffContext` which is a program context for programs which
  **cannot** access `__sk_buff` directly and instead can only use
  `load_bytes`.
* `TcContext` which is a classifier context which can access `__sk_buff`
  directly, hence exposes `data` and `data_end`.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Dave Tucker 945169996c
Merge pull request #379 from dave-tucker/fix-link-segfault
aya: Fix segfault in define_link_wrapper
2 years ago
Dave Tucker 8305ee1eca test: Fix clippy lint
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 18584e2259 aya: Fix segfault in define_link_wrapper
The From<$wrapper> for $base implemention is refers to itself,
eventually causing a segfault.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 6f0637a6c8 aya-log, aya-log-common: start next development iteration 0.1.12-dev.0
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker ba927ac204 aya-log, aya-log-common: release version 0.1.11
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 66b4f79eca
Merge pull request #285 from dave-tucker/btf-redux
aya: Improved BTF Type API
2 years ago
Dave Tucker f34ebeba99 aya: Improved BTF Type API
This commit removes reliance on generated BtfType structs, as
well as adding a dedicated struct for each BTF type. As such,
we can now add nice accessors like `bits()` and `encoding()`
for Int vs. inlined shift/mask operations.

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
conectado 7b143199fb
aya: update `VerifierLogLevel` to use bitflags 2 years ago
Dave Tucker 906c25ff23
Merge pull request #374 from dave-tucker/aya-tool
aya-gen: Rename to aya-tool
2 years ago
Dave Tucker aaa20cc1fd aya-gen: Rename to aya-tool
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Dave Tucker 4826bf7f74
Merge pull request #366 from dave-tucker/pin-redux-2
aya: Fix Link Pinning
2 years ago
Dave Tucker 4c1d645aa6 aya: Fix Link Pinning
1. Removes OwnedLink
2. Allows Links to be converted into FdLink
3. Introduces a PinnedLink type to handle wrap FdLink when pinned and
   support un-pinning

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
2 years ago
Michal Rostecki 9a8409e3a2 aya-log-ebpf-macros: Fix the DisplayHint expression names
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
2 years ago
Alessandro Decina b95adc3135
Merge pull request #371 from conectado/verifier-log-level
aya: expose BPF verifier log level configuration
2 years ago
conectado a6025255f5
aya: update `VerifierLogLevel` level variants 2 years ago
Michal Rostecki 83ec27f06b lib: Add display hints
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>
2 years ago