Skip to content

Commit

Permalink
aya-ebpf: add ifindex support to XdpContext
Browse files Browse the repository at this point in the history
This change exposes the ifindex field from the underlying xdp_md
data structure to the XdpContext in Aya. The ifindex represents the
unique OS-provided index for a network interface.

Fixes aya-rs#1140
  • Loading branch information
gth828r committed Jan 21, 2025
1 parent 29b8213 commit a05e37d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ebpf/aya-ebpf/src/programs/xdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ impl XdpContext {
unsafe { (*self.ctx).data_end as usize }
}

/// Return the interface of the index as determined by the OS.
#[inline]
pub fn ingress_ifindex(&self) -> usize {
unsafe { (*self.ctx).ingress_ifindex as usize }
}

/// Return the raw address of the XdpContext metadata.
#[inline(always)]
pub fn metadata(&self) -> usize {
Expand Down

0 comments on commit a05e37d

Please sign in to comment.