Repository navigation
Implement OSPF control plane and dynamic routing - #2
Conversation
|
Warning Review limit reached
Next review available in: 38 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
| const addresses = Object.values(device.config.interfaces) | ||
| .map((iface) => iface.ipv4Address) | ||
| .filter((value): value is string => Boolean(value)) | ||
| .sort(); | ||
| return addresses.at(-1) ?? device.id; |
There was a problem hiding this comment.
🟡 Automatically chosen router identifier picks the wrong address
The router identifier is derived by sorting interface addresses as plain text (.sort() at apps/api/src/sim/ospf.ts:95) and taking the last one, instead of the numerically highest address, so a router without an explicitly configured identifier can advertise itself under the wrong identity.
Impact: When no router-id is configured, a device may present a router identity that does not match real-device behavior (highest IP), and tie-breaking/ordering can differ from expectations, hurting fidelity and reproducibility.
Why lexicographic sort mis-orders IPv4 addresses
stableRouterId (apps/api/src/sim/ospf.ts:88-97) collects ipv4Address values and calls .sort() (default string comparison) then .at(-1). String order treats each octet character-by-character, so e.g. ["192.168.1.20", "192.168.1.3"] sorts to ["192.168.1.20", "192.168.1.3"] and returns 192.168.1.3, whereas OSPF selects the numerically highest (192.168.1.20). This only triggers when config.ospf.routerId is undefined (allowed by configureOspf at apps/api/src/sim/world.ts:174). CONTRIBUTING.md's "Fidelity Over Convenience" and determinism rules make correct highest-IP selection the expected behavior.
Prompt for agents
In stableRouterId (apps/api/src/sim/ospf.ts:88-97), the fallback router-id selection sorts interface IPv4 addresses lexicographically with .sort() and takes the last element. This does not select the numerically highest IPv4 address the way OSPF does (e.g. 192.168.1.20 should beat 192.168.1.3, but string sort picks 192.168.1.3). Convert each address to its integer form (ipv4ToInt is available in @netsim/shared) and pick the address with the maximum integer value, so the auto-derived router identifier matches real-device behavior and stays deterministic.
Was this helpful? React with 👍 or 👎 to provide feedback.
Scope
This is a real simulator feature, not a documentation-only change.
Validation status
The branch has been submitted to GitHub Actions. I am not claiming it passes until the workflow result has been inspected.