Skip to content

ffmuc-ebpf-clat: report the CLAT traffic through respondd - #67

Merged
awlx merged 1 commit into
parker-release-2026.11from
awlx-parker-clat-counters
Nov 21, 2026
Merged

awlx merged 1 commit into
parker-release-2026.11from
awlx-parker-clat-counters

Conversation

@awlx

@awlx awlx commented Nov 21, 2026

Copy link
Copy Markdown
Member

Closes #62

Summary

The CLAT now counts the packets and bytes that it translates, in both directions. respondd sends these counters in statistics.

  • The eBPF programs count each translated packet in a per-CPU array map. This is one plain add per packet, with no atomic operations.
  • Every 10 s the daemon adds the per-CPU values together. It writes them to /var/run/ebpf-clat/<interface>.
  • A new respondd module (/usr/lib/respondd/ffmuc-ebpf-clat.so) adds the files of all interfaces together.
  • The daemon now also stops cleanly on SIGTERM (procd stop). It removes the TC filters and its stats file.
  • At start, the init script removes old stats files.

respondd fields

Field Meaning
statistics.clat.v4_to_v6.packets IPv4 packets from the clients, sent as IPv6 (egress)
statistics.clat.v4_to_v6.bytes Size of these packets as IPv4
statistics.clat.v6_to_v4.packets IPv6 packets, given to the clients as IPv4 (ingress)
statistics.clat.v6_to_v4.bytes Size of these packets as IPv4
  • Only translated packets count.
  • The counters start at 0 when the daemon starts. The values can be up to 10 s old.
  • A node without a running CLAT (no 464XLAT) sends no clat key.

This PR does not change the map or Grafana.

Tests

  • sh tests/run.sh (unit test of the stats files, ASan and UBSan): pass. It tests the write and read-back of the largest 64-bit value, the sum of two tunnels, and that bad, temporary and hidden files are skipped.
  • sh tests/e2e.sh in a privileged container (clang 20, real kernel, TUN device as for WireGuard): pass.
    • One packet in each direction counts 1 packet and 38 bytes.
    • A packet with a wrong prefix does not count.
    • respondd sends no clat key before the start and after the stop.
    • SIGTERM removes the stats file.
    • With one counter removed from the eBPF code, the test fails, as it should.
  • Build with clang 20 and -Wall -Wextra -Werror: clean.
  • shellcheck, luacheck and editorconfig-checker: clean.
  • The branch merges without conflicts with ffbs-parker-respondd: count the clients of routing nodes #61 and parker-sites: use rx traffic as a second liveness check (carry) #66.
  • Lab test on all 6 lab nodes: pass.
    • Both counters count.
    • A node without CLAT sends no clat key.
    • The stop is clean: 0 stats files and 0 TC filters remain.
    • The counters go back to 0 when the daemon starts.
    • IPv4 traffic through the CLAT works.

Not tested: production nodes.

Known limits (not from this change)

  • After a stop, the clsact qdisc stays on the interface. Only the filters are removed.
  • After SIGKILL, the first restart fails with "Filter already exists". procd starts the daemon again after 5 s, and then it works.

Thank you to the reporter of #62.

Count the packets and bytes that the CLAT translates, in a per-CPU array
map (one plain add per packet, no atomic operations). Only translated
packets count; the byte count is the size of the IPv4 packet.

Every 10 s the daemon adds the per-CPU values together and writes them to
/var/run/ebpf-clat/<interface>. A new respondd module adds the files of
all interfaces together and sends them in statistics:

  statistics.clat.v4_to_v6.{packets,bytes}
  statistics.clat.v6_to_v4.{packets,bytes}

A node without a running CLAT sends no clat key. The daemon now also
stops cleanly on SIGTERM (procd stop) and removes its file.

Closes #62
@awlx
awlx merged commit 5ad880c into parker-release-2026.11 Nov 21, 2026
11 of 12 checks passed
@awlx
awlx deleted the awlx-parker-clat-counters branch November 21, 2026 11:47
awlx added a commit to freifunkMUC/site-ffm that referenced this pull request Nov 21, 2026
Includes:
- freifunkMUC/community-packages#60: tests: fix ShellCheck SC2317
- freifunkMUC/community-packages#61: count the clients of routing nodes
- freifunkMUC/community-packages#66: rx traffic as a second liveness check
- freifunkMUC/community-packages#67: report the CLAT traffic through respondd
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