Keep NAT probes independent of cached conntrack and DHCP timers
This commit is contained in:
1 parent
47948fe847
commit
856fbc61b1
2 files changed
+13
-2
No files matched your search
@@ -103,7 +103,8 @@ class Probes:
|
||||
for gateway in NATS:
|
||||
for node in (n for n in NODES if n.nat == gateway.name):
|
||||
a, b, c = public["a"], public["b"], public["c"]
|
||||
before = self.exchange(c.name, gateway.ip, node.mapped_port, count=1, timeout=0.35)
|
||||
outsider = next(n for n in NODES if n.country == "c" and not n.nat and n.name != c.name)
|
||||
before = self.exchange(outsider.name, gateway.ip, node.mapped_port, count=1, timeout=0.35)
|
||||
if before["observed"]:
|
||||
raise RuntimeError(f"NAT {node.name}: incoming mapping exists before outbound traffic")
|
||||
first = self.exchange(node.name, a.ip)
|
||||
|
||||
@@ -24,6 +24,16 @@ def host_snapshot():
|
||||
return result
|
||||
|
||||
|
||||
def stable_snapshot(value):
|
||||
# DHCP lifetime и route cache age меняются от часов, без изменения конфигурации.
|
||||
if isinstance(value, dict):
|
||||
return {key: stable_snapshot(item) for key, item in value.items()
|
||||
if key not in {"valid_life_time", "preferred_life_time", "expires", "used", "lastuse"}}
|
||||
if isinstance(value, list):
|
||||
return [stable_snapshot(item) for item in value]
|
||||
return value
|
||||
|
||||
|
||||
def inside(args):
|
||||
def interrupted(signum, _frame):
|
||||
raise KeyboardInterrupt(f"signal {signum}")
|
||||
@@ -97,7 +107,7 @@ def main():
|
||||
status = child.wait()
|
||||
after = host_snapshot()
|
||||
(directory / "host-after.json").write_text(json.dumps(after, indent=2) + "\n")
|
||||
unchanged = before == after and os.readlink("/proc/self/ns/net") == original_namespace
|
||||
unchanged = stable_snapshot(before) == stable_snapshot(after) and os.readlink("/proc/self/ns/net") == original_namespace
|
||||
(directory / "host-check.json").write_text(json.dumps({"unchanged": unchanged}, indent=2) + "\n")
|
||||
if not unchanged:
|
||||
print("FAIL: main network namespace snapshot changed during the run", file=sys.stderr)
|
||||
|
||||
Reference in new issue
Block a user