Skip to content

fix(app): reject a guest_mac reserved for the metadata interface - #1286

Open
Saadanjum0 wants to merge 3 commits into
liquidmetal-dev:mainfrom
Saadanjum0:fix/reserved-metadata-mac
Open

Saadanjum0 wants to merge 3 commits into
liquidmetal-dev:mainfrom
Saadanjum0:fix/reserved-metadata-mac

Conversation

@Saadanjum0

Copy link
Copy Markdown

What this PR does / why we need it:

When the provider has the metadata service capability and the spec has no eth0, CreateMicroVM prepends a metadata interface with the fixed MAC AA:FF:00:00:00:01. If another interface in the spec already uses that MAC, the spec is saved and reported as created, but Firecracker then exits with The MAC address is already in use.

This PR checks for that collision in addMetadataInterface and returns an error that names the offending interface, so CreateMicroVM fails up front and nothing is saved. MACs are compared after net.ParseMAC, so a different case (aa:ff:00:00:00:01) or notation (aa-ff-00-00-00-01) is caught too. A spec that defines its own eth0 is unchanged, because no metadata interface is added in that case.

The fixed MAC is now a constant shared by the interface definition and the check.

Note: like the existing validation errors from CreateMicroVM, this error is returned through the gRPC handler as-is, so it does not map to INVALID_ARGUMENT. Changing how create errors map to gRPC codes felt like a separate change, so I left it out.

Which issue(s) this PR fixes:
Fixes #1283

Special notes for your reviewer:

Added a TestApp_CreateMicroVM case where an interface other than eth0 uses aa:ff:00:00:00:01. Without the fix the case fails (the spec reaches Repo.Save, which the mock does not expect); with the fix it passes. go test -race ./core/... ./pkg/... ./infrastructure/grpc/... and golangci-lint run ./core/application/... pass in a Linux container.

The second option from the issue (deriving the metadata MAC per MicroVM) is not part of this PR.

Checklist:

  • squashed commits into logical changes
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

When the provider supports the metadata service and the spec has no eth0,
CreateMicroVM prepends a metadata interface with the fixed MAC
AA:FF:00:00:00:01. If another interface in the spec already uses that MAC,
the VMM refuses to start because two NICs share an address, yet the spec is
saved and the MicroVM is reported as created.

Check for the collision when the metadata interface is added and return an
error naming the interface instead. MACs are compared after parsing, so
case and notation differences are caught too.

Fixes liquidmetal-dev#1283

Signed-off-by: Saadanjum0 <160885369+Saadanjum0@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 5, 2026 14:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@netlify

netlify Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for flintlock-docs ready!

Name Link
🔨 Latest commit a89e91f
🔍 Latest deploy log https://app.netlify.com/projects/flintlock-docs/deploys/6ac9d9514c742b00082b1fb8
😎 Deploy Preview https://deploy-preview-1286--flintlock-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@richardcase richardcase left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @Saadanjum0 . Just the 1 one comment.

Comment thread core/application/commands.go Outdated
// The VMM refuses to start with two interfaces sharing a MAC address, so
// a spec that reuses the metadata interface's MAC can never run.
metadataMAC, _ := net.ParseMAC(metadataInterfaceMAC)
for _, netInt := range mvm.Spec.NetworkInterfaces {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if instead of doing the check here we do this as part of the struct validation early in the command, so as part of this:

https://github.com/liquidmetal-dev/flintlock/blob/main/core/application/commands.go#L34-L38

It would require:

@richardcase

Copy link
Copy Markdown
Member

@Saadanjum0 - one more comment, it would be good to update the docs to state that the MAC address is reserved and shouldn't be used. Hopefully that would stop people using it in the first place.

Saadanjum0 and others added 2 commits October 10, 2026 10:46
Move the check out of addMetadataInterface into a notReservedMAC validator on
NetworkInterface.GuestMAC, so it runs with the rest of the spec validation. The
metadata interface itself (eth0) may still carry the MAC. Document the reserved
address in the proto, swagger and user docs.
@Saadanjum0

Copy link
Copy Markdown
Author

Thanks @richardcase, both done in a89e91f:

  • The reserved-MAC check is now part of the struct validation instead of addMetadataInterface: a notReservedMAC validator in pkg/validation/validate.go, added to the GuestMAC tag in core/models/network.go (omitempty,mac,notReservedMAC). The commands.go / errors.go changes are gone apart from using a new models.MetadataInterfaceMAC constant instead of the literal. One detail: the metadata interface itself (eth0) still has to be allowed to carry that MAC, since it is the spec flintlock builds and stores, so the validator only rejects it on other interfaces.
  • The docs now say the MAC is reserved: the guest_mac comment in microvm.proto (and the generated .pb.go / swagger / proto.md text).

Tests: a validation case for a non-metadata interface using the MAC (fails validation), one confirming eth0 with that MAC is still valid, and the existing app-level case now fails through validation. core/application, pkg/validation and core/models tests pass (run in a Linux container).

This branch has not been deployed

No deployments
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.

CreateMicroVM accepts a guest_mac equal to the metadata interface's MAC, and the VMM then fails to start

3 participants