mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-30 17:34:34 +02:00
Gate the TAP/kernel datapath on uBridge >= 1.3.1
uBridge 1.2.3 already has the tap module, so the persistent-TAP probes (_probe_persistent_taps on the node, probe_tap_support and siblings for /capabilities) pass on it. QEMU, Dynamips and VPCS nodes then anchor on TAPs and the controller builds kernel links that need 1.3.x commands: kernel markers and the eBPF tc modes (1.3.0) and per-interface kernel captures (`capture stop_kernel <ifc>`, 1.3.1). On 1.2.3 a MikroTik CHR node sent frames but never got DHCP past DISCOVER/OFFER, and stopping a capture failed with "Bad number of parameters". Add Hypervisor.supports_kernel_datapath (version >= 1.3.1) and refuse older builds in the node-side probe and the four anchoring capability probes (tap, iol tap, bridge tap, vxlan). The existing fallback then applies: nodes keep the legacy relay datapath with the usual warning, which now names the installed version, and links stay on the relay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4d55cb1b9c
commit
52fcc83494
6 files changed
+118
-1
No files matched your search
@@ -122,6 +122,29 @@ async def test_prepare_tap_datapath_falls_back_without_the_tap_module(vm):
|
||||
assert emit.called
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_prepare_tap_datapath_falls_back_below_the_kernel_dataplane_version(vm):
|
||||
"""
|
||||
uBridge 1.2.3 has the tap module, so a `tap create` probe alone passes
|
||||
— and the node then runs on TAP anchors whose kernel links the build
|
||||
cannot drive. Below the kernel-dataplane version the node keeps the
|
||||
legacy socket-netdev datapath without creating any TAP, and the warning
|
||||
names the installed version.
|
||||
"""
|
||||
|
||||
vm._ubridge_hypervisor.supports_kernel_datapath = False
|
||||
vm._ubridge_hypervisor.version = "1.2.3"
|
||||
with patch.object(vm.project, "emit") as emit:
|
||||
await vm._prepare_tap_datapath()
|
||||
|
||||
assert vm._tap_datapath is False
|
||||
assert vm._kernel_taps == {}
|
||||
assert not any(c.args[0].startswith("tap ") for c in vm._ubridge_send.call_args_list)
|
||||
message = emit.call_args.args[1]["message"]
|
||||
assert "1.2.3" in message
|
||||
assert "1.3.1" in message
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_tap_name_fits_ifnamsiz(vm):
|
||||
"""
|
||||
|
||||
@@ -194,6 +194,24 @@ async def test_accepts_ubridge_1_2_3(tmp_path, monkeypatch):
|
||||
assert hyp.version == "1.2.3"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"version, supported",
|
||||
[
|
||||
("", False), # not started yet: version unknown
|
||||
("1.2.3", False), # has the tap module, but no kernel dataplane
|
||||
("1.3.0", False), # no per-interface capture stop_kernel
|
||||
("1.3.1", True),
|
||||
("1.3.2", True),
|
||||
("1.4.0", True),
|
||||
],
|
||||
)
|
||||
def test_supports_kernel_datapath(tmp_path, monkeypatch, version, supported):
|
||||
|
||||
hyp = _make("unix", tmp_path, monkeypatch)
|
||||
hyp._version = version
|
||||
assert hyp.supports_kernel_datapath is supported
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# start: fail-fast on an immediately-exiting uBridge
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@@ -50,6 +50,9 @@ class FakeHypervisor:
|
||||
# doesn't exist), None = answer 100 (an impossible reply on the probe's
|
||||
# uuid name — the probe must treat it as unknown)
|
||||
bridge_tap_error = "214-bridge 'nosuch' doesn't exist"
|
||||
# False = a build older than the kernel dataplane (uBridge < 1.3.1)
|
||||
supports_kernel_datapath = True
|
||||
version = "1.3.1"
|
||||
spawned = 0
|
||||
|
||||
def __init__(self, project, path, working_dir, transport, host, node_id):
|
||||
@@ -90,6 +93,8 @@ def probe_env(monkeypatch, tmp_path):
|
||||
FakeHypervisor.error = None
|
||||
FakeHypervisor.error_prefix = None
|
||||
FakeHypervisor.bridge_tap_error = "214-bridge 'nosuch' doesn't exist"
|
||||
FakeHypervisor.supports_kernel_datapath = True
|
||||
FakeHypervisor.version = "1.3.1"
|
||||
FakeHypervisor.reply = ["netem=delay,rate;ebpf=1;cbpf=1;ebpf_modes=nth,quota,window,flow"]
|
||||
tc_probe._cache.clear()
|
||||
tc_probe._tap_cache.clear()
|
||||
@@ -285,6 +290,25 @@ async def test_probe_bridge_tap_support_missing_binary(monkeypatch):
|
||||
assert FakeHypervisor.spawned == 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"probe", [probe_tap_support, probe_iol_tap_support, probe_bridge_tap_support, probe_vxlan_support]
|
||||
)
|
||||
async def test_anchor_probes_unknown_below_the_kernel_dataplane_version(probe):
|
||||
"""
|
||||
uBridge 1.2.3 already has the tap module, so its `tap create` succeeds —
|
||||
but the kernel links built on that answer need commands that only 1.3.x
|
||||
has (per-interface `capture stop_kernel`, kernel markers, ...). A build
|
||||
below the kernel-dataplane version is unknown without being asked
|
||||
anything, so every node stays on the relay datapath.
|
||||
"""
|
||||
|
||||
FakeHypervisor.supports_kernel_datapath = False
|
||||
FakeHypervisor.version = "1.2.3"
|
||||
assert await probe() is None
|
||||
assert FakeHypervisor.spawned == 1
|
||||
assert FakeHypervisor.last.commands == []
|
||||
|
||||
|
||||
class _FixedUuid:
|
||||
"""A uuid4 stand-in whose .int/.hex pin the probe's random draws."""
|
||||
|
||||
|
||||
Reference in new issue
Block a user