From f6e3cbbed4458cc5407a51fc3b97e95c0ba7da90 Mon Sep 17 00:00:00 2001 From: Arnabjyoti Kalita Date: Sat, 26 Jun 2021 15:53:48 +0530 Subject: [PATCH] aya: add minimum kernel version for each map and program tyoes --- aya/src/maps/array/array.rs | 4 ++++ aya/src/maps/array/per_cpu_array.rs | 4 ++++ aya/src/maps/array/program_array.rs | 4 ++++ aya/src/maps/hash_map/hash_map.rs | 4 ++++ aya/src/maps/hash_map/per_cpu_hash_map.rs | 4 ++++ aya/src/maps/perf/async_perf_event_array.rs | 4 ++++ aya/src/maps/perf/perf_event_array.rs | 4 ++++ aya/src/maps/queue.rs | 4 ++++ aya/src/maps/sock/sock_hash.rs | 4 ++++ aya/src/maps/sock/sock_map.rs | 4 ++++ aya/src/maps/stack.rs | 4 ++++ aya/src/maps/stack_trace.rs | 4 ++++ aya/src/programs/cgroup_skb.rs | 4 ++++ aya/src/programs/kprobe.rs | 4 ++++ aya/src/programs/lirc_mode2.rs | 4 ++++ aya/src/programs/sk_msg.rs | 4 ++++ aya/src/programs/sk_skb.rs | 4 ++++ aya/src/programs/sock_ops.rs | 4 ++++ aya/src/programs/socket_filter.rs | 3 +++ aya/src/programs/tc.rs | 4 ++++ aya/src/programs/trace_point.rs | 4 ++++ aya/src/programs/xdp.rs | 4 ++++ 22 files changed, 87 insertions(+) diff --git a/aya/src/maps/array/array.rs b/aya/src/maps/array/array.rs index 641af62b..c9176129 100644 --- a/aya/src/maps/array/array.rs +++ b/aya/src/maps/array/array.rs @@ -17,6 +17,10 @@ use crate::{ /// The size of the array is defined on the eBPF side using the `bpf_map_def::max_entries` field. /// All the entries are zero-initialized when the map is created. /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 3.19 +/// /// # Examples /// ```no_run /// # let bpf = aya::Bpf::load(&[], None)?; diff --git a/aya/src/maps/array/per_cpu_array.rs b/aya/src/maps/array/per_cpu_array.rs index 02e18954..514d1c0e 100644 --- a/aya/src/maps/array/per_cpu_array.rs +++ b/aya/src/maps/array/per_cpu_array.rs @@ -17,6 +17,10 @@ use crate::{ /// The size of the array is defined on the eBPF side using the `bpf_map_def::max_entries` field. /// All the entries are zero-initialized when the map is created. /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.6 +/// /// # Examples /// ```no_run /// # #[derive(thiserror::Error, Debug)] diff --git a/aya/src/maps/array/program_array.rs b/aya/src/maps/array/program_array.rs index 263566a9..f305f64f 100644 --- a/aya/src/maps/array/program_array.rs +++ b/aya/src/maps/array/program_array.rs @@ -20,6 +20,10 @@ use crate::{ /// prog_array, index)`. You can use [`ProgramArray`] to configure which /// programs correspond to which jump indexes. /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.2 +/// /// # Examples /// ```no_run /// # let bpf = aya::Bpf::load(&[], None)?; diff --git a/aya/src/maps/hash_map/hash_map.rs b/aya/src/maps/hash_map/hash_map.rs index 1ba608f2..20177c51 100644 --- a/aya/src/maps/hash_map/hash_map.rs +++ b/aya/src/maps/hash_map/hash_map.rs @@ -13,6 +13,10 @@ use crate::{ /// A hash map that can be shared between eBPF programs and user space. /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 3.19 +/// /// # Examples /// /// ```no_run diff --git a/aya/src/maps/hash_map/per_cpu_hash_map.rs b/aya/src/maps/hash_map/per_cpu_hash_map.rs index bb74e83a..2d1f875e 100644 --- a/aya/src/maps/hash_map/per_cpu_hash_map.rs +++ b/aya/src/maps/hash_map/per_cpu_hash_map.rs @@ -20,6 +20,10 @@ use crate::{ /// This type can be used with eBPF maps of type `BPF_MAP_TYPE_PERCPU_HASH` and /// `BPF_MAP_TYPE_LRU_PERCPU_HASH`. /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.6 +/// /// # Examples /// /// ```no_run diff --git a/aya/src/maps/perf/async_perf_event_array.rs b/aya/src/maps/perf/async_perf_event_array.rs index 0e74f99f..6242f90a 100644 --- a/aya/src/maps/perf/async_perf_event_array.rs +++ b/aya/src/maps/perf/async_perf_event_array.rs @@ -26,6 +26,10 @@ use crate::maps::{ /// * call [`AsyncPerfEventArray::open`] /// * call [`AsyncPerfEventArrayBuffer::read_events`] to read the events /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.3 +/// /// # Examples /// /// ```no_run diff --git a/aya/src/maps/perf/perf_event_array.rs b/aya/src/maps/perf/perf_event_array.rs index 3f5330c4..7930bab2 100644 --- a/aya/src/maps/perf/perf_event_array.rs +++ b/aya/src/maps/perf/perf_event_array.rs @@ -76,6 +76,10 @@ impl> AsRawFd for PerfEventArrayBuffer { /// inserted in the buffer /// * call [`PerfEventArrayBuffer::read_events`] to read the events /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.3 +/// /// # Examples /// /// A common way to use a perf array is to have one perf buffer for each diff --git a/aya/src/maps/queue.rs b/aya/src/maps/queue.rs index fb841905..1203adbc 100644 --- a/aya/src/maps/queue.rs +++ b/aya/src/maps/queue.rs @@ -15,6 +15,10 @@ use crate::{ /// A FIFO queue. /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.20 +/// /// # Examples /// ```no_run /// # let bpf = aya::Bpf::load(&[], None)?; diff --git a/aya/src/maps/sock/sock_hash.rs b/aya/src/maps/sock/sock_hash.rs index 258b3855..cc6540be 100644 --- a/aya/src/maps/sock/sock_hash.rs +++ b/aya/src/maps/sock/sock_hash.rs @@ -23,6 +23,10 @@ use crate::{ /// A `SockHash` can also be used to redirect packets to sockets contained by the /// map using `bpf_redirect_map()`, `bpf_sk_redirect_hash()` etc. /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.18 +/// /// # Examples /// /// ```no_run diff --git a/aya/src/maps/sock/sock_map.rs b/aya/src/maps/sock/sock_map.rs index 8d027dc3..29a730f0 100644 --- a/aya/src/maps/sock/sock_map.rs +++ b/aya/src/maps/sock/sock_map.rs @@ -22,6 +22,10 @@ use crate::{ /// A `SockMap` can also be used to redirect packets to sockets contained by the /// map using `bpf_redirect_map()`, `bpf_sk_redirect_map()` etc. /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.14 +/// /// # Examples /// /// ```no_run diff --git a/aya/src/maps/stack.rs b/aya/src/maps/stack.rs index 3c624a66..5745d1ee 100644 --- a/aya/src/maps/stack.rs +++ b/aya/src/maps/stack.rs @@ -15,6 +15,10 @@ use crate::{ /// A LIFO stack. /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.20 +/// /// # Examples /// ```no_run /// # let bpf = aya::Bpf::load(&[], None)?; diff --git a/aya/src/maps/stack_trace.rs b/aya/src/maps/stack_trace.rs index 65579078..4ee2ee39 100644 --- a/aya/src/maps/stack_trace.rs +++ b/aya/src/maps/stack_trace.rs @@ -17,6 +17,10 @@ use crate::{ /// useful for profiling, to associate a trace to an event, etc. You can capture traces calling /// `stack_id = bpf_get_stackid(ctx, map, flags)` from eBPF, and then you can retrieve the traces /// from their stack ids. +/// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.6 /// /// # Examples /// diff --git a/aya/src/programs/cgroup_skb.rs b/aya/src/programs/cgroup_skb.rs index 45017c61..f3ba1fc6 100644 --- a/aya/src/programs/cgroup_skb.rs +++ b/aya/src/programs/cgroup_skb.rs @@ -19,6 +19,10 @@ use super::FdLink; /// /// [cgroup]: https://man7.org/linux/man-pages/man7/cgroups.7.html /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.10 +/// /// # Examples /// /// ```no_run diff --git a/aya/src/programs/kprobe.rs b/aya/src/programs/kprobe.rs index 46572d74..9ddf1c7a 100644 --- a/aya/src/programs/kprobe.rs +++ b/aya/src/programs/kprobe.rs @@ -20,6 +20,10 @@ use crate::{ /// - `kprobe`: get attached to the *start* of the target functions /// - `kretprobe`: get attached to the *return address* of the target functions /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.1 +/// /// # Examples /// /// ```no_run diff --git a/aya/src/programs/lirc_mode2.rs b/aya/src/programs/lirc_mode2.rs index d5c1b7cf..73516948 100644 --- a/aya/src/programs/lirc_mode2.rs +++ b/aya/src/programs/lirc_mode2.rs @@ -15,6 +15,10 @@ use libc::{close, dup}; /// /// [lirc]: https://www.kernel.org/doc/html/latest/userspace-api/media/rc/lirc-dev.html /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.18 +/// /// # Examples /// /// ```no_run diff --git a/aya/src/programs/sk_msg.rs b/aya/src/programs/sk_msg.rs index a02e2302..cbd4575b 100644 --- a/aya/src/programs/sk_msg.rs +++ b/aya/src/programs/sk_msg.rs @@ -11,6 +11,10 @@ use crate::{ /// filter and redirect messages sent on sockets. See also [`SockMap`] and /// [`SockHash`]. /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.17 +/// /// # Examples /// /// ```no_run diff --git a/aya/src/programs/sk_skb.rs b/aya/src/programs/sk_skb.rs index cf4c97e9..615e2d56 100644 --- a/aya/src/programs/sk_skb.rs +++ b/aya/src/programs/sk_skb.rs @@ -21,6 +21,10 @@ pub enum SkSkbKind { /// inspect, redirect or filter incoming packet. See also [`SockMap`] and /// [`SockHash`]. /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.14 +/// /// # Examples /// /// ```no_run diff --git a/aya/src/programs/sock_ops.rs b/aya/src/programs/sock_ops.rs index d288e5aa..390f61bf 100644 --- a/aya/src/programs/sock_ops.rs +++ b/aya/src/programs/sock_ops.rs @@ -12,6 +12,10 @@ use crate::{ /// parameters, watch connection state changes and more. They are attached to /// cgroups. /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.13 +/// /// # Examples /// /// ```no_run diff --git a/aya/src/programs/socket_filter.rs b/aya/src/programs/socket_filter.rs index 7fe0d23b..99dd47c2 100644 --- a/aya/src/programs/socket_filter.rs +++ b/aya/src/programs/socket_filter.rs @@ -26,6 +26,9 @@ pub enum SocketFilterError { /// [`SocketFilter`] programs are attached on sockets and can be used to inspect /// and filter incoming packets. /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.0 /// /// # Examples /// diff --git a/aya/src/programs/tc.rs b/aya/src/programs/tc.rs index 5fdd0f01..8f9b83d4 100644 --- a/aya/src/programs/tc.rs +++ b/aya/src/programs/tc.rs @@ -32,6 +32,10 @@ pub enum TcAttachType { /// /// # Examples /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.1 +/// /// ```no_run /// # #[derive(Debug, thiserror::Error)] /// # enum Error { diff --git a/aya/src/programs/trace_point.rs b/aya/src/programs/trace_point.rs index 5e7e2840..4ff4e342 100644 --- a/aya/src/programs/trace_point.rs +++ b/aya/src/programs/trace_point.rs @@ -22,6 +22,10 @@ pub enum TracePointError { /// be attached to. See `/sys/kernel/debug/tracing/events` for a list of which /// events can be traced. /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.7 +/// /// # Examples /// /// ```no_run diff --git a/aya/src/programs/xdp.rs b/aya/src/programs/xdp.rs index eb3033e8..171be717 100644 --- a/aya/src/programs/xdp.rs +++ b/aya/src/programs/xdp.rs @@ -46,6 +46,10 @@ bitflags! { /// underlying network driver, XDP programs can execute directly on network cards, greatly /// reducing CPU load. /// +/// # Minimum kernel version +/// +/// The minimum kernel version required to use this feature is 4.8 +/// /// # Examples /// /// ```no_run