浏览代码

aya: add doc aliases for maps and programs

Alessandro Decina 3 年之前
父节点
当前提交
768640dd46

+ 1 - 0
aya/src/maps/array/array.rs

@@ -28,6 +28,7 @@ use crate::{
 /// assert_eq!(array.get(&1, 0)?, 42);
 /// # Ok::<(), aya::BpfError>(())
 /// ```
+#[doc(alias = "BPF_MAP_TYPE_ARRAY")]
 pub struct Array<T: Deref<Target = Map>, V: Pod> {
     inner: T,
     _v: PhantomData<V>,

+ 1 - 0
aya/src/maps/array/per_cpu_array.rs

@@ -47,6 +47,7 @@ use crate::{
 /// }
 /// # Ok::<(), Error>(())
 /// ```
+#[doc(alias = "BPF_MAP_TYPE_PERCPU_ARRAY")]
 pub struct PerCpuArray<T: Deref<Target = Map>, V: Pod> {
     inner: T,
     _v: PhantomData<V>,

+ 1 - 0
aya/src/maps/array/program_array.rs

@@ -44,6 +44,7 @@ use crate::{
 /// prog_array.set(2, prog_2, flags);
 /// # Ok::<(), aya::BpfError>(())
 /// ```
+#[doc(alias = "BPF_MAP_TYPE_PROG_ARRAY")]
 pub struct ProgramArray<T: Deref<Target = Map>> {
     inner: T,
 }

+ 1 - 0
aya/src/maps/perf/async_perf_event_array.rs

@@ -83,6 +83,7 @@ use crate::maps::{
 /// # Ok(())
 /// # }
 /// ```
+#[doc(alias = "BPF_MAP_TYPE_PERF_EVENT_ARRAY")]
 pub struct AsyncPerfEventArray<T: DerefMut<Target = Map>> {
     perf_map: PerfEventArray<T>,
 }

+ 1 - 0
aya/src/maps/perf/perf_event_array.rs

@@ -155,6 +155,7 @@ impl<T: DerefMut<Target = Map>> AsRawFd for PerfEventArrayBuffer<T> {
 /// [mio]: https://docs.rs/mio
 /// [tokio]: https://docs.rs/tokio
 /// [async-std]: https://docs.rs/async-std
+#[doc(alias = "BPF_MAP_TYPE_PERF_EVENT_ARRAY")]
 pub struct PerfEventArray<T: DerefMut<Target = Map>> {
     map: Arc<T>,
     page_size: usize,

+ 1 - 0
aya/src/maps/queue.rs

@@ -14,6 +14,7 @@ use crate::{
 };
 
 /// A FIFO queue.
+#[doc(alias = "BPF_MAP_TYPE_QUEUE")]
 pub struct Queue<T: Deref<Target = Map>, V: Pod> {
     inner: T,
     _v: PhantomData<V>,

+ 1 - 0
aya/src/maps/sock/sock_map.rs

@@ -36,6 +36,7 @@ use crate::{
 /// prog.attach(&intercept_ingress)?;
 /// # Ok::<(), aya::BpfError>(())
 /// ```
+#[doc(alias = "BPF_MAP_TYPE_SOCKMAP")]
 pub struct SockMap<T: Deref<Target = Map>> {
     pub(crate) inner: T,
 }

+ 3 - 2
aya/src/maps/stack.rs

@@ -7,7 +7,7 @@ use std::{
 };
 
 use crate::{
-    generated::bpf_map_type::BPF_MAP_TYPE_QUEUE,
+    generated::bpf_map_type::BPF_MAP_TYPE_STACK,
     maps::{Map, MapError, MapRef, MapRefMut},
     sys::{bpf_map_lookup_and_delete_elem, bpf_map_update_elem},
     Pod,
@@ -27,6 +27,7 @@ use crate::{
 /// assert_eq!(stack.pop(0)?, 43);
 /// # Ok::<(), aya::BpfError>(())
 /// ```
+#[doc(alias = "BPF_MAP_TYPE_STACK")]
 pub struct Stack<T: Deref<Target = Map>, V: Pod> {
     inner: T,
     _v: PhantomData<V>,
@@ -35,7 +36,7 @@ pub struct Stack<T: Deref<Target = Map>, V: Pod> {
 impl<T: Deref<Target = Map>, V: Pod> Stack<T, V> {
     fn new(map: T) -> Result<Stack<T, V>, MapError> {
         let map_type = map.obj.def.map_type;
-        if map_type != BPF_MAP_TYPE_QUEUE as u32 {
+        if map_type != BPF_MAP_TYPE_STACK as u32 {
             return Err(MapError::InvalidMapType {
                 map_type: map_type as u32,
             })?;

+ 1 - 0
aya/src/maps/stack_trace.rs

@@ -61,6 +61,7 @@ use crate::{
 /// ```
 ///
 #[derive(Debug)]
+#[doc(alias = "BPF_MAP_TYPE_STACK_TRACE")]
 pub struct StackTraceMap<T> {
     inner: T,
     max_stack_depth: usize,

+ 1 - 0
aya/src/programs/cgroup_skb.rs

@@ -45,6 +45,7 @@ use super::FdLink;
 /// # Ok::<(), Error>(())
 /// ```
 #[derive(Debug)]
+#[doc(alias = "BPF_PROG_TYPE_CGROUP_SKB")]
 pub struct CgroupSkb {
     pub(crate) data: ProgramData,
     pub(crate) expected_attach_type: Option<CgroupSkbAttachType>,

+ 1 - 0
aya/src/programs/kprobe.rs

@@ -32,6 +32,7 @@ use crate::{
 /// # Ok::<(), aya::BpfError>(())
 /// ```
 #[derive(Debug)]
+#[doc(alias = "BPF_PROG_TYPE_KPROBE")]
 pub struct KProbe {
     pub(crate) data: ProgramData,
     pub(crate) kind: ProbeKind,

+ 1 - 0
aya/src/programs/sk_msg.rs

@@ -50,6 +50,7 @@ use crate::{
 /// [`SockMap`]: crate::maps::SockMap
 /// [`SockHash`]: crate::maps::SockHash
 #[derive(Debug)]
+#[doc(alias = "BPF_PROG_TYPE_SK_MSG")]
 pub struct SkMsg {
     pub(crate) data: ProgramData,
 }

+ 1 - 0
aya/src/programs/sk_skb.rs

@@ -40,6 +40,7 @@ pub enum SkSkbKind {
 /// [`SockMap`]: crate::maps::SockMap
 /// [`SockHash`]: crate::maps::SockHash
 #[derive(Debug)]
+#[doc(alias = "BPF_PROG_TYPE_SK_SKB")]
 pub struct SkSkb {
     pub(crate) data: ProgramData,
     pub(crate) kind: SkSkbKind,

+ 1 - 0
aya/src/programs/sock_ops.rs

@@ -37,6 +37,7 @@ use crate::{
 /// prog.attach(file)?;
 /// # Ok::<(), Error>(())
 #[derive(Debug)]
+#[doc(alias = "BPF_PROG_TYPE_SOCK_OPS")]
 pub struct SockOps {
     pub(crate) data: ProgramData,
 }

+ 1 - 0
aya/src/programs/socket_filter.rs

@@ -55,6 +55,7 @@ pub enum SocketFilterError {
 /// # Ok::<(), Error>(())
 /// ```
 #[derive(Debug)]
+#[doc(alias = "BPF_PROG_TYPE_SOCKET_FILTER")]
 pub struct SocketFilter {
     pub(crate) data: ProgramData,
 }

+ 1 - 0
aya/src/programs/tc.rs

@@ -59,6 +59,7 @@ pub enum TcAttachType {
 /// # Ok::<(), Error>(())
 /// ```
 #[derive(Debug)]
+#[doc(alias = "BPF_PROG_TYPE_SCHED_CLS")]
 pub struct SchedClassifier {
     pub(crate) data: ProgramData,
 }

+ 1 - 0
aya/src/programs/trace_point.rs

@@ -46,6 +46,7 @@ pub enum TracePointError {
 /// # Ok::<(), Error>(())
 /// ```
 #[derive(Debug)]
+#[doc(alias = "BPF_PROG_TYPE_TRACEPOINT")]
 pub struct TracePoint {
     pub(crate) data: ProgramData,
 }

+ 1 - 0
aya/src/programs/uprobe.rs

@@ -38,6 +38,7 @@ const LD_SO_CACHE_HEADER: &str = "glibc-ld.so.cache1.1";
 /// - `uprobe`: get attached to the *start* of the target functions
 /// - `uretprobe`: get attached to the *return address* of the target functions
 #[derive(Debug)]
+#[doc(alias = "BPF_PROG_TYPE_KPROBE")]
 pub struct UProbe {
     pub(crate) data: ProgramData,
     pub(crate) kind: ProbeKind,

+ 1 - 0
aya/src/programs/xdp.rs

@@ -58,6 +58,7 @@ bitflags! {
 /// # Ok::<(), aya::BpfError>(())
 /// ```
 #[derive(Debug)]
+#[doc(alias = "BPF_PROG_TYPE_XDP")]
 pub struct Xdp {
     pub(crate) data: ProgramData,
 }