Skip to content

cleanup: drop ucode, share BPF/agent flow types, exporter + logging rework - #7

Merged
vooon merged 6 commits into
mainfrom
cpp-cleanup
Sep 5, 2026
Merged

cleanup: drop ucode, share BPF/agent flow types, exporter + logging rework#7
vooon merged 6 commits into
mainfrom
cpp-cleanup

Conversation

@vooon

@vooon vooon commented Sep 5, 2026

Copy link
Copy Markdown
Owner

What

One cleanup PR over the v0.3.0 C++ rewrite that removes what ucode left behind and tightens the exporter/logging design.

Drop the deprecated ucode agent

  • Delete obserwrt/files/usr/share/ucode/, the fw4-style obserwrt/tests/, scripts/emit-test.uc, uc-lint.mjs, build-ucode.sh, the build-ucode action and their CI steps.
  • AGENTS.md + design.md updated (transitional-ucode sections removed, layout now reflects bpf/).

Shared flow types (BPF ⇋ agent)

  • eBPF source moved to bpf/obserwrt-bpf.c; new bpf/obserwrt-flow.h is the single source for the §5 key/value layouts, included by both the program and flow.hpp.
  • Native byte order, no struct-string packing; FlowMap is now typed (FlowKey/FlowValue structs passed straight to libbpf), lifecycle tracker keyed by the packed key instead of hex.

Exporter design fix

  • Dropped the abstract Sink + external-transport ownership: exporters own a UdpClient, datagrams are std::byte buffers passed as spans, failures counted via UdpClient::take_failures() and folded into obserwrt_export_errors_total each pass.
  • IPFIX encodes big-endian via std::byteswap; datagrams are assembled into one pre-sized buffer (no intermediate copies).
  • Template fields documented with an RFC 7011 IE table.

Diagnostics

  • New src/logfmt.hpp: miniature exceptions-free logfmt logger (SLOG), message-first, gated by main.log_level; replaces printf-style DAEMON_LOG (macro removed). Flow-record encoders are untouched (pinned by the golden harness).
  • Wire formats are unchanged: golden-vector harness passes byte-for-byte.

Testing

  • cmake build clean (0 warnings/errors), ctest golden-vector harness passes.
  • clang-format + clang-tidy clean.
  • eBPF smoke compiles for bpfel and bpfeb.

bumpversion only updated obserwrt/Makefile PKG_VERSION, so the v0.3.0
release shipped obserwrt_0.2.6_amd64.deb (CPack uses PROJECT_VERSION).
- CMakeLists project VERSION -> 0.3.0 (also fixes --version/build_info on
  the Linux build; the OpenWrt -DOBSEWRRT_VERSION cache var is superseded)
- .bumpversion.cfg now bumps CMakeLists.txt together with PKG_VERSION
…r transport

- Drop the deprecated ucode agent entirely: `obserwrt/files/usr/share/ucode/`,
  the fw4-style `obserwrt/tests/`, `scripts/emit-test.uc`/uc-lint.mjs/
  build-ucode.sh, the build-ucode action and their CI steps.
- Move the eBPF source to `bpf/obserwrt-bpf.c` and add `bpf/obserwrt-flow.h`
  as the single source for the §5 flow key/value layouts, shared by the BPF
  program and the C++ agent (native byte order; no struct-string packing).
- Drop the abstract Sink/external-transport ownership: exporters own a
  UdpClient, datagrams are std::byte buffers passed as spans, failures are
  counted via UdpClient::take_failures() and folded into the export-error
  metric each lifecycle pass. IPFIX encodes big-endian via std::byteswap.
- FlowMap is typed (FlowKey/FlowValue structs instead of raw map blobs);
  lifecycle tracker keyed by the packed key instead of its hex.
Replace the short single-line field-list comment with a full IANA IPFIX IE
reference (markdown table: IE id, field, length, meaning) covering both the
v4 and v6 templates, and expand the v6 field list one entry per line with
the same per-field comments as v4.
- Add src/logfmt.hpp: a miniature exceptions-free logfmt logger (SLOG macro,
  message-first msg= field, conditional quoting/escaping) gated by
  main.log_level, replacing the printf-style DAEMON_LOG everywhere.
- Remove the dead DAEMON_LOG macro from log.hpp (only g_log_level remains).
- exporter_ipfix: build each datagram into one pre-sized buffer and reserve
  exact record sizes in emit(), eliminating the intermediate body copy and
  per-field reallocations.
- Wire formats are untouched: flow-record encoders (encode_json/logfmt) stay
  hand-rolled and pinned by the golden harness.
CI (Ubuntu 24.04) ships clang-format 18, which wraps the SLOG fluent
chains differently than the local v22. Reformat to the v18 layout so the
clang-format gate passes.
@vooon
vooon merged commit 883cc37 into main Sep 5, 2026
8 checks passed
@vooon
vooon deleted the cpp-cleanup branch September 5, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant