Configure IPv6 correctly when IPv4 DHCP is enabled#113
Open
rleigh-codelibre wants to merge 2 commits intofreebsd:masterfrom
Open
Configure IPv6 correctly when IPv4 DHCP is enabled#113rleigh-codelibre wants to merge 2 commits intofreebsd:masterfrom
rleigh-codelibre wants to merge 2 commits intofreebsd:masterfrom
Conversation
When dhcp=1 was set for IPv4, two places in the VNET startup code incorrectly prevented IPv6 static addresses from being configured: 1. start_network_interface_vnet: The DHCP address-spoofing check iterated over both IPv4 and IPv6 net_configs, replacing static IPv6 addresses with empty strings. Add `not ipv6` guard so the spoofing only applies to IPv4 entries. 2. start_network_vnet_addr: The `wants_dhcp` flag (derived from IPv4 DHCP settings) gated all ifconfig calls, skipping the `ifconfig inet6` command for static IPv6. Change the condition to `(ipv6 or not wants_dhcp)` so IPv6 addresses are always assigned regardless of IPv4 DHCP state. This allows the intended configuration of dynamic IPv4 via DHCP with static IPv6 addresses to work correctly. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests for start_network_vnet_addr cover: - Static IPv6 assigned when IPv4 DHCP is enabled - IPv4 ifconfig skipped when DHCP handles it - Both address families assigned when DHCP is off - accept_rtadv never triggers ifconfig - DHCP keyword in ip4_addr string skips IPv4 but not IPv6 Tests for start_network_interface_vnet cover: - IPv4 DHCP address spoofing does not affect IPv6 entries - IPv4 addresses are correctly spoofed when DHCP is active - Both addresses pass through unspoofed when DHCP is off Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
This PR fixes a long-standing problem with the networking setup. If IPv4 DHCP was enabled, then the IPv6 network address would be blanked out, resulting in a missing IPv6 address even though it was in the jail configuration. I commonly use this setup so I can have working IPv4 but a static IPv6 for external connections for the actual hosted services.
Example configuration:
Current behaviour:
With the fix:
You can see with the fix that the IPv6 address is now correctly configured within the jail.
Full disclosure: I used Claude to investigate the codebase in detail to identify the specific cause of the problem and to develop the solution, plus to write the unit tests to prevent the a regression in the future.
This was tested on FreeBSD-15.0-RELEASE-p2.