diff mbox series

[ovs-dev] tests: Prevent netcat from forking.

Message ID 20240827142832.632079-1-amusil@redhat.com
State Accepted
Headers show
Series [ovs-dev] tests: Prevent netcat from forking. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes success github build: passed

Commit Message

Ales Musil Aug. 27, 2024, 2:28 p.m. UTC
Netcat is able to handle multiple connections when "-k, --keep-open"
"-e command, --exec command" by forking the netcat. Prevent this
behavior by allowing only one connection at a time. This also
prevents the test getting stuck on cleanup as the netcat PID
wouldn't be added to the cleanup script.

Fixes: d15b12da6fe6 ("northd: Add ACL Sampling.")
Signed-off-by: Ales Musil <amusil@redhat.com>
---
 tests/system-ovn.at | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Mark Michelson Aug. 27, 2024, 8:18 p.m. UTC | #1
Thanks Ales.

Acked-by: Mark Michelson <mmichels@redhat.com>

On 8/27/24 10:28, Ales Musil wrote:
> Netcat is able to handle multiple connections when "-k, --keep-open"
> "-e command, --exec command" by forking the netcat. Prevent this
> behavior by allowing only one connection at a time. This also
> prevents the test getting stuck on cleanup as the netcat PID
> wouldn't be added to the cleanup script.
> 
> Fixes: d15b12da6fe6 ("northd: Add ACL Sampling.")
> Signed-off-by: Ales Musil <amusil@redhat.com>
> ---
>   tests/system-ovn.at | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/tests/system-ovn.at b/tests/system-ovn.at
> index 0831a2108..78020ecda 100644
> --- a/tests/system-ovn.at
> +++ b/tests/system-ovn.at
> @@ -13169,12 +13169,12 @@ dnl And wait for it to be up and running.
>   OVS_WAIT_UNTIL([ovs-ofctl dump-ipfix-flow br-int | grep -q '1 ids'])
>   
>   dnl Start UDP echo server on vm2.
> -NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 1000], [nc-vm2-1000.pid])
> -NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 1010], [nc-vm2-1010.pid])
> -NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 2000], [nc-vm2-2000.pid])
> -NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 2010], [nc-vm2-2010.pid])
> -NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 3000], [nc-vm2-3000.pid])
> -NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 3010], [nc-vm2-3010.pid])
> +NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 1000], [nc-vm2-1000.pid])
> +NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 1010], [nc-vm2-1010.pid])
> +NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 2000], [nc-vm2-2000.pid])
> +NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 2010], [nc-vm2-2010.pid])
> +NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 3000], [nc-vm2-3000.pid])
> +NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 3010], [nc-vm2-3010.pid])
>   
>   dnl Send traffic (2 packets) to the UDP LB1 (hits the from-lport ACL).
>   NS_CHECK_EXEC([vm1], [(echo a; sleep 1; echo a) | nc --send-only -u 43.43.43.43 1000])
> @@ -13337,7 +13337,7 @@ dnl And wait for it to be up and running.
>   OVS_WAIT_UNTIL([ovs-ofctl dump-ipfix-flow br-int | grep -q '1 ids'])
>   
>   dnl Start UDP echo server on vm2.
> -NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 1000], [nc-vm2-1000.pid])
> +NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 1000], [nc-vm2-1000.pid])
>   
>   dnl Send traffic to the UDP server (hits both ACL tiers).
>   NS_CHECK_EXEC([vm1], [echo a | nc --send-only -u 42.42.42.3 1000])
Mark Michelson Aug. 28, 2024, 6:44 p.m. UTC | #2
I pushed this to main and branch-24.09. Thanks Ales!

