]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests: net: Refactor cleanup logic in lib_netcons.sh
authorBreno Leitao <leitao@debian.org>
Fri, 13 Jun 2025 11:31:36 +0000 (04:31 -0700)
committerJakub Kicinski <kuba@kernel.org>
Mon, 16 Jun 2025 22:18:34 +0000 (15:18 -0700)
Extract the network device and namespace cleanup logic from the
cleanup() function into a new do_cleanup() helper in lib_netcons.sh.

The do_cleanup() function only unconfigure the network and
printk, while cleanup() cleans the netconsole targets plus the network
and printk.

This refactoring let this code to be reused in cases netconsole dynamic
is not being used, as in the upcoming patch.

Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20250613-rework-v3-7-0752bf2e6912@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh

index 71a5a8b1712c00e72957ad8bf2236bd9085b0a96..598279139a6e548d1ca395b287e3c0d3a4935397 100644 (file)
@@ -128,16 +128,9 @@ function disable_release_append() {
        echo 1 > "${NETCONS_PATH}"/enabled
 }
 
-function cleanup() {
+function do_cleanup() {
        local NSIM_DEV_SYS_DEL="/sys/bus/netdevsim/del_device"
 
-       # delete netconsole dynamic reconfiguration
-       echo 0 > "${NETCONS_PATH}"/enabled
-       # Remove all the keys that got created during the selftest
-       find "${NETCONS_PATH}/userdata/" -mindepth 1 -type d -delete
-       # Remove the configfs entry
-       rmdir "${NETCONS_PATH}"
-
        # Delete netdevsim devices
        echo "$NSIM_DEV_2_ID" > "$NSIM_DEV_SYS_DEL"
        echo "$NSIM_DEV_1_ID" > "$NSIM_DEV_SYS_DEL"
@@ -149,6 +142,17 @@ function cleanup() {
        echo "${DEFAULT_PRINTK_VALUES}" > /proc/sys/kernel/printk
 }
 
+function cleanup() {
+       # delete netconsole dynamic reconfiguration
+       echo 0 > "${NETCONS_PATH}"/enabled
+       # Remove all the keys that got created during the selftest
+       find "${NETCONS_PATH}/userdata/" -mindepth 1 -type d -delete
+       # Remove the configfs entry
+       rmdir "${NETCONS_PATH}"
+
+       do_cleanup
+}
+
 function set_user_data() {
        if [[ ! -d "${NETCONS_PATH}""/userdata" ]]
        then