Skip to content

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

@mdryaan

Description

@mdryaan

Description

Mirage.Init() in pkg/unikontainers/unikernels/mirage.go reads the subnet mask from the container's network parameters but then ignores it, hardcoding /24 into the IP address string. For any container network using a prefix other than /24 — such as /28, /16, or /30 — the MirageOS kernel command line will have the wrong prefix, causing incorrect routing inside the unikernel.

Steps to reproduce

Add a test that initializes a Mirage struct with a /28 mask and checks the resulting address string:

go test ./pkg/unikontainers/unikernels/ -v -run TestMirageInitSubnetMask

The test will fail before the fix because Net.Address contains /24 instead of /28.

Image

Expected behavior: The CIDR prefix in the Mirage kernel command line matches the actual subnet mask of the container's network interface.

Current behavior: The CIDR prefix is always /24 regardless of the actual subnet mask.

Proposed solution: Call subnetMaskToCIDR() on the value from data.Net.Mask and use the result when building the IP address string, instead of hardcoding /24.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CoreRelated to urunc's internalsGuestsRelated to guestsNetworkbugSomething isn't working

    Type

    No fields configured for Bug.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions