fix: CNI guest MAC for macOS VMs - #26
Merged
CMGS merged 3 commits intoAug 20, 2026
Merged
Conversation
Read the live eth0 MAC from the CNI network namespace before constructing the QEMU spec. This keeps guest frames aligned with the address allowed by macspoofchk while retaining the SMBIOS ROM identity.
CMGS
dismissed
cmgs-simular’s stale review
August 20, 2026 07:52
posted from the wrong account; re-posted below
CMGS
requested changes
Aug 20, 2026
CMGS
left a comment
Contributor
There was a problem hiding this comment.
direction is right — cocoon's own ch/fc contract is guest mac == eth0 mac (hypervisor/cloudhypervisor/create.go feeds cfg.MAC to the guest nic, clonehints tells users to set eth0 to nc.MAC), so macos should follow. but the fix re-implements a value cocoon already hands us, see inline. should shrink to ~4 lines.
two more things:
- the root cause only bites with
macspoofchk: truein the conflist; tc mirred doesn't care about src mac otherwise. please confirm the deployed conflist actually sets it, and do one real run before merge:--net cni --random-smbios→ guest gets a tor ip + ssh works,nft list rulesetshows the spoofcheck rule. build/vet/tests aren't the acceptance here. cocoon-vkin the pr body is an internal hostname, drop it.
fwiw build / vet linux+darwin / gofmt / tests all green on db11908.
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
--net cnimode.Bug trigger path
--net cni --random-smbios.prepareOpenCoregenerates an SMBIOS identity and initially setsrecord.MACfrom the SMBIOS ROM.eth0and returns its MAC incfgs[0].MAC.record.MAC, discarding the CNI-provided MAC.macspoofchkis enabled, frames whose source MAC does not match the address assigned toeth0are dropped.Root cause
The CNI provider already returns the authoritative
eth0MAC throughcfgs[0].MAC, but the existing code preferred the SMBIOS-derived value stored inrecord.MAC.The SMBIOS ROM is a valid guest NIC MAC for user, TAP, and bridge networking. In CNI mode, the guest NIC must instead use the MAC assigned to
eth0whenmacspoofchkis enabled.Fix
Use the CNI-provided MAC directly in CNI mode:
Persist the selected MAC during network provisioning:
This resolves the mismatch at creation time without launch-time namespace inspection, shell commands, or JSON parsing.
The resulting behavior is:
eth0.Validation
Static checks
go test ./...GOOS=linux go vet ./...GOOS=darwin go vet ./...CGO_ENABLED=0 go build ./...git diff --checkRuntime validation
Confirmed that the target CNI configuration enables
macspoofchk.A real macOS VM was started with:
The runtime validation confirmed that:
record.MACmatched the CNI namespace'seth0MAC.en0used the same MAC.The temporary validation VM and its networking resources were removed after the test.