Commit Graph

888 Commits (c51c1b4488e3c40de1730cd6897bc46e0a5071fe)
 

Author SHA1 Message Date
Ayrton Sparling c51c1b4488 Merge remote-tracking branch 'upstream/main' into interface 3 years ago
Ayrton Sparling 5e3d51d8f0 Move interface.rs into util.rs
Also store if_index on XdpLink
Removes XdpLink::TryFrom<FdLink>
3 years ago
Tuetuopay 890e8c9340 bpf: fix set_mark by not copying __sk_buff
Such an assignment in two parts (first deref in `unsafe`, then field
access outside of `unsafe`) is bogus: the deref "returned" by the
`unsafe` block actually creates a copy of the `__sk_buff` struct because
it implements `Copy`. The mark value is written to the `mark` field of
the copy, and not the real `__sk_buff`.

Change it to do it all in the `unsafe` block.

The same is done for the `.len()` getter to avoid copying the whole
`__sk_buff` struct for a 32 bit field. Although such a copy should be
optimized out by the compiler, it's better to help it do so.
3 years ago
Ayrton Sparling dc64377836
Add program::links() and NetworkInterface
NetworkInterface provides a way to store network interface indexes as
well as retrieve an interface's name using the NetworkInterface.name()
method.

Interfaces can be created manually or retrieved via new .interface()
methods on XdpLink and SchedClassifierLink.

Interface names are extracted from the kernel for 2 reasons.
1. Interface names can change within the kernel at anytime which aya
   will not be aware of.
2. Names are not always available when a NetworkInterface is created.
   For example in the XdpLink .interface() implementation.

A new method NetworkInterface::list() also provides a list of network
interfaces from the kernel.

