Skip to content

fix(network): use exact regex pattern in getTapIndex - #1044

Open
Norway-02 wants to merge 1 commit into
urunc-dev:mainfrom
Norway-02:fix/tap-index-regex
Open

Norway-02 wants to merge 1 commit into
urunc-dev:mainfrom
Norway-02:fix/tap-index-regex

Conversation

@Norway-02

Copy link
Copy Markdown

/kind bug

Rationale

In Kubernetes and containerized environments, network interface names created by host systems or CNI plugins often contain "tap" as a substring (e.g. bootstrap0, vtap0, cni-tap0, stape0).

Currently, getTapIndex() in pkg/network/network.go checks:

if strings.Contains(iface.Name, "tap") {
    tapCount++
}

When DynamicNetwork.NetworkSetup() runs during container creation, if tapIndex > 0, urunc aborts container launch with:
unsupported operation: can't spawn multiple unikernels in the same network namespace

This causes urunc to falsely believe a unikernel is already running and refuse to spawn the first container whenever any interface with "tap" in its name exists in the network namespace.

This PR updates getTapIndex() to use the regex pattern ^tap\d+(_urunc)?$, matching urunc's own TAP device naming convention while ignoring unrelated host/CNI interfaces.

Fixes #938

Reviewer Notes

  • Added unit tests TestGetTapIndex and TestTapDeviceRegexMatching in pkg/network/network_test.go.
  • Tagging maintainers @cmainas @OdysseasKalaitsidis for review.

LLM usage

none

fix(network): prevent false positive TAP interface matching in getTapIndex()

Signed-off-by: Norway-02 <anshulkhetade02@gmail.com>
@netlify

netlify Bot commented Sep 12, 2026

Copy link
Copy Markdown

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit a1fdf23
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6aa56cefde472d0008d90268

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.

Bug: DynamicNetwork.NetworkSetup incorrectly blocks container startup when unrelated or stale "tap" interfaces exist in the network namespace

1 participant