refactor(marker): converge to filter single-path model, remove dual-apply endpoints

Markers now follow exactly the same apply pattern as packet filters:
state lives in Link._markers, application goes through NIO
(update() -> PUT /nio -> _ubridge_apply_markers). The former
immediate-apply REST endpoints (/markers/start, /markers/stop on
the compute side) and the per-node start_marker/stop_marker methods
are removed — they were a legacy of the original capture-inspired
design and have been superseded by the NIO flow.

Changes:
- controller/udp_link: start_marker/stop_marker/update_marker now
  set _markers state + call self.update() (mirrors update_filters).
  Removed _marker_capture_nodes runtime dict and its helpers.
- controller/project: _create_link_from_topology_data restores
  _markers directly from persisted data (with BPF validation,
  like filter reload). No long calls start_marker during load.
- compute: _ubridge_apply_markers swallows BPF compile errors
  (warn+skip), matching _ubridge_apply_filters behaviour so a
  single bad expression cannot break link creation / node restart.
- Removed: /markers/start,stop endpoints (6 handlers across
  vpcs/qemu/docker route files), node start_marker/stop_marker
  methods (3 VM files), _ubridge_delete_marker_filter,
  _marker_capture_nodes, MarkerDelete schema.

Net: ~280 lines of dead code removed; marker and packet filter now
share a single, unified apply path via the NIO.
This commit is contained in:
YueGuobin committed 2026-07-16 00:39:51 +08:00
1 parent 88c03d1431
commit c62b9b0283
11 files changed
+73 -412

No files matched your search

-38
View File
@@ -1440,44 +1440,6 @@ class DockerVM(BaseNode):
)
)
async def start_marker(self, adapter_number, name, bpf, pcap_path, tag=None):
"""
Attach a traffic-insight ``mark`` filter to this adapter's uBridge bridge.
On BPF match uBridge emits a MARK signal and appends the packet to the pcap.
:param adapter_number: adapter number
: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.status == "started" and self.ubridge:
adapter = f"bridge{adapter_number}"
await self._ubridge_add_marker_filter(adapter, name, bpf, pcap_path, tag)
log.info(
"Docker VM '{name}' [{id}]: starting marker '{marker}' on adapter {adapter_number}".format(
name=self.name, id=self.id, marker=name, adapter_number=adapter_number
)
)
async def stop_marker(self, adapter_number, name):
"""
Remove a traffic-insight ``mark`` filter from this adapter's uBridge bridge.
:param adapter_number: adapter number
:param name: filter name previously passed to start_marker
"""
if self.status == "started" and self.ubridge:
adapter = f"bridge{adapter_number}"
await self._ubridge_delete_marker_filter(adapter, name)
log.info(
"Docker VM '{name}' [{id}]: stopping marker '{marker}' on adapter {adapter_number}".format(
name=self.name, id=self.id, marker=name, adapter_number=adapter_number
)
)
async def _get_log(self):
"""
Returns the log from the container