nc

package
v0.0.0-...-2df04ca Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: BSD-4-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const ResolvConf string = "/etc/resolv.conf"

ResolvConf path prefix

Variables

View Source
var NetconfdDebugTrace = false

Functions

func CIDRAddrValidate

func CIDRAddrValidate(cidraddr string) error

CIDRAddrValidate validates a string as being or not a CIDR addr

func DHCPCreate

func DHCPCreate(dhcp Dhcp) error

DHCPCreate starts and delete DHCP controller for link interface

func DHCPDelete

func DHCPDelete(ifname LinkID) error

DHCPDelete stops and delete DHCP controller for link interface

func DHCPStaticAddressesManage

func DHCPStaticAddressesManage(ifname LinkID) error

DHCPStaticAddressesManage manages arrangements to also bring up static addresses

func DHCPsConfigure

func DHCPsConfigure(dhcp []Dhcp) error

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 DNSCreate

func DNSCreate(dns Dns) error

func DNSDelete

func DNSDelete(dnsid DnsID) error

DNSDelete delete a DNS entry in resolv.conf

func DNSsConfigure

func DNSsConfigure(dnss []Dns) error

DNSsConfigure configures/overwrites the whole set of dnss

func DNSsDelete

func DNSsDelete() error

DNSsDelete deletes all DNS context

func Del

func Del() error

Del delete whole network config

func InitErrorsLogsTracing

func InitErrorsLogsTracing()

InitErrorsLogsTracing Initializes error logs with tracing

func LinkCreate

func LinkCreate(link Link) error

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

func LinkCreateDown(link Link) error

LinkCreateDown Creates a link interface but does not bring it up

func LinkDelete

func LinkDelete(ifname LinkID) error

LinkDelete deletes a link layer interface

func LinkRename

func LinkRename(currNICIface LinkID, remappedNICIface LinkID) error

LinkRename Rename a NIC Link Ifname

func LinkSetAddresses

func LinkSetAddresses(link Link) error

LinkSetAddresses assignes all addresses of a link (erase and recreate them)

func LinkSetBondSlave

func LinkSetBondSlave(ifname LinkID, masterIfname LinkID) error

LinkSetBondSlave enslaves an interface to a master one

func LinkSetDown

func LinkSetDown(ifname LinkID) error

LinkSetDown set a link up

func LinkSetMTU

func LinkSetMTU(ifname LinkID, mtu int) error

LinkSetMTU set a link MTU

func LinkSetMaster

func LinkSetMaster(ifname LinkID, masterIfname LinkID) error

LinkSetMaster specifies for a given interface (by ifname) the master to federate with (by masterIfname)

func LinkSetUp

func LinkSetUp(ifname LinkID) error

LinkSetUp set a link up

func LinksConfigure

func LinksConfigure(links []Link) error

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

func NewActiveSlaveIfaceNotFoundForActiveBackupBondError(bondIfname LinkID) error

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

func NewBadAddressError(c CIDRAddr) error

NewBadAddressError returns a bad address error on link layer interfaces

func NewCannotStartDHCPError

func NewCannotStartDHCPError(ifname LinkID, e error) error

NewCannotStartDHCPError returns an error for DHCP related stop errors

func NewCannotStatusDHCPError

func NewCannotStatusDHCPError(ifname LinkID, e error) error

NewCannotStatusDHCPError returns an error for DHCP related status errors

func NewCannotStopDHCPError

func NewCannotStopDHCPError(ifname LinkID, e error) error

NewCannotStopDHCPError returns an error for DHCP related stop errors

func NewDHCPAlreadyRunningConflictError

func NewDHCPAlreadyRunningConflictError(ifname LinkID) error

NewDHCPAlreadyRunningConflictError returns an error for DHCP that is requested for an interface where it's already running

func NewDHCPRunningNotFoundError

func NewDHCPRunningNotFoundError(linkID LinkID) error

NewDHCPRunningNotFoundError returns a Not found error on link layer interfaces not managed by DHCP

func NewDNSServerExistsConflictError

func NewDNSServerExistsConflictError(dnsid DnsID) error

NewDNSServerExistsConflictError returns an error for DHCP that is requested for an interface where it's already running

func NewDNSServerNotFoundError

func NewDNSServerNotFoundError(dnsID DnsID) error

NewDNSServerNotFoundError returns a Not found error on DNS not found by ID

func NewDuplicateDNSServersIDsError

func NewDuplicateDNSServersIDsError(dnsid1 DnsID, dnsid2 DnsID) error

