Kernel 4.15 added a new eBPF program that can
be used with cgroup v2 to control & observe device
access (e.g. read, write, mknod) - `BPF_PROG_TYPE_CGROUP_DEVICE`.
We add the ability to create these programs with the `cgroup_device`
proc macro which creates the `cgroup/dev` link section. Device
details are available to the eBPF program in `DeviceContext`.
The userspace representation is provided with the `CgroupDevice`
structure.
Fixes: #212
Signed-off-by: Milan <milan@mdaverde.com>
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>
Instead of returning anyhow>>Result<()> handle errors
'in-place' with unwrap or panic, for more informative
and user-friendly error messages on test failures.
Fixes#421.
Signed-off-by: Dmitry Savintsev <dsavints@gmail.com>
Use a struct called TcOptions for setting priority and handle in SchedClassifier attach
struct TcOptions implements the Default trait, so for the simple use
case in which the defaults are acceptable, we can call attach as
follows:
attach(“eth0”, TcAttachType::Ingress, TcOptions::default())
To specify all options:
attach(“eth0”, TcAttachType::Ingress, TcOptions { priority: (50), handle: (3) })
Or, some options:
attach(“eth0”, TcAttachType::Ingress, TcOptions { priority: (50), ..Default::default() })
Signed-off-by: Andre Fredette <afredette@redhat.com>
Implements step 1 of https://github.com/aya-rs/aya/issues/414.
- Adds handle to the SchedClassifier attach API
- Saves handle in the TcLink sruct and uses it when detaching programs
NOTE: this changes the API, so it will require a bump in the Aya version.
Signed-off-by: Andre Fredette <afredette@redhat.com>
Fix some broken rust doc links.
Make sure rustdoc build fail on warnings
so we catch these broken links in CI.
Signed-off-by: Andrew Stoycos <astoycos@redhat.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>
Remove MapError::UnexpectedMapType
Add Macro for converting from aya::Map to
u32 (map type) for use in
`MapError::InvalidMapType { map_type: x }`
Signed-off-by: Andrew Stoycos <astoycos@redhat.com>