nic

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2020 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package nic provides a way to describe and configure a network interface.

nolint: golint,stylecheck

Index

Constants

View Source
const (

	// MinimumMTU is the lowest allowed MTU for an interface
	MinimumMTU = 68
	// MaximumMTU is the highest allowed MTU for an interface
	MaximumMTU = 65536
)
View Source
const (
	IFLA_VLAN_UNSPEC = iota
	IFLA_VLAN_ID
	IFLA_VLAN_FLAGS
	IFLA_VLAN_EGRESS_QOS
	IFLA_VLAN_INGRESS_QOS
	IFLA_VLAN_PROTOCOL
	IFLA_VLAN_MAX = IFLA_VLAN_PROTOCOL
)
View Source
const (
	VLAN_PROTOCOL_UNKNOWN = 0
	VLAN_PROTOCOL_8021Q   = 0x8100
	VLAN_PROTOCOL_8021AD  = 0x88A8
)

VlanProtocol possible values

Variables

This section is empty.

Functions

This section is empty.

Types

type ADSelect added in v0.3.0

type ADSelect uint8
const (
	AD_SELECT_STABLE ADSelect = iota
	AD_SELECT_BANDWIDTH
	AD_SELECT_COUNT
)

func ADSelectByName added in v0.3.0

func ADSelectByName(sel string) (adsel ADSelect, err error)

func (ADSelect) String added in v0.3.0

func (a ADSelect) String() string

type ARPAllTargets added in v0.3.0

type ARPAllTargets uint32
const (
	ARP_ALL_TARGETS_ANY ARPAllTargets = iota
	ARP_ALL_TARGETS_ALL
)

func ARPAllTargetsByName added in v0.3.0

func ARPAllTargetsByName(a string) (arpa ARPAllTargets, err error)

func (ARPAllTargets) String added in v0.3.0

func (a ARPAllTargets) String() string

type ARPValidate added in v0.3.0

type ARPValidate uint32
const (
	ARP_VALIDATE_NONE ARPValidate = iota
	ARP_VALIDATE_ACTIVE
	ARP_VALIDATE_BACKUP
	ARP_VALIDATE_ALL
)

func ARPValidateByName added in v0.3.0

func ARPValidateByName(a string) (arpv ARPValidate, err error)

func (ARPValidate) String added in v0.3.0

func (a ARPValidate) String() string

type BondMode added in v0.3.0

type BondMode uint8

https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/if_bonding.h

const (
	BOND_MODE_ROUNDROBIN BondMode = iota
	BOND_MODE_ACTIVEBACKUP
	BOND_MODE_XOR
	BOND_MODE_BROADCAST
	BOND_MODE_8023AD
	BOND_MODE_TLB
	BOND_MODE_ALB
)

func BondModeByName added in v0.3.0

func BondModeByName(mode string) (bm BondMode, err error)

func (BondMode) String added in v0.3.0

func (b BondMode) String() string

type BondSetting added in v0.3.0

type BondSetting uint16

https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/if_link.h#L608

const (
	IFLA_BOND_UNSPEC BondSetting = iota
	IFLA_BOND_MODE
	IFLA_BOND_ACTIVE_SLAVE
	IFLA_BOND_MIIMON
	IFLA_BOND_UPDELAY
	IFLA_BOND_DOWNDELAY
	IFLA_BOND_USE_CARRIER
	IFLA_BOND_ARP_INTERVAL
	IFLA_BOND_ARP_IP_TARGET
	IFLA_BOND_ARP_VALIDATE
	IFLA_BOND_ARP_ALL_TARGETS
	IFLA_BOND_PRIMARY
	IFLA_BOND_PRIMARY_RESELECT
	IFLA_BOND_FAIL_OVER_MAC
	IFLA_BOND_XMIT_HASH_POLICY
	IFLA_BOND_RESEND_IGMP
	IFLA_BOND_NUM_PEER_NOTIF
	IFLA_BOND_ALL_SLAVES_ACTIVE
	IFLA_BOND_MIN_LINKS
	IFLA_BOND_LP_INTERVAL
	IFLA_BOND_PACKETS_PER_SLAVE
	IFLA_BOND_AD_LACP_RATE
	IFLA_BOND_AD_SELECT
	IFLA_BOND_AD_INFO
	IFLA_BOND_AD_ACTOR_SYS_PRIO
	IFLA_BOND_AD_USER_PORT_KEY
	IFLA_BOND_AD_ACTOR_SYSTEM
	IFLA_BOND_TLB_DYNAMIC_LB
	IFLA_BOND_PEER_NOTIF_DELAY
)

func (BondSetting) String added in v0.3.0

func (b BondSetting) String() string

type BondXmitHashPolicy added in v0.3.0

