bpfcache

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxPortNum = 10
)
View Source
const (
	MaxServiceNum = 10
)

Variables

This section is empty.

Functions

func CleanupFakeWorkloadMap

func CleanupFakeWorkloadMap(maps bpf2go.KmeshCgroupSockWorkloadMaps)

func LookupAll

func LookupAll[K any, V any](bpfMap *ebpf.Map) []V

Types

type BackendKey

type BackendKey struct {
	BackendUid uint32 // workloadUid to uint32
}

type BackendValue

type BackendValue struct {
	Ip           [16]byte
	ServiceCount uint32
	Services     ServiceList
	WaypointAddr [16]byte
	WaypointPort uint32
}

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache(workloadMap bpf2go.KmeshCgroupSockWorkloadMaps) *Cache

func (*Cache) BackendCount

func (c *Cache) BackendCount() int

BackendCount returns the length of backend map Note only used for testing

func (*Cache) BackendDelete

func (c *Cache) BackendDelete(key *BackendKey) error

func (*Cache) BackendLookup

func (c *Cache) BackendLookup(key *BackendKey, value *BackendValue) error

func (*Cache) BackendLookupAll

func (c *Cache) BackendLookupAll() []BackendValue

func (*Cache) BackendUpdate

func (c *Cache) BackendUpdate(key *BackendKey, value *BackendValue) error

func (*Cache) EndpointCount

func (c *Cache) EndpointCount() int

EndpointCount returns the length of endpoint map Note only used for testing

func (*Cache) EndpointDelete

func (c *Cache) EndpointDelete(key *EndpointKey) error

func (*Cache) EndpointLookup

func (c *Cache) EndpointLookup(key *EndpointKey, value *EndpointValue) error

func (*Cache) EndpointLookupAll

func (c *Cache) EndpointLookupAll() []EndpointValue

func (*Cache) EndpointSwap

func (c *Cache) EndpointSwap(currentIndex, lastIndex uint32, serviceId uint32) error

EndpointSwap update the last endpoint index and remove the current endpoint

func (*Cache) EndpointUpdate

func (c *Cache) EndpointUpdate(key *EndpointKey, value *EndpointValue) error

func (*Cache) FrontendCount

func (c *Cache) FrontendCount() int

FrontendCount returns the length of frontend map Note only used for testing

func (*Cache) FrontendDelete

func (c *Cache) FrontendDelete(key *FrontendKey) error

func (*Cache) FrontendIterFindKey

func (c *Cache) FrontendIterFindKey(upstreamId uint32) []FrontendKey

func (*Cache) FrontendLookup

func (c *Cache) FrontendLookup(key *FrontendKey, value *FrontendValue) error

func (*Cache) FrontendLookupAll

func (c *Cache) FrontendLookupAll() []FrontendValue

func (*Cache) FrontendUpdate

func (c *Cache) FrontendUpdate(key *FrontendKey, value *FrontendValue) error

func (*Cache) GetAllEndpointsForService

func (c *Cache) GetAllEndpointsForService(serviceId uint32) []EndpointValue

GetAllEndpointsForService returns all the endpoints for a service Note only used for testing

func (*Cache) GetEndpointKeys

func (c *Cache) GetEndpointKeys(workloadID uint32) sets.Set[EndpointKey]

func (*Cache) RestoreEndpointKeys

func (c *Cache) RestoreEndpointKeys()

RestoreEndpointKeys called on restart to construct endpoint indexes from bpf map

func (*Cache) ServiceCount

func (c *Cache) ServiceCount() int

ServiceCount returns the length of service map Note only used for testing

func (*Cache) ServiceDelete

func (c *Cache) ServiceDelete(key *ServiceKey) error

func (*Cache) ServiceLookup

func (c *Cache) ServiceLookup(key *ServiceKey, value *ServiceValue) error

func (*Cache) ServiceLookupAll

func (c *Cache) ServiceLookupAll() []ServiceValue

func (*Cache) ServiceUpdate

func (c *Cache) ServiceUpdate(key *ServiceKey, value *ServiceValue) error

func (*Cache) WorkloadPolicyDelete

func (c *Cache) WorkloadPolicyDelete(key *WorkloadPolicyKey) error

func (*Cache) WorkloadPolicyLookup

func (c *Cache) WorkloadPolicyLookup(key *WorkloadPolicyKey, value *WorkloadPolicyValue) error

func (*Cache) WorkloadPolicyLookupAll

func (c *Cache) WorkloadPolicyLookupAll() []WorkloadPolicyValue

func (*Cache) WorkloadPolicyUpdate

func (c *Cache) WorkloadPolicyUpdate(key *WorkloadPolicyKey, value *WorkloadPolicyValue) error

type EndpointKey

type EndpointKey struct {
	ServiceId    uint32 // service id
	BackendIndex uint32 // if endpoint_count = 3, then backend_index = 1/2/3
}

type EndpointValue

type EndpointValue struct {
	BackendUid uint32 // workloadUid to uint32
}

type FrontendKey

type FrontendKey struct {
	Ip [16]byte // Service ip or Pod ip
}

type FrontendValue

type FrontendValue struct {
	UpstreamId uint32 // service id for Service access or backend uid for Pod access
}

type ServiceKey

type ServiceKey struct {
	ServiceId uint32 // service id
}

type ServiceList

type ServiceList [MaxServiceNum]uint32

type ServicePorts

type ServicePorts [MaxPortNum]uint32

type ServiceValue

type ServiceValue struct {
	EndpointCount uint32       // endpoint count of current service
	LbPolicy      uint32       // load balancing algorithm, currently only supports random algorithm
	ServicePort   ServicePorts // ServicePort[i] and TargetPort[i] are a pair, i starts from 0 and max value is MaxPortNum-1
	TargetPort    TargetPorts
	WaypointAddr  [16]byte
	WaypointPort  uint32
}

type TargetPorts

type TargetPorts [MaxPortNum]uint32

type WorkloadPolicyKey

type WorkloadPolicyKey struct {
	WorklodId uint32 // workloadIp to uint32
}

type WorkloadPolicyValue

type WorkloadPolicyValue struct {
	PolicyIds [4]uint32 // name length is [MAX_MEMBER_NUM_PER_POLICY]
}

Jump to

Keyboard shortcuts

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