netattach

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package netattach holds the rules of the device network interfaces and the encoding of the network.cybericebox.com/networks pod annotation shared by the operator (writer), the management agent (validation) and the node-agent (reader).

Index

Constants

View Source
const InterfaceNamePattern = `^[a-z][a-z0-9-]{0,14}$`

InterfaceNamePattern is the shape of a device interface name chosen by a tenant: a DNS-label-like word of at most 15 characters (the Linux interface name limit). Keep it in sync with the CRD validation of InterfaceSpec.Name.

Variables

This section is empty.

Functions

func Encode

func Encode(list []Attachment) string

Encode renders the annotation value: a JSON array, so no character of a name or MAC can start another entry.

func ValidateInterfaceName

func ValidateInterfaceName(n string) error

ValidateInterfaceName checks a tenant-chosen interface name.

func ValidateMAC

func ValidateMAC(m string) error

ValidateMAC checks an interface MAC: empty, "random", or a unicast hardware address that is not all zeros.

Types

type Attachment

type Attachment struct {
	// Iface is the interface name inside the pod netns.
	Iface string `json:"iface"`
	// Name is the OVS port name (set when a lab interface is attached later); empty
	// for a device interface whose connection is wired by the node-agent.
	Name string `json:"name,omitempty"`
	// MAC is the optional hardware address; empty keeps the generated one.
	MAC string `json:"mac,omitempty"`
}

Attachment is one entry of the networks annotation.

func Parse

func Parse(annotation string) []Attachment

Parse reads the annotation value. A JSON array is the current format. The legacy "iface@[name][|MAC],..." form is still read so pods created before the upgrade keep working. Entries named "default" (handled by the CNI plugin) are excluded.

func With

func With(list []Attachment, a Attachment) []Attachment

With returns the list with the attachment added (when absent).

func Without

func Without(list []Attachment, a Attachment) []Attachment

Without returns the list without the attachment.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL