Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteMapEntry(mapFD FD, k []byte) error
- func DeleteMapEntryIfExists(mapFD FD, k []byte) error
- func DisableRepin()
- func DumpMapCmd(m Map) ([]string, error)
- func EnableRepin()
- func GetMapEntry(mapFD FD, k []byte, valueSize int) ([]byte, error)
- func GetMapIdFromPin(pinPath string) (int, error)
- func IsNotExists(err error) bool
- func MapDeleteKeyCmd(m Map, key []byte) ([]string, error)
- func NumPossibleCPUs() int
- func RepinMap(name string, filename string) error
- func ResetSizes()
- func SetSize(name string, size int)
- func ShowMapCmd(m Map) ([]string, error)
- func Size(name string) int
- func UpdateMapEntry(mapFD FD, k, v []byte) error
- func UpdateMapEntryWithFlags(mapFD FD, k, v []byte, flags int) error
- func Upgrade(oldMap, newMap *PinnedMap) error
- type AsBytes
- type FD
- type IterCallback
- type Iterator
- type IteratorAction
- type Key
- type Map
- type MapInfo
- type MapParameters
- type MapWithDeleteIfExists
- type MapWithExistsCheck
- type MapWithUpdateWithFlags
- type PinnedMap
- func (b *PinnedMap) Close() error
- func (b *PinnedMap) CopyDeltaFromOldMap() error
- func (b *PinnedMap) Delete(k []byte) error
- func (b *PinnedMap) DeleteIfExists(k []byte) error
- func (b *PinnedMap) EnsureExists() error
- func (*PinnedMap) ErrIsNotExists(err error) bool
- func (b *PinnedMap) Get(k []byte) ([]byte, error)
- func (b *PinnedMap) GetName() string
- func (b *PinnedMap) Iter(f IterCallback) error
- func (b *PinnedMap) MapFD() FD
- func (b *PinnedMap) Open() error
- func (b *PinnedMap) Path() string
- func (b *PinnedMap) Update(k, v []byte) error
- func (b *PinnedMap) UpdateWithFlags(k, v []byte, flags int) error
- type TypedMap
- type Upgradable
- type Value
Constants ¶
const IteratorNumKeys = 16
Batch size established by trial and error; 8-32 seemed to be the sweet spot for the conntrack map.
Variables ¶
var ErrIterationFinished = errors.New("iteration finished")
ErrIterationFinished is returned by the Iterator's Next() method when there are no more keys.
var ErrNotSupported = fmt.Errorf("prog_array iteration not supported")
var ErrVisitedTooManyKeys = errors.New("visited 10x the max size of the map keys")
ErrVisitedTooManyKeys is returned by the Iterator's Next() method if it sees many more keys than there should be in the map.
Functions ¶
func DeleteMapEntry ¶
func DeleteMapEntryIfExists ¶
func DisableRepin ¶
func DisableRepin()
func DumpMapCmd ¶
DumpMapCmd returns the command that can be used to dump a map or an error
func EnableRepin ¶
func EnableRepin()
func GetMapIdFromPin ¶
func IsNotExists ¶
func NumPossibleCPUs ¶
func NumPossibleCPUs() int
func RepinMap ¶
RepinMap finds a map by a given name and pins it to a path. Note that if there are multiple maps of the same name in the system, it will use the first one it finds.
func ResetSizes ¶
func ResetSizes()
func ShowMapCmd ¶
func UpdateMapEntry ¶
Types ¶
type IterCallback ¶
type IterCallback func(k, v []byte) IteratorAction
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator handles one pass of iteration over the map.
func NewIterator ¶
func (*Iterator) Next ¶
Next gets the next key/value pair from the iteration. The key and value []byte slices returned point to the Iterator's internal buffers (which are allocated on the C heap); they should not be retained or modified. Returns ErrIterationFinished at the end of the iteration or ErrVisitedTooManyKeys if it visits considerably more keys than the maximum size of the map.
type IteratorAction ¶
type IteratorAction string
const ( IterNone IteratorAction = "" IterDelete IteratorAction = "delete" )
type Key ¶
type Key interface { comparable AsBytes }
type Map ¶
type Map interface { GetName() string // EnsureExists opens the map, creating and pinning it if needed. EnsureExists() error // Open opens the map, returns error if it does not exist. Open() error // Close closes the map, returns error for any error. Close() error // MapFD gets the file descriptor of the map, only valid after calling EnsureExists(). MapFD() FD // Path returns the path that the map is (to be) pinned to. Path() string // CopyDeltaFromOldMap() copies data from old map to new map CopyDeltaFromOldMap() error Iter(IterCallback) error Update(k, v []byte) error Get(k []byte) ([]byte, error) Delete(k []byte) error }
type MapInfo ¶
func GetMapInfo ¶
type MapParameters ¶
type MapParameters struct { PinDir string Type string KeySize int ValueSize int MaxEntries int Name string Flags int Version int UpdatedByBPF bool }
func (*MapParameters) VersionedFilename ¶
func (mp *MapParameters) VersionedFilename() string
func (*MapParameters) VersionedName ¶
func (mp *MapParameters) VersionedName() string
type MapWithDeleteIfExists ¶
type MapWithExistsCheck ¶
type MapWithUpdateWithFlags ¶
type PinnedMap ¶
type PinnedMap struct { MapParameters // Callbacks to handle upgrade UpgradeFn func(*PinnedMap, *PinnedMap) error GetMapParams func(int) MapParameters KVasUpgradable func(int, []byte, []byte) (Upgradable, Upgradable) // contains filtered or unexported fields }
func NewPinnedMap ¶
func NewPinnedMap(params MapParameters) *PinnedMap
func (*PinnedMap) CopyDeltaFromOldMap ¶
func (*PinnedMap) DeleteIfExists ¶
func (*PinnedMap) EnsureExists ¶
func (*PinnedMap) ErrIsNotExists ¶
func (*PinnedMap) Iter ¶
func (b *PinnedMap) Iter(f IterCallback) error
Iter iterates over the map, passing each key/value pair to the provided callback function. Warning: The key and value are owned by the iterator and will be clobbered by the next iteration so they must not be retained or modified.
type Upgradable ¶
type Upgradable interface { Upgrade() Upgradable AsBytes() []byte }
type Value ¶
type Value interface { comparable AsBytes }