common

package
v1.9.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: Apache-2.0 Imports: 8 Imported by: 9

Documentation

Index

Constants

View Source
const (

	// OperationalPath is the base path to store the operational details in the kvstore.
	OperationalPath = "cilium-net/operational"

	// ServicesKeyPath is the base path where services are stored in the kvstore.
	ServicesKeyPath = OperationalPath + "/ServicesV2/SHA256SUMServices"
	// ServicePathV1 is the base path for the services stored in the kvstore.
	ServicePathV1 = OperationalPath + "/Services/"

	// NodeConfigFile is the name of the C header which contains the node's
	// network parameters.
	NodeConfigFile = "node_config.h"
	// CHeaderFileName is the name of the C header file for BPF programs for a
	// particular endpoint.
	CHeaderFileName = "ep_config.h"
	// OldCHeaderFileName is the previous name of the C header file for BPF
	// programs for a particular endpoint. It can be removed once Cilium v1.8
	// is the oldest supported version.
	OldCHeaderFileName = "lxc_config.h"
	// NetdevHeaderFileName is the name of the header file used for bpf_host.c and bpf_overlay.c.
	NetdevHeaderFileName = "netdev_config.h"
	// PreFilterHeaderFileName is the name of the header file used for bpf_xdp.c.
	PreFilterHeaderFileName = "filter_config.h"
	// HostObjFileName is the name of the host object file.
	HostObjFileName = "bpf_host.o"
	// CiliumCHeaderPrefix is the prefix using when printing/writing an endpoint in a
	// base64 form.
	CiliumCHeaderPrefix = "CILIUM_BASE64_"

	// PossibleCPUSysfsPath is used to retrieve the number of CPUs for per-CPU maps.
	PossibleCPUSysfsPath = "/sys/devices/system/cpu/possible"
)

Variables

This section is empty.

Functions

func C2GoArray

func C2GoArray(str string) []byte

C2GoArray transforms an hexadecimal string representation into a byte slice. Example: str := "0x12, 0xff, 0x0, 0x1" fmt.Print(C2GoArray(str)) //`{0x12, 0xFF, 0x0, 0x01}`"

func GetNumPossibleCPUs

func GetNumPossibleCPUs(log *logrus.Entry) int

GetNumPossibleCPUs returns a total number of possible CPUS, i.e. CPUs that have been allocated resources and can be brought online if they are present. The number is retrieved by parsing /sys/device/system/cpu/possible.

See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/cpumask.h?h=v4.19#n50 for more details.

func GoArray2C

func GoArray2C(array []byte) string

GoArray2C transforms a byte slice into its hexadecimal string representation. Example: array := []byte{0x12, 0xFF, 0x0, 0x01} fmt.Print(GoArray2C(array)) // "{ 0x12, 0xff, 0x0, 0x1 }"

func GoArray2CNoSpaces

func GoArray2CNoSpaces(array []byte) string

GoArray2CNoSpaces does the same as GoArray2C, but no spaces are used in the final output. Example: array := []byte{0x12, 0xFF, 0x0, 0x01} fmt.Print(GoArray2CNoSpaces(array)) // "{0x12,0xff,0x0,0x1}"

func MapStringStructToSlice

func MapStringStructToSlice(m map[string]struct{}) []string

MapStringStructToSlice returns a slice with all keys of the given map[string]struct{}

func MoveNewFilesTo added in v1.8.0

func MoveNewFilesTo(oldDir, newDir string) error

MoveNewFilesTo copies all files, that do not exist in newDir, from oldDir.

func RequireRootPrivilege

func RequireRootPrivilege(cmd string)

RequireRootPrivilege checks if the user running cmd is root. If not, it exits the program

Types

This section is empty.

Jump to

Keyboard shortcuts

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