mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-04 22:41:12 +02:00
feat: implement traffic insight marker backend (ubridge mark filter)
Add compute-side marker subsystem that receives ubridge UDP MARK signals
and forwards them as project-scoped notifications to the web UI for
real-time traffic coloring. Matched packets are always saved to per-link
pcaps for future replay.
Key components:
- gns3server/compute/marker/: MarkerManager (singleton, UDP listener +
O(1) registry keyed by (node_id, filter_name)) + MarkerListener
(DatagramProtocol parsing MARK lines per ubridge integration contract)
- gns3server/compute/base_node.py: marker sink/node config at ubridge
startup; shared _ubridge_add_marker_filter / _ubridge_delete_marker_filter
- Per-node start_marker/stop_marker: VPCS (VPCS-{id}), QEMU
(QEMU-{id}-{adapter}), Docker (bridge{adapter})
- Compute REST /markers/start + /markers/stop (vpcs/qemu/docker route files)
- Controller Link._markers state + UDPLink.start_marker/stop_marker/
update_marker (mirror capture pattern: BPF validation, _choose_capture_side,
node.post forwarding, topology persistence)
- Controller REST GET/POST/DELETE/PUT /v3/projects/{p}/links/{l}/markers
- Config: marker_listen_host / marker_listen_port in ServerSettings
- Signal routing: creation-time registry O(1) lookup, no node-table scan;
project-scoped WS stream (not global); event payload always carries
project_id for frontend scoping
Tests: 14 unit tests (registry, listener parsing, UDP round-trip);
562 existing tests pass with zero regressions.
This commit is contained in:
21 files changed
+1135
-1
No files matched your search
@@ -512,6 +512,42 @@ class VPCSVM(BaseNode):
|
||||
)
|
||||
)
|
||||
|
||||
async def start_marker(self, port_number, name, bpf, pcap_path, tag=None):
|
||||
"""
|
||||
Attach a traffic-insight ``mark`` filter to this node's uBridge bridge.
|
||||
On BPF match uBridge emits a MARK signal and appends the packet to the pcap.
|
||||
|
||||
:param port_number: port number (kept for API symmetry; VPCS has a single bridge)
|
||||
:param name: stable filter name — pcap identity and echoed in MARK signals
|
||||
:param bpf: libpcap BPF expression
|
||||
:param pcap_path: absolute path ubridge appends matched packets to
|
||||
:param tag: optional correlation id echoed in MARK signals
|
||||
"""
|
||||
|
||||
if self.ubridge:
|
||||
await self._ubridge_add_marker_filter(f"VPCS-{self._id}", name, bpf, pcap_path, tag)
|
||||
log.info(
|
||||
"VPCS '{name}' [{id}]: starting marker '{marker}' on port {port_number}".format(
|
||||
name=self.name, id=self.id, marker=name, port_number=port_number
|
||||
)
|
||||
)
|
||||
|
||||
async def stop_marker(self, port_number, name):
|
||||
"""
|
||||
Remove a traffic-insight ``mark`` filter from this node's uBridge bridge.
|
||||
|
||||
:param port_number: port number (kept for API symmetry)
|
||||
:param name: filter name previously passed to start_marker
|
||||
"""
|
||||
|
||||
if self.ubridge:
|
||||
await self._ubridge_delete_marker_filter(f"VPCS-{self._id}", name)
|
||||
log.info(
|
||||
"VPCS '{name}' [{id}]: stopping marker '{marker}' on port {port_number}".format(
|
||||
name=self.name, id=self.id, marker=name, port_number=port_number
|
||||
)
|
||||
)
|
||||
|
||||
def _build_command(self):
|
||||
"""
|
||||
Command to start the VPCS process.
|
||||
|
||||
Reference in new issue
Block a user