feat(dynamips): anchor every Ethernet port on a persistent TAP

Dynamips links can now ride the kernel datapath like Docker, QEMU and IOU:
each Ethernet slot/port gets a persistent TAP anchor (gd{id}e{slot}p{port}),
created through uBridge's tap module, and the Dynamips hypervisor opens it
with nio create_tap — the hypervisor holds the fd, exactly QEMU's shape.
Links attach the anchor to their per-link kernel bridge; the legacy UDP
tunnel remains the relay datapath for every other port.

Anchor lifecycle: born at node start (tap module probed with one
create/delete cycle, sweep of stale devices, ownership handed to the server
user, born down); a kernel link opens the anchor in the hypervisor, binds
the slot/port and enslaves it; removing the link releases the fd again
(nio delete) and detaches. A link bound while the router is stopped is
wired by the next start (deferred wiring). Node close follows QEMU's stop
order — the hypervisor's TAP NIOs go before tap delete, since it is
Dynamips, not uBridge, that holds the fds.

Stop is not close: vm stop only halts the emulated router, so the
hypervisor, the TAP fds, the bindings and the per-link bridges all survive
a stop/start untouched (attach skips ports that still hold their TAP NIO).

Port selection follows the adapter registry: ETHERNET_ADAPTERS and
ETHERNET_WICS name the models whose ports carry Ethernet frames (WIC-1ENET
included, at its Dynamips port number); serial, ATM and POS ports never
anchor, and a kernel link there errors with the relay-datapath message
instead of half-wiring. Adapters hot-added to a running router (OIR) get
their anchors at once.

The compute NIO routes accept nio_bridge alongside nio_udp (the same
widening QEMU needed), carry the endpoint's suspend flag on update (it is
the anchor's admin state on a kernel link), skip the hypervisor delete for
a kernel NIO (its TAP NIO was already released by the slot removal), and
the close path leaves NIOBridge instances to _stop_ubridge.
This commit is contained in:
YueGuobin committed 2026-10-06 00:21:09 +08:00
1 parent 6633304e97
commit 7201a870da
5 files changed
+1019 -13

No files matched your search

@@ -15,6 +15,37 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Adapter and WIC models whose ports carry Ethernet frames (by __str__
# name, matching the controller's port matrix). Only these ports get a
# kernel-datapath anchor TAP: a TAP cannot carry the serial/ATM/POS
# encapsulations the other models speak.
ETHERNET_ADAPTERS = frozenset(
{
"C1700-MB-1FE",
"C2600-MB-1E",
"C2600-MB-1FE",
"C2600-MB-2E",
"C2600-MB-2FE",
"C7200-IO-2FE",
"C7200-IO-FE",
"C7200-IO-GE-E",
"GT96100-FE",
"Leopard-2FE",
"NM-16ESW",
"NM-1E",
"NM-1FE-TX",
"NM-4E",
"PA-2FE-TX",
"PA-4E",
"PA-8E",
"PA-FE-TX",
"PA-GE",
}
)
ETHERNET_WICS = frozenset({"WIC-1ENET"})
class Adapter:
"""
Base class for adapters.