mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-28 22:44:08 -04:00
Currently, the rdma rxe selftests fail with an exit code of 1 when
required kernel modules are not present. This causes spurious failures
in environments where these modules might not be compiled or available.
Include the standard kselftest 'ktap_helpers.sh' and replace the
hardcoded error exits with '$KSFT_SKIP'. This ensures the tests are
properly marked as skipped rather than failed.
Fixes: e01027cab3 ("RDMA/rxe: Add testcase for net namespace rxe")
Signed-off-by: Yi Lai <yi1.lai@intel.com>
Link: https://patch.msgid.link/20260507125106.3114167-1-yi1.lai@intel.com
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
83 lines
2.0 KiB
Bash
Executable File
83 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Configuration
|
|
PORT=4791
|
|
MODS=("tun" "rdma_rxe")
|
|
|
|
source "$(dirname "$0")/../kselftest/ktap_helpers.sh"
|
|
|
|
exec > /dev/null
|
|
|
|
# --- Helper: Cleanup Routine ---
|
|
cleanup() {
|
|
echo "Cleaning up resources..."
|
|
rdma link del rxe1 2>/dev/null
|
|
rdma link del rxe0 2>/dev/null
|
|
ip link del tun0 2>/dev/null
|
|
ip link del tun1 2>/dev/null
|
|
for m in "${MODS[@]}"; do modprobe -r "$m" 2>/dev/null; done
|
|
}
|
|
|
|
# Ensure cleanup runs on script exit or interrupt
|
|
trap cleanup EXIT
|
|
|
|
# --- Phase 1: Environment Check ---
|
|
if [[ $EUID -ne 0 ]]; then
|
|
echo "Error: This script must be run as root."
|
|
exit 1
|
|
fi
|
|
|
|
for m in "${MODS[@]}"; do
|
|
if ! modinfo "$m" >/dev/null 2>&1; then
|
|
echo "SKIP: Kernel module '$m' not found." >&2
|
|
exit $KSFT_SKIP
|
|
fi
|
|
modprobe "$m" || { echo "Error: Failed to load $m"; exit 1; }
|
|
done
|
|
|
|
# --- Phase 2: Create Interfaces & RXE Links ---
|
|
echo "Creating tun0 (1.1.1.1) and rxe0..."
|
|
ip tuntap add mode tun tun0
|
|
ip addr add 1.1.1.1/24 dev tun0
|
|
ip link set tun0 up
|
|
rdma link add rxe0 type rxe netdev tun0
|
|
|
|
# Verify port 4791 is listening
|
|
if ! ss -Huln sport = :$PORT | grep -q ":$PORT"; then
|
|
echo "Error: UDP port $PORT not found after rxe0 creation"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Creating tun1 (2.2.2.2) and rxe1..."
|
|
ip tuntap add mode tun tun1
|
|
ip addr add 2.2.2.2/24 dev tun1
|
|
ip link set tun1 up
|
|
rdma link add rxe1 type rxe netdev tun1
|
|
|
|
# Verify port 4791 is still listening
|
|
if ! ss -Huln sport = :$PORT | grep -q ":$PORT"; then
|
|
echo "Error: UDP port $PORT missing after rxe1 creation"
|
|
exit 1
|
|
fi
|
|
|
|
# --- Phase 3: Targeted Deletion ---
|
|
echo "Deleting rxe1..."
|
|
rdma link del rxe1
|
|
|
|
# Port should still be active because rxe0 is still alive
|
|
if ! ss -Huln sport = :$PORT | grep -q ":$PORT"; then
|
|
echo "Error: UDP port $PORT closed prematurely"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Deleting rxe0..."
|
|
rdma link del rxe0
|
|
|
|
# Port should now be gone
|
|
if ss -Huln sport = :$PORT | grep -q ":$PORT"; then
|
|
echo "Error: UDP port $PORT still exists after all links deleted"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Test passed successfully."
|