Linux Netfilter development
 help / color / mirror / Atom feed
* [PATCH nf-next v2 0/4] selftest: netfilter: small test tweaks
@ 2023-05-04  8:48 Boris Sukholitko
  2023-05-04  8:48 ` [PATCH nf-next v2 1/4] selftest: netfilter: use /proc for pid checking Boris Sukholitko
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Boris Sukholitko @ 2023-05-04  8:48 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Ilya Lifshits, Boris Sukholitko

[-- Attachment #1: Type: text/plain, Size: 830 bytes --]

Hi,

These patches allow nft_flowtable.sh test script to work in busybox environment
(patches 1-2).

More exact wait for netcat running in the background is in patch 3.

Small adaptive sleep optimization (patch 4) helps with running on busy servers
and cuts default sleep time a bit.

Thanks,
Boris.

- v2:
    - extracted from controversial dscp offload series
    - added Acked-by: Florian Westphal <fw.de> on patch 4

Boris Sukholitko (4):
  selftest: netfilter: use /proc for pid checking
  selftest: netfilter: no need for ps -x option
  selftest: netfilter: wait for specific nc pids
  selftest: netfilter: monitor result file sizes

 .../selftests/netfilter/nft_flowtable.sh      | 21 +++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)


base-commit: 19c60fdee5db881a99a9c39fb31942a530d20c63
-- 
2.32.0


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4221 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH nf-next v2 1/4] selftest: netfilter: use /proc for pid checking
  2023-05-04  8:48 [PATCH nf-next v2 0/4] selftest: netfilter: small test tweaks Boris Sukholitko
@ 2023-05-04  8:48 ` Boris Sukholitko
  2023-05-04  8:48 ` [PATCH nf-next v2 2/4] selftest: netfilter: no need for ps -x option Boris Sukholitko
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Boris Sukholitko @ 2023-05-04  8:48 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Ilya Lifshits, Boris Sukholitko

[-- Attachment #1: Type: text/plain, Size: 796 bytes --]

Some ps commands (e.g. busybox derived) have no -p option. Use /proc for
pid existence check.

Signed-off-by: Boris Sukholitko <boris.sukholitko@broadcom.com>
---
 tools/testing/selftests/netfilter/nft_flowtable.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/netfilter/nft_flowtable.sh b/tools/testing/selftests/netfilter/nft_flowtable.sh
index 7060bae04ec8..4d8bc51b7a7b 100755
--- a/tools/testing/selftests/netfilter/nft_flowtable.sh
+++ b/tools/testing/selftests/netfilter/nft_flowtable.sh
@@ -288,11 +288,11 @@ test_tcp_forwarding_ip()
 
 	sleep 3
 
-	if ps -p $lpid > /dev/null;then
+	if test -d /proc/"$lpid"/; then
 		kill $lpid
 	fi
 
-	if ps -p $cpid > /dev/null;then
+	if test -d /proc/"$cpid"/; then
 		kill $cpid
 	fi
 
-- 
2.32.0


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4221 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH nf-next v2 2/4] selftest: netfilter: no need for ps -x option
  2023-05-04  8:48 [PATCH nf-next v2 0/4] selftest: netfilter: small test tweaks Boris Sukholitko
  2023-05-04  8:48 ` [PATCH nf-next v2 1/4] selftest: netfilter: use /proc for pid checking Boris Sukholitko
@ 2023-05-04  8:48 ` Boris Sukholitko
  2023-05-04  8:48 ` [PATCH nf-next v2 3/4] selftest: netfilter: wait for specific nc pids Boris Sukholitko
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Boris Sukholitko @ 2023-05-04  8:48 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Ilya Lifshits, Boris Sukholitko

[-- Attachment #1: Type: text/plain, Size: 997 bytes --]

Some ps commands (e.g. busybox derived) have no -x option. For the
purposes of hash calculation of the list of processes this option is
inessential.

Signed-off-by: Boris Sukholitko <boris.sukholitko@broadcom.com>
---
 tools/testing/selftests/netfilter/nft_flowtable.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/netfilter/nft_flowtable.sh b/tools/testing/selftests/netfilter/nft_flowtable.sh
index 4d8bc51b7a7b..3cf20e9bd3a6 100755
--- a/tools/testing/selftests/netfilter/nft_flowtable.sh
+++ b/tools/testing/selftests/netfilter/nft_flowtable.sh
@@ -489,8 +489,8 @@ ip -net $nsr1 addr add 10.0.1.1/24 dev veth0
 ip -net $nsr1 addr add dead:1::1/64 dev veth0
 ip -net $nsr1 link set up dev veth0
 
-KEY_SHA="0x"$(ps -xaf | sha1sum | cut -d " " -f 1)
-KEY_AES="0x"$(ps -xaf | md5sum | cut -d " " -f 1)
+KEY_SHA="0x"$(ps -af | sha1sum | cut -d " " -f 1)
+KEY_AES="0x"$(ps -af | md5sum | cut -d " " -f 1)
 SPI1=$RANDOM
 SPI2=$RANDOM
 
-- 
2.32.0


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4221 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH nf-next v2 3/4] selftest: netfilter: wait for specific nc pids
  2023-05-04  8:48 [PATCH nf-next v2 0/4] selftest: netfilter: small test tweaks Boris Sukholitko
  2023-05-04  8:48 ` [PATCH nf-next v2 1/4] selftest: netfilter: use /proc for pid checking Boris Sukholitko
  2023-05-04  8:48 ` [PATCH nf-next v2 2/4] selftest: netfilter: no need for ps -x option Boris Sukholitko
@ 2023-05-04  8:48 ` Boris Sukholitko
  2023-05-04  8:48 ` [PATCH nf-next v2 4/4] selftest: netfilter: monitor result file sizes Boris Sukholitko
  2023-05-10  7:09 ` [PATCH nf-next v2 0/4] selftest: netfilter: small test tweaks Pablo Neira Ayuso
  4 siblings, 0 replies; 6+ messages in thread
From: Boris Sukholitko @ 2023-05-04  8:48 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Ilya Lifshits, Boris Sukholitko

[-- Attachment #1: Type: text/plain, Size: 918 bytes --]

Doing wait with no parameters may interfere with some of the tests
having their own background processes.

Although no such test is currently present, the cleanup is useful
to rely on the nft_flowtable.sh for local development (e.g. running
background tcpdump command during the tests).

Signed-off-by: Boris Sukholitko <boris.sukholitko@broadcom.com>
---
 tools/testing/selftests/netfilter/nft_flowtable.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/netfilter/nft_flowtable.sh b/tools/testing/selftests/netfilter/nft_flowtable.sh
index 3cf20e9bd3a6..92bc308bf168 100755
--- a/tools/testing/selftests/netfilter/nft_flowtable.sh
+++ b/tools/testing/selftests/netfilter/nft_flowtable.sh
@@ -296,7 +296,8 @@ test_tcp_forwarding_ip()
 		kill $cpid
 	fi
 
-	wait
+	wait $lpid
+	wait $cpid
 
 	if ! check_transfer "$nsin" "$ns2out" "ns1 -> ns2"; then
 		lret=1
-- 
2.32.0


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4221 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH nf-next v2 4/4] selftest: netfilter: monitor result file sizes
  2023-05-04  8:48 [PATCH nf-next v2 0/4] selftest: netfilter: small test tweaks Boris Sukholitko
                   ` (2 preceding siblings ...)
  2023-05-04  8:48 ` [PATCH nf-next v2 3/4] selftest: netfilter: wait for specific nc pids Boris Sukholitko
@ 2023-05-04  8:48 ` Boris Sukholitko
  2023-05-10  7:09 ` [PATCH nf-next v2 0/4] selftest: netfilter: small test tweaks Pablo Neira Ayuso
  4 siblings, 0 replies; 6+ messages in thread
From: Boris Sukholitko @ 2023-05-04  8:48 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Ilya Lifshits, Boris Sukholitko, Florian Westphal

[-- Attachment #1: Type: text/plain, Size: 1257 bytes --]

When running nft_flowtable.sh in VM on a busy server we've found that
the time of the netcat file transfers vary wildly.

Therefore replace hardcoded 3 second sleep with the loop checking for
a change in the file sizes. Once no change in detected we test the results.

Nice side effect is that we shave 1 second sleep in the fast case
(hard-coded 3 second sleep vs two 1 second sleeps).

Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Boris Sukholitko <boris.sukholitko@broadcom.com>
---
 tools/testing/selftests/netfilter/nft_flowtable.sh | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/netfilter/nft_flowtable.sh b/tools/testing/selftests/netfilter/nft_flowtable.sh
index 92bc308bf168..51f986f19fee 100755
--- a/tools/testing/selftests/netfilter/nft_flowtable.sh
+++ b/tools/testing/selftests/netfilter/nft_flowtable.sh
@@ -286,7 +286,15 @@ test_tcp_forwarding_ip()
 	ip netns exec $nsa nc -w 4 "$dstip" "$dstport" < "$nsin" > "$ns1out" &
 	cpid=$!
 
-	sleep 3
+	sleep 1
+
+	prev="$(ls -l $ns1out $ns2out)"
+	sleep 1
+
+	while [[ "$prev" != "$(ls -l $ns1out $ns2out)" ]]; do
+		sleep 1;
+		prev="$(ls -l $ns1out $ns2out)"
+	done
 
 	if test -d /proc/"$lpid"/; then
 		kill $lpid
-- 
2.32.0


[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4221 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH nf-next v2 0/4] selftest: netfilter: small test tweaks
  2023-05-04  8:48 [PATCH nf-next v2 0/4] selftest: netfilter: small test tweaks Boris Sukholitko
                   ` (3 preceding siblings ...)
  2023-05-04  8:48 ` [PATCH nf-next v2 4/4] selftest: netfilter: monitor result file sizes Boris Sukholitko
@ 2023-05-10  7:09 ` Pablo Neira Ayuso
  4 siblings, 0 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2023-05-10  7:09 UTC (permalink / raw)
  To: Boris Sukholitko; +Cc: netfilter-devel, Ilya Lifshits

On Thu, May 04, 2023 at 11:48:10AM +0300, Boris Sukholitko wrote:
> Hi,
> 
> These patches allow nft_flowtable.sh test script to work in busybox environment
> (patches 1-2).
> 
> More exact wait for netcat running in the background is in patch 3.
> 
> Small adaptive sleep optimization (patch 4) helps with running on busy servers
> and cuts default sleep time a bit.

Thanks, I am going to route this batch through nf.git instead, I think
it is good to get this selftests updates there.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-05-10  7:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-04  8:48 [PATCH nf-next v2 0/4] selftest: netfilter: small test tweaks Boris Sukholitko
2023-05-04  8:48 ` [PATCH nf-next v2 1/4] selftest: netfilter: use /proc for pid checking Boris Sukholitko
2023-05-04  8:48 ` [PATCH nf-next v2 2/4] selftest: netfilter: no need for ps -x option Boris Sukholitko
2023-05-04  8:48 ` [PATCH nf-next v2 3/4] selftest: netfilter: wait for specific nc pids Boris Sukholitko
2023-05-04  8:48 ` [PATCH nf-next v2 4/4] selftest: netfilter: monitor result file sizes Boris Sukholitko
2023-05-10  7:09 ` [PATCH nf-next v2 0/4] selftest: netfilter: small test tweaks Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox