How Wren selects a route
Follow a prefix
flowchart LR
proto[Protocol task] -->|import filter| upd[Route update]
upd --> rib[Router loop<br/>RIB per table and prefix]
rib -->|winner changed| chg[Install or removal]
chg -->|FIB export policy| be{Backend}
be --> k[kernel: netlink]
be --> m[memory: in process]
rib -->|redistribution| proto
rib --> mon[wren monitor routes]
- A protocol accepts an advertisement and submits a candidate to the route manager.
- The RIB compares candidates for that table and prefix. When the winner changes, the RIB produces an install or a removal.
- The selected backend applies the forwarding update. Import and FIB export policy can affect what is retained or installed. Connected networks stay under kernel ownership.
Learned, selected and installed are three views:
wren show bgp routes
wren show routes
ip -4 route show proto bgp
Compare competing sources
Within a table and prefix, higher administrative preference wins, followed by lower metric. Defaults include Connected 240, Static 200, OSPF 150, IS-IS 145, RIP 120, Babel 115, BGP 100, and Kernel 10. A BGP path first competes with other BGP paths inside the protocol. A configured static administrative distance uses the opposite scale: a larger distance makes it a weaker candidate.
Trace the implementation
| Component | Responsibility |
|---|---|
| wren-core | Prefixes, next hops, route identity, best-route selection, and the FIB trait |
| wren-filter | Apply rule sets at import and export |
| wren-daemon | Sockets, timers, control queries, the router loop, and configuration reload |
| wren-netlink | Encode decisions as Linux kernel route updates |
Other processes can subscribe to forwarding changes over the local control socket.