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
Progress log — P2 (Data & lookup)#
See PLAN.md for the phase table and migration model.
- 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 inircd-testkit. Dropped from the link set:patricia.o,class.o,list.o; substituted:whowas.o→whowas_link.o,hash.o→hash_link.o, andsupport.o→support_link.onow also-DPORT_SUPPORT_P2(soMyMalloc/MyRealloccome 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.- Verified config findings that shaped the port:
ENABLE_CIDR_LIMITSis ON (config.h:738) →patricia.cis live,add_classcarries the trailingcidrlen_s,aClasshas the CIDR fields,free_classcallspatricia_destroy.USE_HOSTHASH+USE_IPHASHON →hash.chas 6 tables.MyFreeis a macro (sys_def.h:26), not a symbol → the "trio" is reallyMyMalloc+MyRealloc+outofmemory; Rust ports call libcfree. - Partial‑port mechanism (extends P1's
support_link.o):m_whowasandm_hashare command handlers (P5) that format replies through the variadicsendto_one/replies[]path, so they stay C. The CREF oracle compiles the pristine unguarded.o; the link set compiles a<mod>_link.owith-DPORT_<MOD>_P2that#ifdefs out the ported fns + their owning globals andexterns the now‑Rust‑owned ones. To make the oracle export the neededcref_*, file‑static data (was/lockedin whowas; the tables/counters/hashtabin hash) was given external linkage — behaviourally inert. - 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/ip31*+), head‑prepend insertion, stored‑hashv‑then‑mycmpfind; whowas ring index advance/wraparound + theuwaslink storing the index not a pointer;make_clientself/interior pointers + theCLIENT_REMOTE_SIZE = offset_of!(Client,count)branch;make_user/make_serverrefcnt=1 andfree_user/free_server-211000/-211001recursion sentinels. - Also fixed: a pre‑existing P1 flake — the four
dbuf_difftests raced on the sharedpoolsize/freelistunder parallelcargo test; now serialized through a process‑wide mutex. - Verification:
cargo buildwarning‑free; the Rust‑drivenircdbinary links withlist.odropped (all alloc/list logic now Rust); every*_diffL1 test zero‑diff vscref_*; layout net green. Deferred to L2/post‑P3: them_whowas/report_classessendto_*wire output.
- Verified config findings that shaped the port: