mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
scripts/check-config: fix kernel version checks
Looking at the code, I found out that kernel_lt function was actually
doing le ("less than or equal") rather than lt ("less than") operation.
Let's fix this and do exactly what the name says.
A bigger issue is, the function use was not consistent (some uses
implied "less than or equal").
To fix the usage, find out all relevant kernel commits and kernel
versions that have them (the latter is done using "git describe
--contains $sha"), and fix the wrong cases. While at it, add references
to all these kernel commits for the future generations of
check-config.sh hackers.
Also, add kernel_ge function which is the opposite of kernel_lt,
and document both.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
+24
-7
@@ -29,9 +29,19 @@ kernelMajor="${kernelVersion%%.*}"
|
||||
kernelMinor="${kernelVersion#"$kernelMajor".}"
|
||||
kernelMinor="${kernelMinor%%.*}"
|
||||
|
||||
# Usage: to check if kernel version is < 4.8, use
|
||||
# kernel_lt 4 8
|
||||
# (here "lt" stands for "less than").
|
||||
kernel_lt() {
|
||||
[ "$kernelMajor" -lt "$1" ] && return
|
||||
[ "$kernelMajor" -eq "$1" ] && [ "$kernelMinor" -le "$2" ]
|
||||
[ "$kernelMajor" -eq "$1" ] && [ "$kernelMinor" -lt "$2" ]
|
||||
}
|
||||
|
||||
# Usage: to check if kernel version is >= 6.1, use
|
||||
# kernel_ge 6 1
|
||||
# (here "ge" stands for "greater or equal").
|
||||
kernel_ge() {
|
||||
! kernel_lt "$1" "$2"
|
||||
}
|
||||
|
||||
is_set() {
|
||||
@@ -234,16 +244,17 @@ flags=(
|
||||
)
|
||||
check_flags "${flags[@]}"
|
||||
|
||||
if ! kernel_lt 4 14; then
|
||||
if [ $cgroup = "v2" ]; then
|
||||
check_flags CGROUP_BPF
|
||||
fi
|
||||
# Linux kernel commit 3007098494be.
|
||||
if kernel_ge 4 10 && [ $cgroup = "v2" ]; then
|
||||
check_flags CGROUP_BPF
|
||||
fi
|
||||
|
||||
# Linux kernel commit 3bf195ae6037.
|
||||
if kernel_lt 5 1; then
|
||||
check_flags NF_NAT_IPV4
|
||||
fi
|
||||
|
||||
# Linux kernel commit 4806e975729f99c7.
|
||||
if kernel_lt 5 2; then
|
||||
check_flags NF_NAT_NEEDED
|
||||
fi
|
||||
@@ -259,9 +270,11 @@ echo 'Optional Features:'
|
||||
check_flags SECCOMP_FILTER
|
||||
check_flags CGROUP_PIDS
|
||||
|
||||
# Linux kernel commit e55b9f96860f.
|
||||
if kernel_lt 6 1; then
|
||||
check_flags MEMCG_SWAP
|
||||
fi
|
||||
# Linux kernel commit 2d1c498072de.
|
||||
if kernel_lt 5 8; then
|
||||
check_flags MEMCG_SWAP_ENABLED
|
||||
if is_set MEMCG_SWAP && ! is_set MEMCG_SWAP_ENABLED; then
|
||||
@@ -270,20 +283,24 @@ echo 'Optional Features:'
|
||||
fi
|
||||
}
|
||||
|
||||
# Linux kernel commit d886f4e483ce.
|
||||
if kernel_lt 4 5; then
|
||||
check_flags MEMCG_KMEM
|
||||
fi
|
||||
|
||||
if kernel_lt 3 18; then
|
||||
# Linux kernel commit 5b1efc027c0b.
|
||||
if kernel_lt 3 19; then
|
||||
check_flags RESOURCE_COUNTERS
|
||||
fi
|
||||
|
||||
if kernel_lt 3 13; then
|
||||
# Linux kernel commit 86f8515f9721.
|
||||
if kernel_lt 3 14; then
|
||||
netprio=NETPRIO_CGROUP
|
||||
else
|
||||
netprio=CGROUP_NET_PRIO
|
||||
fi
|
||||
|
||||
# Linux kernel commit f382fb0bcef4.
|
||||
if kernel_lt 5 0; then
|
||||
check_flags IOSCHED_CFQ CFQ_GROUP_IOSCHED
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user