Add --vmnet-disable-dhcp to disable the vmnet DHCP server (macOS 26+)#165
Add --vmnet-disable-dhcp to disable the vmnet DHCP server (macOS 26+)#165fpolica91 wants to merge 1 commit into
Conversation
b6652cf to
8ca37c4
Compare
What's this? |
macOS 26 introduced the vmnet_network_configuration_* API, including vmnet_network_configuration_disable_dhcp(), which disables the DHCP server while keeping shared-mode NAT. (Noted in #139 but intentionally not used there to avoid a 26-only dependency.) |
There was a problem hiding this comment.
Pull request overview
Adds support for disabling vmnet.framework’s built-in DHCP server on macOS 26+ via a new --vmnet-disable-dhcp CLI flag, and introduces an integration test (plus CI coverage) to validate that guests do not obtain a DHCP lease when DHCP is disabled.
Changes:
- Add
--vmnet-disable-dhcpoption to the CLI (parse + help text). - Implement a macOS 26+ vmnet start path using the
vmnet_network_configurationAPI with DHCP disabled. - Add iPXE/QEMU-based integration test and run it in the GitHub Actions QEMU workflow (skipping on < macOS 26).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
main.c |
Adds a macOS 26+ vmnet initialization path that disables DHCP using the network configuration API. |
cli.h |
Extends CLI options struct with a vmnet_disable_dhcp flag. |
cli.c |
Adds flag parsing and help text for --vmnet-disable-dhcp. |
test/test-disable-dhcp.sh |
New integration test script that starts socket_vmnet with DHCP disabled and runs QEMU+iPXE to verify no lease is obtained. |
test/test-disable-dhcp.ipxe |
New iPXE script used by the integration test to attempt DHCP and print the resulting IP. |
.github/workflows/qemu.yaml |
Runs the new disable-DHCP integration test in CI (with a macOS 26 runner in the matrix). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9fcfa17 to
640805d
Compare
9e6fa13 to
f5035c7
Compare
2d13d9f to
83704d9
Compare
83704d9 to
a359ea6
Compare
This comment was marked as low quality.
This comment was marked as low quality.
|
Please squash the commits and fulfill the PR description |
…S 26+) Add a --vmnet-disable-dhcp flag that starts the interface through the macOS 26 vmnet_network_configuration API (vmnet_network_create + vmnet_interface_start_with_network) with the built-in DHCP server disabled, while keeping shared-mode NAT. This lets an external DHCP/PXE server own the subnet. - Guard the new code path at compile time (requires the macOS 26 SDK) and at runtime (__builtin_available), erroring out clearly on older hosts and SDKs. Invocations without the flag keep using the legacy vmnet_start_interface path unchanged. - Derive the subnet address for vmnet_network_configuration_set_ipv4_subnet by masking --vmnet-gateway with --vmnet-mask, and validate both values separately (inet_aton does not set errno on failure). - Apply --vmnet-nat66-prefix via vmnet_network_configuration_set_ipv6_prefix. - Warn that --vmnet-dhcp-end, --vmnet-interface-id and --vmnet-network-identifier are ignored on this path: no DHCP server is started, and the new API has no equivalent for the other two. The checks run in cli_options_parse before defaults are filled in, so only explicitly passed options warn. - Name the selected start API in the failure log to ease debugging. - Add an iPXE-based e2e test (test/test-disable-dhcp.sh) asserting that no DHCP lease is offered, wired into the qemu workflow. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: fpolica91 <fabriciopolicarpo0@gmail.com>
a359ea6 to
48ae903
Compare
|
Squashed into a single signed-off commit and filled in the PR description. The |
|
@AkihiroSuda I have addressed the comments on this PR. Thank you for taking the time to review, if there is anything else needed please don't hesitate to let me know. |
What
Adds a
--vmnet-disable-dhcpflag that starts the vmnet interface with the built-in DHCP server disabled while keeping shared-mode NAT, so an external DHCP/PXE server can own the subnet.The existing
--vmnet-network-identifiermechanism (#139) disables DHCP only for isolated host-mode networks, which also gives up NAT/internet access. This flag covers the shared-mode case.How
vmnet_network_configurationAPI:vmnet_network_configuration_create→set_ipv4_subnet/set_ipv6_prefix/set_external_interface(driven by the existing options) →vmnet_network_configuration_disable_dhcp→vmnet_network_create→vmnet_interface_start_with_network.vmnet_start_interfaceXPC path is used as before.__builtin_available(macOS 26.0, *)), with explicit errors on older SDKs/hosts.--vmnet-gatewaywith--vmnet-mask, sinceset_ipv4_subnettakes the network address (the API reserves the second address of the range for the host).--vmnet-dhcp-end,--vmnet-interface-id,--vmnet-network-identifier) emit a warning instead of being silently ignored. The checks run incli_options_parsebefore defaults are filled in, so only explicitly passed options warn. (Verified on macOS 26.4 thatvmnet_interface_start_with_networkassigns its own interface id even whenvmnet_interface_id_keyis supplied ininterface_desc.)Testing
-Wall -Wextra -pedanticagainst the macOS 26 SDK.test/test-disable-dhcp.sh, wired into the qemu workflow: boots iPXE through the daemon started with--vmnet-disable-dhcpand asserts that no DHCP lease is offered; the daemon is cleaned up via--pidfile.Usage
sudo socket_vmnet --vmnet-gateway=192.168.105.1 --vmnet-disable-dhcp /var/run/socket_vmnet