Support interface IPv6 prefix tracking for RA and DHCPv6#8340
Open
Omoeba wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds interface-derived IPv6 prefix tracking to AdGuard Home's DHCPv6 / Router Advertisement implementation.
In addition to tests and linters, I've verified both the backend behavior and the UI on a Raspberry Pi 5 running Pi OS Trixie with a delegated
/64from Cox. Any testing on other platforms and ISPs would be much appreciated.The current static
dhcp.dhcpv6.range_startworks poorly on networks where the LAN/64comes from a dynamic delegated prefix that may change over time.This change adds a new
dhcp.dhcpv6.prefix_sourcesetting:static(default): preserve the current behaviorinterface: derive the current/64from the configured LAN interface, track prefix changes over time, and use the observed Prefix Information lifetimes instead of the current hardcoded RA prefix lifetimesThis is similar to dnsmasq's
constructor:<interface>behavior.Closes #6637.
Config model
In
prefix_source: interfacemode,dhcp.dhcpv6.range_startis treated as a host template, not as a fixed prefix.Example:
range_start: ::702001:db8:1234:5678::/642001:db8:1234:5678::70In other words:
range_startFor
ra_slaac_only: true, no DHCPv6 allocation pool is needed, sorange_startis optional in interface mode.What this changes
adds
dhcp.dhcpv6.prefix_sourcekeeps
staticmode fully backward compatibleadds a portable IPv6 interface-state observation layer
ifconfigparsingderives the active RA prefix from live interface state in
interfacemodeuses the observed preferred/valid lifetimes for RA Prefix Information Options
tracks active and deprecated prefixes across renumbering events
updates the effective DHCPv6 pool when the active renewable prefix changes
allows existing dynamic leases on deprecated prefixes to continue until their valid lifetime expires
persists renewable / deprecated prefix metadata so renumbering state can survive restart
Behavior
Static mode
prefix_source: staticpreserves the current behavior.Interface mode
When
prefix_source: interfaceis enabled:In RA-only mode, AGH continues to send Router Advertisements but does not start the DHCPv6 server.
Design notes
This PR is intentionally modeled after dnsmasq's constructor-based IPv6 behavior, but adapted to AGH's existing configuration and runtime model.
The main semantic difference is that AGH uses:
instead of dnsmasq's
constructor:<interface>syntax.The intended outcome is the same:
Limitations
ra_slaac_only: trueandprefix_source: interface.Implementation overview
Core files touched by this PR:
internal/aghnet/prefix.gointernal/aghnet/prefix_linux.gointernal/aghnet/prefix_darwin.gointernal/aghnet/prefix_freebsd.gointernal/aghnet/prefix_openbsd.gointernal/dhcpd/routeradv_state.gointernal/dhcpd/routeradv.gointernal/dhcpd/v6_unix.gointernal/dhcpd/config.gointernal/dhcpd/db.gointernal/dhcpd/http_unix.goAt a high level:
internal/aghnet/prefix_*provides portable observation of IPv6 interface address state and lifetimesrouteradv_state.gomanages active / deprecated prefix staterouteradv.gorebuilds RA packets from runtime state instead of serializing a single fixed packet at init timev6_unix.goties the tracked prefix state into DHCPv6 pool selection and lease lifetime behaviordb.gopersists renewable / deprecated prefix metadata for restart safetyTesting
This PR adds or updates tests for:
UI / API
This PR also includes the corresponding API/OpenAPI/UI updates for the new setting.
If maintainers would prefer a smaller review surface, I can split the UI/API portion into a follow-up PR and keep this PR backend-only.