Documentation
¶
Overview ¶
Package kf provides primitives for BPF programs / Network Functions.
Package kf provides primitives for l3afd's network function configs.
Package kf provides primitives for NF process monitoring.
Package kf provides primitives for l3afd's network function configs.
Package kf provides primitives for NF process monitoring.
Index ¶
- func BinarySearch(names []string, target string) bool
- func DisableLRO(ifaceName string) error
- func GetPlatform() (string, error)
- func GetTestExecutableName() string
- func GetTestExecutablePath() string
- func GetTestExecutablePathName() string
- func GetTestNonexecutablePathName() string
- func IsProcessRunning(pid int, name string) (bool, error)
- func NewpCheck(rc int, chain bool, interval time.Duration) *pCheck
- func NewpKFMetrics(chain bool, interval int) *kfMetrics
- func SetupKFDebug(ebpfChainDebugAddr string, kfConfigs *NFConfigs)
- func StopExternalRunningProcess(processName string) error
- func ValidatePath(filePath string, destination string) (string, error)
- func VerifyNMountBPFFS() error
- func VerifyNMountTraceFS() error
- func ViewHandler(w http.ResponseWriter, r *http.Request)
- type BPF
- func (b *BPF) AddBPFMap(mapName string) error
- func (b *BPF) AddMetricsBPFMap(mapName, aggregator string, key, samplesLength int) error
- func (b *BPF) GetArtifacts(conf *config.Config) error
- func (b *BPF) GetBPFMap(mapName string) (*BPFMap, error)
- func (b *BPF) GetProgID() (int, error)
- func (b *BPF) MonitorMaps(ifaceName string, intervals int) error
- func (b *BPF) ProcessTerminate() error
- func (b *BPF) PutNextProgFDFromID(progID int) error
- func (b *BPF) RemoveNextProgFD() error
- func (b *BPF) RemovePrevProgFD() error
- func (b *BPF) RunKFConfigs() error
- func (b *BPF) SetPrLimits() error
- func (b *BPF) Start(ifaceName, direction string, chain bool) error
- func (b *BPF) Stop(ifaceName, direction string, chain bool) error
- func (b *BPF) Update(ifaceName, direction string) error
- func (b *BPF) VerifyAndGetArtifacts(conf *config.Config) error
- func (b *BPF) VerifyMetricsMapsVanish() error
- func (b *BPF) VerifyPinnedMapExists(chain bool) error
- func (b *BPF) VerifyPinnedMapVanish(chain bool) error
- func (b *BPF) VerifyProcessObject() error
- type BPFMap
- type MetricsBPFMap
- type NFConfigs
- func (c *NFConfigs) AddAndStartBPF(bpfProg *models.BPFProgram, ifaceName string, direction string) error
- func (c *NFConfigs) AddProgramWithoutChaining(ifaceName string, bpfProgs *models.BPFPrograms) error
- func (c *NFConfigs) AddProgramsOnInterface(ifaceName, HostName string, bpfProgs *models.BPFPrograms) error
- func (c *NFConfigs) AddeBPFPrograms(bpfProgs []models.L3afBPFPrograms) error
- func (c *NFConfigs) Close(ctx context.Context) error
- func (c *NFConfigs) DeleteEbpfPrograms(bpfProgs []models.L3afBPFProgramNames) error
- func (c *NFConfigs) DeleteProgramsOnInterface(ifaceName, HostName string, bpfProgs *models.BPFProgramNames) error
- func (c *NFConfigs) DeleteProgramsOnInterfaceHelper(e *list.Element, ifaceName string, direction string, bpfList *list.List) error
- func (c *NFConfigs) Deploy(ifaceName, HostName string, bpfProgs *models.BPFPrograms) error
- func (c *NFConfigs) DeployeBPFPrograms(bpfProgs []models.L3afBPFPrograms) error
- func (c *NFConfigs) DownloadAndStartBPFProgram(element *list.Element, ifaceName, direction string) error
- func (c *NFConfigs) EBPFPrograms(iface string) models.L3afBPFPrograms
- func (c *NFConfigs) EBPFProgramsAll() []models.L3afBPFPrograms
- func (c *NFConfigs) InsertAndStartBPFProgram(bpfProg *models.BPFProgram, ifaceName, direction string) error
- func (c *NFConfigs) KFDetails(iface string) []*BPF
- func (c *NFConfigs) LinkBPFPrograms(leftBPF, rightBPF *BPF) error
- func (c *NFConfigs) MoveToLocation(element *list.Element, bpfList *list.List) error
- func (c *NFConfigs) PushBackAndStartBPF(bpfProg *models.BPFProgram, ifaceName, direction string) error
- func (c *NFConfigs) RemoveMissingBPFProgramsInConfig(bpfProg models.L3afBPFPrograms, ifaceName, direction string) error
- func (c *NFConfigs) RemoveMissingNetIfacesNBPFProgsInConfig(bpfProgCfgs []models.L3afBPFPrograms) error
- func (c *NFConfigs) SaveConfigsToConfigStore() error
- func (c *NFConfigs) StopNRemoveAllBPFPrograms(ifaceName, direction string) error
- func (c *NFConfigs) StopRootProgram(ifaceName, direction string) error
- func (c *NFConfigs) VerifyAndStartTCRootProgram(ifaceName, direction string) error
- func (c *NFConfigs) VerifyAndStartXDPRootProgram(ifaceName, direction string) error
- func (c *NFConfigs) VerifyNUpdateBPFProgram(bpfProg *models.BPFProgram, ifaceName, direction string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinarySearch ¶
BinarySearch: It is checking a target string exists in sorted slice of strings
func DisableLRO ¶
DisableLRO - XDP programs are failing when LRO is enabled, to fix this we use to manually disable. # ethtool -K ens7 lro off # ethtool -k ens7 | grep large-receive-offload large-receive-offload: off
func GetPlatform ¶
This method get the Linux distribution Codename. This logic works on ubuntu Here assumption is all edge nodes are running with lsb modules. It returns empty string in case of error
func GetTestExecutableName ¶
func GetTestExecutableName() string
func GetTestExecutablePath ¶
func GetTestExecutablePath() string
func GetTestExecutablePathName ¶
func GetTestExecutablePathName() string
func GetTestNonexecutablePathName ¶
func GetTestNonexecutablePathName() string
func NewpKFMetrics ¶
func SetupKFDebug ¶
func StopExternalRunningProcess ¶
Stop the NF process if running outside l3afd
func VerifyNMountTraceFS ¶
func VerifyNMountTraceFS() error
VerifyNMounTraceFS - Mounting trace filesystem
func ViewHandler ¶
func ViewHandler(w http.ResponseWriter, r *http.Request)
Types ¶
type BPF ¶
type BPF struct { Program models.BPFProgram Cmd *exec.Cmd FilePath string // Binary file path RestartCount int // To track restart count PrevMapNamePath string // Previous Map name with path to link MapNamePath string // Map name with path ProgID int // eBPF Program ID BpfMaps map[string]BPFMap // Config maps passed as map-args, Map name is Key MetricsBpfMaps map[string]*MetricsBPFMap // Metrics map name+key+aggregator is key Ctx context.Context Done chan bool `json:"-"` // contains filtered or unexported fields }
BPF defines run time details for BPFProgram.
func LoadRootProgram ¶
func LoadRootProgram(ifaceName string, direction string, progType string, conf *config.Config) (*BPF, error)
LoadRootProgram - Loading the Root Program for a given interface.
func NewBpfProgram ¶
func (*BPF) AddMetricsBPFMap ¶
Add eBPF map into BPFMaps list
func (*BPF) GetArtifacts ¶
GetArtifacts downloads artifacts from the specified eBPF repo
func (*BPF) MonitorMaps ¶
This method to fetch values from bpf maps and publish to metrics
func (*BPF) ProcessTerminate ¶
ProcessTerminate - Send sigterm to the process
func (*BPF) PutNextProgFDFromID ¶
Updating next program FD from program ID
func (*BPF) RemoveNextProgFD ¶
Delete the entry if its last program in the chain. This method is called when sequence of the program changed to last in the chain
func (*BPF) RemovePrevProgFD ¶
Delete the entry if the last element
func (*BPF) RunKFConfigs ¶
func (*BPF) SetPrLimits ¶
Set process resource limits only non-zero value
func (*BPF) Start ¶
Start returns the last error seen, but starts bpf program. Here initially prevprogmap entry is removed and passed to the bpf program After starting the user program, will update the kernel progam fd into prevprogram map. This method waits till prog fd entry is updated, else returns error assuming kernel program is not loaded. It also verifies the next program pinned map is created or not.
func (*BPF) Stop ¶
Stop returns the last error seen, but stops bpf program. Clean up all map handles. Verify next program pinned map file is removed
func (*BPF) VerifyAndGetArtifacts ¶
Check binary already exists
func (*BPF) VerifyMetricsMapsVanish ¶
VerifyMetricsMapsVanish - checks for all metrics maps references are removed from the kernel
func (*BPF) VerifyPinnedMapExists ¶
making sure program fd map's pinned file is created
func (*BPF) VerifyPinnedMapVanish ¶
VerifyPinnedMapVanish - making sure XDP program fd map's pinned file is removed
func (*BPF) VerifyProcessObject ¶
This method to verify cmd and process object is populated or not
type BPFMap ¶
type BPFMap struct { Name string MapID ebpf.MapID Type ebpf.MapType // BPFProg reference in case of stale map id BPFProg *BPF `json:"-"` }
func (*BPFMap) Update ¶
The update function is used to update eBPF maps, which are used by network functions. Supported types are Array and Hash Multiple values are comma separated Hashmap can be multiple values or single values. If hash map entries then key will be values and value will be set to 1 In case of Array then key will be index starting from 0 and values are stored. for e.g.
HashMap scenario 1. --ports="80,443" values are stored in rl_ports_map BPF map key => 80 value => 1 key => 443 value => 1 HashMap scenario 2. --ports="443" value is stored in rl_ports_map BPF map key => 443 value => 1 Array scenario 1. --ports="80,443" values are stored in rl_ports_map BPF map key => 0 value => 80 key => 1 value => 443 Array scenario 2. --rate="10000" value is stored in rl_config_map BPF map key => 0 value => 10000
type MetricsBPFMap ¶
This stores Metrics map details.
func (*MetricsBPFMap) AvgValue ¶
func (b *MetricsBPFMap) AvgValue() float64
This method calculates the average
func (*MetricsBPFMap) GetValue ¶
func (b *MetricsBPFMap) GetValue() float64
Get value of the map for given key There are 2 aggregators are supported here max-rate - this calculates delta requests / sec and stores absolute value. avg - stores the values in the circular queue We can implement more aggregate function as needed.
func (*MetricsBPFMap) MaxValue ¶
func (b *MetricsBPFMap) MaxValue() float64
This method finds the max value in the circular list
type NFConfigs ¶
type NFConfigs struct { HostName string // configs sync.Map // key: string, val: *models.L3afDNFConfigDetail // These holds bpf programs in the list // map keys are network iface names index's are seq_id, position in the chain // root element will be root program IngressXDPBpfs map[string]*list.List IngressTCBpfs map[string]*list.List EgressTCBpfs map[string]*list.List HostConfig *config.Config // contains filtered or unexported fields }
func NewNFConfigs ¶
func (*NFConfigs) AddAndStartBPF ¶
func (*NFConfigs) AddProgramWithoutChaining ¶
func (c *NFConfigs) AddProgramWithoutChaining(ifaceName string, bpfProgs *models.BPFPrograms) error
AddProgramWithoutChaining : add eBPF program on given interface when chaining is not enabled
func (*NFConfigs) AddProgramsOnInterface ¶
func (c *NFConfigs) AddProgramsOnInterface(ifaceName, HostName string, bpfProgs *models.BPFPrograms) error
AddProgramsOnInterface: AddProgramsOnInterface will add given ebpf programs on given interface
func (*NFConfigs) AddeBPFPrograms ¶
func (c *NFConfigs) AddeBPFPrograms(bpfProgs []models.L3afBPFPrograms) error
AddeBPFPrograms - Starts eBPF programs on the node if they are not running
func (*NFConfigs) DeleteEbpfPrograms ¶
func (c *NFConfigs) DeleteEbpfPrograms(bpfProgs []models.L3afBPFProgramNames) error
DeleteEbpfPrograms - Delete eBPF programs on the node if they are running
func (*NFConfigs) DeleteProgramsOnInterface ¶
func (c *NFConfigs) DeleteProgramsOnInterface(ifaceName, HostName string, bpfProgs *models.BPFProgramNames) error
DeleteProgramsOnInterface : It will delete ebpf Programs on the given interface
func (*NFConfigs) DeleteProgramsOnInterfaceHelper ¶
func (c *NFConfigs) DeleteProgramsOnInterfaceHelper(e *list.Element, ifaceName string, direction string, bpfList *list.List) error
DeleteProgramsOnInterfaceHelper : helper function for DeleteProgramsOnInterface function
func (*NFConfigs) Deploy ¶
func (c *NFConfigs) Deploy(ifaceName, HostName string, bpfProgs *models.BPFPrograms) error
func (*NFConfigs) DeployeBPFPrograms ¶
func (c *NFConfigs) DeployeBPFPrograms(bpfProgs []models.L3afBPFPrograms) error
DeployeBPFPrograms - Starts eBPF programs on the node if they are not running
func (*NFConfigs) DownloadAndStartBPFProgram ¶
func (*NFConfigs) EBPFPrograms ¶
func (c *NFConfigs) EBPFPrograms(iface string) models.L3afBPFPrograms
EBPFPrograms - Method provides list of eBPF Programs running on iface
func (*NFConfigs) EBPFProgramsAll ¶
func (c *NFConfigs) EBPFProgramsAll() []models.L3afBPFPrograms
EBPFProgramsAll - Method provides list of eBPF Programs running on all ifaces on the host
func (*NFConfigs) InsertAndStartBPFProgram ¶
func (c *NFConfigs) InsertAndStartBPFProgram(bpfProg *models.BPFProgram, ifaceName, direction string) error
InsertAndStartBPFProgram method for tc programs
func (*NFConfigs) LinkBPFPrograms ¶
Link BPF programs
func (*NFConfigs) MoveToLocation ¶
func (*NFConfigs) PushBackAndStartBPF ¶
func (c *NFConfigs) PushBackAndStartBPF(bpfProg *models.BPFProgram, ifaceName, direction string) error
This method inserts the element at the end of the list
func (*NFConfigs) RemoveMissingBPFProgramsInConfig ¶
func (c *NFConfigs) RemoveMissingBPFProgramsInConfig(bpfProg models.L3afBPFPrograms, ifaceName, direction string) error
RemoveMissingBPFProgramsInConfig - This method to stop the eBPF programs which are not listed in the config.
func (*NFConfigs) RemoveMissingNetIfacesNBPFProgsInConfig ¶
func (c *NFConfigs) RemoveMissingNetIfacesNBPFProgsInConfig(bpfProgCfgs []models.L3afBPFPrograms) error
RemoveMissingNetIfacesNBPFProgsInConfig - Stops running eBPF programs which are missing in the config
func (*NFConfigs) SaveConfigsToConfigStore ¶
SaveConfigsToConfigStore - Writes configs to persistent store
func (*NFConfigs) StopNRemoveAllBPFPrograms ¶
Stopping all programs in order
func (*NFConfigs) StopRootProgram ¶
StopRootProgram -This method stops the root program, removes the root node from the list and reset the list to nil
func (*NFConfigs) VerifyAndStartTCRootProgram ¶
Check for TC root program is running for a interface. If not start it
func (*NFConfigs) VerifyAndStartXDPRootProgram ¶
Check for XDP programs are not loaded then initialise the array Check for XDP root program is running for a interface. if not loaded it
func (*NFConfigs) VerifyNUpdateBPFProgram ¶
func (c *NFConfigs) VerifyNUpdateBPFProgram(bpfProg *models.BPFProgram, ifaceName, direction string) error
VerifyNUpdateBPFProgram - This method checks the following conditions 1. BPF Program already running with no change 2. BPF Program running but needs to stop (admin_status == disabled) 3. BPF Program running but needs version update 4. BPF Program running but position change (seq_id change) 5. BPF Program not running but needs to start.