Documentation ¶
Index ¶
- Constants
- Variables
- func CIDRAddrValidate(cidraddr string) error
- func DHCPCreate(dhcp Dhcp) error
- func DHCPDelete(ifname LinkID) error
- func DHCPStaticAddressesManage(ifname LinkID) error
- func DHCPsConfigure(dhcp []Dhcp) error
- func DHCPsDelete() error
- func DNSCreate(dns Dns) error
- func DNSDelete(dnsid DnsID) error
- func DNSsConfigure(dnss []Dns) error
- func DNSsDelete() error
- func Del() error
- func InitErrorsLogsTracing()
- func LinkCreate(link Link) error
- func LinkCreateDown(link Link) error
- func LinkDelete(ifname LinkID) error
- func LinkRename(currNICIface LinkID, remappedNICIface LinkID) error
- func LinkSetAddresses(link Link) error
- func LinkSetBondSlave(ifname LinkID, masterIfname LinkID) error
- func LinkSetDown(ifname LinkID) error
- func LinkSetMTU(ifname LinkID, mtu int) error
- func LinkSetMaster(ifname LinkID, masterIfname LinkID) error
- func LinkSetUp(ifname LinkID) error
- func LinksConfigure(links []Link) error
- func LinksDelete() error
- func LinksVMReorder() error
- func NewActiveSlaveIfaceNotFoundForActiveBackupBondError(bondIfname LinkID) error
- func NewBackupSlaveIfaceFoundForNonActiveBackupBondError(backupIfname LinkID, bondIfname LinkID) error
- func NewBadAddressError(c CIDRAddr) error
- func NewCannotStartDHCPError(ifname LinkID, e error) error
- func NewCannotStatusDHCPError(ifname LinkID, e error) error
- func NewCannotStopDHCPError(ifname LinkID, e error) error
- func NewDHCPAlreadyRunningConflictError(ifname LinkID) error
- func NewDHCPRunningNotFoundError(linkID LinkID) error
- func NewDNSServerExistsConflictError(dnsid DnsID) error
- func NewDNSServerNotFoundError(dnsID DnsID) error
- func NewDuplicateDNSServersIDsError(dnsid1 DnsID, dnsid2 DnsID) error
- func NewEACCESError(r Resource) error
- func NewEEXISTError(r Resource) error
- func NewEINVALError() error
- func NewENETUNREACHError(r Resource) error
- func NewEPERMError(r Resource) error
- func NewERANGEError(r Resource) error
- func NewGenericError(err error) error
- func NewGenericErrorWithReason(reason string) error
- func NewGenericSemanticError() error
- func NewInvalidIPAddressError(addr string) error
- func NewInvalidPrefixLenForIPv4AddrError(len int) error
- func NewInvalidPrefixLenForIPv6AddrError(len int) error
- func NewInvalidUnmanagedResourceTypeError(t Type) error
- func NewLinkDeviceDoesNotExistError(linkID LinkID) error
- func NewLinkExistsConflictError(linkID LinkID) error
- func NewLinkNotFoundError(linkID LinkID) error
- func NewLinkUnknownFlagTypeError(flag LinkFlag) error
- func NewMultipleActiveSlaveIfacesFoundForActiveBackupBondError(bondIfname LinkID) error
- func NewNonBondMasterLinkTypeError(ifname LinkID) error
- func NewParentLinkNotFoundForVlan(ifname LinkID, parentIfname LinkID) error
- func NewRouteByIDNotFoundError(routeid RouteID) error
- func NewRouteExistsConflictError(routeID RouteID) error
- func NewRouteLinkDeviceNotFoundError(routeID RouteID, linkID LinkID) error
- func NewRuleExistsConflictError(ruleID RuleID) error
- func NewTooManyDNSServersError() error
- func NewUnexpectedCornerCaseError(reason string) error
- func NewUnknownLinkDeviceLabel(label string) error
- func NewUnknownLinkKindError(linkKind string) error
- func NewUnknownUnsupportedDNSServersIDsError(dnsid1 DnsID) error
- func NewUnmanagedLinkCannotBeModifiedError(ifname LinkID) error
- func NewUnmanagedLinkDHCPCannotBeModifiedError(ifname LinkID) error
- func NewUnmanagedLinkRouteCannotBeModifiedError(r Route) error
- func NewUnmanagedLinkRuleCannotBeModifiedError(r Rule) error
- func NewUnmanagedResourceNotFoundError(id UnmanagedID) error
- func NewUnsupportedError(reason string) error
- func NewUnsupportedSlaveKindError(infoSlaveKind string) error
- func Patch(n Network) error
- func Put(n Network) error
- func RouteDelete(routeid RouteID) error
- func RoutesConfigure(routes []Route) error
- func RoutesDelete() error
- func RuleDelete(ruleid RuleID) error
- func UnamanagedListConfigure(umgmts []Unmanaged) error
- func UnmanagedCreate(u Unmanaged) error
- func UnmanagedDelete(id UnmanagedID) error
- func UnmanagedListDelete() error
- type CIDRAddr
- func (a *CIDRAddr) Address() string
- func (a *CIDRAddr) IsV4() bool
- func (a *CIDRAddr) IsValid() bool
- func (a CIDRAddr) MarshalJSON() ([]byte, error)
- func (a *CIDRAddr) Netmask() string
- func (a *CIDRAddr) ParseCIDRNetStr(straddr string) error
- func (a *CIDRAddr) ParseIP(ip string)
- func (a *CIDRAddr) ParseIPNet(ip net.IPNet)
- func (a *CIDRAddr) PrefixLen() int
- func (a *CIDRAddr) SetIP(ip net.IP)
- func (a *CIDRAddr) SetNet(ipnet net.IPNet)
- func (a *CIDRAddr) SetPrefixLen(len int) error
- func (a *CIDRAddr) String() string
- func (a *CIDRAddr) ToIPNet() net.IPNet
- func (a *CIDRAddr) UnmarshalJSON(data []byte) error
- type ConflictError
- type Dhcp
- type Dns
- type DnsID
- type ErrorCode
- type GenericError
- type Link
- type LinkAddrInfo
- type LinkFlag
- type LinkFlags
- type LinkID
- type LinkLinkinfo
- type LinkLinkinfoInfoData
- type LinkLinkinfoInfoSlaveData
- type ModelDefault
- type Network
- type NotFoundError
- type PortRange
- type Resource
- type Route
- type RouteID
- type Rule
- type RuleID
- type Scope
- type SemanticError
- type SyntaxError
- type Type
- type UnexpectedCornerCaseError
- type UnknownTypeError
- type Unmanaged
- type UnmanagedID
- type UnsupportedError
Constants ¶
const ResolvConf string = "/etc/resolv.conf"
ResolvConf path prefix
Variables ¶
var NetconfdDebugTrace = false
Functions ¶
func CIDRAddrValidate ¶
CIDRAddrValidate validates a string as being or not a CIDR addr
func DHCPCreate ¶
DHCPCreate starts and delete DHCP controller for link interface
func DHCPDelete ¶
DHCPDelete stops and delete DHCP controller for link interface
func DHCPStaticAddressesManage ¶
DHCPStaticAddressesManage manages arrangements to also bring up static addresses
func DHCPsConfigure ¶
DHCPsConfigure configures the DHCP for each link interface of the array.
func DHCPsDelete ¶
func DHCPsDelete() error
DHCPsDelete stops/deletes all DHCP control managements for each interface
func DNSsConfigure ¶
DNSsConfigure configures/overwrites the whole set of dnss
func InitErrorsLogsTracing ¶
func InitErrorsLogsTracing()
InitErrorsLogsTracing Initializes error logs with tracing
func LinkCreate ¶
LinkCreate creates a link layer interface Link types (or kind): $> ip link help type ... TYPE := { vlan | veth | vcan | vxcan | dummy | ifb | macvlan | macvtap |
bridge | bond | team | ipoib | ip6tnl | ipip | sit | vxlan | gre | gretap | erspan | ip6gre | ip6gretap | ip6erspan | vti | nlmon | team_slave | bond_slave | ipvlan | geneve | bridge_slave | vrf | macsec }
func LinkCreateDown ¶
LinkCreateDown Creates a link interface but does not bring it up
func LinkRename ¶
LinkRename Rename a NIC Link Ifname
func LinkSetAddresses ¶
LinkSetAddresses assignes all addresses of a link (erase and recreate them)
func LinkSetBondSlave ¶
LinkSetBondSlave enslaves an interface to a master one
func LinkSetMaster ¶
LinkSetMaster specifies for a given interface (by ifname) the master to federate with (by masterIfname)
func LinksConfigure ¶
LinksConfigure configures the whole set of links to manage in the correct sequential order for example some of the link properties require other links to be established already or to have the link down/up etc.. This function tries to wipe out every type of conflicting in place configuration such as existing links whose ifname LinkID collides with the ones being created.
func LinksDelete ¶
func LinksDelete() error
LinksDelete remove all non physical and non loopback links Refs: Loopback uniqueness: https://elixir.bootlin.com/linux/latest/source/drivers/net/loopback.c#L195 Phy interfaces can't be removed if not for modprobe -r or Hot-Plug events https://github.com/ryoon/e1000e-linux/blob/master/src/netdev.c#L7968
func LinksVMReorder ¶
func LinksVMReorder() error
LinksVMReorder renames link devices to reflect hypervisor order on vmware or at least to be consistent over hypervisor changes. Beware that after renaming the interfaces are turned off.
func NewActiveSlaveIfaceNotFoundForActiveBackupBondError ¶
NewActiveSlaveIfaceNotFoundForActiveBackupBondError Returns an error if an active interface is not found for an Active-Backup type bond
func NewBackupSlaveIfaceFoundForNonActiveBackupBondError ¶
func NewBackupSlaveIfaceFoundForNonActiveBackupBondError(backupIfname LinkID, bondIfname LinkID) error
NewBackupSlaveIfaceFoundForNonActiveBackupBondError Returns an error if a backup interface is found for a non Active-Backup type bond
func NewBadAddressError ¶
NewBadAddressError returns a bad address error on link layer interfaces
func NewCannotStartDHCPError ¶
NewCannotStartDHCPError returns an error for DHCP related stop errors
func NewCannotStatusDHCPError ¶
NewCannotStatusDHCPError returns an error for DHCP related status errors
func NewCannotStopDHCPError ¶
NewCannotStopDHCPError returns an error for DHCP related stop errors
func NewDHCPAlreadyRunningConflictError ¶
NewDHCPAlreadyRunningConflictError returns an error for DHCP that is requested for an interface where it's already running
func NewDHCPRunningNotFoundError ¶
NewDHCPRunningNotFoundError returns a Not found error on link layer interfaces not managed by DHCP
func NewDNSServerExistsConflictError ¶
NewDNSServerExistsConflictError returns an error for DHCP that is requested for an interface where it's already running
func NewDNSServerNotFoundError ¶
NewDNSServerNotFoundError returns a Not found error on DNS not found by ID
func NewDuplicateDNSServersIDsError ¶
NewDuplicateDNSServersIDsError describes a config error on the DNS serves IDs
func NewEACCESError ¶
NewEACCESError returns an out of range error
func NewEINVALError ¶
func NewEINVALError() error
NewEINVALError returns a bad address error on link layer interfaces
func NewENETUNREACHError ¶
NewENETUNREACHError returns a network unreachable error
func NewEPERMError ¶
NewEPERMError returns a missing permissions error
func NewERANGEError ¶
NewERANGEError returns an out of range error
func NewGenericError ¶
NewGenericError returns a generic error
func NewGenericErrorWithReason ¶
NewGenericErrorWithReason returns a generic semantic error
func NewGenericSemanticError ¶
func NewGenericSemanticError() error
NewGenericSemanticError returns a generic semantic error
func NewInvalidIPAddressError ¶
NewInvalidIPAddressError Returns an error if a backup interface is found for a non Active-Backup type bond
func NewInvalidPrefixLenForIPv4AddrError ¶
NewInvalidPrefixLenForIPv4AddrError returns a bad address error on link layer interfaces
func NewInvalidPrefixLenForIPv6AddrError ¶
NewInvalidPrefixLenForIPv6AddrError returns a bad address error on link layer interfaces
func NewInvalidUnmanagedResourceTypeError ¶
NewInvalidUnmanagedResourceTypeError returns a bad address error on link layer interfaces
func NewLinkDeviceDoesNotExistError ¶
NewLinkDeviceDoesNotExistError returns a Conflict error on link layer interfaces
func NewLinkExistsConflictError ¶
NewLinkExistsConflictError returns a Conflict error on link layer interfaces
func NewLinkNotFoundError ¶
NewLinkNotFoundError returns a Not found error on link layer interfaces
func NewLinkUnknownFlagTypeError ¶
NewLinkUnknownFlagTypeError returns a Conflict error on link layer interfaces
func NewMultipleActiveSlaveIfacesFoundForActiveBackupBondError ¶
NewMultipleActiveSlaveIfacesFoundForActiveBackupBondError Returns an error if an active interface is not found for an Active-Backup type bond
func NewNonBondMasterLinkTypeError ¶
NewNonBondMasterLinkTypeError returns an error for non bond master link type
func NewParentLinkNotFoundForVlan ¶
NewParentLinkNotFoundForVlan returns a Not found error on link layer interfaces
func NewRouteByIDNotFoundError ¶
NewRouteByIDNotFoundError returns a Not found error on link layer interfaces
func NewRouteExistsConflictError ¶
NewRouteExistsConflictError returns a Conflict error on link layer interfaces
func NewRouteLinkDeviceNotFoundError ¶
NewRouteLinkDeviceNotFoundError describes a link device not found for a route to create
func NewRuleExistsConflictError ¶
NewruleExistsConflictError returns a Conflict error on link layer interfaces
func NewTooManyDNSServersError ¶
func NewTooManyDNSServersError() error
NewTooManyDNSServersError describes an error on the number of requested DNS servers
func NewUnexpectedCornerCaseError ¶
NewUnexpectedCornerCaseError returns a Conflict error on link layer interfaces
func NewUnknownLinkDeviceLabel ¶
NewUnknownLinkDeviceLabel
func NewUnknownLinkKindError ¶
NewUnknownLinkKindError returns a SemanticError error on link layer type interfaces
func NewUnknownUnsupportedDNSServersIDsError ¶
NewUnknownUnsupportedDNSServersIDsError describes a config error on the DNS serves IDs
func NewUnmanagedLinkCannotBeModifiedError ¶
NewUnmanagedLinkCannotBeModifiedError returns an error for unmanaged links which are requested to be configured
func NewUnmanagedLinkDHCPCannotBeModifiedError ¶
NewUnmanagedLinkDHCPCannotBeModifiedError returns an error for unmanaged links which are requested to be configured
func NewUnmanagedLinkRouteCannotBeModifiedError ¶
NewUnmanagedLinkRouteCannotBeModifiedError returns an error for unmanaged links routes which are requested to be configured
func NewUnmanagedLinkRuleCannotBeModifiedError ¶
NewUnmanagedLinkRuleCannotBeModifiedError returns an error for unmanaged links rules which are requested to be configured
func NewUnmanagedResourceNotFoundError ¶
func NewUnmanagedResourceNotFoundError(id UnmanagedID) error
NewUnmanagedResourceNotFoundError returns a Not found error on unmanaged resource not found
func NewUnsupportedError ¶
NewUnsupportedError returns a Conflict error on link layer interfaces
func NewUnsupportedSlaveKindError ¶
NewUnsupportedSlaveKindError returns a SemanticError error un unsupported kind of device enslavement
func RoutesConfigure ¶
RoutesConfigure configures the whole set of links to manage in the correct sequential order for example some of the link properties require other links to be established already or to have the link down/up etc.. This function tries to wipe out every type of conflicting in place configuration such as existing links whose ifname LinkID collides with the ones being created.
func UnamanagedListConfigure ¶
UnamanagedListConfigure configures the array of unmanaged resources
func UnmanagedCreate ¶
UnmanagedCreate adds a new unmanaged network resource object
func UnmanagedDelete ¶
func UnmanagedDelete(id UnmanagedID) error
UnmanagedDelete adds a new unmanaged network resource object
func UnmanagedListDelete ¶
func UnmanagedListDelete() error
UnmanagedListDelete deletes all unmanaged resouces
Types ¶
type CIDRAddr ¶
type CIDRAddr struct {
// contains filtered or unexported fields
}
CIDRAddr is an address and a network mask (According to RFC 4632 and RFC 4291). Additionally to a net.IPNet, it allows for specifying further than the netmask bits. Those are intended to define an addresses within the IP network being defined along with. E.g. : 10.1.2.3/24 -> 10.1.2.3 in network 10.1.2.0/24
func NewCIDRAddr ¶
NewCIDRAddr creates new CIDR address. If network is unspecified it is assumed to be /32 for ipv4 and /128 for ipv6
func (*CIDRAddr) Address ¶
Address returns the address (e.g. 255.255.255.0) of a CIDR address/network
func (CIDRAddr) MarshalJSON ¶
MarshalJSON JSON Marshaller
func (*CIDRAddr) Netmask ¶
Netmask returns the netmask (e.g. 255.255.255.0) of a CIDR address/network
func (*CIDRAddr) ParseCIDRNetStr ¶
ParseCIDRNetStr loads a CIDR network from a string. If network is unspecified it is assumed to be /32 for ipv4 and /128 for ipv6
func (*CIDRAddr) ParseIPNet ¶
ParseIPNet translates an IP network into a CIDRAddr
func (*CIDRAddr) SetPrefixLen ¶
SetPrefixLen translates an IP network prefix length into a CIDRAddr mask
func (*CIDRAddr) UnmarshalJSON ¶
UnmarshalJSON implements unmarshalling
type ConflictError ¶
type ConflictError GenericError
ConflictError describes a conflict with the network state and requested changes
func (*ConflictError) Error ¶
func (e *ConflictError) Error() string
type Dhcp ¶
type Dhcp struct { // Interface name Ifname LinkID `json:"ifname,omitempty"` }
Dhcp DHCP link context to enable. When an object of this kind is specified, the DHCP protocol daemon is enabled on the defined interface if it exists.
type Dns ¶
type Dns struct { // The DNS server ip address to send DNS queries to Nameserver net.IP `json:"nameserver,omitempty"` // Evaluated priority Id DnsID `json:"__id,omitempty"` }
Dns Name server for DNS resolution
type ErrorCode ¶
type ErrorCode int
ErrorCode describes the error type via enumeration
const ( //CONFLICT error type (inconsistency with respect to the existing state) CONFLICT ErrorCode = iota //NOT_FOUND error types encodes a restful resource not found by its ID NOT_FOUND //SEMANTIC error type of the requested operation in the syntax or logical content SEMANTIC //SYNTAX error type is for synctactical errors SYNTAX //UNKNOWN_TYPE error type (the value type is not recognized/supported) UNKNOWN_TYPE //UNEXPECTED_CORNER_CASE error type describes an error that was not meant to appear UNEXPECTED_CORNER_CASE //UNSUPPORTED error type describes an error where a part of the implementation is missing UNSUPPORTED //RESERVED can be used for outer error enum cohexistence RESERVED = 1000 )
type GenericError ¶
type GenericError struct { //code error type Code ErrorCode `json:"code"` //reason describes the specific reason for the error Reason string `json:"reason"` }
GenericError describes a generic error of the library
func (*GenericError) Error ¶
func (e *GenericError) Error() string
type Link ¶
type Link struct { // Inteface index ID Ifindex int32 `json:"ifindex,omitempty"` // Interface name identifier Ifname LinkID `json:"ifname"` // Specify what is the physical device the virtual device is linked to. Applies to vlan type virtual devices Link LinkID `json:"link,omitempty"` // Maximum Transfer Unit value Mtu int32 `json:"mtu,omitempty"` // In case the interface is part of a bond or bridge, specifies the bond/bridge interface it belongs to. Master LinkID `json:"master,omitempty"` Linkinfo LinkLinkinfo `json:"linkinfo,omitempty"` LinkType string `json:"link_type"` Address string `json:"address,omitempty"` AddrInfo []LinkAddrInfo `json:"addr_info,omitempty"` Flags LinkFlags `json:"flags,omitempty"` // Readonly state of the interface. Provides information on the state being for example UP of an interface. It is ignored when applying the config Operstate string `json:"operstate,omitempty"` }
Link definition For Bond parameters information please refer to https://www.kernel.org/doc/Documentation/networking/bonding.txt https://www.kernel.org/doc/Documentation/networking/operstates.txt
type LinkAddrInfo ¶
type LinkAddrInfo struct { Local CIDRAddr `json:"local,omitempty"` //Prefixlen int32 `json:"prefixlen,omitempty"` //Broadcast CIDRAddr `json:"broadcast,omitempty"` Address *net.IP `json:"local,omitempty"` }
LinkAddrInfo struct for LinkAddrInfo
type LinkFlags ¶
type LinkFlags []LinkFlag
LinkFlags is a slice of flags
type LinkLinkinfo ¶
type LinkLinkinfo struct { // Type of link layer interface. Supported Types: * `dummy` - Dummy link type interface for binding intenal services * `bridge` - Link layer virtual switch type interface * `bond` - Bond type interface letting two interfaces be seen as one * `vlan` - Virtual LAN (TAG ID based) interface * `veth` - Virtual ethernet (with virtual MAC and IP address) * `macvlan` - Direct virtual eth interface connected to the physical interface, with owned mac address * `ipvlan` - Direct virtual eth interface connected to the physical interface. Physical interface MAC address is reused. L2 type directly connects the lan to the host phyisical device. L3 type adds a routing layer in between. InfoKind string `json:"info_kind,omitempty"` // FILL ME InfoSlaveKind string `json:"info_slave_kind,omitempty"` InfoSlaveData LinkLinkinfoInfoSlaveData `json:"info_slave_data,omitempty"` InfoData LinkLinkinfoInfoData `json:"info_data,omitempty"` }
LinkLinkinfo definition
type LinkLinkinfoInfoData ¶
type LinkLinkinfoInfoData struct { // Bonding modes. Supported Modes: * `balance-rr` - Round-robin: Transmit network packets in sequential order from the first available network interface (NIC) slave through the last. This mode provides load balancing and fault tolerance. * `active-backup` - Active-backup: Only one NIC slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The single logical bonded interface's MAC address is externally visible on only one NIC (port) to avoid distortion in the network switch. This mode provides fault tolerance. * `balance-xor` - XOR: Transmit network packets based on a hash of the packet's source and destination. The default algorithm only considers MAC addresses (layer2). Newer versions allow selection of additional policies based on IP addresses (layer2+3) and TCP/UDP port numbers (layer3+4). This selects the same NIC slave for each destination MAC address, IP address, or IP address and port combination, respectively. This mode provides load balancing and fault tolerance. * `broadcast` - Broadcast: Transmit network packets on all slave network interfaces. This mode provides fault tolerance. * `802.3ad` - IEEE 802.3ad Dynamic link aggregation: Creates aggregation groups that share the same speed and duplex settings. Utilizes all slave network interfaces in the active aggregator group according to the 802.3ad specification. This mode is similar to the XOR mode above and supports the same balancing policies. The link is set up dynamically between two LACP-supporting peers. * `balance-tlb` - Adaptive transmit load balancing: Linux bonding driver mode that does not require any special network-switch support. The outgoing network packet traffic is distributed according to the current load (computed relative to the speed) on each network interface slave. Incoming traffic is received by one currently designated slave network interface. If this receiving slave fails, another slave takes over the MAC address of the failed receiving slave. * `balance-alb` - Adaptive load balancing: includes balance-tlb plus receive load balancing (rlb) for IPV4 traffic, and does not require any special network switch support. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the NIC slaves in the single logical bonded interface such that different network-peers use different MAC addresses for their network packet traffic. Mode string `json:"mode,omitempty"` // Specifies the MII link monitoring frequency in milliseconds. The default value is 0, and this will disable the MII monitor Miimon int32 `json:"miimon,omitempty"` // Specifies the time, in milliseconds, to wait before enabling a slave after a link recovery has been detected. The updelay value should be a multiple of the miimon value Updelay int32 `json:"updelay,omitempty"` // Specifies the time, in milliseconds, to wait before disabling a slave after a link failure has been detected. The downdelay value should be a multiple of the miimon value. Downdelay int32 `json:"downdelay,omitempty"` // Specify the delay, in milliseconds, between each peer notification (gratuitous ARP and unsolicited IPv6 Neighbor Advertisement) when they are issued after a failover event. This delay should be a multiple of the link monitor interval (arp_interval or miimon, whichever is active). The default value is 0 which means to match the value of the link monitor interval. PeerNotifyDelay int32 `json:"peer_notify_delay,omitempty"` // Specifies whether or not miimon should use MII or ETHTOOL ioctls vs. netif_carrier_ok() to determine the link status. The MII or ETHTOOL ioctls are less efficient and utilize a deprecated calling sequence within the kernel. The netif_carrier_ok() relies on the device driver to maintain its state with netif_carrier_on/off; at this writing, most, but not all, device drivers support this facility. If bonding insists that the link is up when it should not be, it may be that your network device driver does not support netif_carrier_on/off. The default state for netif_carrier is \"carrier on,\" so if a driver does not support netif_carrier, it will appear as if the link is always up. In this case, setting use_carrier to 0 will cause bonding to revert to the MII / ETHTOOL ioctl method to determine the link state. A value of 1 enables the use of netif_carrier_ok(), a value of 0 will use the deprecated MII / ETHTOOL ioctls. The default value is 1. UseCarrier int32 `json:"use_carrier,omitempty"` // Specifies the ARP link monitoring frequency in milliseconds. The ARP monitor works by periodically checking the slave devices to determine whether they have sent or received traffic recently (the precise criteria depends upon the bonding mode, and the state of the slave). Regular traffic is generated via ARP probes issued for the addresses specified by the arp_ip_target option. This behavior can be modified by the arp_validate option, below. If ARP monitoring is used in an etherchannel compatible mode (modes 0 and 2), the switch should be configured in a mode that evenly distributes packets across all links. If the switch is configured to distribute the packets in an XOR fashion, all replies from the ARP targets will be received on the same link which could cause the other team members to fail. ARP monitoring should not be used in conjunction with miimon. A value of 0 disables ARP monitoring. The default value is 0. ArpInterval int32 `json:"arp_interval,omitempty"` // Specifies whether or not ARP probes and replies should be validated in any mode that supports arp monitoring, or whether non-ARP traffic should be filtered (disregarded) for link monitoring purposes. Possible values are: * `none` - or 0 No validation or filtering is performed. * `active` - or 1 Validation is performed only for the active slave. * `backup` - or 2 Validation is performed only for backup slaves. * `all` - or 3 Validation is performed for all slaves. * `filter` - or 4 Filtering is applied to all slaves. No validation is performed. * `filter_active` - or 5 Filtering is applied to all slaves, validation is performed only for the active slave. * `filter_backup` - or 6 Filtering is applied to all slaves, validation is performed only for backup slaves. ArpValidate string `json:"arp_validate,omitempty"` // Specifies the quantity of arp_ip_targets that must be reachable in order for the ARP monitor to consider a slave as being up. This option affects only active-backup mode for slaves with arp_validation enabled. Possible values are: * `any` - or 0 consider the slave up only when any of the arp_ip_targets is reachable * `all` - or 1 consider the slave up only when all of the arp_ip_targets are reachable ArpAllTargets string `json:"arp_all_targets,omitempty"` // Specifies the reselection policy for the primary slave. This affects how the primary slave is chosen to become the active slave when failure of the active slave or recovery of the primary slave occurs. This option is designed to prevent flip-flopping between the primary slave and other slaves. Possible values are: * `always` - or 0 (default) The primary slave becomes the active slave whenever it comes back up. * `better` - or 1 The primary slave becomes the active slave when it comes back up, if the speed and duplex of the primary slave is better than the speed and duplex of the current active slave. * `failure` - or 2 The primary slave becomes the active slave only if the current active slave fails and the primary slave is up. The primary_reselect setting is ignored in two cases: * If no slaves are active, the first slave to recover is made the active slave. * When initially enslaved, the primary slave is always made the active slave. Changing the primary_reselect policy via sysfs will cause an immediate selection of the best active slave according to the new policy. This may or may not result in a change of the active slave, depending upon the circumstances. This option was added for bonding version 3.6.0. PrimaryReselect string `json:"primary_reselect,omitempty"` // Specifies whether active-backup mode should set all slaves to the same MAC address at enslavement (the traditional behavior), or, when enabled, perform special handling of the bond's MAC address in accordance with the selected policy. The default policy is none, unless the first slave cannot change its MAC address, in which case the active policy is selected by default. This option may be modified via sysfs only when no slaves are present in the bond. This option was added in bonding version 3.2.0. The \"follow\" policy was added in bonding version 3.3.0. Possible values are: * `none` - or 0 This setting disables fail_over_mac, and causes bonding to set all slaves of an active-backup bond to the same MAC address at enslavement time. This is the default. * `active` - or 1 The \"active\" fail_over_mac policy indicates that the MAC address of the bond should always be the MAC address of the currently active slave. The MAC address of the slaves is not changed; instead, the MAC address of the bond changes during a failover. This policy is useful for devices that cannot ever alter their MAC address, or for devices that refuse incoming broadcasts with their own source MAC (which interferes with the ARP monitor). The down side of this policy is that every device on the network must be updated via gratuitous ARP, vs. just updating a switch or set of switches (which often takes place for any traffic, not just ARP traffic, if the switch snoops incoming traffic to update its tables) for the traditional method. If the gratuitous ARP is lost, communication may be disrupted. When this policy is used in conjunction with the mii monitor, devices which assert link up prior to being able to actually transmit and receive are particularly susceptible to loss of the gratuitous ARP, and an appropriate updelay setting may be required. * `follow` - or 2 The \"follow\" fail_over_mac policy causes the MAC address of the bond to be selected normally (normally the MAC address of the first slave added to the bond). However, the second and subsequent slaves are not set to this MAC address while they are in a backup role; a slave is programmed with the bond's MAC address at failover time (and the formerly active slave receives the newly active slave's MAC address). This policy is useful for multiport devices that either become confused or incur a performance penalty when multiple ports are programmed with the same MAC address. FailOverMac string `json:"fail_over_mac,omitempty"` // Hash policy to route packets on different bond interfaces. Supported Modes: * `layer2` - Hash is made on L2 metadata * `layer2+3` - Hash is made on L2 and L3 metadata * `layer3+4` - Hash is made on L3 and L4 metadata XmitHashPolicy string `json:"xmit_hash_policy,omitempty"` // Specifies the number of IGMP membership reports to be issued after a failover event. One membership report is issued immediately after the failover, subsequent packets are sent in each 200ms interval. The valid range is 0 - 255; the default value is 1. A value of 0 prevents the IGMP membership report from being issued in response to the failover event. This option is useful for bonding modes balance-rr (0), active-backup (1), balance-tlb (5) and balance-alb (6), in which a failover can switch the IGMP traffic from one slave to another. Therefore a fresh IGMP report must be issued to cause the switch to forward the incoming IGMP traffic over the newly selected slave. This option was added for bonding version 3.7.0. ResendIgmp int32 `json:"resend_igmp,omitempty"` // Specifies that duplicate frames (received on inactive ports) should be dropped (0) or delivered (1). Normally, bonding will drop duplicate frames (received on inactive ports), which is desirable for most users. But there are some times it is nice to allow duplicate frames to be delivered. The default value is 0 (drop duplicate frames received on inactive ports). AllSlavesActive int32 `json:"all_slaves_active,omitempty"` // Specifies the minimum number of links that must be active before asserting carrier. It is similar to the Cisco EtherChannel min-links feature. This allows setting the minimum number of member ports that must be up (link-up state) before marking the bond device as up (carrier on). This is useful for situations where higher level services such as clustering want to ensure a minimum number of low bandwidth links are active before switchover. This option only affect 802.3ad mode. The default value is 0. This will cause carrier to be asserted (for 802.3ad mode) whenever there is an active aggregator, regardless of the number of available links in that aggregator. Note that, because an aggregator cannot be active without at least one available link, setting this option to 0 or to 1 has the exact same effect. MinLinks int32 `json:"min_links,omitempty"` // Specifies the number of seconds between instances where the bonding driver sends learning packets to each slaves peer switch. The valid range is 1 - 0x7fffffff; the default value is 1. This Option has effect only in balance-tlb and balance-alb modes. LpInterval int32 `json:"lp_interval,omitempty"` // Specify the number of packets to transmit through a slave before moving to the next one. When set to 0 then a slave is chosen at random. The valid range is 0 - 65535; the default value is 1. This option has effect only in balance-rr mode. PacketsPerSlave int32 `json:"packets_per_slave,omitempty"` // Rate at which LACP control packets are sent to an LACP-supported interface Supported Modes: * `slow` - LACP Slow Rate (less bandwidth) * `fast` - LACP Fast Rate (faster fault detection) AdLacpRate string `json:"ad_lacp_rate,omitempty"` // Specifies the 802.3ad aggregation selection logic to use. The possible values and their effects are: * `stable` - or 0 The active aggregator is chosen by largest aggregate bandwidth. Reselection of the active aggregator occurs only when all slaves of the active aggregator are down or the active aggregator has no slaves. This is the default value. * `bandwidth` or 1 The active aggregator is chosen by largest aggregate bandwidth. Reselection occurs if: - A slave is added to or removed from the bond - Any slave's link state changes - Any slave's 802.3ad association state changes - The bond's administrative state changes to up * `count` - or 2 The active aggregator is chosen by the largest number of ports (slaves). Reselection occurs as described under the \"bandwidth\" setting, above. The bandwidth and count selection policies permit failover of 802.3ad aggregations when partial failure of the active aggregator occurs. This keeps the aggregator with the highest availability (either in bandwidth or in number of ports) active at all times. This option was added in bonding version 3.4.0. AdSelect string `json:"ad_select,omitempty"` // Specifies if dynamic shuffling of flows is enabled in tlb mode. The value has no effect on any other modes. The default behavior of tlb mode is to shuffle active flows across slaves based on the load in that interval. This gives nice lb characteristics but can cause packet reordering. If re-ordering is a concern use this variable to disable flow shuffling and rely on load balancing provided solely by the hash distribution. xmit-hash-policy can be used to select the appropriate hashing for the setup. The sysfs entry can be used to change the setting per bond device and the initial value is derived from the module parameter. The sysfs entry is allowed to be changed only if the bond device is down. The default value is \"1\" that enables flow shuffling while value \"0\" disables it. This option was added in bonding driver 3.7.1 TlbDynamicLb int32 `json:"tlb_dynamic_lb,omitempty"` // VLAN protocols. Supported protocols: * `802.1Q` - 802.1Q protocol Protocol string `json:"protocol,omitempty"` // VLAN TAG ID Id int32 `json:"id,omitempty"` // Flags of the virtual device Flags []string `json:"flags,omitempty"` // Local IP Address on which the GRE is built Local net.IP `json:"local,omitempty"` // Remote IP Address endpoint of a GRE tunnel Remote net.IP `json:"remote,omitempty"` // Routing Table ID. Typical values for table IDs mapping can be found in `/etc/iproute2/rt_tables`: 255 local 254 main 253 default 0 unspec Reference: [IP Route manpage](https://man7.org/linux/man-pages/man8/ip-route.8.html) Table *uint32 `json:"table,omitempty"` }
LinkLinkinfoInfoData Additional information on the link
type LinkLinkinfoInfoSlaveData ¶
type LinkLinkinfoInfoSlaveData struct { // State of the link: * `ACTIVE` - Link is actively used * `BACKUP` - Link is used for failover State string `json:"state,omitempty"` // MII Status: * `UP` * `DOWN` MiiStatus string `json:"mii_status,omitempty"` // Number of link failures LinkFailureCount uint32 `json:"link_failure_count,omitempty"` // Hardware address PermHwaddr string `json:"perm_hwaddr,omitempty"` // Queue Identifier QueueId uint16 `json:"queue_id,omitempty"` // Routing Table ID of master VRF. Typical values for table IDs mapping can be found in `/etc/iproute2/rt_tables`: 255 local 254 main 253 default 0 unspec Reference: [IP Route manpage](https://man7.org/linux/man-pages/man8/ip-route.8.html) Table *uint32 `json:"table,omitempty"` }
LinkLinkinfoInfoSlaveData Info about slave state/config
type Network ¶
type Network struct { // Series of links layer interfaces to configure within the namespace Links []Link `json:"links,omitempty"` // Namespace routes Routes []Route `json:"routes,omitempty"` // DHCP context Dhcp []Dhcp `json:"dhcp,omitempty"` // DNS context Dnss []Dns //Unmanaged context Unmanaged []Unmanaged // IP Rules Rules []Rule }
Network struct for Network
type NotFoundError ¶
type NotFoundError ConflictError
NotFoundError is a logical error on the content of the operation requested to be performed
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type Route ¶
type Route struct { ID RouteID `json:"id"` Dst CIDRAddr `json:"dst,omitempty"` Gateway net.IP `json:"gateway,omitempty"` // Interface name Dev LinkID `json:"dev,omitempty"` Protocol string `json:"protocol,omitempty"` Metric int32 `json:"metric,omitempty"` Scope Scope `json:"scope,omitempty"` Prefsrc net.IP `json:"prefsrc,omitempty"` // Route flags Flags *[]string `json:"flags,omitempty"` // Route table ID. Typical values for table IDs mapping can be found in `/etc/iproute2/rt_tables`: 255 local 254 main 253 default 0 unspec Reference: [IP Route manpage](https://man7.org/linux/man-pages/man8/ip-route.8.html) Table uint32 `json:"table,omitempty"` }
Route IP L3 Ruote entry
type RouteID ¶
type RouteID string
RouteID identifies a route via MD5 of its content
func RouteCreate ¶
RouteCreate create and add a new route
func RouteIDGet ¶
type Rule ¶
type Rule struct { ID RuleID Priority int Family int Table int Mark int Mask int Tos uint TunID uint Goto int Src *net.IPNet Dst *net.IPNet Flow int IifName string OifName string SuppressIfgroup int SuppressPrefixlen int Invert bool Dport *PortRange Sport *PortRange }
Rule represents a netlink rule.
type SemanticError ¶
type SemanticError GenericError
SemanticError is a logical error on the content of the operation requested to be performed
func (*SemanticError) Error ¶
func (e *SemanticError) Error() string
type SyntaxError ¶
type SyntaxError GenericError
SyntaxError is a logical error on the content of the operation requested to be performed
func (*SyntaxError) Error ¶
func (e *SyntaxError) Error() string
type UnexpectedCornerCaseError ¶
type UnexpectedCornerCaseError GenericError
UnexpetecdCornerCaseError is fundamentally an implementation error catch exception It makes explitic to developer that he did not think of a case that instead happened
func (*UnexpectedCornerCaseError) Error ¶
func (e *UnexpectedCornerCaseError) Error() string
type UnknownTypeError ¶
type UnknownTypeError GenericError
UnknownTypeError is a logical error on the content of the operation requested to be performed
func (*UnknownTypeError) Error ¶
func (e *UnknownTypeError) Error() string
type Unmanaged ¶
type Unmanaged struct { // Resource type Type Type `json:"type,omitempty"` // ID of the resource to ignore ID UnmanagedID `json:"id,omitempty"` }
Unmanaged Unmanaged Resource For link type resources, the related context (routes or DHCP) are also unmanaged
func UnmanagedGet ¶
func UnmanagedGet(id UnmanagedID) (Unmanaged, error)
UnmanagedGet adds a new unmanaged network resource object
func UnmanagedListGet ¶
UnmanagedListGet returns list of unmanaged objects
type UnmanagedID ¶
type UnmanagedID string
type UnsupportedError ¶
type UnsupportedError GenericError
Unsupported describes an error about a part of implementation which is missing
func (*UnsupportedError) Error ¶
func (e *UnsupportedError) Error() string