From: Florian Westphal Date: Thu, 9 Jul 2026 20:03:53 +0000 (+0200) Subject: tests: runtest.sh: run inside namespace X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=84d939e29a4c21e9cc92a78616c64bc1b4f91a2a;p=thirdparty%2Fipset.git tests: runtest.sh: run inside namespace re-exec the script in case IPSET_UNSHARED environment variable isn't set yet. Add a dummy device named 'eth0' as thats what tests expect to be present. Signed-off-by: Florian Westphal Signed-off-by: Jozsef Kadlecsik --- diff --git a/tests/runtest.sh b/tests/runtest.sh index d102305..766335f 100755 --- a/tests/runtest.sh +++ b/tests/runtest.sh @@ -18,13 +18,32 @@ tests="$tests hash:net,port,net hash:net6,port,net6" tests="$tests hash:net,iface.t hash:mac.t" tests="$tests comment setlist restore" # tests="$tests iptree iptreemap" + +if [ "$IPSET_UNSHARED" = "" ]; then + # Re-execute in new network namespace + export IPSET_UNSHARED="yes" + sysctl net.netfilter.nf_log_all_netns=1 + exec unshare -n -- "$0" "$@" +fi + +sysctl net.ipv4.conf.all.rp_filter=0 + cleanup() { rm -f "$tmpdir"/.foo* rm -f "$tmpdir/.loglines" rmdir "$tmpdir" + ip link del eth0 } trap cleanup EXIT -tmpdir=$(mktemp -t -d ipset-XXXXXXXX) +tmpdir=$(mktemp -t -d ip-set-XXXXXXXX) + +ip link set lo up + +# test cases send and expect packets on eth0. +ip link add dev eth0 type dummy +ip link set eth0 up +ip addr add 10.255.255.64/8 dev eth0 +sysctl net.ipv4.conf.eth0.rp_filter=0 # For correct sorting: LC_ALL=C