Skip to content

fix(unikernels): use actual subnet mask in Mirage IP configuration instead of hardcoded /24#703

Open
mdryaan wants to merge 1 commit into
urunc-dev:mainfrom
mdryaan:fix/mirage-hardcoded-subnet
Open

fix(unikernels): use actual subnet mask in Mirage IP configuration instead of hardcoded /24#703
mdryaan wants to merge 1 commit into
urunc-dev:mainfrom
mdryaan:fix/mirage-hardcoded-subnet

Conversation

@mdryaan
Copy link
Copy Markdown
Contributor

@mdryaan mdryaan commented May 18, 2026

Description

Mirage.Init() reads the subnet mask from data.Net.Mask but ignores it, always hardcoding /24 into the IP address
string. Any network with a prefix other than /24 produces a wrong kernel command line, causing incorrect routing inside
the MirageOS unikernel.

The fix calls subnetMaskToCIDR() — already present in the same package and used correctly by Hermit.Init() and
Mewz.Init() — and uses the returned CIDR prefix instead of the hardcoded /24.

Related issues

How was this tested?

Added TestMirageInitSubnetMask in pkg/unikontainers/unikernels/mirage_test.go with three sub-tests: a non-/24 mask (255.255.255.240/28), a /24 mask (regression check), and no network (empty mask guard).

Before fix

Screenshot 2026-05-17 094253

After fix:

Screenshot 2026-05-17 094340

LLM usage

N/A

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.

…stead of hardcoded /24

Signed-off-by: Md Raiyan <alikhurshid842001@gmail.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 18, 2026

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit 7ea0bc2
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a0b6f663a23ca0007975d90

@cmainas
Copy link
Copy Markdown
Contributor

cmainas commented May 19, 2026

There is something wrong with the PR description. Please if you use LLMs you must disclose it. This is important for various reasons.

@mdryaan
Copy link
Copy Markdown
Contributor Author

mdryaan commented May 21, 2026

There is something wrong with the PR description. Please if you use LLMs you must disclose it. This is important for various reasons.

Hi @cmainas , sorry about the messy description I didn't use any LLM to write the code or tests, but I did use GPT-5 to
help format the PR description following the template and forgot to clean it up properly before submitting. I've read
the LLM policy, If I use LLMs for code in the future, I’ll make sure to disclose it properly

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.

use actual subnet mask in Mirage IP configuration instead of hardcoded /24

2 participants