aya-bpf: Fix XDP Map documentation

Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
pull/858/head
Dave Tucker 11 months ago
parent e9e2f48d4f
commit 19af2497d7

@ -25,9 +25,9 @@ use crate::{
/// static MAP: CpuMap = CpuMap::with_max_entries(8, 0); /// static MAP: CpuMap = CpuMap::with_max_entries(8, 0);
/// ///
/// #[xdp] /// #[xdp]
/// fn xdp(_ctx: XdpContext) -> i32 { /// fn xdp(_ctx: XdpContext) -> u32 {
/// // Redirect to CPU 7 or drop packet if no entry found. /// // 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)] #[repr(transparent)]

@ -27,8 +27,8 @@ use crate::{
/// static MAP: DevMap = DevMap::with_max_entries(1, 0); /// static MAP: DevMap = DevMap::with_max_entries(1, 0);
/// ///
/// #[xdp] /// #[xdp]
/// fn xdp(_ctx: XdpContext) -> i32 { /// fn xdp(_ctx: XdpContext) -> u32 {
/// MAP.redirect(0, xdp_action::XDP_PASS as u64) /// MAP.redirect(0, xdp_action::XDP_PASS as u64).unwrap_or(xdp_action::XDP_DROP)
/// } /// }
/// ``` /// ```
#[repr(transparent)] #[repr(transparent)]
@ -100,7 +100,7 @@ impl DevMap {
/// #[map] /// #[map]
/// static MAP: DevMap = DevMap::with_max_entries(1, 0); /// 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 /// // redirect to if_index
/// ``` /// ```

@ -29,8 +29,8 @@ use crate::{
/// static MAP: DevMapHash = DevMapHash::with_max_entries(1, 0); /// static MAP: DevMapHash = DevMapHash::with_max_entries(1, 0);
/// ///
/// #[xdp] /// #[xdp]
/// fn xdp(_ctx: XdpContext) -> i32 { /// fn xdp(_ctx: XdpContext) -> u32 {
/// MAP.redirect(42, xdp_action::XDP_PASS as u64) /// MAP.redirect(42, xdp_action::XDP_PASS as u64).unwrap_or(xdp_action::XDP_DROP)
/// } /// }
/// ``` /// ```
#[repr(transparent)] #[repr(transparent)]
@ -102,7 +102,7 @@ impl DevMapHash {
/// #[map] /// #[map]
/// static MAP: DevMapHash = DevMapHash::with_max_entries(1, 0); /// 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 /// // redirect to ifindex
/// ``` /// ```

@ -28,9 +28,9 @@ use crate::{
/// static SOCKS: XskMap = XskMap::with_max_entries(8, 0); /// static SOCKS: XskMap = XskMap::with_max_entries(8, 0);
/// ///
/// #[xdp] /// #[xdp]
/// fn xdp(ctx, XdpContext) -> i32 { /// fn xdp(ctx: XdpContext) -> u32 {
/// let queue_id = unsafe { (*ctx.ctx).rx_queue_index }; /// 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)
/// } /// }
/// ``` /// ```
/// ///
@ -68,7 +68,7 @@ impl XskMap {
/// use aya_bpf::{macros::map, maps::XskMap}; /// use aya_bpf::{macros::map, maps::XskMap};
/// ///
/// #[map] /// #[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 { pub const fn with_max_entries(max_entries: u32, flags: u32) -> XskMap {
XskMap { XskMap {
@ -93,7 +93,7 @@ impl XskMap {
/// use aya_bpf::{macros::map, maps::XskMap}; /// use aya_bpf::{macros::map, maps::XskMap};
/// ///
/// #[map] /// #[map]
/// static SOCKS: XskMap::pinned(8, 0); /// static SOCKS: XskMap = XskMap::pinned(8, 0);
/// ``` /// ```
pub const fn pinned(max_entries: u32, flags: u32) -> XskMap { pub const fn pinned(max_entries: u32, flags: u32) -> XskMap {
XskMap { XskMap {
@ -151,9 +151,9 @@ impl XskMap {
/// static SOCKS: XskMap = XskMap::with_max_entries(8, 0); /// static SOCKS: XskMap = XskMap::with_max_entries(8, 0);
/// ///
/// #[xdp] /// #[xdp]
/// fn xdp(ctx, XdpContext) -> u32 { /// fn xdp(ctx: XdpContext) -> u32 {
/// let queue_id = unsafe { (*ctx.ctx).rx_queue_index }; /// 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)] #[inline(always)]

Loading…
Cancel
Save