mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
feat: concurrent kernel captures, one per interface
uBridge's capture module now serves one AF_PACKET capture per interface, any number per process, and `capture stop_kernel` takes the interface it stops — this rides that (breaking, paired-binary) protocol change. The server-side single-slot tracker (_kernel_capture_ifc with its reserve/release/owned_by helpers) is gone: same-port duplicates were already refused by the NIO capturing flag, uBridge answers EALREADY on a same-interface duplicate, and per-interface stops removed the process- wide stop the ownership gating guarded against. The docker e2e drives ten concurrent captures on one node's uBridge and asserts a per-interface stop freezes exactly the stopped half while the live half keeps recording.
This commit is contained in:
15 files changed
+155
-171
No files matched your search
@@ -768,14 +768,11 @@ class EthernetSwitch(KernelDatapathMixin, BaseNode):
|
||||
if self._ubridge_hypervisor and self._ubridge_hypervisor.is_running():
|
||||
anchor = self._kernel_ports.get(port_number)
|
||||
if anchor is not None:
|
||||
# One capture per uBridge process — see
|
||||
# _reserve_kernel_capture; a failed start rolls the port's
|
||||
# flag back so it cannot later stop the winner's capture.
|
||||
# One capture per interface; a failed start rolls the port's
|
||||
# flag back.
|
||||
try:
|
||||
self._reserve_kernel_capture(anchor)
|
||||
await self._ubridge_send(f'capture start_kernel {anchor} "{output_file}"')
|
||||
except Exception:
|
||||
self._release_kernel_capture(anchor)
|
||||
nio.stop_packet_capture()
|
||||
raise
|
||||
else:
|
||||
@@ -797,12 +794,8 @@ class EthernetSwitch(KernelDatapathMixin, BaseNode):
|
||||
if self._ubridge_hypervisor and self._ubridge_hypervisor.is_running():
|
||||
anchor = self._kernel_ports.get(port_number)
|
||||
if anchor is not None:
|
||||
# Process-wide and argument-less: only the port owning the
|
||||
# slot may stop it (a second port's stop would kill this
|
||||
# capture while its own flag still says capturing).
|
||||
if self._kernel_capture_owned_by(anchor):
|
||||
await self._ubridge_send("capture stop_kernel")
|
||||
self._release_kernel_capture(anchor)
|
||||
# Per-interface stop: only this port's capture is stopped.
|
||||
await self._ubridge_send(f'capture stop_kernel {anchor}')
|
||||
else:
|
||||
ubridge_bridge = self._ubridge_bridge_name(port_number)
|
||||
await self._ubridge_send(f"bridge stop_capture {ubridge_bridge}")
|
||||
|
||||
Reference in new issue
Block a user