> be me
> 4am, zipped up in the oversized charcoal b♂y hoodie, monster ultra on the desk, terminal cursor blinking
> someone asks: "slop, how does slopbgp actually work under the hood? like how do you even write a carrier-grade BGP daemon in Gleam?"
> autistic infodump mode fully engaged. grab a warm mug, let me explain how the whole machine works:
1. OTP ACTOR-PER-PEER SUPERVISION & FAULT ISOLATION
traditional C/C++ BGP daemons (BIRD, FRR) use monolithic event loops. a single malformed BGP UPDATE, buffer overflow, or use-after-free corrupts memory or panics the daemon, dropping all 40 peering sessions at once and flushing your kernel routing table.
in slopbgp, every peer session is an isolated Erlang/OTP actor process with its own garbage-collected heap. if a remote peer violates protocol or drops TCP, its supervisor catches the exit and gracefully resets only that peer FSM. the Loc-RIB, kernel FIB, and all other peers keep forwarding packets without a microsecond of downtime.
2. ZERO-COPY BINARY PATTERN MATCHING & RFC 8654 EXTENDED MESSAGES
Gleam compiles down to BEAM bitstrings. parsing BGP frames (16-byte marker, 16-bit length, message type) and extracting variable-length path attributes happens with native zero-copy binary pattern matching at wire speed.
with RFC 8654 Extended Messages, slopbgp streams massive UPDATE frames up to 65,535 bytes (far beyond the legacy 4,096-byte limit), unpacking complex MP-BGP reachability NLRI and RFC 8092 Large Communities in a single pass.
3. 10-STAGE LOC-RIB DECISION ENGINE & DN42 LATENCY TIE-BREAKER
incoming routes from all peers converge into the Loc-RIB through a strict 10-stage deterministic tie-breaker:
1. RFC 6811 RPKI/ROA Validation (VALID > NOT_FOUND > INVALID)
2. Highest Local Preference (LocalPref)
3. Shortest AS-Path length (ignoring AS_CONFED confederation sequences)
4. Origin code preference (IGP < EGP < Incomplete)
5. Lowest Multi-Exit Discriminator (MED)
6. eBGP over iBGP routes
7. DN42 measured link latency metric (preferring lowest RTT paths)
8. Shorter Route Reflector cluster list length
9. Lowest Originator ID / BGP Identifier
10. Oldest route arrival timestamp (flapping resistance)
4. SLOPFILTER POLICY PIPELINE, TRACE ENGINE & STATIC AUDIT OPTIMIZER
our policy engine supports prefix sets (Exact, Longer, OrLonger), AS-Path regexes, and community wildcards, while enforcing strict RFC 7454 / RFC 7938 route hygiene (dropping Martian ASNs, RFC 6890 bogons, excessive prepending >6, and enforcing First-AS).
even cooler:
- slopbgpctl filter test <prefix> <asn> traces route evaluation step-by-step, recording condition evaluations, attribute mutations, and terminal verdicts.
- slopbgpctl filter audit performs static reachability analysis on your policy chains, detecting shadowed / unreachable rules and dead branches, outputting an optimized, pruned filter pipeline.
5. GLOBAL NETWORK MODEL, SIMULATOR & WHAT-IF BLAST RADIUS
instead of hand-crafting brittle configs for every router, you model your entire multi-region autonomous system in a single declarative JSON document (examples/slopnet_global.json). slopbgp automatically derives router configs, iBGP meshes, and Route Reflector client hierarchies.
- "slopbgpctl netmodel sim" boots the entire global network in-memory, simulating discrete route propagation across Frankfurt, New York, and Tokyo, tracking latency tags, and catching RFC 9234 route leaks before anything touches production.
- "slopbgpctl netmodel whatif" simulates router hardware failures, fiber cuts, or maintenance node drains, instantly recalculating network topology to detect lost reachability bindings and score disaster blast radius (0-100).
6. GITOPS FLEET DEPLOYMENT PLANNER
"slopbgpctl netmodel plan" previews declarative provisioning diffs across your entire fleet. it calculates all peer additions, RR client hierarchies, latency tags, and BFD sessions, and mathematically verifies 100% hot-reload safety with zero session resets and zero packet loss.
7. CARRIER ENTERPRISE FABRICS & DDOS MITIGATION
slopbgp implements RFC 4364 L3VPN Multi-Tenant VRF isolation with route distinguishers, RFC 8669 BGP Prefix-SID (Segment Routing SR-MPLS & SRv6), RFC 5549 BGP Unnumbered over IPv6 link-local, RFC 7752 BGP-LS Link-State topology export, RFC 7999 RTBH blackholing, RFC 8955/8956 Flowspec traffic filtering, and sub-second BFD hardware failover.
8. OBSERVABILITY & DARK-MODE DASHBOARD
comes with a reactive dark-mode web dashboard on :9179 featuring a glowing radial SVG topology graph, carrier Looking Glass with longest-prefix match (LPM) and regex search, and Prometheus OpenMetrics exporter (/metrics).
all 48 test suites passing in hermetic offline Nix sandbox.
MIT licensed, 100% open source:
https://git.freifick.net/slop/slopbgp
https://github.com/slopinger/slopbgp
— Open image attachment 1 of 2
— Open image attachment 2 of 2