On 8/27/24 10:28, Ales Musil wrote:
> Netcat is able to handle multiple connections when "-k, --keep-open"
> "-e command, --exec command" by forking the netcat. Prevent this
> behavior by allowing only one connection at a time. This also
> prevents the test getting stuck on cleanup as the netcat PID
> wouldn't be added to the cleanup script.
> 
> Fixes: d15b12da6fe6 ("northd: Add ACL Sampling.")
> Signed-off-by: Ales Musil <amusil@redhat.com>
> ---
>   tests/system-ovn.at | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/tests/system-ovn.at b/tests/system-ovn.at
> index 0831a2108..78020ecda 100644
> --- a/tests/system-ovn.at
> +++ b/tests/system-ovn.at
> @@ -13169,12 +13169,12 @@ dnl And wait for it to be up and running.
>   OVS_WAIT_UNTIL([ovs-ofctl dump-ipfix-flow br-int | grep -q '1 ids'])
>   
>   dnl Start UDP echo server on vm2.
> -NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 1000], [nc-vm2-1000.pid])
> -NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 1010], [nc-vm2-1010.pid])
> -NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 2000], [nc-vm2-2000.pid])
> -NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 2010], [nc-vm2-2010.pid])
> -NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 3000], [nc-vm2-3000.pid])
> -NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 3010], [nc-vm2-3010.pid])
> +NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 1000], [nc-vm2-1000.pid])
> +NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 1010], [nc-vm2-1010.pid])
> +NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 2000], [nc-vm2-2000.pid])
> +NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 2010], [nc-vm2-2010.pid])
> +NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 3000], [nc-vm2-3000.pid])
> +NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 3010], [nc-vm2-3010.pid])
>   
>   dnl Send traffic (2 packets) to the UDP LB1 (hits the from-lport ACL).
>   NS_CHECK_EXEC([vm1], [(echo a; sleep 1; echo a) | nc --send-only -u 43.43.43.43 1000])
> @@ -13337,7 +13337,7 @@ dnl And wait for it to be up and running.
>   OVS_WAIT_UNTIL([ovs-ofctl dump-ipfix-flow br-int | grep -q '1 ids'])
>   
>   dnl Start UDP echo server on vm2.
> -NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 1000], [nc-vm2-1000.pid])
> +NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 1000], [nc-vm2-1000.pid])
>   
>   dnl Send traffic to the UDP server (hits both ACL tiers).
>   NS_CHECK_EXEC([vm1], [echo a | nc --send-only -u 42.42.42.3 1000])
diff mbox series

Patch

diff --git a/tests/system-ovn.at b/tests/system-ovn.at
index 0831a2108..78020ecda 100644
--- a/tests/system-ovn.at
+++ b/tests/system-ovn.at
@@ -13169,12 +13169,12 @@  dnl And wait for it to be up and running.
 OVS_WAIT_UNTIL([ovs-ofctl dump-ipfix-flow br-int | grep -q '1 ids'])
 
 dnl Start UDP echo server on vm2.
-NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 1000], [nc-vm2-1000.pid])
-NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 1010], [nc-vm2-1010.pid])
-NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 2000], [nc-vm2-2000.pid])
-NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 2010], [nc-vm2-2010.pid])
-NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 3000], [nc-vm2-3000.pid])
-NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 3010], [nc-vm2-3010.pid])
+NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 1000], [nc-vm2-1000.pid])
+NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 1010], [nc-vm2-1010.pid])
+NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 2000], [nc-vm2-2000.pid])
+NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 2010], [nc-vm2-2010.pid])
+NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 3000], [nc-vm2-3000.pid])
+NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 3010], [nc-vm2-3010.pid])
 
 dnl Send traffic (2 packets) to the UDP LB1 (hits the from-lport ACL).
 NS_CHECK_EXEC([vm1], [(echo a; sleep 1; echo a) | nc --send-only -u 43.43.43.43 1000])
@@ -13337,7 +13337,7 @@  dnl And wait for it to be up and running.
 OVS_WAIT_UNTIL([ovs-ofctl dump-ipfix-flow br-int | grep -q '1 ids'])
 
 dnl Start UDP echo server on vm2.
-NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l 1000], [nc-vm2-1000.pid])
+NETNS_DAEMONIZE([vm2], [nc -e /bin/cat -k -u -v -l -m 1 1000], [nc-vm2-1000.pid])
 
 dnl Send traffic to the UDP server (hits both ACL tiers).
 NS_CHECK_EXEC([vm1], [echo a | nc --send-only -u 42.42.42.3 1000])