Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

RDMA/rxe: Add testcase for net namespace rxe

Add 4 testcases for rxe with net namespace.

Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Link: https://patch.msgid.link/20260313023058.13020-5-yanjun.zhu@linux.dev
Signed-off-by: Leon Romanovsky <leon@kernel.org>

authored by

Zhu Yanjun and committed by
Leon Romanovsky
e01027ca f1327abd

+300
+2
MAINTAINERS
··· 12555 12555 F: include/uapi/rdma/ 12556 12556 F: samples/bpf/ibumad_kern.c 12557 12557 F: samples/bpf/ibumad_user.c 12558 + F: tools/testing/selftests/rdma/ 12558 12559 12559 12560 INGENIC JZ4780 NAND DRIVER 12560 12561 M: Harvey Hunt <harveyhuntnexus@gmail.com> ··· 24504 24503 S: Supported 24505 24504 F: drivers/infiniband/sw/rxe/ 24506 24505 F: include/uapi/rdma/rdma_user_rxe.h 24506 + F: tools/testing/selftests/rdma/rxe* 24507 24507 24508 24508 SOFTLOGIC 6x10 MPEG CODEC 24509 24509 M: Bluecherry Maintainers <maintainers@bluecherrydvr.com>
+1
tools/testing/selftests/Makefile
··· 94 94 TARGETS += pstore 95 95 TARGETS += ptrace 96 96 TARGETS += openat2 97 + TARGETS += rdma 97 98 TARGETS += resctrl 98 99 TARGETS += riscv 99 100 TARGETS += rlimits
+7
tools/testing/selftests/rdma/Makefile
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + TEST_PROGS := rxe_rping_between_netns.sh \ 3 + rxe_ipv6.sh \ 4 + rxe_socket_with_netns.sh \ 5 + rxe_test_NETDEV_UNREGISTER.sh 6 + 7 + include ../lib.mk
+3
tools/testing/selftests/rdma/config
··· 1 + CONFIG_TUN 2 + CONFIG_VETH 3 + CONFIG_RDMA_RXE
+63
tools/testing/selftests/rdma/rxe_ipv6.sh
··· 1 + #!/bin/bash 2 + 3 + # Configuration 4 + NS_NAME="net6" 5 + VETH_HOST="veth0" 6 + VETH_NS="veth1" 7 + RXE_NAME="rxe6" 8 + PORT=4791 9 + IP6_ADDR="2001:db8::1/64" 10 + 11 + exec > /dev/null 12 + 13 + # Cleanup function to run on exit (even on failure) 14 + cleanup() { 15 + ip netns del "$NS_NAME" 2>/dev/null 16 + modprobe -r rdma_rxe 2>/dev/null 17 + echo "Done." 18 + } 19 + trap cleanup EXIT 20 + 21 + # 1. Prerequisites check 22 + for mod in tun veth rdma_rxe; do 23 + if ! modinfo "$mod" >/dev/null 2>&1; then 24 + echo "Error: Kernel module '$mod' not found." 25 + exit 1 26 + fi 27 + done 28 + 29 + modprobe rdma_rxe 30 + 31 + # 2. Setup Namespace and Networking 32 + echo "Setting up IPv6 network namespace..." 33 + ip netns add "$NS_NAME" 34 + ip link add "$VETH_HOST" type veth peer name "$VETH_NS" 35 + ip link set "$VETH_NS" netns "$NS_NAME" 36 + ip netns exec "$NS_NAME" ip addr add "$IP6_ADDR" dev "$VETH_NS" 37 + ip netns exec "$NS_NAME" ip link set "$VETH_NS" up 38 + ip link set "$VETH_HOST" up 39 + 40 + # 3. Add RDMA Link 41 + echo "Adding RDMA RXE link..." 42 + if ! ip netns exec "$NS_NAME" rdma link add "$RXE_NAME" type rxe netdev "$VETH_NS"; then 43 + echo "Error: Failed to create RXE link." 44 + exit 1 45 + fi 46 + 47 + # 4. Verification: Port should be listening 48 + # Using -H to skip headers and -q for quiet exit codes 49 + if ! ip netns exec "$NS_NAME" ss -Hul6n sport = :$PORT | grep -q ":$PORT"; then 50 + echo "Error: UDP port $PORT is NOT listening after link creation." 51 + exit 1 52 + fi 53 + echo "Verified: Port $PORT is active." 54 + 55 + # 5. Removal and Verification 56 + echo "Deleting RDMA link..." 57 + ip netns exec "$NS_NAME" rdma link del "$RXE_NAME" 58 + 59 + if ip netns exec "$NS_NAME" ss -Hul6n sport = :$PORT | grep -q ":$PORT"; then 60 + echo "Error: UDP port $PORT still active after link deletion." 61 + exit 1 62 + fi 63 + echo "Verified: Port $PORT closed successfully."
+85
tools/testing/selftests/rdma/rxe_rping_between_netns.sh
··· 1 + #!/bin/bash 2 + 3 + # Configuration 4 + NS="test1" 5 + VETH_A="veth-a" 6 + VETH_B="veth-b" 7 + IP_A="1.1.1.1" 8 + IP_B="1.1.1.2" 9 + PORT=4791 10 + 11 + exec > /dev/null 12 + 13 + # --- Cleanup Routine --- 14 + cleanup() { 15 + echo "Cleaning up resources..." 16 + rdma link del rxe1 2>/dev/null 17 + ip netns exec "$NS" rdma link del rxe0 2>/dev/null 18 + ip link delete "$VETH_B" 2>/dev/null 19 + ip netns del "$NS" 2>/dev/null 20 + modprobe -r rdma_rxe 2>/dev/null 21 + } 22 + trap cleanup EXIT 23 + 24 + # --- Prerequisite Checks --- 25 + if [[ $EUID -ne 0 ]]; then 26 + echo "This script must be run as root" 27 + exit 1 28 + fi 29 + 30 + modprobe rdma_rxe || { echo "Failed to load rdma_rxe"; exit 1; } 31 + 32 + # --- Setup Network Topology --- 33 + echo "Setting up network namespace and veth pair..." 34 + ip netns add "$NS" 35 + ip link add "$VETH_A" type veth peer name "$VETH_B" 36 + ip link set "$VETH_A" netns "$NS" 37 + 38 + # Configure Namespace side (test1) 39 + ip netns exec "$NS" ip addr add "$IP_A/24" dev "$VETH_A" 40 + ip netns exec "$NS" ip link set "$VETH_A" up 41 + ip netns exec "$NS" ip link set lo up 42 + 43 + # Configure Host side 44 + ip addr add "$IP_B/24" dev "$VETH_B" 45 + ip link set "$VETH_B" up 46 + 47 + # --- RXE Link Creation --- 48 + echo "Creating RDMA links..." 49 + ip netns exec "$NS" rdma link add rxe0 type rxe netdev "$VETH_A" 50 + rdma link add rxe1 type rxe netdev "$VETH_B" 51 + 52 + # Verify UDP 4791 is listening 53 + check_port() { 54 + local target=$1 # "host" or "ns" 55 + if [ "$target" == "ns" ]; then 56 + ip netns exec "$NS" ss -Huln sport == :$PORT | grep -q ":$PORT" 57 + else 58 + ss -Huln sport == :$PORT | grep -q ":$PORT" 59 + fi 60 + } 61 + 62 + check_port "ns" || { echo "Error: RXE port not listening in namespace"; exit 1; } 63 + check_port "host" || { echo "Error: RXE port not listening on host"; exit 1; } 64 + 65 + # --- Connectivity Test --- 66 + echo "Testing connectivity with rping..." 67 + ping -c 2 -W 1 "$IP_A" > /dev/null || { echo "Ping failed"; exit 1; } 68 + 69 + # Start rping server in background 70 + ip netns exec "$NS" rping -s -a "$IP_A" -v > /dev/null 2>&1 & 71 + RPING_PID=$! 72 + sleep 1 # Allow server to bind 73 + 74 + # Run rping client 75 + rping -c -a "$IP_A" -d -v -C 3 76 + RESULT=$? 77 + 78 + kill $RPING_PID 2>/dev/null 79 + 80 + if [ $RESULT -eq 0 ]; then 81 + echo "SUCCESS: RDMA traffic verified." 82 + else 83 + echo "FAILURE: rping failed." 84 + exit 1 85 + fi
+76
tools/testing/selftests/rdma/rxe_socket_with_netns.sh
··· 1 + #!/bin/bash 2 + 3 + # Configuration 4 + PORT=4791 5 + MODS=("tun" "rdma_rxe") 6 + 7 + exec > /dev/null 8 + 9 + # --- Helper: Cleanup Routine --- 10 + cleanup() { 11 + echo "Cleaning up resources..." 12 + rdma link del rxe1 2>/dev/null 13 + rdma link del rxe0 2>/dev/null 14 + ip link del tun0 2>/dev/null 15 + ip link del tun1 2>/dev/null 16 + for m in "${MODS[@]}"; do modprobe -r "$m" 2>/dev/null; done 17 + } 18 + 19 + # Ensure cleanup runs on script exit or interrupt 20 + trap cleanup EXIT 21 + 22 + # --- Phase 1: Environment Check --- 23 + if [[ $EUID -ne 0 ]]; then 24 + echo "Error: This script must be run as root." 25 + exit 1 26 + fi 27 + 28 + for m in "${MODS[@]}"; do 29 + modprobe "$m" || { echo "Error: Failed to load $m"; exit 1; } 30 + done 31 + 32 + # --- Phase 2: Create Interfaces & RXE Links --- 33 + echo "Creating tun0 (1.1.1.1) and rxe0..." 34 + ip tuntap add mode tun tun0 35 + ip addr add 1.1.1.1/24 dev tun0 36 + ip link set tun0 up 37 + rdma link add rxe0 type rxe netdev tun0 38 + 39 + # Verify port 4791 is listening 40 + if ! ss -Huln sport = :$PORT | grep -q ":$PORT"; then 41 + echo "Error: UDP port $PORT not found after rxe0 creation" 42 + exit 1 43 + fi 44 + 45 + echo "Creating tun1 (2.2.2.2) and rxe1..." 46 + ip tuntap add mode tun tun1 47 + ip addr add 2.2.2.2/24 dev tun1 48 + ip link set tun1 up 49 + rdma link add rxe1 type rxe netdev tun1 50 + 51 + # Verify port 4791 is still listening 52 + if ! ss -Huln sport = :$PORT | grep -q ":$PORT"; then 53 + echo "Error: UDP port $PORT missing after rxe1 creation" 54 + exit 1 55 + fi 56 + 57 + # --- Phase 3: Targeted Deletion --- 58 + echo "Deleting rxe1..." 59 + rdma link del rxe1 60 + 61 + # Port should still be active because rxe0 is still alive 62 + if ! ss -Huln sport = :$PORT | grep -q ":$PORT"; then 63 + echo "Error: UDP port $PORT closed prematurely" 64 + exit 1 65 + fi 66 + 67 + echo "Deleting rxe0..." 68 + rdma link del rxe0 69 + 70 + # Port should now be gone 71 + if ss -Huln sport = :$PORT | grep -q ":$PORT"; then 72 + echo "Error: UDP port $PORT still exists after all links deleted" 73 + exit 1 74 + fi 75 + 76 + echo "Test passed successfully."
+63
tools/testing/selftests/rdma/rxe_test_NETDEV_UNREGISTER.sh
··· 1 + #!/bin/bash 2 + 3 + # Configuration 4 + DEV_NAME="tun0" 5 + RXE_NAME="rxe0" 6 + RDMA_PORT=4791 7 + 8 + exec > /dev/null 9 + 10 + # --- Cleanup Routine --- 11 + # Ensures environment is clean even if the script hits an error 12 + cleanup() { 13 + echo "Performing cleanup..." 14 + rdma link del $RXE_NAME 2>/dev/null 15 + ip link del $DEV_NAME 2>/dev/null 16 + modprobe -r rdma_rxe 2>/dev/null 17 + } 18 + trap cleanup EXIT 19 + 20 + # 1. Dependency Check 21 + if ! modinfo rdma_rxe >/dev/null 2>&1; then 22 + echo "Error: rdma_rxe module not found." 23 + exit 1 24 + fi 25 + 26 + modprobe rdma_rxe 27 + 28 + # 2. Setup TUN Device 29 + echo "Creating $DEV_NAME..." 30 + ip tuntap add mode tun "$DEV_NAME" 31 + ip addr add 1.1.1.1/24 dev "$DEV_NAME" 32 + ip link set "$DEV_NAME" up 33 + 34 + # 3. Attach RXE Link 35 + echo "Attaching RXE link $RXE_NAME to $DEV_NAME..." 36 + rdma link add "$RXE_NAME" type rxe netdev "$DEV_NAME" 37 + 38 + # 4. Verification: Port Check 39 + # Use -H (no header) and -q (quiet) for cleaner scripting logic 40 + if ! ss -Huln sport == :$RDMA_PORT | grep -q ":$RDMA_PORT"; then 41 + echo "Error: UDP port $RDMA_PORT is not listening." 42 + exit 1 43 + fi 44 + echo "Verified: RXE is listening on UDP $RDMA_PORT." 45 + 46 + # 5. Trigger NETDEV_UNREGISTER 47 + # We delete the underlying device without deleting the RDMA link first. 48 + echo "Triggering NETDEV_UNREGISTER by deleting $DEV_NAME..." 49 + ip link del "$DEV_NAME" 50 + 51 + # 6. Final Verification 52 + # The RXE link and the UDP port should be automatically cleaned up by the kernel. 53 + if rdma link show "$RXE_NAME" 2>/dev/null; then 54 + echo "Error: $RXE_NAME still exists after netdev removal." 55 + exit 1 56 + fi 57 + 58 + if ss -Huln sport == :$RDMA_PORT | grep -q ":$RDMA_PORT"; then 59 + echo "Error: UDP port $RDMA_PORT still listening after netdev removal." 60 + exit 1 61 + fi 62 + 63 + echo "Success: NETDEV_UNREGISTER handled correctly."