nmstate

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeVETH   = "veth"
	TypeBridge = "bridge"
	TypeDummy  = "dummy"
	TypeTap    = "tap"
)
View Source
const (
	IfaceStateUnknown = "unknown"
	IfaceStateUp      = "up"
	IfaceStateDown    = "down"
	IfaceStateAbsent  = "absent"
)

Variables

This section is empty.

Functions

func AnyInterface

func AnyInterface(ifaces []Interface, predicate func(Interface) bool) bool

func DefaultDestinationRoute

func DefaultDestinationRoute(family int) *net.IPNet

func WithAdapter

func WithAdapter(adapter adapter) option

Types

type Ethtool

type Ethtool struct {
	Feature Feature `json:"feature,omitempty"`
}

type Feature

type Feature struct {
	TxChecksum *bool `json:"tx-checksum,omitempty"`
}

type IP

type IP struct {
	Enabled *bool       `json:"enabled,omitempty"`
	Address []IPAddress `json:"address,omitempty"`
}

type IPAddress

type IPAddress struct {
	IP        string `json:"IP,omitempty"`
	PrefixLen int    `json:"prefix-length,omitempty"`
}

type IfaceMetadata

type IfaceMetadata struct {
	// Pid refers to the process ID of the virt-launcher.
	Pid int
	// NetworkName refers to the logical network interface name which is associated with the interface spec.
	NetworkName string
}

IfaceMetadata includes extra data which is piggyback on the nmstate object. Users of the nmstate object can use it to store data and use it in some scenarios (e.g. creating the tap device).

type Interface

type Interface struct {
	Name        string  `json:"name"`
	Index       int     `json:"index,omitempty"`
	TypeName    string  `json:"type,omitempty"`
	State       string  `json:"state,omitempty"`
	MacAddress  string  `json:"mac-address,omitempty"`
	CopyMacFrom string  `json:"copy-mac-from,omitempty"`
	MTU         int     `json:"mtu,omitempty"`
	Controller  string  `json:"controller,omitempty"`
	Ethtool     Ethtool `json:"ethtool,omitempty"`

	Tap *TapDevice `json:"tap,omitempty"`

	IPv4 IP `json:"IPv4,omitempty"`
	IPv6 IP `json:"IPv6,omitempty"`

	LinuxStack LinuxIfaceStack `json:"linux-stack,omitempty"`

	Metadata *IfaceMetadata
}

func LookupInterface

func LookupInterface(ifaces []Interface, predicate func(Interface) bool) *Interface

type LinuxIfaceStack

type LinuxIfaceStack struct {
	IP4RouteLocalNet *bool `json:"ip4-route-local-net,omitempty"`
	PortLearning     *bool `json:"port-learning,omitempty"`
}

type LinuxStack

type LinuxStack struct {
	IPv4 LinuxStackIP4 `json:"ipv4,omitempty"`
	IPv6 LinuxStackIP6 `json:"ipv6,omitempty"`
}

type LinuxStackIP4

type LinuxStackIP4 struct {
	ArpIgnore             *procsys.ArpReplyMode `json:"arp-ignore,omitempty"`
	Forwarding            *bool                 `json:"forwarding,omitempty"`
	PingGroupRange        []int                 `json:"ping-group-range,omitempty"`
	UnprivilegedPortStart *int                  `json:"unprivileged-port-start,omitempty"`
}

type LinuxStackIP6

type LinuxStackIP6 struct {
	Forwarding *bool `json:"forwarding,omitempty"`
}

type NMState

type NMState struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...option) NMState

func (NMState) Apply

func (n NMState) Apply(spec *Spec) error

func (NMState) Read

func (n NMState) Read() (*Status, error)

type Route

type Route struct {
	Destination      string `json:"destination"`
	NextHopInterface string `json:"next-hop-interface,omitempty"`
	NextHopAddress   string `json:"next-hop-address,omitempty"`
	TableID          int    `json:"table-id,omitempty"`
}

type Routes

type Routes struct {
	Running []Route `json:"running,omitempty"`
}

type Spec

type Spec struct {
	Interfaces []Interface `json:"interfaces,omitempty"`
	LinuxStack LinuxStack  `json:"linux-stack,omitempty"`
}

type Status

type Status struct {
	Interfaces []Interface `json:"interfaces"`
	Routes     Routes      `json:"routes"`
	LinuxStack LinuxStack  `json:"linux-stack,omitempty"`
}

type TapDevice

type TapDevice struct {
	Queues int `json:"queues,omitempty"`
	UID    int `json:"UID,omitempty"`
	GID    int `json:"GID,omitempty"`
}

Jump to

Keyboard shortcuts

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