Thread (3 messages) 3 messages, 1 author, 1d ago

[PATCH net v2 2/2] selftests: net: check failed rps_default_mask writes

flat view

From: Yingjie Wang <hidden>
Date: 2026-10-29 15:10:40
Also in: linux-kselftest, lkml
Subsystem: kernel selftest framework, networking [general], the rest · Maintainers: Shuah Khan, Shuah Khan, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

A failed write to rps_default_mask must not change the configured value.
Add a case with a valid low chunk followed by an invalid high chunk. The
old handler leaves the low chunk installed before returning an error,
whereas the fixed handler retains the previous mask.

Signed-off-by: Yingjie Wang <redacted>
---
 .../testing/selftests/net/rps_default_mask.sh | 23 +++++++++++++++++++
 1 file changed, 23 insertions(+)
diff --git a/tools/testing/selftests/net/rps_default_mask.sh b/tools/testing/selftests/net/rps_default_mask.sh
index b200019b3c80a..91e163fd25450 100755
--- a/tools/testing/selftests/net/rps_default_mask.sh
+++ b/tools/testing/selftests/net/rps_default_mask.sh
@@ -45,8 +45,31 @@ chk_rps() {
 	fi
 }
 
+chk_rps_default_mask() {
+	local rps_mask expected_rps_mask=$2
+	local msg=$1
+
+	rps_mask=$(cat /proc/sys/net/core/rps_default_mask)
+	printf "%-60s" "$msg"
+
+	rps_mask=${rps_mask//,}
+	if [ "$rps_mask" -eq "$expected_rps_mask" ]; then
+		echo "[ ok ]"
+	else
+		echo "[fail] expected $expected_rps_mask found $rps_mask"
+		ret=1
+	fi
+}
+
 trap cleanup EXIT
 
+echo 1 > /proc/sys/net/core/rps_default_mask
+if echo "zz,00000003" > /proc/sys/net/core/rps_default_mask 2>/dev/null; then
+	echo "invalid rps_default_mask write unexpectedly succeeded"
+	ret=1
+fi
+chk_rps_default_mask "failed write doesn't change rps_default_mask" 1
+
 echo 0 > /proc/sys/net/core/rps_default_mask
 setup
 chk_rps "empty rps_default_mask" $NETNS lo 0
-- 
2.43.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help