type BondXmitHashPolicy uint8
const (
	BOND_XMIT_POLICY_LAYER2 BondXmitHashPolicy = iota
	BOND_XMIT_POLICY_LAYER34
	BOND_XMIT_POLICY_LAYER23
	BOND_XMIT_POLICY_ENCAP23
	BOND_XMIT_POLICY_ENCAP34
)

func BondXmitHashPolicyByName added in v0.3.0

func BondXmitHashPolicyByName(policy string) (xmit BondXmitHashPolicy, err error)

func (BondXmitHashPolicy) String added in v0.3.0

func (b BondXmitHashPolicy) String() string

type FailOverMAC added in v0.3.0

type FailOverMAC uint8
const (
	FAIL_OVER_MAC_NONE FailOverMAC = iota
	FAIL_OVER_MAC_ACTIVE
	FAIL_OVER_MAC_FOLLOW
)

func FailOverMACByName added in v0.3.0

func FailOverMACByName(f string) (fo FailOverMAC, err error)

type LACPRate added in v0.3.0

type LACPRate uint8
const (
	LACP_RATE_SLOW LACPRate = iota
	LACP_RATE_FAST
)

func LACPRateByName added in v0.3.0

func LACPRateByName(mode string) (rate LACPRate, err error)

func (LACPRate) String added in v0.3.0

func (l LACPRate) String() string

type NetworkInterface

type NetworkInterface struct {
	Name          string
	Type          int
	Ignore        bool
	Bonded        bool
	MTU           uint32
	Link          *net.Interface
	SubInterfaces []*net.Interface
	AddressMethod []address.Addressing
	BondSettings  *netlink.AttributeEncoder
	Vlans         []*Vlan
	// contains filtered or unexported fields
}

NetworkInterface provides an abstract configuration representation for a network interface.

func New added in v0.3.0

func New(setters ...Option) (*NetworkInterface, error)

New returns a NetworkInterface with all of the given setter options applied.

func (*NetworkInterface) Addressing added in v0.3.0

func (n *NetworkInterface) Addressing() error

Addressing handles the address method for a configured interface ( dhcp/static ). This is inclusive of the address itself as well as any defined routes.

func (*NetworkInterface) AddressingSub added in v0.4.0

func (n *NetworkInterface) AddressingSub() error

AddressingSub handles the address method for a configured sub interface ( dhcp/static ). This is inclusive of the address itself as well as any defined routes.

func (*NetworkInterface) Configure added in v0.3.0

func (n *NetworkInterface) Configure() (err error)

Configure is used to set the link state and configure any necessary bond settings ( ex, mode ).

func (*NetworkInterface) Create added in v0.3.0

func (n *NetworkInterface) Create() error

Create creates the underlying link if it does not already exist.

func (*NetworkInterface) CreateSub added in v0.4.0

func (n *NetworkInterface) CreateSub() error

CreateSub create VLAN devices that belongs to a master device

func (*NetworkInterface) IsIgnored

func (n *NetworkInterface) IsIgnored() bool

IsIgnored checks the network interface to see if it should be ignored and not configured.

func (*NetworkInterface) Renew added in v0.3.0

func (n *NetworkInterface) Renew()

Renew is the mechanism for keeping a dhcp lease active.

func (*NetworkInterface) Reset added in v0.3.0

func (n *NetworkInterface) Reset()

Reset removes addressing configuration from a given link.

type Option

type Option func(*NetworkInterface) error

Option is the functional option func.

func WithADActorSysPrio added in v0.3.0

func WithADActorSysPrio(o uint16) Option

WithADActorSysPrio in an AD system, this specifies the system priority.

func WithADSelect added in v0.3.0

func WithADSelect(o string) Option

WithADSelect specifies the 802.3ad aggregation selection logic to use.

func WithADUserPortKey added in v0.3.0

func WithADUserPortKey(o uint16) Option

WithADUserPortKey specifies the upper 10 bits of the port key.

func WithARPAllTargets added in v0.3.0

func WithARPAllTargets(o string) Option

WithARPAllTargets specifies the quantity of arp_ip_targets that must be reachable in order for the ARP monitor to consider a slave as being up.

func WithARPInterval added in v0.3.0

func WithARPInterval(o uint32) Option

WithARPInterval specifies the ARP link monitoring frequency in milliseconds.

func WithARPValidate added in v0.3.0

func WithARPValidate(o string) Option

WithARPValidate specifies whether or not ARP probes and replies should be validated.

func WithAddressing

func WithAddressing(a address.Addressing) Option

WithAddressing defines how the addressing for a given interface should be configured

func WithAllSlavesActive added in v0.3.0

func WithAllSlavesActive(o uint8) Option

WithAllSlavesActive specifies that duplicate frames (received on inactive ports) should be dropped (0) or delivered (1).

func WithBond added in v0.3.0

