Documentation
¶
Overview ¶
Package ipamcore provides the core functionality for the IPAM service.
The IPAM is organized like a binary tree, where each node represents a network. In order to optimize the network allocation we use buddy mmory allocation alghorithm to allocate networks like they are memory blocks (https://en.wikipedia.org/wiki/Buddy_memory_allocation). When a network is splitted in two, the left child represents the first half of the network, while the right child represents the second half. The splitting is done until the network is splitted in blocks of the desired size.
Index ¶
- type Ipam
- func (ipam *Ipam) IPAcquire(prefix netip.Prefix) (*netip.Addr, error)
- func (ipam *Ipam) IPAcquireWithAddr(prefix netip.Prefix, addr netip.Addr) (*netip.Addr, error)
- func (ipam *Ipam) IPIsAllocated(prefix netip.Prefix, addr netip.Addr) (bool, error)
- func (ipam *Ipam) IPRelease(prefix netip.Prefix, addr netip.Addr, gracePeriod time.Duration) (*netip.Addr, error)
- func (ipam *Ipam) IPSetCreationTimestamp(addr netip.Addr, prefix netip.Prefix, creationTimestamp time.Time) error
- func (ipam *Ipam) IsPrefixInRoots(prefix netip.Prefix) bool
- func (ipam *Ipam) ListIPs(prefix netip.Prefix) ([]netip.Addr, error)
- func (ipam *Ipam) ListNetworks() []netip.Prefix
- func (ipam *Ipam) NetworkAcquire(size int) *netip.Prefix
- func (ipam *Ipam) NetworkAcquireWithPrefix(prefix netip.Prefix) *netip.Prefix
- func (ipam *Ipam) NetworkIsAvailable(prefix netip.Prefix) bool
- func (ipam *Ipam) NetworkRelease(prefix netip.Prefix, gracePeriod time.Duration) *netip.Prefix
- func (ipam *Ipam) NetworkSetLastUpdateTimestamp(prefix netip.Prefix, lastUpdateTimestamp time.Time) error
- func (ipam *Ipam) ToGraphviz() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ipam ¶
type Ipam struct {
// contains filtered or unexported fields
}
Ipam represents the IPAM core structure.
func (*Ipam) IPAcquire ¶
IPAcquire allocates an IP address from the given prefix. It returns the allocated IP address or nil if the IP address is not available.
func (*Ipam) IPAcquireWithAddr ¶
IPAcquireWithAddr allocates the IP address from the given prefix. It returns the allocated IP address or nil if the IP address is not available.
func (*Ipam) IPIsAllocated ¶
IPIsAllocated checks if the IP address is allocated from the given prefix. It returns true if the IP address is allocated, false otherwise.
func (*Ipam) IPRelease ¶
func (ipam *Ipam) IPRelease(prefix netip.Prefix, addr netip.Addr, gracePeriod time.Duration) (*netip.Addr, error)
IPRelease frees the IP address from the given prefix. It returns the freed IP address or nil if the IP address is not found.
func (*Ipam) IPSetCreationTimestamp ¶
func (ipam *Ipam) IPSetCreationTimestamp(addr netip.Addr, prefix netip.Prefix, creationTimestamp time.Time) error
IPSetCreationTimestamp sets the creation timestamp of the IP address with the given address. This function is for testing purposes only.
func (*Ipam) IsPrefixInRoots ¶
IsPrefixInRoots checks if the given prefix is contained in the roots. It returns true if the prefix is contained, false otherwise.
func (*Ipam) ListNetworks ¶
ListNetworks returns the list of allocated networks.
func (*Ipam) NetworkAcquire ¶
NetworkAcquire allocates a network of the given size. It returns the allocated network or nil if no network is available.
func (*Ipam) NetworkAcquireWithPrefix ¶
NetworkAcquireWithPrefix allocates a network with the given prefix. It returns the allocated network or nil if the network is not available.
func (*Ipam) NetworkIsAvailable ¶
NetworkIsAvailable checks if the network with the given prefix is allocated. It returns false if the network is allocated or there is no suitable pool, true otherwise.
func (*Ipam) NetworkRelease ¶
NetworkRelease frees the network with the given prefix. It returns the freed network or nil if the network is not found.
func (*Ipam) NetworkSetLastUpdateTimestamp ¶
func (ipam *Ipam) NetworkSetLastUpdateTimestamp(prefix netip.Prefix, lastUpdateTimestamp time.Time) error
NetworkSetLastUpdateTimestamp sets the last update time of the network with the given prefix. This function is for testing purposes only.
func (*Ipam) ToGraphviz ¶
ToGraphviz generates the Graphviz representation of the IPAM structure.