strategycode

package
v0.0.0-...-1e60831 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: NIST-PD-fallback Imports: 16 Imported by: 0

README

ndn-dpdk/container/strategycode

This package manages the BPF programs of NDN-DPDK's forwarding strategies. Every loaded strategy is identified by a numeric ID and has a (non-unique) short name for presentation purposes.

Strategy Loader

This package loads eBPF programs from an ELF object using two libraries: the DPDK BPF library and the uBPF library. DPDK contains a BPF validator that disallows loops, which is necessary for a forwarding strategy. uBPF has a limited ELF parser that is unable to handle ELF objects compiled by clang-4.0 and later.

To make these two libraries work together, load.c monkey-patches the rte_bpf_load function. When loading a strategy ELF object:

  1. The Load function writes the ELF object to a temporary file.
  2. DPDK's rte_bpf_elf_load reads the file and processes the relocations.
  3. The rte_bpf_load monkey patch receives eBPF instructions and passes them to uBPF.
  4. A struct ubpf_vm* pointer is stored into the bpf->prm.xsym variable.

Documentation

Overview

Package strategycode manages forwarding strategy BPF programs.

Index

Constants

This section is empty.

Variables

View Source
var (
	GqlStrategyType *gqlserver.NodeType[*Strategy]
)

GraphQL types.

Functions

func DestroyAll

func DestroyAll()

DestroyAll immediately unloads all strategies. Panics if some strategies are still used in FIB entry.

Types

type Strategy

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

Strategy is a reference of a forwarding strategy.

func Find

func Find(name string) *Strategy

Find retrieves strategy by name.

func Get

func Get(id int) *Strategy

Get retrieves strategy by numeric ID.

func List

func List() []*Strategy

List returns a list of loaded strategies.

func Load

func Load(name string, elf []byte) (sc *Strategy, e error)

Load loads a strategy BPF program from ELF object.

func LoadFile

func LoadFile(name, filename string) (sc *Strategy, e error)

LoadFile loads a strategy BPF program from ELF file. If filename is empty, search for an ELF file in default locations.

func MakeEmpty

func MakeEmpty(name string) *Strategy

MakeEmpty returns an empty strategy for unit testing. Panics on error.

func (*Strategy) CountRefs

func (sc *Strategy) CountRefs() int

CountRefs returns number of references. Each FIB entry using the strategy has a reference. There's also a reference from table.go.

func (*Strategy) ID

func (sc *Strategy) ID() int

ID returns numeric ID.

func (*Strategy) InitFunc

func (sc *Strategy) InitFunc() func(arg unsafe.Pointer, sizeofArg uintptr) uint64

InitFunc returns the init function, or nil if it does not exist.

func (*Strategy) Name

func (sc *Strategy) Name() string

Name returns short name.

func (*Strategy) Ptr

func (sc *Strategy) Ptr() unsafe.Pointer

Ptr returns *C.Strategy pointer.

func (*Strategy) String

func (sc *Strategy) String() string

func (*Strategy) Unref

func (sc *Strategy) Unref()

Unref reduces the number of references by one. The strategy cannot be retrieved via Get(), Find(), List(). It will be unloaded when its reference count reaches zero.

func (*Strategy) ValidateParams

func (sc *Strategy) ValidateParams(params map[string]any) error

ValidateParams validates JSON parameters.

type Xsyms

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

Xsyms references eBPF external symbols.

var (
	XsymsMain Xsyms // fwdp init
	XsymsInit Xsyms
)

External symbols available to eBPF programs.

func (*Xsyms) Assign

func (x *Xsyms) Assign(ptr unsafe.Pointer, n int)

Assign sets eBPF external symbols.

Jump to

Keyboard shortcuts

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