Skip to content

Commit 661a4f3

Browse files
author
Florian Westphal
committed
selftests: netfilter: fix udpclash tool hang
Yi Chen reports that 'udpclash' loops forever depending on compiler (and optimization level used); while (x == 1) gets optimized into for (;;). Add volatile qualifier to avoid that. While at it, also run it under timeout(1) and fix the resize script to not ignore the timeout passed as second parameter to insert_flood. Reported-by: Yi Chen <[email protected]> Suggested-by: Yi Chen <[email protected]> Fixes: 78a5883 ("selftests: netfilter: add conntrack clash resolution test case") Signed-off-by: Florian Westphal <[email protected]>
1 parent 8156210 commit 661a4f3

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

tools/testing/selftests/net/netfilter/conntrack_clash.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ run_one_clash_test()
9999
local entries
100100
local cre
101101

102-
if ! ip netns exec "$ns" ./udpclash $daddr $dport;then
102+
if ! ip netns exec "$ns" timeout 30 ./udpclash $daddr $dport;then
103103
echo "INFO: did not receive expected number of replies for $daddr:$dport"
104104
ip netns exec "$ctns" conntrack -S
105105
# don't fail: check if clash resolution triggered after all.

tools/testing/selftests/net/netfilter/conntrack_resize.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ ct_udpclash()
187187
[ -x udpclash ] || return
188188

189189
while [ $now -lt $end ]; do
190-
ip netns exec "$ns" ./udpclash 127.0.0.1 $((RANDOM%65536)) > /dev/null 2>&1
190+
ip netns exec "$ns" timeout 30 ./udpclash 127.0.0.1 $((RANDOM%65536)) > /dev/null 2>&1
191191

192192
now=$(date +%s)
193193
done
@@ -277,6 +277,7 @@ check_taint()
277277
insert_flood()
278278
{
279279
local n="$1"
280+
local timeout="$2"
280281
local r=0
281282

282283
r=$((RANDOM%$insert_count))
@@ -302,7 +303,7 @@ test_floodresize_all()
302303
read tainted_then < /proc/sys/kernel/tainted
303304

304305
for n in "$nsclient1" "$nsclient2";do
305-
insert_flood "$n" &
306+
insert_flood "$n" "$timeout" &
306307
done
307308

308309
# resize table constantly while flood/insert/dump/flushs

tools/testing/selftests/net/netfilter/udpclash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct thread_args {
2929
int sockfd;
3030
};
3131

32-
static int wait = 1;
32+
static volatile int wait = 1;
3333

3434
static void *thread_main(void *varg)
3535
{

0 commit comments

Comments
 (0)