loader

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2019 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Overview

Package loader provides accessors to compilation and BPF load routines necessary for creating datapath objects and attaching them to links.

Index

Constants

This section is empty.

Variables

View Source
var (
	TemplateSecurityID = identity.ReservedIdentityWorld
	TemplateLxcID      = uint16(65535)
	TemplateMAC        = mac.MAC([]byte{0x02, 0x00, 0x60, 0x0D, 0xF0, 0x0D})
	TemplateIPv4       = []byte{192, 0, 2, 3}
	TemplateIPv6       = []byte{0x20, 0x01, 0xdb, 0x8, 0x0b, 0xad, 0xca, 0xfe, 0x60, 0x0d, 0xbe, 0xe2, 0x0b, 0xad, 0xca, 0xfe}

	CallsMapName = "cilium_calls_"
)
View Source
var (
	// DatapathSHA is set during build to the SHA generated from bindata.sh
	// which is hashed across all datapath template code, excluding the
	// node, netdev, lxc and sockops header files (see daemon/Makefile).
	DatapathSHA string
)
View Source
var (
	Subsystem = "datapath-loader"
)

Functions

func Compile

func Compile(ctx context.Context, src string, out string) error

Compile compiles a BPF program generating an object file.

func CompileAndLoad

func CompileAndLoad(ctx context.Context, ep endpoint) error

CompileAndLoad compiles the BPF datapath programs for the specified endpoint and loads it onto the interface associated with the endpoint.

Expects the caller to have created the directory at the path ep.StateDir().

func CompileOrLoad

func CompileOrLoad(ctx context.Context, ep endpoint, stats *SpanStat) error

CompileOrLoad loads the BPF datapath programs for the specified endpoint.

In contrast with CompileAndLoad(), it attempts to find a pre-compiled template datapath object to use, to avoid a costly compile operation. Only if there is no existing template that has the same configuration parameters as the specified endpoint, this function will compile a new template for this configuration.

This function will block if the cache does not contain an entry for the same EndpointConfiguration and multiple goroutines attempt to concurrently CompileOrLoad with the same configuration parameters. When the first goroutine completes compilation of the template, all other CompileOrLoad invocations will be released.

func DeleteDatapath

func DeleteDatapath(ctx context.Context, ifName, direction string) error

DeleteDatapath filter from the given ifName

func ELFSubstitutions

func ELFSubstitutions(ep endpoint) (map[string]uint32, map[string]string)

ELFSubstitutions fetches the set of variable and map substitutions that must be implemented against an ELF template to configure the datapath for the specified endpoint.

func EndpointHash

func EndpointHash(cfg datapath.EndpointConfiguration) (string, error)

EndpointHash hashes the specified endpoint configuration with the current datapath hash cache and returns the hash as string.

func Init

Init initializes the datapath cache with base program hashes derived from the LocalNodeConfiguration.

func NewObjectCache

func NewObjectCache(dp datapath.Datapath, nodeCfg *datapath.LocalNodeConfiguration) *objectCache

NewObjectCache creates a new cache for datapath objects, basing the hash upon the configuration of the datapath and the specified node configuration.

func ReloadDatapath

func ReloadDatapath(ctx context.Context, ep endpoint, stats *SpanStat) (err error)

func RestoreTemplates

func RestoreTemplates(stateDir string) error

RestoreTemplates populates the object cache from templates on the filesystem at the specified path.

Types

type OutputType

type OutputType string

OutputType determines the type to be generated by the compilation steps.

type SpanStat

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

SpanStat is a statistics structure for storing metrics related to datapath load operations.

func (*SpanStat) GetMap

func (s *SpanStat) GetMap() map[string]*spanstat.SpanStat

GetMap returns a map of statistic names to stats

Jump to

Keyboard shortcuts

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