Skip to content

Fix: Parse MTU to Firecracker network configuration#836

Open
HARSHVARANDANI wants to merge 3 commits into
urunc-dev:mainfrom
HARSHVARANDANI:fix/mtu-parsing
Open

Fix: Parse MTU to Firecracker network configuration#836
HARSHVARANDANI wants to merge 3 commits into
urunc-dev:mainfrom
HARSHVARANDANI:fix/mtu-parsing

Conversation

@HARSHVARANDANI

Copy link
Copy Markdown

Description

This PR fixes an issue where the host veth's MTU was not propagated to Firecracker virtual machines.
The dynamic network implementation correctly reads the host veth's MTU, but the static network mode was leaving it unset (defaulting to 0). Furthermore, the Firecracker VMM driver completely lacked support for configuring the MTU in the generated fc.json config file. Consequently, the guest Linux kernel defaulted to an MTU of 1500 regardless of the MTU configured on the host.
Specifically, this change:

  • Updates pkg/network/network_static.go to populate the MTU field in the returned Interface struct from redirectLink.Attrs().MTU.
  • Adds an mtu field to the FirecrackerNet JSON structure in pkg/unikontainers/hypervisors/firecracker.go and sets it using args.Net.MTU. This enables VIRTIO_NET_F_MTU feature negotiation with the guest.
  • Adds a new unit test suite (firecracker_test.go) covering the command construction, JSON config building, and JSON serialization for Firecracker.

Related issues

How was this tested?

The unit tests written in firecracker_test.go verify that the Firecracker command-line constructor (BuildExecCmd) correctly compiles and generates JSON configuration files. The test suite uses a table-driven approach to validate baseline parameters (like boot settings, seccomp filters, custom memory sizes, and virtual CPUs), verify the serialization of both default (1500) and custom (9000) MTU values, assert that zero-value MTUs are omitted from the serialized JSON configuration using the omitempty struct tag, and test the integration of auxiliary configurations such as vsock devices and custom initramfs images.

LLM usage

Used Google Antigravity for writing tests and scoping the issue. All changes have been manually reviewed.

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

Ensure the MTU is retrieved from the container interface and populated in the Interface struct, preventing it from defaulting to 0.

Signed-off-by: HARSHVARANDANI <hpvarandani@gmail.com>
Add MTU field to FirecrackerNet config struct and serialize it to the Firecracker config JSON to enable VIRTIO_NET_F_MTU negotiation with the guest.

Signed-off-by: HARSHVARANDANI <hpvarandani@gmail.com>
… building

Add test cases covering MTU parsing, JSON serialization, and baseline configuration generation for Firecracker.

Signed-off-by: HARSHVARANDANI <hpvarandani@gmail.com>
@netlify

netlify Bot commented Jul 18, 2026

Copy link
Copy Markdown

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit 2623e40
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a5bab5952e3490008a2f173

@cmainas

cmainas commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Hello @HARSHVARANDANI ,

thank you for opening the PR. Regarding the test method, we will need to verify that this works end-to-end, meaning that the Firecracker guest getc configured with the MTU we specify. A unit test is not enough for the testing.

You can take a look at #564 on how to test this end-to-end.

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.

Set the MTU in the interface inside the sandbox

2 participants