Skip to content

Enhance bridge networking with helper-based bridging support#1622

Open
curdbecker wants to merge 7 commits into
apple:mainfrom
curdbecker:add-bridge-mode-network
Open

Enhance bridge networking with helper-based bridging support#1622
curdbecker wants to merge 7 commits into
apple:mainfrom
curdbecker:add-bridge-mode-network

Conversation

@curdbecker
Copy link
Copy Markdown

@curdbecker curdbecker commented Jun 1, 2026

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Based on @torarnv's existing pull request, this pull request introduces support via a BridgeNetworkService in the vmnet plugin helper to enable socket-based bridge forwarding. The BridgeNetworkService is heavily inspired by nirs/vmnet-helper and draws on the same concept - although simplified only towards bridge networking with a vmnet interface and lacking basically all performance optimization so far.

This allow bridging to a real host network interface without having the binary signed with the com.apple.vm.networking entitlement, e.g. during container development.

In addition, this pull request rebases the changes of the existing pull request on the refactoring done in the current main branch which seems to working towards a more general network plugin interface and also introduces several, likely temporary enhancements to bridge the current gap of getting the network configuration options actually to the network helper during creation.

Specifically, the bridged networking understands two additional variants:
.bridged network attachments to a BridgedNetworkInterface for the given host interface from the original PR.
.bridgedViaHelper network attachments to a FileHandleNetworkInterface for the FileHandle endpoint where the plugin helper will provide bridging services to the runtime.

Simple example:
Screenshot 2026-06-01 at 15 58 32

Requires apple/containerization#759 (also based on @torarnv's work)
Extends #1463
Fixes #489

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

torarnv and others added 7 commits June 1, 2026 15:02
- Attachment.ipv4Address and .ipv4Gateway made optional; bridge
  attachments carry no pre-allocated IP (assigned via DHCP at runtime)
- Update all call sites and tests for optional IP fields

Co-authored-by: Curd Becker <me@curd-becker.de>
The setter for adding an XPCDictionary to an XPCMessage is present,
but the getter to retrieve it again is missing.

This might be connected to the fact that xpc_endpoint_t is a type
alias to xpc_object_t, so they appear to use an identical setter
implementation (unless there is some implicit argument overloading
that I am not aware of), but they apparently they cannot use the
same getter method, since there is a dedicated
`xpc_dictionary_get_dictionary` method to retrieve the dictionary again.
Right now, the configuration for a network is only saved in the
`NetworksService` after the network has been successfully started.
However, that constitutes a dependency issue when the vmnet helper
implementation depends on options in order to be able to create
and start the network in the first place.

This commit fixes this issue by passing the options (excluding the
variant) explicitly along as a serialized json dictionary. This is not
that elegant, but works well for now. To me it looks also that this
area is still undergoing quite some refactoring, so this might be
a workaround until a more elegant permanent solution is implace.
For each bridge attachment (ipv4Address == nil) at interface index n,
append ip=:::::eth<n>:dhcp to the kernel cmdline before booting the VM.
The kernel's built-in DHCP client (CONFIG_IP_PNP_DHCP=y) acquires the
lease before userspace starts, so no DHCP binary is needed in the rootfs.

We also pass the hostname to the DHCP server.

VZVirtualMachineManager creation is moved after attachment allocation
and interface creation, so interface indices are known when the cmdline is
finalized.

Co-authored-by: Curd Becker <me@curd-becker.de>
This was previously just a private enum inside the NetworkVmnetHelper
entrypoint, but it makes sense to make this actually globally accessible
... at least for now. I imagine this is also going to be likely the focus
of the ongoing refactoring.
…rategy

Implements the vmnet plugin side of bridge networking: a new
BridgedVmnetNetwork actor that uses placeholder subnets (no IP pool) and
a .bridged/.bridgedViaHelper NetworkVariant for the plugin helper.
The BridgeInterfaceStrategy communicates XPC additional data payload
forwarded by the BridgedVmnetNetwork to the concrete network interface.

BridgeInterfaceStrategy maps:
 - .bridged network attachments to a BridgedNetworkInterface
    for the given host interface.
 - .bridgedViaHelper network attachments to a FileHandleNetworkInterface
    for the FileHandle endpoint where the plugin helper will provide
    bridging services to the runtime.

Co-authored-by: Curd Becker <me@curd-becker.de>
The BridgeNetworkService is heavily inspired by nirs/vmnet-helper
and draws on the same concept. This allow bridging to a real host
network interface without having a binary signed with the
com.apple.vm.networking entitlement, e.g. during container development.

Therefore, the service allocates a standalone vmnet interface and a
dedicate UNIX datagram socket pair. One end of the pair remains local
to the service as the network attachment of the runtime, the other
end is sent to the runtime where it is assigned in the underlying VM
configuration as `VZFileHandleNetworkDeviceAttachment`.

This setup allows the service to perform manual bridging between
the vmnnet network interface attached to the host interface and the
runtime using event handlers on both sides.

While this is obviously certainly less performant and generally inferior
to having the same capabilities integrated directly in the Virtualization
Framework, it provides a very similar setting and is actually possible
without root privileges or any special entitlements.
@curdbecker curdbecker mentioned this pull request Jun 1, 2026
7 tasks
@jglogan jglogan self-requested a review June 1, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Request]: Bridge Mode

3 participants