func WithBond(o bool) Option

WithBond defines if the interface should be bonded.

func WithBondMode added in v0.3.0

func WithBondMode(o string) Option

WithBondMode sets the mode the bond should operate in.

func WithDownDelay added in v0.3.0

func WithDownDelay(o uint32) Option

WithDownDelay configures the down delay for interfaces that makes up a bond. The value is given in ms.

func WithFailOverMAC added in v0.3.0

func WithFailOverMAC(o string) Option

WithFailOverMAC specifies whether active-backup mode should set all slaves to the same MAC address.

func WithHashPolicy added in v0.3.0

func WithHashPolicy(o string) Option

WithHashPolicy configures the transmit hash policy for the bonded interface.

func WithIgnore

func WithIgnore() Option

WithIgnore indicates that the interface should not be processed by talos.

func WithLACPRate added in v0.3.0

func WithLACPRate(o string) Option

WithLACPRate configures the bond LACP rate.

func WithLPInterval added in v0.3.0

func WithLPInterval(o uint32) Option

WithLPInterval specifies the number of seconds between instances where the bonding driver sends learning packets to each slaves peer switch.

func WithMIIMon added in v0.3.0

func WithMIIMon(o uint32) Option

WithMIIMon configures the miimon interval for a bond. The value is given in ms.

func WithMinLinks(o uint32) Option

WithMinLinks specifies the minimum number of links that must be active before asserting carrier.

func WithName

func WithName(o string) Option

WithName sets the name of the interface to the given name.

func WithNoAddressing added in v0.4.0

func WithNoAddressing() Option

WithNoAddressing defines how the addressing for a given interface should be configured

func WithNumPeerNotif added in v0.3.0

func WithNumPeerNotif(o uint8) Option

WithNumPeerNotif specifies the number of peer notifications (gratuitous ARPs and unsolicited IPv6 Neighbor Advertisements) to be issued after a failover event.

func WithPacketsPerSlave added in v0.3.0

func WithPacketsPerSlave(o uint32) Option

WithPacketsPerSlave specify the number of packets to transmit through a slave before moving to the next one.

func WithPeerNotifyDelay added in v0.3.0

func WithPeerNotifyDelay(o uint32) Option

WithPeerNotifyDelay specifies the delay between each peer notification (gratuitous ARP and unsolicited IPv6 Neighbor Advertisement) when they are issued after a failover event. The value is given in ms.

func WithPrimary added in v0.3.0

func WithPrimary(o string) Option

WithPrimary specifies which slave is the primary device.

func WithPrimaryReselect added in v0.3.0

func WithPrimaryReselect(o string) Option

WithPrimaryReselect specifies the reselection policy for the primary slave.

func WithResendIGMP added in v0.3.0

func WithResendIGMP(o uint32) Option

WithResendIGMP specifies the number of IGMP membership reports to be issued after a failover event.

func WithSubInterface

func WithSubInterface(o ...string) Option

WithSubInterface defines which interfaces make up the bond.

func WithTLBDynamicLB added in v0.3.0

func WithTLBDynamicLB(o uint8) Option

WithTLBDynamicLB specifies if dynamic shuffling of flows is enabled in tlb mode.

func WithUpDelay added in v0.3.0

func WithUpDelay(o uint32) Option

WithUpDelay configures the up delay for interfaces that makes up a bond. The value is given in ms.

func WithUseCarrier added in v0.3.0

func WithUseCarrier(o bool) Option

WithUseCarrier configures how miimon will determine the link status.

func WithVlan added in v0.4.0

func WithVlan(id uint16) Option

WithVlan defines the VLAN id to use

func WithVlanCIDR added in v0.4.0

func WithVlanCIDR(id uint16, cidr string, routeList []machine.Route) Option

WithVlanCIDR defines if the interface have static CIDRs added

func WithVlanDhcp added in v0.4.0

func WithVlanDhcp(id uint16) Option

WithVlanDhcp sets a VLAN device with DHCP

type PrimaryReselect added in v0.3.0

type PrimaryReselect uint8
const (
	PRIMARY_RESELECT_ALWAYS PrimaryReselect = iota
	PRIMARY_RESELECT_BETTER
	PRIMARY_RESELECT_FAILURE
)

func PrimaryReselectByName added in v0.3.0

func PrimaryReselectByName(p string) (pr PrimaryReselect, err error)

func (PrimaryReselect) String added in v0.3.0

func (p PrimaryReselect) String() string

type Vlan added in v0.4.0

type Vlan struct {
	Parent        string
	ID            uint16
	Link          *net.Interface
	VlanSettings  *netlink.AttributeEncoder
	AddressMethod []address.Addressing
}

Vlan contins interface related parameters to a VLAN device

Jump to

Keyboard shortcuts

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