Documentation ¶
Index ¶
- Constants
- Variables
- func IPToUint32(ip netip.Addr) (uint32, error)
- func LbAssertLayout(m map[string]*DWARFStruct) error
- func LbConfigAssertLayout(s *DWARFStruct) error
- func NowNanoseconds() uint64
- func PrepSystemForXDP() error
- func ReadDWARFStructs(binPath string) (map[string]*DWARFStruct, error)
- func StatCountersAssertLayout(s *DWARFStruct) error
- func XdpRetValToString(retval uint32) string
- type Bindings
- type Config
- type DWARFStruct
- type DWARFStructField
- type DestinationEntries
- type DestinationEntry
- type L4LB
- type LbConfig
- type LinkAttacher
- type StatCounters
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 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 ¶
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 (*Bindings) ReadStatCountersAggregate ¶
func (b *Bindings) ReadStatCountersAggregate() (*StatCounters, error)
func (*Bindings) ResetStatCounters ¶
type DWARFStruct ¶
type DWARFStruct struct { Name string Size int64 Fields map[string]DWARFStructField }
type DWARFStructField ¶
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 (*L4LB) DumpCounters ¶
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 ¶
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
Click to show internal directories.
Click to hide internal directories.