ebpf

package
v0.8.10 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxItemLen is the maximal amount of items like ports or IP ranges to include
	// or/and exclude. It's currently hardcoded to 10 as merbridge during creation
	// of this map is assigning hardcoded 244 bytes for map values:
	//
	//  Cidr:        8 bytes
	//    Cidr.Net:  4 bytes
	//    Cidr.Mask: 1 byte
	//    pad:       3 bytes
	//
	//  PodConfig:                                  244 bytes
	//    PodConfig.StatusPort:                       2 bytes
	//    pad:                                        2 bytes
	//    PodConfig.ExcludeOutRanges (10x Cidr):     80 bytes
	//    PodConfig.IncludeOutRanges (10x Cidr):     80 bytes
	//    PodConfig.IncludeInPorts   (10x 2 bytes):  20 bytes
	//    PodConfig.IncludeOutPorts  (10x 2 bytes):  20 bytes
	//    PodConfig.ExcludeInPorts   (10x 2 bytes):  20 bytes
	//    PodConfig.ExcludeOutPorts  (10x 2 bytes):  20 bytes
	//
	// todo (bartsmykla): merbridge flagged this constant to be changed, so if
	//                    it will be changed, we have to update it
	MaxItemLen = 10
	// MapRelativePathLocalPodIPs is a path where the local_pod_ips map
	// is pinned, it's hardcoded as "{BPFFS_path}/tc/globals/local_pod_ips" because
	// merbridge is hard-coding it as well, and we don't want to allot to change it
	// by mistake
	MapRelativePathLocalPodIPs   = "/local_pod_ips"
	MapRelativePathNetNSPodIPs   = "/netns_pod_ips"
	MapRelativePathCookieOrigDst = "/cookie_orig_dst"
	MapRelativePathProcessIP     = "/process_ip"
	MapRelativePathPairOrigDst   = "/pair_orig_dst"
	MapRelativePathSockPairMap   = "/sock_pair_map"
)
View Source
const (
	FSTypeCgroup2 = "cgroup2"
	FSTypeBPF     = "bpf"
)

Variables

This section is empty.

Functions

func CgroupFlags added in v0.8.3

func CgroupFlags(
	cfg config.Config,
	cgroup string,
	bpffs string,
) ([]string, error)

func CleanPathsRelativeToBPFFS added in v0.8.3

func CleanPathsRelativeToBPFFS(paths ...string) func(cfg config.Config) error

func Cleanup added in v0.8.0

func Cleanup(cfg config.Config) (string, error)

func GetFileInode added in v0.7.0

func GetFileInode(path string) (uint64, error)

func GetNonLoopbackRunningInterface added in v0.8.3

func GetNonLoopbackRunningInterface() (string, error)

func InterfaceIsUp added in v0.8.3

func InterfaceIsUp(ifName string) bool

func LoadAndAttachEbpfPrograms

func LoadAndAttachEbpfPrograms(programs []*Program, cfg config.Config) error

func Setup

func Setup(cfg config.Config) (string, error)

func UnloadEbpfPrograms added in v0.8.4

func UnloadEbpfPrograms(programs []*Program, cfg config.Config) (string, error)

Types

type Cidr

type Cidr struct {
	Net  uint32 // network order
	Mask uint8
	// contains filtered or unexported fields
}

type FlagGenerator added in v0.7.1

type FlagGenerator = func(
	cfg config.Config,
	cgroup string,
	bpffs string,
) ([]string, error)

func Flags added in v0.8.3

func Flags(flags map[string]string) FlagGenerator

type PodConfig

type PodConfig struct {
	StatusPort uint16

	ExcludeOutRanges [MaxItemLen]Cidr
	IncludeOutRanges [MaxItemLen]Cidr
	IncludeInPorts   [MaxItemLen]uint16
	IncludeOutPorts  [MaxItemLen]uint16
	ExcludeInPorts   [MaxItemLen]uint16
	ExcludeOutPorts  [MaxItemLen]uint16
	// contains filtered or unexported fields
}

type Program

type Program struct {
	Name    string
	Flags   FlagGenerator
	Cleanup func(cfg config.Config) error
}

func (Program) LoadAndAttach added in v0.7.1

func (p Program) LoadAndAttach(
	cfg config.Config,
	cgroup string,
	bpffs string,
) error

Jump to

Keyboard shortcuts

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