l4lbdrv

package
v0.0.0-...-7ddeb54 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	XDP_ABORTED = uint32(0)
	XDP_DROP    = 1
	XDP_PASS    = 2
	XDP_TX      = 3
)
View Source
const (
	DESTINATIONS_SIZE = 255 // ../c/lb.c:66
)
View Source
const DestinationEntrySize = 10

Variables

View Source
var LinkCheckFrequency = time.Second

Functions

func IPToUint32

func IPToUint32(ip netip.Addr) (uint32, error)

func LbAssertLayout

func LbAssertLayout(m map[string]*DWARFStruct) error

func LbConfigAssertLayout

func LbConfigAssertLayout(s *DWARFStruct) error

func NowNanoseconds

func NowNanoseconds() uint64

NowNanoseconds returns a time that can be compared to bpf_ktime_get_ns() adopted from https://github.com/iovisor/gobpf/ (Apache 2.0 License)

func PrepSystemForXDP

func PrepSystemForXDP() error

`PrepSystemForXDP` configures RLIMIT_MEMLOCK to ensure enough room to allocate eBPF programs and maps on older Linux systems.

func ReadDWARFStructs

func ReadDWARFStructs(binPath string) (map[string]*DWARFStruct, error)

func StatCountersAssertLayout

func StatCountersAssertLayout(s *DWARFStruct) error

func XdpRetValToString

func XdpRetValToString(retval uint32) string

Types

type Bindings

type Bindings struct {
	LBMain           *ebpf.Program `ebpf:"lb_main"`
	StatCountersMap  *ebpf.Map     `ebpf:"stat_counters_map"`
	XdpcapHook       *ebpf.Map     `ebpf:"xdpcap_hook"`
	DestinationArray *ebpf.Map     `ebpf:"destinations_map"`
	ConfigMap        *ebpf.Map     `ebpf:"lb_config_map"`
}

func BindBalancer

func BindBalancer(binPath, xdpcapHookPath string) (*Bindings, error)

func (*Bindings) Close

func (b *Bindings) Close() error

func (*Bindings) ReadStatCountersAggregate

func (b *Bindings) ReadStatCountersAggregate() (*StatCounters, error)

func (*Bindings) ResetStatCounters

func (b *Bindings) ResetStatCounters() error

type Config

type Config struct {
	BinPath        string
	InterfaceName  string
	XdpCapHookPath string

	VIP   netip.Addr
	Dests DestinationEntries
}

type DWARFStruct

type DWARFStruct struct {
	Name   string
	Size   int64
	Fields map[string]DWARFStructField
}

type DWARFStructField

type DWARFStructField struct {
	Name   string
	Offset int64
}

type DestinationEntries

type DestinationEntries []DestinationEntry

func (DestinationEntries) MarshalBinary

func (es DestinationEntries) MarshalBinary() ([]byte, error)

type DestinationEntry

type DestinationEntry struct {
	IPAddr       netip.Addr
	HardwareAddr net.HardwareAddr
}

func (DestinationEntry) String

func (e DestinationEntry) String() string

type L4LB

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

func New

func New(cfg *Config) (*L4LB, error)

func (*L4LB) Close

func (lb *L4LB) Close() error

func (*L4LB) DumpCounters

func (lb *L4LB) DumpCounters() error

func (*L4LB) Sync

func (lb *L4LB) Sync() error

type LbConfig

type LbConfig struct {
	VipAddress uint32 // ../c/lb.c:50
	NumDests   uint32 // ../c/lb.c:51
}

type LinkAttacher

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

`LinkAttacher` monitors the link and reattaches the XDP program if it is detached. This is a workaround to some buggy Linux environments where XDP programs are unattached from the interface spontaneously.

func AttachToLink(link netlink.Link, fd int) (*LinkAttacher, error)

func (*LinkAttacher) Close

func (a *LinkAttacher) Close() error

type StatCounters

type StatCounters struct {
	RxPacketTotal                uint64 // ../c/lb.c:29
	RxTotalSize                  uint64 // ../c/lb.c:30
	TooShortPacketTotal          uint64 // ../c/lb.c:32
	NonIpv4PacketTotal           uint64 // ../c/lb.c:33
	IpOptionPacketTotal          uint64 // ../c/lb.c:34
	NonSupportedProtoPacketTotal uint64 // ../c/lb.c:35
	NoVipMatchTotal              uint64 // ../c/lb.c:36
	FailedAdjustHeadTotal        uint64 // ../c/lb.c:37
	FailedAdjustTailTotal        uint64 // ../c/lb.c:38
}

func (*StatCounters) Add

func (c *StatCounters) Add(other *StatCounters)

func (*StatCounters) String

func (c *StatCounters) String() string

Jump to

Keyboard shortcuts

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