cidrset

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCIDRRangeNoCIDRsRemaining occurs when there is no more space
	// to allocate CIDR ranges.
	ErrCIDRRangeNoCIDRsRemaining = errors.New(
		"CIDR allocation failed; there are no remaining CIDRs left to allocate in the accepted range")
	// ErrCIDRSetSubNetTooBig occurs when the subnet mask size is too
	// big compared to the CIDR mask size.
	ErrCIDRSetSubNetTooBig = errors.New(
		"New CIDR set failed; the node CIDR size is too big")
	// ErrSubNetMaskSizeInvalid occurs when the subnet mask size  is invalid:
	// bigger than 32 for IPv4 and bigger than 128 for IPv6
	ErrSubNetMaskSizeInvalid = fmt.Errorf(
		"SubNetMask is invalid, should be lower or equal to %d for IPv4 and to %d for IPv6",
		maxSubNetMaskSizeIPv4, maxSubNetMaskSizeIPv6)
)

Functions

This section is empty.

Types

type CidrSet

type CidrSet struct {
	lock.Mutex
	// contains filtered or unexported fields
}

CidrSet manages a set of CIDR ranges from which blocks of IPs can be allocated.

func NewCIDRSet

func NewCIDRSet(clusterPrefix netip.Prefix, subNetMaskSize int) (*CidrSet, error)

NewCIDRSet creates a new CidrSet.

func (*CidrSet) AllocateNext

func (s *CidrSet) AllocateNext() (netip.Prefix, error)

AllocateNext allocates the next free CIDR range. This will set the range as occupied and return the allocated range.

func (*CidrSet) InRange

func (s *CidrSet) InRange(prefix netip.Prefix) bool

InRange returns true if the given prefix is inside the range of the allocatable CidrSet.

func (*CidrSet) IsAllocated

func (s *CidrSet) IsAllocated(prefix netip.Prefix) (bool, error)

IsAllocated verifies if the given prefix is allocated.

func (*CidrSet) IsClusterCIDR

func (s *CidrSet) IsClusterCIDR(prefix netip.Prefix) bool

IsClusterCIDR returns true if the given prefix is equal to this CidrSet's cluster CIDR.

func (*CidrSet) IsFull

func (s *CidrSet) IsFull() bool

IsFull returns true if CidrSet does not have any more available CIDRs.

func (*CidrSet) Occupy

func (s *CidrSet) Occupy(prefix netip.Prefix) (err error)

Occupy marks the given prefix range as used. Occupy succeeds even if the prefix range was previously used.

func (*CidrSet) Prefix

func (s *CidrSet) Prefix() netip.Prefix

Prefix returns the CidrSet's prefix.

func (*CidrSet) Release

func (s *CidrSet) Release(prefix netip.Prefix) error

Release releases the given prefix range.

func (*CidrSet) String

func (s *CidrSet) String() string

Jump to

Keyboard shortcuts

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