Skip to content

Commit

Permalink
Merge pull request #858 from dave-tucker/ringbuf-doctests
Browse files Browse the repository at this point in the history
Fix docs build
  • Loading branch information
dave-tucker committed Dec 20, 2023
2 parents 44f416a + 19af249 commit 13f21dc
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 20 deletions.
27 changes: 26 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: Check C formatting
run: git ls-files -- '*.c' '*.h' | xargs clang-format --dry-run --Werror

- name: Check Markdown
uses: DavidAnson/markdownlint-cli2-action@v14

Expand Down Expand Up @@ -111,6 +111,20 @@ jobs:
--exclude integration-test \
--workspace
- name: Doctests
env:
RUST_BACKTRACE: full
run: |
set -euxo pipefail
cargo hack test --doc --feature-powerset \
--exclude aya-bpf \
--exclude aya-bpf-bindings \
--exclude aya-log-ebpf \
--exclude init \
--exclude integration-ebpf \
--exclude integration-test \
--workspace
build-test-aya-bpf:
strategy:
fail-fast: false
Expand Down Expand Up @@ -149,6 +163,17 @@ jobs:
--target ${{ matrix.target }} \
-Z build-std=core
- name: Test
env:
CARGO_CFG_BPF_TARGET_ARCH: ${{ matrix.arch }}
RUST_BACKTRACE: full
run: |
set -euxo pipefail
cargo hack test --doc \
--package aya-bpf \
--package aya-log-ebpf \
--feature-powerset
run-integration-test:
strategy:
fail-fast: false
Expand Down
10 changes: 5 additions & 5 deletions aya/src/maps/ring_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ use crate::{
/// # }
/// # fn clear_ready(&mut self) {}
/// # }
/// # let bpf = aya::Bpf::load(&[])?;
/// # let mut bpf = aya::Bpf::load(&[])?;
/// use aya::maps::RingBuf;
/// use std::convert::TryFrom;
///
/// let ring_buf = RingBuf::try_from(bpf.map_mut("ARRAY")?)?;
/// let poll = poll_fd(ring_buf);
/// let ring_buf = RingBuf::try_from(bpf.map_mut("ARRAY").unwrap()).unwrap();
/// let mut poll = poll_fd(ring_buf);
/// loop {
/// let mut guard = poll.readable()?;
/// let ring_buf = guard.inner_mut()
/// let mut guard = poll.readable();
/// let ring_buf = guard.inner_mut();
/// while let Some(item) = ring_buf.next() {
/// println!("Received: {:?}", item);
/// }
Expand Down
4 changes: 2 additions & 2 deletions bpf/aya-bpf/src/maps/xdp/cpu_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ use crate::{
/// static MAP: CpuMap = CpuMap::with_max_entries(8, 0);
///
/// #[xdp]
/// fn xdp(_ctx: XdpContext) -> i32 {
/// fn xdp(_ctx: XdpContext) -> u32 {
/// // Redirect to CPU 7 or drop packet if no entry found.
/// MAP.redirect(7, xdp_action::XDP_DROP as u64)
/// MAP.redirect(7, xdp_action::XDP_DROP as u64).unwrap_or(xdp_action::XDP_DROP)
/// }
/// ```
#[repr(transparent)]
Expand Down
6 changes: 3 additions & 3 deletions bpf/aya-bpf/src/maps/xdp/dev_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ use crate::{
/// static MAP: DevMap = DevMap::with_max_entries(1, 0);
///
/// #[xdp]
/// fn xdp(_ctx: XdpContext) -> i32 {
/// MAP.redirect(0, xdp_action::XDP_PASS as u64)
/// fn xdp(_ctx: XdpContext) -> u32 {
/// MAP.redirect(0, xdp_action::XDP_PASS as u64).unwrap_or(xdp_action::XDP_DROP)
/// }
/// ```
#[repr(transparent)]
Expand Down Expand Up @@ -100,7 +100,7 @@ impl DevMap {
/// #[map]
/// static MAP: DevMap = DevMap::with_max_entries(1, 0);
///
/// let target_if_index = MAP.get(0).target_if_index;
/// let target_if_index = MAP.get(0).unwrap().if_index;
///
/// // redirect to if_index
/// ```
Expand Down
6 changes: 3 additions & 3 deletions bpf/aya-bpf/src/maps/xdp/dev_map_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use crate::{
/// static MAP: DevMapHash = DevMapHash::with_max_entries(1, 0);
///
/// #[xdp]
/// fn xdp(_ctx: XdpContext) -> i32 {
/// MAP.redirect(42, xdp_action::XDP_PASS as u64)
/// fn xdp(_ctx: XdpContext) -> u32 {
/// MAP.redirect(42, xdp_action::XDP_PASS as u64).unwrap_or(xdp_action::XDP_DROP)
/// }
/// ```
#[repr(transparent)]
Expand Down Expand Up @@ -102,7 +102,7 @@ impl DevMapHash {
/// #[map]
/// static MAP: DevMapHash = DevMapHash::with_max_entries(1, 0);
///
/// let target_if_index = MAP.get(42).target_if_index;
/// let target_if_index = MAP.get(42).unwrap().if_index;
///
/// // redirect to ifindex
/// ```
Expand Down
12 changes: 6 additions & 6 deletions bpf/aya-bpf/src/maps/xdp/xsk_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ use crate::{
/// static SOCKS: XskMap = XskMap::with_max_entries(8, 0);
///
/// #[xdp]
/// fn xdp(ctx, XdpContext) -> i32 {
/// fn xdp(ctx: XdpContext) -> u32 {
/// let queue_id = unsafe { (*ctx.ctx).rx_queue_index };
/// MAP.redirect(queue_id, xdp_action::XDP_DROP as u64)
/// SOCKS.redirect(queue_id, xdp_action::XDP_DROP as u64).unwrap_or(xdp_action::XDP_DROP)
/// }
/// ```
///
Expand Down Expand Up @@ -68,7 +68,7 @@ impl XskMap {
/// use aya_bpf::{macros::map, maps::XskMap};
///
/// #[map]
/// static SOCKS: XskMap::with_max_entries(8, 0);
/// static SOCKS: XskMap = XskMap::with_max_entries(8, 0);
/// ```
pub const fn with_max_entries(max_entries: u32, flags: u32) -> XskMap {
XskMap {
Expand All @@ -93,7 +93,7 @@ impl XskMap {
/// use aya_bpf::{macros::map, maps::XskMap};
///
/// #[map]
/// static SOCKS: XskMap::pinned(8, 0);
/// static SOCKS: XskMap = XskMap::pinned(8, 0);
/// ```
pub const fn pinned(max_entries: u32, flags: u32) -> XskMap {
XskMap {
Expand Down Expand Up @@ -151,9 +151,9 @@ impl XskMap {
/// static SOCKS: XskMap = XskMap::with_max_entries(8, 0);
///
/// #[xdp]
/// fn xdp(ctx, XdpContext) -> u32 {
/// fn xdp(ctx: XdpContext) -> u32 {
/// let queue_id = unsafe { (*ctx.ctx).rx_queue_index };
/// MAP.redirect(queue_id, 0).unwrap_or(xdp_action::XDP_DROP)
/// SOCKS.redirect(queue_id, 0).unwrap_or(xdp_action::XDP_DROP)
/// }
/// ```
#[inline(always)]
Expand Down

0 comments on commit 13f21dc

Please sign in to comment.