Repository: aya-rs/aya (language: rust)

Issue:
Document the minimum kernel version required by each feature
The documentation of all map and program types should include the minimum kernel version required to use the types. 


Discussion / hints:

Fix patch:
diff --git a/aya/src/maps/array/array.rs b/aya/src/maps/array/array.rs
index 641af62be..bc920573a 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 02e189547..e4116d64c 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 263566a97..a2134810c 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 1ba608f22..3ebdd1a7c 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 bb74e83a1..fb23fb43f 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 0e74f99f2..623191c4a 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 3f5330c48..5a727eaba 100644
--- a/aya/src/maps/perf/perf_event_array.rs
+++ b/aya/src/maps/perf/perf_event_array.rs
@@ -76,6 +76,10 @@ impl<T: DerefMut<Target = Map>> AsRawFd for PerfEventArrayBuffer<T> {
 ///   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 fb841905a..d0b34a9cf 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 258b38555..ca5b5682b 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 8d027dc37..47f6e95fa 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 3c624a66f..304d46282 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 655790787..ca20073d0 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
 ///
@@ -39,7 +43,7 @@ use crate::{
 /// // load kernel symbols from /proc/kallsyms
 /// let ksyms = kernel_symbols()?;
 ///
-/// // NOTE: you tipically send stack_ids from eBPF to user space using other maps
+/// // NOTE: you typically send stack_ids from eBPF to user space using other maps
 /// let stack_id = 1234;
 /// let mut stack_trace = stack_traces.get(&stack_id, 0)?;
 ///
diff --git a/aya/src/programs/cgroup_skb.rs b/aya/src/programs/cgroup_skb.rs
index 45017c616..68971886c 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 46572d74f..32f5bd8c2 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 d5c1b7cf1..48a2b267e 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 a02e23023..4e42136ef 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 cf4c97e9c..ffaebf6ac 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 d288e5aab..048bb9508 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 7fe0d23bb..ac75f081e 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 5fdd0f018..6847a68ea 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 5e7e28402..a3cb52f63 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 eb3033e85..acf2c53fb 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


Test patch: