counter

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package counter provides generic reference counter objects

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IntCounter

type IntCounter map[int]int

IntCounter tracks references for integers with an optional limiter.

No threadsafety is provided within this structure, the user is expected to handle concurrent access to this structure if it is used from multiple threads.

func (IntCounter) Add

func (i IntCounter) Add(key int) (changed bool)

Add increments the reference count for the specified integer key.

func (IntCounter) DeepCopy

func (i IntCounter) DeepCopy() IntCounter

DeepCopy makes a new copy of the received IntCounter.

func (IntCounter) Delete

func (i IntCounter) Delete(key int) bool

Delete decrements the reference count for the specified integer key.

func (IntCounter) ToBPFData

func (i IntCounter) ToBPFData() []int

ToBPFData returns the keys as a slice, sorted from high to low.

type PrefixLengthCounter

type PrefixLengthCounter struct {
	lock.RWMutex
	// contains filtered or unexported fields
}

PrefixLengthCounter tracks references to prefix lengths, limited by the maxUniquePrefixes count. Neither of the IPv4 or IPv6 counters nested within may contain more keys than the specified maximum number of unique prefixes.

func NewPrefixLengthCounter

func NewPrefixLengthCounter(maxUniquePrefixes6, maxUniquePrefixes4 int) *PrefixLengthCounter

NewPrefixLengthCounter returns a new PrefixLengthCounter which limits insertions to the specified maximum number of unique prefix lengths.

func (*PrefixLengthCounter) Add

func (p *PrefixLengthCounter) Add(prefixes []*net.IPNet) (bool, error)

Add increments references to prefix lengths for the specified IPNets to the counter. If the maximum number of unique prefix lengths would be exceeded, returns an error.

Returns true if adding these prefixes results in an increase in the total number of unique prefix lengths in the counter.

func (*PrefixLengthCounter) Delete

func (p *PrefixLengthCounter) Delete(prefixes []*net.IPNet) (changed bool)

Delete reduces references to prefix lengths in the the specified IPNets from the counter. Returns true if removing references to these prefix lengths would result in a decrese in the total number of unique prefix lengths in the counter.

func (*PrefixLengthCounter) ToBPFData

func (p *PrefixLengthCounter) ToBPFData() (s6, s4 []int)

ToBPFData converts the counter into a set of prefix lengths that the BPF datapath can use for LPM lookup.

Jump to

Keyboard shortcuts

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