refactor(builtin): use deterministic bridge name from switch UUID

Replace psutil.net_if_addrs() scan with a deterministic name derived from
the switch's node UUID: gns3 + first 6 hex chars (10 chars, fits kernel
IFNAMSIZ limit of 15). Taps: <bridge>-<port> (12-13 chars).

Crash recovery: brctl delete the bridge first (best-effort), then create
fresh. Stale bridges from abnormal gns3server shutdown are automatically
reclaimed on the next start — no EEXIST or leaked interfaces.

Remove _free_iface helper and psutil import (no longer needed).
This commit is contained in:
YueGuobin committed 2026-07-18 01:18:32 +08:00
1 parent aabbee3a04
commit 18a123e0b9
2 files changed
+13 -13

No files matched your search

@@ -84,6 +84,7 @@ class TestEthernetSwitchNodesRoutes:
node = compute_project.get_node(response.json()["node_id"])
br = node._bridge_name
node._ubridge_send.assert_has_calls([
call(f'brctl delete "{br}"'),
call(f'brctl create "{br}"'),
call(f'link set "{br}" up'),
call(f'brctl vlanfiltering "{br}" on'),