NewDuplicateDNSServersIDsError describes a config error on the DNS serves IDs

func NewEACCESError

func NewEACCESError(r Resource) error

NewEACCESError returns an out of range error

func NewEEXISTError

func NewEEXISTError(r Resource) error

NewEEXISTError returns a conflict error

func NewEINVALError

func NewEINVALError() error

NewEINVALError returns a bad address error on link layer interfaces

func NewENETUNREACHError

func NewENETUNREACHError(r Resource) error

NewENETUNREACHError returns a network unreachable error

func NewEPERMError

func NewEPERMError(r Resource) error

NewEPERMError returns a missing permissions error

func NewERANGEError

func NewERANGEError(r Resource) error

NewERANGEError returns an out of range error

func NewGenericError

func NewGenericError(err error) error

NewGenericError returns a generic error

func NewGenericErrorWithReason

func NewGenericErrorWithReason(reason string) error

NewGenericErrorWithReason returns a generic semantic error

func NewGenericSemanticError

func NewGenericSemanticError() error

NewGenericSemanticError returns a generic semantic error

func NewInvalidIPAddressError

func NewInvalidIPAddressError(addr string) error

NewInvalidIPAddressError Returns an error if a backup interface is found for a non Active-Backup type bond

func NewInvalidPrefixLenForIPv4AddrError

func NewInvalidPrefixLenForIPv4AddrError(len int) error

NewInvalidPrefixLenForIPv4AddrError returns a bad address error on link layer interfaces

func NewInvalidPrefixLenForIPv6AddrError

func NewInvalidPrefixLenForIPv6AddrError(len int) error

NewInvalidPrefixLenForIPv6AddrError returns a bad address error on link layer interfaces

func NewInvalidUnmanagedResourceTypeError

func NewInvalidUnmanagedResourceTypeError(t Type) error

NewInvalidUnmanagedResourceTypeError returns a bad address error on link layer interfaces

func NewLinkDeviceDoesNotExistError

func NewLinkDeviceDoesNotExistError(linkID LinkID) error

NewLinkDeviceDoesNotExistError returns a Conflict error on link layer interfaces

func NewLinkExistsConflictError

func NewLinkExistsConflictError(linkID LinkID) error

NewLinkExistsConflictError returns a Conflict error on link layer interfaces

func NewLinkNotFoundError

func NewLinkNotFoundError(linkID LinkID) error

NewLinkNotFoundError returns a Not found error on link layer interfaces

func NewLinkUnknownFlagTypeError

func NewLinkUnknownFlagTypeError(flag LinkFlag) error

NewLinkUnknownFlagTypeError returns a Conflict error on link layer interfaces

func NewMultipleActiveSlaveIfacesFoundForActiveBackupBondError

func NewMultipleActiveSlaveIfacesFoundForActiveBackupBondError(bondIfname LinkID) error

NewMultipleActiveSlaveIfacesFoundForActiveBackupBondError Returns an error if an active interface is not found for an Active-Backup type bond

func NewNonBondMasterLinkTypeError

func NewNonBondMasterLinkTypeError(ifname LinkID) error

NewNonBondMasterLinkTypeError returns an error for non bond master link type

func NewParentLinkNotFoundForVlan

func NewParentLinkNotFoundForVlan(ifname LinkID, parentIfname LinkID) error

NewParentLinkNotFoundForVlan returns a Not found error on link layer interfaces

func NewRouteByIDNotFoundError

func NewRouteByIDNotFoundError(routeid RouteID) error

NewRouteByIDNotFoundError returns a Not found error on link layer interfaces

func NewRouteExistsConflictError

func NewRouteExistsConflictError(routeID RouteID) error

NewRouteExistsConflictError returns a Conflict error on link layer interfaces

func NewRouteLinkDeviceNotFoundError

func NewRouteLinkDeviceNotFoundError(routeID RouteID, linkID LinkID) error

NewRouteLinkDeviceNotFoundError describes a link device not found for a route to create

func NewRuleExistsConflictError

func NewRuleExistsConflictError(ruleID RuleID) error

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

func NewUnexpectedCornerCaseError(reason string) error

NewUnexpectedCornerCaseError returns a Conflict error on link layer interfaces

func NewUnknownLinkDeviceLabel

func NewUnknownLinkDeviceLabel(label string) error

NewUnknownLinkDeviceLabel

func NewUnknownLinkKindError

func NewUnknownLinkKindError(linkKind string) error

NewUnknownLinkKindError returns a SemanticError error on link layer type interfaces

