selftests: netfilter: Run nft_audit.sh in its own netns
authorPhil Sutter <phil@nwl.cc>
Fri, 13 Oct 2023 20:02:24 +0000 (22:02 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Oct 2023 10:03:07 +0000 (12:03 +0200)
commit 2e2d9c7d4d37d74873583d7b0c94eac8b6869486 upstream.

Don't mess with the host's firewall ruleset. Since audit logging is not
per-netns, add an initial delay of a second so other selftests' netns
cleanups have a chance to finish.

Fixes: e8dbde59ca3f ("selftests: netfilter: Test nf_tables audit logging")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/testing/selftests/netfilter/nft_audit.sh

index bb34329e02a7f99b0b60bef66f9f1a2441b04c16..5267c88496d5180d5d773562afe35e6248e80f41 100755 (executable)
@@ -11,6 +11,12 @@ nft --version >/dev/null 2>&1 || {
        exit $SKIP_RC
 }
 
+# Run everything in a separate network namespace
+[ "${1}" != "run" ] && { unshare -n "${0}" run; exit $?; }
+
+# give other scripts a chance to finish - audit_logread sees all activity
+sleep 1
+
 logfile=$(mktemp)
 rulefile=$(mktemp)
 echo "logging into $logfile"