[PATCH mptcp-next v2 5/7] selftests: mptcp: drop iptables/ip6tables vars

Geliang Tang posted 7 patches 1 year, 11 months ago
There is a newer version of this series
[PATCH mptcp-next v2 5/7] selftests: mptcp: drop iptables/ip6tables vars
Posted by Geliang Tang 1 year, 11 months ago
From: Geliang Tang <tanggeliang@kylinos.cn>

Since iptables-legacy/ip6tables-legacy are dropped in the commit
5b31f0f6f954 ("selftests: mptcp: stop forcing iptables-legacy"),
there's no need to use ${iptables}/${ip6tables} variables anymore.
This patch drops them, and use iptables/ip6tables directly.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 .../testing/selftests/net/mptcp/mptcp_join.sh | 20 +++++++++----------
 .../selftests/net/mptcp/mptcp_sockopt.sh      | 16 +++++++--------
 2 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 88074f64f0a7..9b35a16a7c8b 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -25,8 +25,6 @@ capout=""
 ns1=""
 ns2=""
 ksft_skip=4
-iptables="iptables"
-ip6tables="ip6tables"
 timeout_poll=30
 timeout_test=$((timeout_poll * 2 + 1))
 capture=false
@@ -161,11 +159,11 @@ check_tools()
 		exit $ksft_skip
 	fi
 
-	if ! "${iptables}" -V &> /dev/null; then
-		echo "SKIP: Could not run all tests without ${iptables} tool"
+	if ! iptables -V &> /dev/null; then
+		echo "SKIP: Could not run all tests without iptables tool"
 		exit $ksft_skip
-	elif ! "${ip6tables}" -V &> /dev/null; then
-		echo "SKIP: Could not run all tests without ${ip6tables} tool"
+	elif ! ip6tables -V &> /dev/null; then
+		echo "SKIP: Could not run all tests without ip6tables tool"
 		exit $ksft_skip
 	fi
 }
@@ -348,9 +346,9 @@ reset_with_add_addr_timeout()
 
 	reset "${1}" || return 1
 
-	tables="${iptables}"
+	tables="iptables"
 	if [ $ip -eq 6 ]; then
-		tables="${ip6tables}"
+		tables="ip6tables"
 	fi
 
 	ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1
@@ -414,9 +412,9 @@ setup_fail_rules()
 	local ip="${2:-4}"
 	local tables
 
-	tables="${iptables}"
+	tables="iptables"
 	if [ $ip -eq 6 ]; then
-		tables="${ip6tables}"
+		tables="ip6tables"
 	fi
 
 	ip netns exec $ns2 $tables \
@@ -475,7 +473,7 @@ reset_with_tcp_filter()
 	local src="${2}"
 	local target="${3}"
 
-	if ! ip netns exec "${ns}" ${iptables} \
+	if ! ip netns exec "${ns}" iptables \
 			-A INPUT \
 			-s "${src}" \
 			-p tcp \
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
index dac8e1fc7143..722b0872f00d 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
@@ -11,8 +11,6 @@ cout=""
 ksft_skip=4
 timeout_poll=30
 timeout_test=$((timeout_poll * 2 + 1))
-iptables="iptables"
-ip6tables="ip6tables"
 
 sec=$(date +%s)
 rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
@@ -26,7 +24,7 @@ add_mark_rules()
 	local m=$2
 
 	local t
-	for t in ${iptables} ${ip6tables}; do
+	for t in "iptables" "ip6tables"; do
 		# just to debug: check we have multiple subflows connection requests
 		ip netns exec $ns $t -A OUTPUT -p tcp --syn -m mark --mark $m -j ACCEPT
 
@@ -96,11 +94,11 @@ if [ $? -ne 0 ];then
 	exit $ksft_skip
 fi
 
-if ! "${iptables}" -V &> /dev/null; then
-	echo "SKIP: Could not run all tests without ${iptables} tool"
+if ! iptables -V &> /dev/null; then
+	echo "SKIP: Could not run all tests without iptables tool"
 	exit $ksft_skip
-elif ! "${ip6tables}" -V &> /dev/null; then
-	echo "SKIP: Could not run all tests without ${ip6tables} tool"
+elif ! ip6tables -V &> /dev/null; then
+	echo "SKIP: Could not run all tests without ip6tables tool"
 	exit $ksft_skip
 fi
 
@@ -109,10 +107,10 @@ check_mark()
 	local ns=$1
 	local af=$2
 
-	local tables=${iptables}
+	local tables="iptables"
 
 	if [ $af -eq 6 ];then
-		tables=${ip6tables}
+		tables="ip6tables"
 	fi
 
 	local counters values
-- 
2.40.1
Re: [PATCH mptcp-next v2 5/7] selftests: mptcp: drop iptables/ip6tables vars
Posted by Matthieu Baerts 1 year, 11 months ago
Hi Geliang,

On 16/02/2024 10:50, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
> 
> Since iptables-legacy/ip6tables-legacy are dropped in the commit
> 5b31f0f6f954 ("selftests: mptcp: stop forcing iptables-legacy"),
> there's no need to use ${iptables}/${ip6tables} variables anymore.

I agree, there is no need to use variables for the moment. But as I
mentioned in the commit message, I kept "the variables to easily change
them later or add options". They don't hurt, we might want to use
'iptables -w', force using 'iptables-nft' if available, or other options
for the debugging. I don't think we need this not so small patch.

In other words, the patch is OK, but maybe we don't need it?

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.