[LTP] [COMMITTED][PATCH 1/1] net: Use API function tst_net_use_netns()

Petr Vorel pvorel@suse.cz
Thu Jan 13 16:36:48 CET 2022


instead of LTP_NETNS variable

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/network/nfs/nfs_stress/nfs_lib.sh | 4 ++--
 testcases/network/nfs/nfsstat01/nfsstat01   | 2 +-
 testcases/network/virt/wireguard01.sh       | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/testcases/network/nfs/nfs_stress/nfs_lib.sh b/testcases/network/nfs/nfs_stress/nfs_lib.sh
index b012151363..884109890d 100644
--- a/testcases/network/nfs/nfs_stress/nfs_lib.sh
+++ b/testcases/network/nfs/nfs_stress/nfs_lib.sh
@@ -91,7 +91,7 @@ nfs_mount()
 	local host_type=rhost
 	local mount_dir
 
-	[ -n "$LTP_NETNS" ] && host_type=
+	tst_net_use_netns && host_type=
 
 	if [ $TST_IPV6 ]; then
 		mount_dir="[$(tst_ipaddr $host_type)]:$remote_dir"
@@ -102,7 +102,7 @@ nfs_mount()
 	local mnt_cmd="mount -v -t nfs $opts $mount_dir $local_dir"
 
 	tst_res TINFO "Mounting NFS: $mnt_cmd"
-	if [ -n "$LTP_NETNS" ] && [ -z "$LTP_NFS_NETNS_USE_LO" ]; then
+	if tst_net_use_netns && [ -z "$LTP_NFS_NETNS_USE_LO" ]; then
 		tst_rhost_run -c "$mnt_cmd" > mount.log
 	else
 		$mnt_cmd > mount.log
diff --git a/testcases/network/nfs/nfsstat01/nfsstat01 b/testcases/network/nfs/nfsstat01/nfsstat01
index b71129fd25..06844af396 100755
--- a/testcases/network/nfs/nfsstat01/nfsstat01
+++ b/testcases/network/nfs/nfsstat01/nfsstat01
@@ -17,7 +17,7 @@ get_calls()
 	local opt=
 	[ "$name" = "rpc" ] && opt="r" || opt="n"
 
-	if [ -n "$LTP_NETNS" -o "$nfs_f" = "nfs" ]; then
+	if tst_net_use_netns || [ "$nfs_f" = "nfs" ]; then
 		calls="$(grep $name /proc/net/rpc/$nfs_f | cut -d' ' -f$field)"
 		ROD nfsstat -c$opt | grep -q "$calls"
 		echo "$calls"
diff --git a/testcases/network/virt/wireguard01.sh b/testcases/network/virt/wireguard01.sh
index ff0c7e92b5..05d696a786 100755
--- a/testcases/network/virt/wireguard01.sh
+++ b/testcases/network/virt/wireguard01.sh
@@ -12,7 +12,7 @@ TST_CNT=3
 
 setup()
 {
-	if [ -n "$LTP_NETNS" -a "$VIRT_PERF_THRESHOLD" -lt 700 ]; then
+	if tst_net_use_netns && [ "$VIRT_PERF_THRESHOLD" -lt 700 ]; then
 		tst_res TINFO "Adjust threshold for veth (no encap/encrypt)"
 		VIRT_PERF_THRESHOLD=700
 	fi
-- 
2.34.1



More information about the ltp mailing list