strategycode

package
v0.0.0-...-c2e30b8 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: NIST-PD-fallback Imports: 10 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 an eBPF program 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.

Package strategycode manages forwarding strategy BPF programs.

Index

Constants

This section is empty.

Variables

View Source
var (
	GqlStrategyNodeType *gqlserver.NodeType
	GqlStrategyType     *graphql.Object
)

GraphQL types.

View Source
var (
	Xsyms  unsafe.Pointer
	NXsyms int
)

External symbols available to eBPF programs, provided by ndn-dpdk/app/fwdp package.

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 C.StrategyCode

Strategy is a reference of a forwarding strategy BPF program.

func Find

func Find(name string) *Strategy

Find retrieves strategy by name.

func FromPtr

func FromPtr(ptr unsafe.Pointer) *Strategy

FromPtr converts *C.Strategy to *Strategy.

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.

func MakeEmpty

func MakeEmpty(name string) *Strategy

MakeEmpty creates an empty BPF program. This is useful for unit testing.

func (*Strategy) Close

func (sc *Strategy) Close() error

Close reduces the number of references by one. The strategy will be unloaded when its reference count reaches zero.

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) 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

Jump to

Keyboard shortcuts

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