Documentation ¶
Overview ¶
The subnets package provides a subnet pool from which networks may be dynamically acquired or statically reserved.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInsufficientSubnets is returned by AcquireDynamically if no more subnets can be allocated. ErrInsufficientSubnets = errors.New("insufficient subnets remaining in the pool") // ErrInsufficientIPs is returned by AcquireDynamically if no more IPs can be allocated. ErrInsufficientIPs = errors.New("insufficient IPs remaining in the pool") // ErrReleasedUnallocatedNetwork is returned by Release if the subnet is not allocated. ErrReleasedUnallocatedSubnet = errors.New("subnet is not allocated") // ErrOverlapsExistingSubnet is returned if a recovered subnet overlaps an existing, allocated subnet ErrOverlapsExistingSubnet = errors.New("subnet overlaps an existing subnet") // ErrInvalidRange is returned by AcquireStatically and by Recover if the subnet range is invalid. ErrInvalidRange = errors.New("subnet has invalid range") // ErrInvalidIP is returned if a static IP is requested inside a subnet // which does not contain that IP ErrInvalidIP = errors.New("the requested IP is not within the subnet") // ErrIPAlreadyAcquired is returned if a static IP is requested which has already been allocated ErrIPAlreadyAcquired = errors.New("the requested IP is already allocated") // ErrIpCannotBeNil is returned by Release(..) and Recover(..) if a nil // IP address is passed. ErrIpCannotBeNil = errors.New("the IP field cannot be empty") ErrIPEqualsGateway = errors.New("a container IP must not equal the gateway IP") ErrIPEqualsBroadcast = errors.New("a container IP must not equal the broadcast IP") )
var DynamicIPSelector dynamicIPSelector = 0
DynamicIPSelector requests the next available ("dynamic") IP address from a given subnet. Returns an error if no more IP addresses remain in the subnet.
var DynamicSubnetSelector dynamicSubnetSelector = 0
DynamicSubnetSelector requests the next unallocated ("dynamic") subnet from the dynamic range. Returns an error if there are no remaining subnets in the dynamic range.
Functions ¶
Types ¶
type IPSelector ¶
type IPSelector interface { // Returns an IP address in the given subnet which is not one of the given existing // IP addresses. If no such IP address can be found, returns an error. SelectIP(subnet *net.IPNet, existing []net.IP) (net.IP, error) }
IPSelector is a strategy for selecting an IP address in a subnet.
type StaticIPSelector ¶
StaticIPSelector requests a specific ("static") IP address. Returns an error if the IP is already allocated, or if it is outside the given subnet.
type StaticSubnetSelector ¶
StaticSubnetSelector requests a specific ("static") subnet. Returns an error if the subnet is already allocated.
func (StaticSubnetSelector) SelectSubnet ¶
type SubnetSelector ¶
type SubnetSelector interface { // Returns a subnet based on a dynamic range and some existing statically-allocated // subnets. If no suitable subnet can be found, returns an error. SelectSubnet(dynamic *net.IPNet, existing []*net.IPNet) (*net.IPNet, error) }
SubnetSelector is a strategy for selecting a subnet.
type Subnets ¶
type Subnets interface { // Allocates an IP address and associates it with a subnet. The subnet is selected by the given SubnetSelector. // The IP address is selected by the given IPSelector. // Returns a subnet, an IP address, and a boolean which is true if and only if this is the // first IP address to be associated with this subnet. // If either selector fails, an error is returned. Acquire(SubnetSelector, IPSelector, lager.Logger) (*linux_backend.Network, error) // Releases an IP address associated with an allocated subnet. If the subnet has no other IP // addresses associated with it, it is deallocated. // Returns a boolean which is true if and only if the subnet was deallocated. // Returns an error if the given combination is not already in the pool. Release(*linux_backend.Network, lager.Logger) error // Remove an IP address so it appears to be associated with the given subnet. Remove(*linux_backend.Network, lager.Logger) error // Returns the number of /30 subnets which can be Acquired by a DynamicSubnetSelector. Capacity() int }
Subnets provides a means of allocating subnets and associated IP addresses.