summaryrefslogtreecommitdiffstats
path: root/iptables-test.py
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2020-11-17 19:00:45 +0100
committerPhil Sutter <phil@nwl.cc>2020-11-17 20:04:01 +0100
commit21873c24159053ce0a6bbd7e93091ceb0b73f90b (patch)
treeae8c51f7a066763f22587fc8890e262c78ae205b /iptables-test.py
parent47251c8bda92b8f655453c52699454b739cc2231 (diff)
iptables-test.py: Try to unshare netns by default
If user did not explicitly requst to "test netnamespace path", try an import of 'unshare' module and call unshare() to avoid killing the local host's network by accident. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables-test.py')
-rwxr-xr-xiptables-test.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/iptables-test.py b/iptables-test.py
index 52897a5d..ca5efb1b 100755
--- a/iptables-test.py
+++ b/iptables-test.py
@@ -366,6 +366,13 @@ def main():
if i.endswith('.t')]
file_list.sort()
+ if not args.netns:
+ try:
+ import unshare
+ unshare.unshare(unshare.CLONE_NEWNET)
+ except:
+ print("Cannot run in own namespace, connectivity might break")
+
for filename in file_list:
file_tests, file_passed = run_test_file(filename, args.netns)
if file_tests: