Documentation
¶
Index ¶
- type CNI
- func (c *CNI) Config(ctx context.Context, vmID string, numNICs int, vmCfg *types.VMConfig, ...) (configs []*types.NetworkConfig, retErr error)
- func (c *CNI) Delete(ctx context.Context, vmIDs []string) ([]string, error)
- func (c *CNI) GCModule() gc.Module[cniSnapshot]
- func (c *CNI) Inspect(ctx context.Context, id string) (*types.Network, error)
- func (c *CNI) List(ctx context.Context) ([]*types.Network, error)
- func (c *CNI) RegisterGC(orch *gc.Orchestrator)
- func (c *CNI) Type() string
- func (c *CNI) Verify(_ context.Context, vmID string) error
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CNI ¶
type CNI struct {
// contains filtered or unexported fields
}
CNI implements network.Network using CNI plugins with per-VM netns + bridge + tap.
func New ¶
New creates a CNI network provider. CNI conflist loading is best-effort at creation time; if no conflist is available (e.g. no network needed), Delete/Inspect/List still work. Config() will fail if the conflist is not loaded.
func (*CNI) Config ¶
func (c *CNI) Config(ctx context.Context, vmID string, numNICs int, vmCfg *types.VMConfig, existing ...*types.NetworkConfig) (configs []*types.NetworkConfig, retErr error)
Config creates the network namespace, runs CNI ADD for each NIC, sets up TC redirect (eth↔tap) inside the netns, and returns NetworkConfigs ready for CH --net.
Flow per NIC:
- Create named netns cocoon-{vmID}
- CNI ADD (containerID=vmID, netns path, ifName=eth{i})
- Inside netns: flush eth{i} IP, create tap{i}, wire via TC ingress mirred
- Return NetworkConfig{Tap: "tap{i}", Mac: generated, Network: CNI result}
func (*CNI) Delete ¶
Delete removes all network resources for the given VM IDs:
- CNI DEL for each NIC (releases IP from IPAM, removes veth pair).
- Remove the named netns (kernel cleans up bridge + tap automatically).
- Remove network records from the DB.
Best-effort: failing to clean one VM does not block others. Returns the VM IDs that were fully cleaned.
func (*CNI) GCModule ¶
GCModule returns the GC module for orphan netns and stale CNI record cleanup.
func (*CNI) Inspect ¶
Inspect returns the network record for a single network ID. Returns (nil, nil) if not found.
func (*CNI) RegisterGC ¶
func (c *CNI) RegisterGC(orch *gc.Orchestrator)
RegisterGC registers the CNI GC module with the given Orchestrator.
type Config ¶
Config holds CNI network provider specific configuration, embedding the global config.
func (*Config) EnsureDirs ¶
EnsureDirs creates all static directories required by the CNI network provider.