The RA settings API reads and writes the advertised prefixes, validates them, and syncs the shared list to cluster peers #192

Open
opened 2026-10-31 12:42:23 -04:00 by claude · 0 comments
Owner
  • Draft: BUG-60
  • Priority: low
  • Agent: coder
  • Depends on: none
  • Decisions: Q-BUG-14

Why

See #191.

What changes

  • GetRa/PatchRa: a whole-array-replace prefixes field at the top level and in each interface override, shaped like the existing routes handling (DhcpSettingsController.cs:1118-1180): prefix, prefix length, on-link, autonomous, valid lifetime, preferred lifetime (RaAdvertisedPrefixOptions.cs:16-50). Messages name the field as prefixes[i].field.
  • Validation, reusing src/dotnet/src/Ninlil.Dhcp.Server.Ra/RaContentRules.cs (the lifetime rule at :241 exists) and adding what is missing there so the configuration file gets the same checks:
    • an IPv6 address with no bits set beyond the prefix length;
    • not link-local fe80::/10 and not multicast ff00::/8 (RFC 4862 §5.5.3, RFC 4861 §6.3.4);
    • preferred lifetime not above the valid lifetime (RFC 4862 §5.5.3);
    • an autonomous (SLAAC) prefix must be a /64, because hosts ignore one whose length plus the interface identifier is not 128 (RFC 4862 §5.5.3, RFC 4291 §2.5.1);
    • no prefix twice in one list.
  • RA content is read per send (IOptionsMonitor, :51-56), so PatchRa keeps returning the hot-reloaded note.
  • Cluster sync: after a write that changes the top-level prefixes, call ClusterConfigSyncSettingsRecorder.RecordAndPublishAsync (src/dotnet/src/Ninlil.Web/ClusterSync/ClusterConfigSyncSettingsRecorder.cs:61) with only that setting, under its own sync key (for example DhcpServer:Ra:Prefixes) so it does not share last-writer-wins state with RA fields that do not sync. Check that SettingsClusterConfigSyncApplier writes by each entry's section path (:105) and accepts the key. Interface-override prefixes do not sync: interface names belong to one node. Update the recorder's summary (it lists the syncing controllers, :14-19).
  • Rewrite the summaries at DhcpSettingsController.cs:64-75 and of DhcpRaSettingsDetail, which say prefixes are file-only.
  • README Router Advertisement and cluster sections.

Acceptance

  • Web.Tests, red first: PATCH prefixes with 2001:db8:1::/64 autonomous, then GET returns it and the next advertisement built by RaAdvertisementProvider carries it.
  • 400 for each rule above (one test per rule, naming the field).
  • An override's prefixes round-trip and are not passed to the recorder; the top-level list is, under the separate key (fake recorder).
  • src/dotnet/tests/Ninlil.Dhcp.Server.Ra.Tests (the shared rules) and src/dotnet/tests/Ninlil.Dns.Server.ClusterSync.Tests pass; Web.Tests pass except OpenApiSnapshotTests (#193, same PR).

Source

#191.

- **Draft:** BUG-60 - **Priority:** low - **Agent:** coder - **Depends on:** none - **Decisions:** Q-BUG-14 ### Why See #191. ### What changes - `GetRa`/`PatchRa`: a whole-array-replace `prefixes` field at the top level and in each interface override, shaped like the existing `routes` handling (`DhcpSettingsController.cs:1118-1180`): prefix, prefix length, on-link, autonomous, valid lifetime, preferred lifetime (`RaAdvertisedPrefixOptions.cs:16-50`). Messages name the field as `prefixes[i].field`. - Validation, reusing `src/dotnet/src/Ninlil.Dhcp.Server.Ra/RaContentRules.cs` (the lifetime rule at `:241` exists) and adding what is missing there so the configuration file gets the same checks: - an IPv6 address with no bits set beyond the prefix length; - not link-local `fe80::/10` and not multicast `ff00::/8` (RFC 4862 §5.5.3, RFC 4861 §6.3.4); - preferred lifetime not above the valid lifetime (RFC 4862 §5.5.3); - an autonomous (SLAAC) prefix must be a /64, because hosts ignore one whose length plus the interface identifier is not 128 (RFC 4862 §5.5.3, RFC 4291 §2.5.1); - no prefix twice in one list. - RA content is read per send (`IOptionsMonitor`, `:51-56`), so `PatchRa` keeps returning the hot-reloaded note. - Cluster sync: after a write that changes the top-level `prefixes`, call `ClusterConfigSyncSettingsRecorder.RecordAndPublishAsync` (`src/dotnet/src/Ninlil.Web/ClusterSync/ClusterConfigSyncSettingsRecorder.cs:61`) with only that setting, under its own sync key (for example `DhcpServer:Ra:Prefixes`) so it does not share last-writer-wins state with RA fields that do not sync. Check that `SettingsClusterConfigSyncApplier` writes by each entry's section path (`:105`) and accepts the key. Interface-override prefixes do not sync: interface names belong to one node. Update the recorder's summary (it lists the syncing controllers, `:14-19`). - Rewrite the summaries at `DhcpSettingsController.cs:64-75` and of `DhcpRaSettingsDetail`, which say prefixes are file-only. - README Router Advertisement and cluster sections. ### Acceptance - [ ] Web.Tests, red first: PATCH `prefixes` with `2001:db8:1::/64` autonomous, then GET returns it and the next advertisement built by `RaAdvertisementProvider` carries it. - [ ] 400 for each rule above (one test per rule, naming the field). - [ ] An override's prefixes round-trip and are not passed to the recorder; the top-level list is, under the separate key (fake recorder). - [ ] `src/dotnet/tests/Ninlil.Dhcp.Server.Ra.Tests` (the shared rules) and `src/dotnet/tests/Ninlil.Dns.Server.ClusterSync.Tests` pass; Web.Tests pass except `OpenApiSnapshotTests` (#193, same PR). ### Source #191.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
lantea-one/ninlil#192
No description provided.