Skip to content

fix(unikernels): use actual subnet mask in Unikraft netdev.ip args#823

Open
Aditya-132 wants to merge 1 commit into
urunc-dev:mainfrom
Aditya-132:fix/unikraft-subnet-mask
Open

fix(unikernels): use actual subnet mask in Unikraft netdev.ip args#823
Aditya-132 wants to merge 1 commit into
urunc-dev:mainfrom
Aditya-132:fix/unikraft-subnet-mask

Conversation

@Aditya-132

@Aditya-132 Aditya-132 commented Jul 14, 2026

Copy link
Copy Markdown

The current-version args path in configureUnikraftArgs hardcoded a /24 CIDR prefix in the netdev.ip= boot argument, ignoring the container interface's actual subnet mask. Any network with a different prefix (e.g. a /16 CNI subnet) resulted in a guest with a wrong netmask and broken on-link routing decisions.

Convert the mask with the existing subnetMaskToCIDR helper and use the real prefix. Keep /24 only as a fallback when no mask is provided, to preserve the no-network behavior. Return an error for malformed masks, consistent with Mirage, Hermit and Mewz.

Fixes: #827

Description

Related issues

  • Fixes #

How was this tested?

LLM usage

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.

The current-version args path in configureUnikraftArgs hardcoded a /24
CIDR prefix in the netdev.ip= boot argument, ignoring the container
interface's actual subnet mask. Any network with a different prefix
(e.g. a /16 CNI subnet) resulted in a guest with a wrong netmask and
broken on-link routing decisions.

Convert the mask with the existing subnetMaskToCIDR helper and use the
real prefix. Keep /24 only as a fallback when no mask is provided, to
preserve the no-network behavior. Return an error for malformed masks,
consistent with Mirage, Hermit and Mewz.

Fixes: #1
Signed-off-by: Aditya-132 <adityachincholkar11@gmail.com>
@netlify

netlify Bot commented Jul 14, 2026

Copy link
Copy Markdown

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit 0957a25
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a55e74634c1440008600781

@Aditya-132

Copy link
Copy Markdown
Author

@Reviewer please reviewe it

@cmainas

cmainas commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Hello @Aditya-132 , which issue does this PR solv. (it is linked to #1) which is resolved. Could you also go through the checklist in the PR template?

@Aditya-132

Copy link
Copy Markdown
Author

Hello @Aditya-132 , which issue does this PR solv. (it is linked to #1) which is resolved. Could you also go through the checklist in the PR template?

check now

maskCIDR := 24
if ethDeviceMask != "" {
var err error
maskCIDR, err = subnetMaskToCIDR(ethDeviceMask)

@Nachiket-Roy Nachiket-Roy Jul 15, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CIDR conversion now happens before version routing, so compat/old versions can fail on masks they previously just passed through untouched.
I'd also add a test case for old version + invalid mask to lock in that the compat path stays unaffected.

@Nachiket-Roy

Nachiket-Roy commented Jul 15, 2026

Copy link
Copy Markdown

check now

Your PR description still doesn't match the template. You can check other contributors PRs to understand /Fixit.
Also your commit message need to be updated.

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.

Unikraft guest network ignores container subnet mask (hardcoded /24) in current-version args path

3 participants