net: scope host device families per installation (net_scope) - #196
Merged
Conversation
Move the standalone RefuseManifest below the type blocks so the asl funcpartition rule (type immediately followed by its methods) holds.
GC sweeps two host-wide name families by name — bridge TAPs bt<vmid8>-<nic> in the host netns and CNI netns cocoon-<vmid> under /var/run/netns — and reclaims every entry whose VM its own DB does not know. Both prefixes were package constants, so a second installation on the same host (another root_dir, or a cocoon-derived runner such as cocoon-macos provisioning through cocoon's bridge/CNI backends) shares the families and has its live guests' TAPs and netns torn down by the peer's sweep. Add config net_scope: two alphanumerics keying an installation's families (<scope><vmid8>-<nic>, <scope>-<vmid>); empty keeps the legacy names. The fixed length keeps distinct scopes from being prefixes of each other, and bt / rm are rejected as aliases of the legacy and restore TAP families. The naming primitives live in package network next to TAPName; bridge and cni take the resolved prefix, and cocoon stays ignorant of any downstream.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
GC sweeps two host-wide name families by name — bridge TAPs
bt<vmid8>-<nic>in the host netns and CNI netnscocoon-<vmid>under/var/run/netns— and reclaims every entry whose VM its own DB does not know. Both prefixes were package constants, so any second installation on the same host (anotherroot_dir, or a cocoon-derived runner such as cocoon-macos that provisions through cocoon's bridge/CNI backends) lands in the same families and has its live guests' TAPs / netns torn down by the peer's sweep (observed:btALZMITW2-0reclaimed by the hourly GC, guest SSHNo route to host).Fix
One installation-identity knob; cocoon stays ignorant of any particular downstream — each installation only manages its own families.
config.Config.NetScope(net_scope, envCOCOON_NET_SCOPE): two alphanumerics; empty keeps the legacybt/cocoon-names. Scoped families are<scope><vmid8>-<nic>and<scope>-<vmid>. The fixed length means no two scopes are prefixes of each other, so families are disjoint by construction;btandrmare rejected because they alias the legacy bridge family and CH's transient restore TAPs.networknext toTAPName:BridgeTAPPrefix(scope),NetnsPrefix(scope),ValidateScope,RestoreTAPPrefix(moved fromcloudhypervisor).bridge:Newresolves the prefix once;GCModule(prefix)/CleanupTAPs(prefix, ids)take the resolved string like the siblingCgroupGCModule/vmlock.GCModuleregistrations;parseTAPNamematches the configured prefix only.cni:netnsName/netnsPathareConfigmethods; the GC netns scan cuts the scoped prefix.cmd/corepasses the resolved prefix; viper registersnet_scope; docs (cli.md,networking.md,gc.md) describe the families and the knob.Defaults are unchanged, so existing installations keep their device names. A second installation sets
net_scopebefore its first VM.Evidence
make lintGOOS=linux + darwin: 0 issues;asl ./...both GOOS: clean (the pre-existingmeta/sqlite/store.gofinding is fixed in the separatereview:commit)go test ./...darwin: greengo test ./config/ ./network/... ./cmd/core/ ./hypervisor/cloudhypervisor/green; linux-onlyTestParseTAPNameruns and passes with a foreign-scope negative case/simplifyfour lenses applied (single knob, primitives moved tonetwork, resolved-string signatures, no cached-vs-derived duplication)Follow-up (cocoon-macos)
Set
NetScopein itsconfig.Configliteral (e.g.mt) and passnetwork.BridgeTAPPrefix(conf.NetScope)tobridge.CleanupTAPs.