Skip to content

Commit 742ad97

Browse files
Florian Westphalummakynes
Florian Westphal
authored andcommitted
selftests: netfilter: nft_queue.sh: add test for disappearing listener
If userspace program exits while the queue its subscribed to has packets those need to be discarded. commit dc21c6c ("netfilter: nfnetlink_queue: acquire rcu_read_lock() in instance_destroy_rcu()") fixed a (harmless) rcu splat that could be triggered in this case. Add a test case to cover this. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent e296302 commit 742ad97

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,42 @@ EOF
375375
wait 2>/dev/null
376376
}
377377

378+
test_queue_removal()
379+
{
380+
read tainted_then < /proc/sys/kernel/tainted
381+
382+
ip netns exec "$ns1" nft -f - <<EOF
383+
flush ruleset
384+
table ip filter {
385+
chain output {
386+
type filter hook output priority 0; policy accept;
387+
ip protocol icmp queue num 0
388+
}
389+
}
390+
EOF
391+
ip netns exec "$ns1" ./nf_queue -q 0 -d 30000 -t "$timeout" &
392+
local nfqpid=$!
393+
394+
busywait "$BUSYWAIT_TIMEOUT" nf_queue_wait "$ns1" 0
395+
396+
ip netns exec "$ns1" ping -w 2 -f -c 10 127.0.0.1 -q >/dev/null
397+
kill $nfqpid
398+
399+
ip netns exec "$ns1" nft flush ruleset
400+
401+
if [ "$tainted_then" -ne 0 ];then
402+
return
403+
fi
404+
405+
read tainted_now < /proc/sys/kernel/tainted
406+
if [ "$tainted_now" -eq 0 ];then
407+
echo "PASS: queue program exiting while packets queued"
408+
else
409+
echo "TAINT: queue program exiting while packets queued"
410+
ret=1
411+
fi
412+
}
413+
378414
ip netns exec "$nsrouter" sysctl net.ipv6.conf.all.forwarding=1 > /dev/null
379415
ip netns exec "$nsrouter" sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null
380416
ip netns exec "$nsrouter" sysctl net.ipv4.conf.veth1.forwarding=1 > /dev/null
@@ -413,5 +449,6 @@ test_tcp_localhost
413449
test_tcp_localhost_connectclose
414450
test_tcp_localhost_requeue
415451
test_icmp_vrf
452+
test_queue_removal
416453

417454
exit $ret

0 commit comments

Comments
 (0)