tcmanager

package
v1.10.0-alloy Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

line below avoids linter errors on Mac nolint:unused

Index

Constants

View Source
const (
	TCBackendTC = TCBackend(iota + 1)
	TCBackendTCX
	TCBackendAuto
)
View Source
const (
	AttachmentEgress = AttachmentType(iota)
	AttachmentIngress
)
View Source
const (
	MonitorPoll = MonitorMode(iota)
	MonitorWatch
)
View Source
const DefaultChannelBufferLen = 10
View Source
const DefaultMonitorMode = MonitorMode(MonitorWatch)
View Source
const DefaultPollPeriod = 10 * time.Second

Variables

View Source
var IsTCXSupported = sync.OnceValue(func() bool {
	prog, err := ebpf.NewProgram(&ebpf.ProgramSpec{
		Type: ebpf.SchedCLS,
		Instructions: asm.Instructions{
			asm.Mov.Imm(asm.R0, 0),
			asm.Return(),
		},
		License: "Apache-2.0",
	})

	if err != nil {
		return false
	}

	defer prog.Close()

	l, err := link.AttachTCX(link.TCXOptions{
		Program:   prog,
		Attach:    ebpf.AttachTCXIngress,
		Interface: 1,
		Anchor:    link.Tail(),
	})

	if err != nil {
		return false
	}

	if err := l.Close(); err != nil {
		return false
	}

	return true
})

Functions

func EnsureCiliumCompatibility

func EnsureCiliumCompatibility(backend TCBackend) error

Types

type AttachmentType

type AttachmentType uint8

type IMIfaceMap

type IMIfaceMap map[int]*ifaces.Interface

type InterfaceFilter

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

func NewInterfaceFilter

func NewInterfaceFilter(allowed []string, excluded []string) (*InterfaceFilter, error)

func (*InterfaceFilter) Allow

func (itf *InterfaceFilter) Allow(pattern string) error

func (*InterfaceFilter) Deny

func (itf *InterfaceFilter) Deny(pattern string) error

func (*InterfaceFilter) IsAllowed

func (itf *InterfaceFilter) IsAllowed(name string) bool

type InterfaceManager

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

func NewInterfaceManager

func NewInterfaceManager() *InterfaceManager

func (*InterfaceManager) AddInterfaceAddedCallback

func (im *InterfaceManager) AddInterfaceAddedCallback(cb InterfaceManagerCB) uint64

func (*InterfaceManager) AddInterfaceRemovedCallback

func (im *InterfaceManager) AddInterfaceRemovedCallback(cb InterfaceManagerCB) uint64

func (*InterfaceManager) InterfaceName

func (im *InterfaceManager) InterfaceName(ifaceIndex int) (string, bool)

func (*InterfaceManager) Interfaces

func (im *InterfaceManager) Interfaces() IMIfaceMap

func (*InterfaceManager) RemoveCallback

func (im *InterfaceManager) RemoveCallback(id uint64)

func (*InterfaceManager) SetChannelBufferLen

func (im *InterfaceManager) SetChannelBufferLen(channelBufferLen int)

func (*InterfaceManager) SetInterfaceFilter

func (im *InterfaceManager) SetInterfaceFilter(filter *InterfaceFilter)

func (*InterfaceManager) SetMonitorMode

func (im *InterfaceManager) SetMonitorMode(mode MonitorMode)

func (*InterfaceManager) SetPollPeriod

func (im *InterfaceManager) SetPollPeriod(period time.Duration)

func (*InterfaceManager) Start

func (im *InterfaceManager) Start(ctx context.Context)

func (*InterfaceManager) Wait

func (im *InterfaceManager) Wait()

type InterfaceManagerCB

type InterfaceManagerCB func(iface *ifaces.Interface)

type MonitorMode

type MonitorMode uint8

type TCBackend

type TCBackend uint8

func (*TCBackend) UnmarshalText

func (b *TCBackend) UnmarshalText(text []byte) error

func (TCBackend) Valid

func (b TCBackend) Valid() bool

type TCManager

type TCManager interface {
	Shutdown()
	AddProgram(name string, prog *ebpf.Program, attachment AttachmentType)
	RemoveProgram(name string)
	SetInterfaceManager(im *InterfaceManager)
}

func NewNetlinkManager

func NewNetlinkManager() TCManager

func NewTCManager

func NewTCManager(backend TCBackend) TCManager

func NewTCXManager

func NewTCXManager() TCManager

Jump to

Keyboard shortcuts

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