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 ¶
const GroupLegMACPrefix = 0x0a
GroupLegMACPrefix is the first byte of the hardware addresses of the lab legs of the VPN and gateway pods of a group (locally administered, unicast). It is reserved: a device may not be given an address that starts with it.
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 ¶
ValidateInterfaceName checks a tenant-chosen interface name.
func ValidateMAC ¶
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.