Proof of concept mechanical port of ircnet/ircd to Rust as part of a bit about C being insecure for network services
2.8 kB
10 lines
1# Progress log — P2 (Data & lookup)
2
3See [PLAN.md](../../PLAN.md) for the phase table and migration model.
4
5- **2026‑06‑02 — P2 (Data & lookup) merged.** All five modules ported into `ircd-common` (`patricia.rs`, `class.rs`, `whowas.rs`, `hash.rs`, `list.rs`), each with an L1 differential test in `ircd-testkit`. Dropped from the link set: `patricia.o`, `class.o`, `list.o`; substituted: `whowas.o`→`whowas_link.o`, `hash.o`→`hash_link.o`, and `support.o`→`support_link.o` now also `-DPORT_SUPPORT_P2` (so `MyMalloc`/`MyRealloc` come from Rust). Spec: `docs/superpowers/specs/2026-06-02-p2-data-lookup-design.md`; plan: `docs/superpowers/plans/2026-06-02-p2-data-lookup.md`.
6 - **Verified config findings that shaped the port:** `ENABLE_CIDR_LIMITS` is **ON** (config.h:738) → `patricia.c` is live, `add_class` carries the trailing `cidrlen_s`, `aClass` has the CIDR fields, `free_class` calls `patricia_destroy`. `USE_HOSTHASH`+`USE_IPHASH` **ON** → `hash.c` has 6 tables. **`MyFree` is a macro** (`sys_def.h:26`), not a symbol → the "trio" is really `MyMalloc`+`MyRealloc`+`outofmemory`; Rust ports call libc `free`.
7 - **Partial‑port mechanism (extends P1's `support_link.o`):** `m_whowas` and `m_hash` are command handlers (P5) that format replies through the variadic `sendto_one`/`replies[]` path, so they stay C. The CREF oracle compiles the pristine unguarded `.o`; the link set compiles a `<mod>_link.o` with `-DPORT_<MOD>_P2` that `#ifdef`s out the ported fns + their owning globals and `extern`s the now‑Rust‑owned ones. To make the oracle export the needed `cref_*`, file‑static data (`was`/`locked` in whowas; the tables/counters/`hashtab` in hash) was given external linkage — behaviourally inert.
8 - **Determinism preserved (pinned by L1):** bit‑exact hash fns (`hashtab[i]=tolower((char)i)*109`, nick `(<<4)+`, uid `(<<4)^`, channel start‑5/cap‑30/`+(i<<1)`, host/ip `31*+`), head‑prepend insertion, stored‑hashv‑then‑`mycmp` find; whowas ring index advance/wraparound + the `uwas` link storing the **index** not a pointer; `make_client` self/interior pointers + the `CLIENT_REMOTE_SIZE = offset_of!(Client,count)` branch; `make_user`/`make_server` refcnt=1 and `free_user`/`free_server` `-211000/-211001` recursion sentinels.
9 - **Also fixed:** a pre‑existing P1 flake — the four `dbuf_diff` tests raced on the shared `poolsize`/`freelist` under parallel `cargo test`; now serialized through a process‑wide mutex.
10 - **Verification:** `cargo build` warning‑free; the Rust‑driven `ircd` binary links with `list.o` dropped (all alloc/list logic now Rust); every `*_diff` L1 test zero‑diff vs `cref_*`; layout net green. Deferred to L2/post‑P3: the `m_whowas`/`report_classes` `sendto_*` wire output.