lxcmap

package
v1.10.6 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: Apache-2.0 Imports: 6 Imported by: 49

Documentation

Overview

Package lxcmap represents the endpoints BPF map in the BPF programs. It is implemented as a hash table containing an entry for all local endpoints. The hashtable can be accessed through the key EndpointKey and points which points to the value EndpointInfo. +groupName=maps

Index

Constants

View Source
const (
	MapName = "cilium_lxc"

	// MaxEntries represents the maximum number of endpoints in the map
	MaxEntries = 65535

	// PortMapMax represents the maximum number of Ports Mapping per container.
	PortMapMax = 16
)
View Source
const (
	// EndpointFlagHost indicates that this endpoint represents the host
	EndpointFlagHost = 1
)

Variables

View Source
var (
	// LXCMap represents the BPF map for endpoints
	LXCMap = bpf.NewMap(MapName,
		bpf.MapTypeHash,
		&EndpointKey{},
		int(unsafe.Sizeof(EndpointKey{})),
		&EndpointInfo{},
		int(unsafe.Sizeof(EndpointInfo{})),
		MaxEntries,
		0, 0,
		bpf.ConvertKeyValue,
	).WithCache().WithPressureMetric()
)

Functions

func AddHostEntry added in v0.10.0

func AddHostEntry(ip net.IP) error

AddHostEntry adds a special endpoint which represents the local host

func DeleteElement added in v0.10.0

func DeleteElement(f EndpointFrontend) []error

DeleteElement deletes the endpoint using all keys which represent the endpoint. It returns the number of errors encountered during deletion.

func DeleteEntry added in v0.15.7

func DeleteEntry(ip net.IP) error

DeleteEntry deletes a single map entry

func DumpToMap added in v0.15.7

func DumpToMap() (map[string]*EndpointInfo, error)

DumpToMap dumps the contents of the lxcmap into a map and returns it

func SyncHostEntry added in v0.15.7

func SyncHostEntry(ip net.IP) (bool, error)

SyncHostEntry checks if a host entry exists in the lxcmap and adds one if needed. Returns boolean indicating if a new entry was added and an error.

func WriteEndpoint added in v0.10.0

func WriteEndpoint(f EndpointFrontend) error

WriteEndpoint updates the BPF map with the endpoint information and links the endpoint information to all keys provided.

Types

type EndpointFrontend added in v0.10.0

type EndpointFrontend interface {
	LXCMac() mac.MAC
	GetNodeMAC() mac.MAC
	GetIfIndex() int
	GetID() uint64
	IPv4Address() addressing.CiliumIPv4
	IPv6Address() addressing.CiliumIPv6
}

EndpointFrontend is the interface to implement for an object to synchronize with the endpoint BPF map.

type EndpointInfo added in v0.10.0

type EndpointInfo struct {
	IfIndex uint32 `align:"ifindex"`
	Unused  uint16 `align:"unused"`
	LxcID   uint16 `align:"lxc_id"`
	Flags   uint32 `align:"flags"`

	MAC     MAC        `align:"mac"`
	NodeMAC MAC        `align:"node_mac"`
	Pad     pad4uint32 `align:"pad"`
	// contains filtered or unexported fields
}

EndpointInfo represents the value of the endpoints BPF map.

Must be in sync with struct endpoint_info in <bpf/lib/common.h> +k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=github.com/cilium/cilium/pkg/bpf.MapValue

func GetBPFValue added in v0.15.7

func GetBPFValue(e EndpointFrontend) (*EndpointInfo, error)

GetBPFValue returns the value which should represent this endpoint in the BPF endpoints map Must only be called if init() succeeded.

func (*EndpointInfo) DeepCopy added in v1.5.1

func (in *EndpointInfo) DeepCopy() *EndpointInfo

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointInfo.

func (*EndpointInfo) DeepCopyInto added in v1.5.1

func (in *EndpointInfo) DeepCopyInto(out *EndpointInfo)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*EndpointInfo) DeepCopyMapValue added in v1.5.1

func (in *EndpointInfo) DeepCopyMapValue() bpf.MapValue

DeepCopyMapValue is an autogenerated deepcopy function, copying the receiver, creating a new bpf.MapValue.

func (*EndpointInfo) GetValuePtr added in v0.10.0

func (v *EndpointInfo) GetValuePtr() unsafe.Pointer

GetValuePtr returns the unsafe pointer to the BPF value

func (*EndpointInfo) IsHost added in v0.15.7

func (v *EndpointInfo) IsHost() bool

IsHost returns true if the EndpointInfo represents a host IP

func (*EndpointInfo) String added in v0.10.0

func (v *EndpointInfo) String() string

String returns the human readable representation of an EndpointInfo

type EndpointKey added in v0.10.0

type EndpointKey struct {
	bpf.EndpointKey
}

+k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=github.com/cilium/cilium/pkg/bpf.MapKey

func GetBPFKeys added in v0.15.7

func GetBPFKeys(e EndpointFrontend) []*EndpointKey

GetBPFKeys returns all keys which should represent this endpoint in the BPF endpoints map

func NewEndpointKey added in v0.10.0

func NewEndpointKey(ip net.IP) *EndpointKey

NewEndpointKey returns an EndpointKey based on the provided IP address. The address family is automatically detected

func (*EndpointKey) DeepCopy added in v1.5.1

func (in *EndpointKey) DeepCopy() *EndpointKey

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EndpointKey.

func (*EndpointKey) DeepCopyInto added in v1.5.1

func (in *EndpointKey) DeepCopyInto(out *EndpointKey)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*EndpointKey) DeepCopyMapKey added in v1.5.1

func (in *EndpointKey) DeepCopyMapKey() bpf.MapKey

DeepCopyMapKey is an autogenerated deepcopy function, copying the receiver, creating a new bpf.MapKey.

func (EndpointKey) NewValue added in v0.10.0

func (k EndpointKey) NewValue() bpf.MapValue

NewValue returns a new empty instance of the structure representing the BPF map value

type MAC

type MAC uint64

MAC is the __u64 representation of a MAC address.

func (MAC) String

func (m MAC) String() string

Jump to

Keyboard shortcuts

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