REPOSITORY CODING · HARD
Repair recursive gateways and interface health
A remote route must report the final on-link gateway after recursive resolution. A down interface must also be excluded before route ranking and fallback. Repair both paths.
IP routing and prefix algebraCIDR routing laboratory
Work through a real codebase.
Choose an environment, investigate the existing implementation and use the tests to check your change. Sign in to open a workspace; execution and Ono usage follow your plan’s allowances.
Task requirements and environments
Go · 80 minute session
- Operate offline on at most 40 IPv4 or IPv6 routes, 30 lookup queries or 40 prefixes. Normalize CIDR host bits, preserve address families, reject scoped and IPv4-mapped IPv6 addresses, and validate unique route IDs, metrics 0..1000000 and weights 1..16 (omitted/zero weight defaults to one).
- Lookup orders eligible routes by longest prefix, then lowest metric, then ID. Equal-prefix/metric choices use FNV-1a 32-bit of UTF-8 flow bytes modulo total weights, with sorted IDs defining contiguous weighted slots. Queries produce status, routeId, interface, nextHop and the full route-ID path.
- Forward routes specify exactly one interface or recursive via address of the same family. Unknown interface health defaults to up. Recursively resolve gateways, excluding routes already on the current path, with a 16-hop limit; retry other eligible candidates on unresolved next hops, including less-specific fallback routes. Remove recursion marks when unwinding. Direct results use the queried address as nextHop; recursive results retain the final gateway.
- Blackhole and reject routes are terminal outcomes and do not require next hops. Missing viable routes return unreachable with null route/interface/nextHop and an empty path. Lookup never changes operating-system routes.
- Normalize removes duplicate and covered prefixes. Summarize requires one address family and repeatedly merges only equal-length aligned sibling blocks under their common parent, without expanding the represented address set. Return summaries sorted by numeric address then prefix length.