netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: <netdev@vger.kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	<netfilter-devel@vger.kernel.org>,
	pablo@netfilter.org
Subject: [PATCH net-next v2 06/12] selftests: netfilter: xt_string.sh: shellcheck cleanups
Date: Thu, 18 Apr 2024 17:27:34 +0200	[thread overview]
Message-ID: <20240418152744.15105-7-fw@strlen.de> (raw)
In-Reply-To: <20240418152744.15105-1-fw@strlen.de>

no functional change intended.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 .../selftests/net/netfilter/xt_string.sh      | 34 +++++++++----------
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/tools/testing/selftests/net/netfilter/xt_string.sh b/tools/testing/selftests/net/netfilter/xt_string.sh
index ec7042b502e4..8d401c69e317 100755
--- a/tools/testing/selftests/net/netfilter/xt_string.sh
+++ b/tools/testing/selftests/net/netfilter/xt_string.sh
@@ -37,7 +37,7 @@ hdrlen=$((20 + 8)) # IPv4 + UDP
 add_rule() { # (alg, from, to)
 	ip netns exec "$netns" \
 		iptables -A OUTPUT -o d0 -m string \
-			--string "$pattern" --algo $1 --from $2 --to $3
+			--string "$pattern" --algo "$1" --from "$2" --to "$3"
 }
 showrules() { # ()
 	ip netns exec "$netns" iptables -v -S OUTPUT | grep '^-A'
@@ -49,10 +49,10 @@ countrule() { # (pattern)
 	showrules | grep -c -- "$*"
 }
 send() { # (offset)
-	( for ((i = 0; i < $1 - $hdrlen; i++)); do
-		printf " "
+	( for ((i = 0; i < $1 - hdrlen; i++)); do
+		echo -n " "
 	  done
-	  printf "$pattern"
+	  echo -n "$pattern"
 	) > "$infile"
 
 	ip netns exec "$netns" socat -t 1 -u STDIN UDP-SENDTO:10.1.2.2:27374 < "$infile"
@@ -65,8 +65,8 @@ add_rule kmp 1400 1600
 
 zerorules
 send 0
-send $((1000 - $patlen))
-if [ $(countrule -c 0 0) -ne 4 ]; then
+send $((1000 - patlen))
+if [ "$(countrule -c 0 0)" -ne 4 ]; then
 	echo "FAIL: rules match data before --from"
 	showrules
 	((rc--))
@@ -74,16 +74,16 @@ fi
 
 zerorules
 send 1000
-send $((1400 - $patlen))
-if [ $(countrule -c 2) -ne 2 ]; then
+send $((1400 - patlen))
+if [ "$(countrule -c 2)" -ne 2 ]; then
 	echo "FAIL: only two rules should match at low offset"
 	showrules
 	((rc--))
 fi
 
 zerorules
-send $((1500 - $patlen))
-if [ $(countrule -c 1) -ne 4 ]; then
+send $((1500 - patlen))
+if [ "$(countrule -c 1)" -ne 4 ]; then
 	echo "FAIL: all rules should match at end of packet"
 	showrules
 	((rc--))
@@ -91,7 +91,7 @@ fi
 
 zerorules
 send 1495
-if [ $(countrule -c 1) -ne 1 ]; then
+if [ "$(countrule -c 1)" -ne 1 ]; then
 	echo "FAIL: only kmp with proper --to should match pattern spanning fragments"
 	showrules
 	((rc--))
@@ -99,23 +99,23 @@ fi
 
 zerorules
 send 1500
-if [ $(countrule -c 1) -ne 2 ]; then
+if [ "$(countrule -c 1)" -ne 2 ]; then
 	echo "FAIL: two rules should match pattern at start of second fragment"
 	showrules
 	((rc--))
 fi
 
 zerorules
-send $((1600 - $patlen))
-if [ $(countrule -c 1) -ne 2 ]; then
+send $((1600 - patlen))
+if [ "$(countrule -c 1)" -ne 2 ]; then
 	echo "FAIL: two rules should match pattern at end of largest --to"
 	showrules
 	((rc--))
 fi
 
 zerorules
-send $((1600 - $patlen + 1))
-if [ $(countrule -c 1) -ne 0 ]; then
+send $((1600 - patlen + 1))
+if [ "$(countrule -c 1)" -ne 0 ]; then
 	echo "FAIL: no rules should match pattern extending largest --to"
 	showrules
 	((rc--))
@@ -123,7 +123,7 @@ fi
 
 zerorules
 send 1600
-if [ $(countrule -c 1) -ne 0 ]; then
+if [ "$(countrule -c 1)" -ne 0 ]; then
 	echo "FAIL: no rule should match pattern past largest --to"
 	showrules
 	((rc--))
-- 
2.43.2


  parent reply	other threads:[~2024-04-18 15:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-18 15:27 [PATCH net-next v2 00/12] testing: make netfilter selftests functional in vng environment Florian Westphal
2024-04-18 15:27 ` [PATCH net-next v2 01/12] selftests: netfilter: nft_queue.sh: move to lib.sh infra Florian Westphal
2024-04-18 15:27 ` [PATCH net-next v2 02/12] selftests: netfilter: nft_queue.sh: shellcheck cleanups Florian Westphal
2024-04-18 15:27 ` [PATCH net-next v2 03/12] selftests: netfilter: nft_synproxy.sh: move to lib.sh infra Florian Westphal
2024-04-18 15:27 ` [PATCH net-next v2 04/12] selftests: netfilter: nft_zones_many.sh: " Florian Westphal
2024-04-18 15:27 ` [PATCH net-next v2 05/12] selftests: netfilter: xt_string.sh: " Florian Westphal
2024-04-18 15:27 ` Florian Westphal [this message]
2024-04-18 15:27 ` [PATCH net-next v2 07/12] selftests: netfilter: nft_nat_zones.sh: shellcheck cleanups Florian Westphal
2024-04-18 15:27 ` [PATCH net-next v2 08/12] selftests: netfilter: conntrack_ipip_mtu.sh: " Florian Westphal
2024-04-18 15:27 ` [PATCH net-next v2 09/12] selftests: netfilter: nft_fib.sh: " Florian Westphal
2024-04-18 15:27 ` [PATCH net-next v2 10/12] selftests: netfilter: nft_meta.sh: small shellcheck cleanup Florian Westphal
2024-04-18 15:27 ` [PATCH net-next v2 11/12] selftests: netfilter: nft_audit.sh: add more skip checks Florian Westphal
2024-04-18 15:27 ` [PATCH net-next v2 12/12] selftests: netfilter: update makefiles and kernel config Florian Westphal
2024-04-20  3:30 ` [PATCH net-next v2 00/12] testing: make netfilter selftests functional in vng environment patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240418152744.15105-7-fw@strlen.de \
    --to=fw@strlen.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).