func NewUnknownUnsupportedDNSServersIDsError

func NewUnknownUnsupportedDNSServersIDsError(dnsid1 DnsID) error

NewUnknownUnsupportedDNSServersIDsError describes a config error on the DNS serves IDs

func NewUnmanagedLinkCannotBeModifiedError

func NewUnmanagedLinkCannotBeModifiedError(ifname LinkID) error

NewUnmanagedLinkCannotBeModifiedError returns an error for unmanaged links which are requested to be configured

func NewUnmanagedLinkDHCPCannotBeModifiedError

func NewUnmanagedLinkDHCPCannotBeModifiedError(ifname LinkID) error

NewUnmanagedLinkDHCPCannotBeModifiedError returns an error for unmanaged links which are requested to be configured

func NewUnmanagedLinkRouteCannotBeModifiedError

func NewUnmanagedLinkRouteCannotBeModifiedError(r Route) error

NewUnmanagedLinkRouteCannotBeModifiedError returns an error for unmanaged links routes which are requested to be configured

func NewUnmanagedLinkRuleCannotBeModifiedError

func NewUnmanagedLinkRuleCannotBeModifiedError(r Rule) error

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

func NewUnsupportedError(reason string) error

NewUnsupportedError returns a Conflict error on link layer interfaces

func NewUnsupportedSlaveKindError

func NewUnsupportedSlaveKindError(infoSlaveKind string) error

NewUnsupportedSlaveKindError returns a SemanticError error un unsupported kind of device enslavement

func Patch

func Patch(n Network) error

Patch network config

func Put

func Put(n Network) error

Put network config (wipe out and redeploy)

func RouteDelete

func RouteDelete(routeid RouteID) error

RouteDelete deletes a route by ID

func RoutesConfigure

func RoutesConfigure(routes []Route) error

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 RoutesDelete

func RoutesDelete() error

RoutesDelete deletes all routes

func RuleDelete

func RuleDelete(ruleid RuleID) error

RuleDelete deletes a rule by ID

func UnamanagedListConfigure

func UnamanagedListConfigure(umgmts []Unmanaged) error

UnamanagedListConfigure configures the array of unmanaged resources

func UnmanagedCreate

func UnmanagedCreate(u Unmanaged) error

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 CIDRAddrLoad

func CIDRAddrLoad(ip string, len int) (CIDRAddr, error)

func NewCIDRAddr

func NewCIDRAddr(addr string) CIDRAddr

NewCIDRAddr creates new CIDR address. If network is unspecified it is assumed to be /32 for ipv4 and /128 for ipv6

func (*CIDRAddr) Address

func (a *CIDRAddr) Address() string

Address returns the address (e.g. 255.255.255.0) of a CIDR address/network

func (*CIDRAddr) IsV4

func (a *CIDRAddr) IsV4() bool

IsV4 tells if the address is V4

func (*CIDRAddr) IsValid

func (a *CIDRAddr) IsValid() bool

IsValid returns true if address is set and valid

func (CIDRAddr) MarshalJSON

func (a CIDRAddr) MarshalJSON() ([]byte, error)

MarshalJSON JSON Marshaller

func (*CIDRAddr) Netmask

func (a *CIDRAddr) Netmask() string

Netmask returns the netmask (e.g. 255.255.255.0) of a CIDR address/network

func (*CIDRAddr) ParseCIDRNetStr

func (a *CIDRAddr) ParseCIDRNetStr(straddr string) error

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) ParseIP

func (a *CIDRAddr) ParseIP(ip string)

ParseIP parses the IP address

func (*CIDRAddr) ParseIPNet

func (a *CIDRAddr) ParseIPNet(ip net.IPNet)

ParseIPNet translates an IP network into a CIDRAddr

func (*CIDRAddr) PrefixLen

func (a *CIDRAddr) PrefixLen() int

PrefixLen returns the length of the network prefix

func (*CIDRAddr) SetIP

func (a *CIDRAddr) SetIP(ip net.IP)

SetIP parses the IP address

func (*CIDRAddr) SetNet

func (a *CIDRAddr) SetNet(ipnet net.IPNet)

SetNet parses the IP address

func (*CIDRAddr) SetPrefixLen

func (a *CIDRAddr) SetPrefixLen(len int) error

SetPrefixLen translates an IP network prefix length into a CIDRAddr mask

func (*CIDRAddr) String

func (a *CIDRAddr) String() string

func (*CIDRAddr) ToIPNet

func (a *CIDRAddr) ToIPNet() net.IPNet