Signed-off-by: Ayrton Sparling <ayrton@sparling.us>
3 years ago
ajwerner 12927cf699 Don't panic in init when bpf programs don't log
This was broken in d6cb1a16ad.
3 years ago
ajwerner 1a22792ee7 Resolve symbol address for PIE executables
See https://github.com/foniod/redbpf/pull/308 for a similar change.
3 years ago
Alessandro Decina b3ae7786d3 aya: fix detaching links on drop
https://github.com/aya-rs/aya/pull/366 broke detaching links on drop for
everything but FdLink. This restores detach on drop for all links.
3 years ago
Michal Rostecki 9f5d157628
Merge pull request #461 from FallingSnow/main
Add ability to iterate over LpmTrie keys and matches
3 years ago
Ayrton Sparling 10ac5957c1
Fix LpnTrieKeys -> LpmTrieKeys typo 3 years ago
Alessandro Decina d1919a83ed
Merge pull request #466 from bpfdeploy-io/ml/cgroup-device
Add support for BPF_PROG_TYPE_CGROUP_DEVICE
3 years ago
Milan 925504f230 Fix doctest issue 3 years ago
Milan 4b6d97e4db Fix CI, clippy and feedback
Signed-off-by: Milan <milan@mdaverde.com>
3 years ago
Milan 8f1163a400 Add support for BPF_PROG_TYPE_CGROUP_DEVICE
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>
3 years ago
Alessandro Decina 9ce1530695 tests: skip tests that assume bpf_link based XDP on older kernels 3 years ago
Ayrton Sparling a44f054bec fix formatting 3 years ago
Alessandro Decina 66d435fc7c
Merge pull request #460 from Tuetuopay/owned-per-cpu-hash-map
maps: add missing TryFrom<Map> for HashMap, PerCpuHashMap and LpmTrie
3 years ago
Ayrton Sparling 1368eb94e7 Remove old test 3 years ago
Ayrton Sparling 9a3682e793 Add ability to iterate over lpmtrie key matches 3 years ago
Ayrton Sparling 8fe64aef1f Fix lpmtrie iter returning nothing 3 years ago
Alexis Bauvin 51bb50ed8e maps: add missing TryFrom<Map> for HashMap, PerCpuHashMap and LpmTrie 3 years ago
Ayrton Sparling e4182a9eab Iterate lpmtrie 3 years ago
Michal Rostecki 16b029ed37
Merge pull request #456 from dmitris/uninlined_format_args
autofix clippy uninlined_format_args issues
3 years ago
Dmitry Savintsev 055d94f58b fix uninlined_format_args clippy issues 3 years ago
Dmitry Savintsev 22340764a3 upgrade clap to 4.x 3 years ago
Michal Rostecki 52b9ffed60
Merge pull request #451 from aya-rs/dependabot/cargo/bindgen-0.63
build(deps): update bindgen requirement from 0.61 to 0.63
3 years ago
Michal Rostecki 1ded0e61cd
Merge pull request #450 from aya-rs/dependabot/cargo/object-0.30
build(deps): update object requirement from 0.29 to 0.30
3 years ago
Michal Rostecki f9bef9f8c0
Merge pull request #449 from aya-rs/dependabot/cargo/env_logger-0.10
build(deps): update env_logger requirement from 0.9 to 0.10
3 years ago
dependabot[bot] 1c8088b16c
build(deps): update env_logger requirement from 0.9 to 0.10
Updates the requirements on [env_logger](https://github.com/rust-cli/env_logger) to permit the latest version.
- [Release notes](https://github.com/rust-cli/env_logger/releases)
- [Changelog](https://github.com/rust-cli/env_logger/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-cli/env_logger/compare/v0.9.0...v0.10.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
dependabot[bot] 1fe7bba070
build(deps): update object requirement from 0.29 to 0.30
Updates the requirements on [object](https://github.com/gimli-rs/object) to permit the latest version.
- [Release notes](https://github.com/gimli-rs/object/releases)
- [Changelog](https://github.com/gimli-rs/object/blob/master/CHANGELOG.md)
- [Commits](https://github.com/gimli-rs/object/compare/0.29.0...0.30.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
dependabot[bot] 9608da58a1
build(deps): update bindgen requirement from 0.61 to 0.63
Updates the requirements on [bindgen](https://github.com/rust-lang/rust-bindgen) to permit the latest version.
- [Release notes](https://github.com/rust-lang/rust-bindgen/releases)
- [Changelog](https://github.com/rust-lang/rust-bindgen/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/rust-bindgen/compare/v0.61.0...v0.63.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
3 years ago
Michal Rostecki 9382de75cc
Merge pull request #452 from vadorovsky/fix-lint
Fix clippy error
3 years ago
Michal Rostecki d2b44c1e0f github: Refresh package cache before installing pre-requisites
Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
3 years ago
Michal Rostecki 176d61ae23 Fix clippy error
`'local` lifetime can be elided to `'_` which triggers:

https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
3 years ago
Alessandro Decina 7fef833e3a
Merge pull request #418 from anfredette/tc-handle
Support using handle in tc programs
3 years ago
Andre Fredette abb75ba029 Make doc fixes
Signed-off-by: Andre Fredette <afredette@redhat.com>
3 years ago
Alessandro Decina 88d7777553
Merge pull request #431 from 0b01/refs
aya: use impl Borrow<T> instead of T for maps
3 years ago
Alessandro Decina 0b41018ee2 Revert "aya-log, aya-log-common: temporarily revert to old map API so we can release"
This reverts commit 0d040d2290.
3 years ago
Alessandro Decina 832bdd280c {{crate_name}}: release version 0.1.13 3 years ago
Alessandro Decina 0d040d2290 aya-log, aya-log-common: temporarily revert to old map API so we can release 3 years ago
Alessandro Decina dfb03382f6 release.toml: fix pre/post release templates 3 years ago
Alessandro Decina 5d0527ae51 release.toml: dev-version* are gone too 3 years ago
Alessandro Decina a564ab6e5b release.toml: consolidate-pushes doesn't exist anymore 3 years ago
0b01 76e417a474 Fix formatting 3 years ago
Dave Tucker 3adb9b049f
Merge pull request #436 from vadorovsky/aya-log-mac-addr
aya-log: Add format hints for MAC addresses
3 years ago
tiann 49404367d8 bpf: Add bindings for uid and gid 3 years ago
Andre Fredette a3e3e80698 Support both attach() and attach_with_options() for SchedClassifier
Signed-off-by: Andre Fredette <afredette@redhat.com>
3 years ago
Michal Rostecki 3e089a61d1
Merge pull request #435 from vadorovsky/pin-fix-error-msg
maps: Fix the error message in `MapData::pin()`
3 years ago
Michal Rostecki 2223ab828d aya-log: Add format hints for MAC addresses
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>
3 years ago
Michal Rostecki e0a9895260 maps: Fix the error message in `MapData::pin()`
The syscall name is `BPF_OBJ_PIN`, not `BPF_OBJ_GET`.

Signed-off-by: Michal Rostecki <vadorovsky@gmail.com>
3 years ago
Ricky Han 6ce60ad21d make sure everything is marked correctly 3 years ago