ToIPNet returns an IP network (the non network part is zeroed out)

func (*CIDRAddr) UnmarshalJSON

func (a *CIDRAddr) UnmarshalJSON(data []byte) error

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.

func DHCPGet

func DHCPGet(ifname LinkID) (Dhcp, error)

DHCPGet gets DHCP controller info for link interface

func DHCPsGet

func DHCPsGet() ([]Dhcp, error)

DHCPsGet Get all DHCP interfaces administrated by DHCP and related config/state.

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

func DNSsGet

func DNSsGet() ([]Dns, error)

DNSsGet Get all DNS interfaces administrated by DNS and related config/state.

func DnsGet

func DnsGet(dnsid DnsID) (Dns, error)

type DnsID

type DnsID string
const (
	DnsPrimary   DnsID = "primary"
	DnsSecondary       = "secondary"
)

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 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

func LinkGet

func LinkGet(ifname LinkID) (Link, error)

LinkGet Returns the list of existing link layer devices on the machine

func LinksGet

func LinksGet() ([]Link, error)

LinksGet Returns the list of existing link layer devices on the machine

func (*Link) Print

func (l *Link) Print() string

Print implements route print

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 LinkFlag

type LinkFlag string

LinkFlag the model 'LinkFlag'

const (
	BROADCAST LinkFlag = "broadcast"
	MULTICAST LinkFlag = "multicast"
	LOOPBACK  LinkFlag = "loopback"
	UP        LinkFlag = "up"
)

List of link_flag

type LinkFlags

type LinkFlags []LinkFlag

LinkFlags is a slice of flags

func (LinkFlags) ClearFlag

func (flags LinkFlags) ClearFlag(flag LinkFlag) LinkFlags

ClearFlag return true if the searched flag is found

func (LinkFlags) HaveFlag

func (flags LinkFlags) HaveFlag(flag LinkFlag) bool

HaveFlag return true if the searched flag is found

func (LinkFlags) SetFlag

func (flags LinkFlags) SetFlag(flag LinkFlag) LinkFlags

SetFlag return true if the searched flag is found

type LinkID

type LinkID string

LinkID type

func (LinkID) IsValid

func (l LinkID) IsValid() bool

IsValid checks whether a link is valid

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 ModelDefault

type ModelDefault string

ModelDefault This is equivalent to 0.0.0.0/0 or ::/0

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

func Get

func Get() (Network, error)

Get network config

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 PortRange

type PortRange struct {
	Start uint16
	End   uint16
}

PortRange represents rule sport/dport range.

func ParsePortRange

func ParsePortRange(prange string) (error, PortRange)

func (PortRange) IsSingle

func (p PortRange) IsSingle() bool

func (*PortRange) String

func (p *PortRange) String() string

type Resource

type Resource interface {
	Print() string
}

Resource is a network resource interface

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

func RouteGet

func RouteGet(_routeID RouteID) (Route, error)

RouteGet Returns a route if it exists

func RoutesGet

func RoutesGet() ([]Route, error)

RoutesGet returns the array of routes

func (*Route) Print

func (r *Route) Print() string

Print implements route print

type RouteID

type RouteID string

RouteID identifies a route via MD5 of its content

func RouteCreate

func RouteCreate(route Route) (RouteID, error)

RouteCreate create and add a new route

func RouteIDGet

func RouteIDGet(route Route) RouteID

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.

func RuleGet

func RuleGet(_ruleID RuleID) (Rule, error)

RuleGet Returns a rule if it exists

func RulesGet

func RulesGet() ([]Rule, error)

RulesGet returns the array of rules

func (*Rule) Print

func (r *Rule) Print() string

Print implements rule print

type RuleID

type RuleID string

RuleID identifies a rule via MD5 of its content

func RuleCreate

func RuleCreate(rule Rule) (RuleID, error)

RuleCreate create and add a new rule

func RuleIDGet

func RuleIDGet(r Rule) RuleID

type Scope

type Scope string

Scope scope of the object (link or global)

const (
	LINK   Scope = "link"
	GLOBAL Scope = "global"
)

List of scope

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 Type

type Type string

Type identifies the type of a resource

const (
	LINKTYPE Type = "link"
	DNSTYPE  Type = "dns"
)

List of scope

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

func UnmanagedListGet() ([]Unmanaged, error)

UnmanagedListGet returns list of unmanaged objects

func (*Unmanaged) Print

func (u *Unmanaged) Print() string

Print implements unmanaged resource print

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

Jump to

Keyboard shortcuts

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