Documentation
¶
Index ¶
- Constants
- func ActionAsString(action int) string
- func LoaderModeAsString(mode int) string
- func StringAsXdpAction(action string) xdpAction
- func XdpActionAsString(action xdpAction) string
- type BpfMetrics
- type ControlBpfReq
- type IPNet
- type JericoRuntimeConfig
- type PassMap
- type PassMap4
- type PassMap6
- type PerfHistorgram
- func (m *PerfHistorgram) Close() error
- func (m *PerfHistorgram) Entries() ([64]uint64, error)
- func (m *PerfHistorgram) Keys() ([64]uint32, error)
- func (m *PerfHistorgram) LoadPinnedMap() error
- func (m *PerfHistorgram) MapName() string
- func (m *PerfHistorgram) Update(key uint32, value uint64) error
- func (m *PerfHistorgram) Zero(key uint32) error
- func (m *PerfHistorgram) ZeroAll() error
- type PerfMetrics
- func (m *PerfMetrics) Close() error
- func (m *PerfMetrics) Entries() ([64]uint64, error)
- func (m *PerfMetrics) Keys() ([64]uint32, error)
- func (m *PerfMetrics) LoadPinnedMap() error
- func (m *PerfMetrics) MapName() string
- func (m *PerfMetrics) Update(key uint32, value uint64) error
- func (m *PerfMetrics) Zero(key uint32) error
- func (m *PerfMetrics) ZeroAll() error
- type RREntry
- type RREntryA
- type RREntryAAAA
- type RRKey
- type RRMap
- type RRMapA
- func (m *RRMapA) Close() error
- func (m *RRMapA) Create(qname RRQname, qtype uint16, ttl uint32, ip netip.Addr) error
- func (m *RRMapA) Entries() ([]RREntry, error)
- func (m *RRMapA) LoadPinnedMap() error
- func (m *RRMapA) Lookup(qname RRQname, qtype uint16) (RREntry, error)
- func (m *RRMapA) MapName() string
- func (m *RRMapA) Remove(qname RRQname, qtype uint16) error
- func (m *RRMapA) Update(qname RRQname, qtype uint16, ttl uint32, ip netip.Addr) error
- type RRMapAAAA
- func (m *RRMapAAAA) Close() error
- func (m *RRMapAAAA) Create(qname RRQname, qtype uint16, ttl uint32, ip netip.Addr) error
- func (m *RRMapAAAA) Entries() ([]RREntry, error)
- func (m *RRMapAAAA) LoadPinnedMap() error
- func (m *RRMapAAAA) Lookup(qname RRQname, qtype uint16) (RREntry, error)
- func (m *RRMapAAAA) MapName() string
- func (m *RRMapAAAA) Remove(qname RRQname, qtype uint16) error
- func (m *RRMapAAAA) Update(qname RRQname, qtype uint16, ttl uint32, ip netip.Addr) error
- type RRQname
- type RRValue
- type RRValueA
- type RRValueAAAA
- type RuntimeConfigOptions
- type Switches
- type TAddr
- type TConfigControls
- type TConfigLoader
- type TConfigNetdev
- type TConfigNetdevProg
- type TConfigNetdevXdp
- type TConfigOptions
- type TDnsDaddr4
- type TDnsDaddr6
- type THookLoader
- type TOffloaderPlugin
- func (t *TOffloaderPlugin) GetXdpService() *TXdpService
- func (t *TOffloaderPlugin) L() *TOffloaderPluginConfig
- func (t *TOffloaderPlugin) Monitor(m *monitor.TMonitorPlugin)
- func (t *TOffloaderPlugin) MountBpffs() error
- func (t *TOffloaderPlugin) Run(ctx context.Context, overrides *plugins.OverrideOptions) error
- func (t *TOffloaderPlugin) SetBpfOptions(ctx echo.Context) error
- func (t *TOffloaderPlugin) SetClientBpfOptions(options *ControlBpfReq) error
- func (t *TOffloaderPlugin) SetupMethods(group *echo.Group)
- func (t *TOffloaderPlugin) Stop() error
- func (t *TOffloaderPlugin) TickServer(ctx context.Context) error
- type TOffloaderPluginConfig
- type TPerfValue
- type TXdpCiliumBinary
- type TXdpService
- func (t *TXdpService) ApplyActions(name string, passmap PassMap, actions map[int][]TAddr) error
- func (t *TXdpService) AttachHook(hookMap *ebpf.Map, fd int, index int) error
- func (t *TXdpService) DetectLoaderMode(netdev string) (int, error)
- func (t *TXdpService) GetConfiguredActions(src map[string]TAddr, dst map[string]TAddr) map[int][]TAddr
- func (t *TXdpService) GetConfiguredIP(name string) (map[string]TAddr, error)
- func (t *TXdpService) GetPassMaps(tag string, names []string) (map[string]map[string]TAddr, map[string]PassMap, error)
- func (t *TXdpService) GetRuntimeConfigMap() ([]uint32, error)
- func (t *TXdpService) Run(ctx context.Context) error
- func (t *TXdpService) SecondaryAttachHook(fd int) error
- func (t *TXdpService) SetDryrun(dryrun bool) error
- func (t *TXdpService) Stop() error
- func (t *TXdpService) SyncPassMap(tag string, names []string, srcs map[string]map[string]TAddr) error
- func (t *TXdpService) SyncRuntimeConfigMap(options *RuntimeConfigOptions) error
- type TXdpServiceFlags
Constants ¶
View Source
const ( // we have default class IN with uint16 "1" DefaultClassIN = 1 // a length of key for dns name used to // validate fqdn in import code DefaultQnameMaxLength = 48 )
View Source
const ( JericoMetricsPacketRX = 0 JericoMetricsPacketTX = 1 JericoMetricsPacketPass = 2 JericoMetricsPacketError = 3 JericoMetricsMax = 63 )
View Source
const ( ActionRemove = 0 ActionCreate = 1 )
View Source
const ( // metric counter for example plugin MetricNameCounter = "counter" // monitor class for check MonitorClass = "offloader" )
View Source
const ( // plugin name is used by controller to link // code and configuration NamePlugin = "offloader" // some predefined values, in seconds DefaultWatcherInterval = 20 )
View Source
const ( // default interface to bind if no options // provided DefaultInterface = "lo" // default bpf object file DefaultPath = "/usr/lib/yadns-xdp.bpf.o" // default pin path, for now we have to check // if it exists - use it, if not, create a path DefaultOffloaderPinPath = "/sys/fs/bpf/xdp/globals" // Response case flags: AA, RD, MBZ FlagAA = "AA" FlagRD = "RD" FlagMBZ = "MBZ" // prefix used for bpf program flag name PrefixFlag = "yadns_xdp_resp_flag_" // a list of constants to set BpfConstantRespRandomTTL = "yadns_xdp_resp_random_ttl" BpfConstantMetricsEnabled = "yadns_xdp_bpf_metrics_enabled" BpfConstantXdpcapEnabled = "yadns_xdp_bpf_xdpcap_enabled" BpfConstantBpfDyrun = "yadns_xdp_bpf_dryrun" // a list of loader mode, could be // primary or secondary, via "auto" LoaderModePrimary = 100 // secondary mode also could be set // via "auto" LoaderModeSecondary = 101 // default pin path for exported hook // from primary DefaultHookPinPath = "/sys/fs/bpf/xdp/bpftail-call/xdpcap_hook" // default list of xdp actions to set DefaultAction = xdpPass // default binary IP DefaultIPBinary = "/usr/sbin/ip" // a list of mode loader LoaderConfigModePrimary = "primary" LoaderConfigModeSecondary = "secondary" LoaderConfigModeAuto = "auto" //default value for dst address as value DefaultDstValue = 0 )
View Source
const (
JericoRuntimeConfigDryrun = 0
)
Variables ¶
This section is empty.
Functions ¶
func ActionAsString ¶
func LoaderModeAsString ¶
func StringAsXdpAction ¶
func StringAsXdpAction(action string) xdpAction
func XdpActionAsString ¶
func XdpActionAsString(action xdpAction) string
Types ¶
type BpfMetrics ¶
type ControlBpfReq ¶
type ControlBpfReq struct {
Dryrun bool `json:"dryrun"`
Option string `json:"option"`
Value bool `json:"value"`
ValueList []string `json:"values,omitempty"`
}
func (*ControlBpfReq) AsJSON ¶
func (c *ControlBpfReq) AsJSON() []byte
func (*ControlBpfReq) AsString ¶
func (c *ControlBpfReq) AsString() string
type IPNet ¶
func NewIPNetFromIP4 ¶
func NewIPNetFromIP4(addr TDnsDaddr4) IPNet
func NewIPNetFromIP6 ¶
func NewIPNetFromIP6(addr TDnsDaddr6) IPNet
func (*IPNet) AsDNSDaddr4 ¶
func (m *IPNet) AsDNSDaddr4() TDnsDaddr4
func (*IPNet) AsDNSDaddr6 ¶
func (m *IPNet) AsDNSDaddr6() TDnsDaddr6
func (*IPNet) UnmarshalText ¶
type JericoRuntimeConfig ¶
func (*JericoRuntimeConfig) Close ¶
func (m *JericoRuntimeConfig) Close() error
func (*JericoRuntimeConfig) Entries ¶
func (m *JericoRuntimeConfig) Entries() ([]uint32, error)
func (*JericoRuntimeConfig) LoadPinnedMap ¶
func (m *JericoRuntimeConfig) LoadPinnedMap() error
func (*JericoRuntimeConfig) MapName ¶
func (m *JericoRuntimeConfig) MapName() string
type PassMap4 ¶
func (*PassMap4) LoadPinnedMap ¶
type PassMap6 ¶
func (*PassMap6) LoadPinnedMap ¶
type PerfHistorgram ¶
func (*PerfHistorgram) Close ¶
func (m *PerfHistorgram) Close() error
func (*PerfHistorgram) Entries ¶
func (m *PerfHistorgram) Entries() ([64]uint64, error)
func (*PerfHistorgram) Keys ¶
func (m *PerfHistorgram) Keys() ([64]uint32, error)
func (*PerfHistorgram) LoadPinnedMap ¶
func (m *PerfHistorgram) LoadPinnedMap() error
func (*PerfHistorgram) MapName ¶
func (m *PerfHistorgram) MapName() string
func (*PerfHistorgram) Zero ¶
func (m *PerfHistorgram) Zero(key uint32) error
func (*PerfHistorgram) ZeroAll ¶
func (m *PerfHistorgram) ZeroAll() error
type PerfMetrics ¶
func (*PerfMetrics) Close ¶
func (m *PerfMetrics) Close() error
func (*PerfMetrics) Entries ¶
func (m *PerfMetrics) Entries() ([64]uint64, error)
func (*PerfMetrics) Keys ¶
func (m *PerfMetrics) Keys() ([64]uint32, error)
func (*PerfMetrics) LoadPinnedMap ¶
func (m *PerfMetrics) LoadPinnedMap() error
func (*PerfMetrics) MapName ¶
func (m *PerfMetrics) MapName() string
func (*PerfMetrics) Zero ¶
func (m *PerfMetrics) Zero(key uint32) error
func (*PerfMetrics) ZeroAll ¶
func (m *PerfMetrics) ZeroAll() error
type RREntryAAAA ¶
type RREntryAAAA struct {
RRKey
RRValueAAAA
}
func (RREntryAAAA) AsRawString ¶
func (m RREntryAAAA) AsRawString() string
func (RREntryAAAA) IP ¶
func (m RREntryAAAA) IP() netip.Addr
func (RREntryAAAA) QTTL ¶
func (m RREntryAAAA) QTTL() uint32
func (RREntryAAAA) Qdata ¶
func (m RREntryAAAA) Qdata() string
func (RREntryAAAA) Qname ¶
func (m RREntryAAAA) Qname() RRQname
func (RREntryAAAA) QnameAsBytes ¶
func (m RREntryAAAA) QnameAsBytes() []byte
func (RREntryAAAA) Qtype ¶
func (m RREntryAAAA) Qtype() uint16
type RRKey ¶
type RRKey struct {
// question type and class
Qtype uint16 `json:"qtype"`
Qclass uint16 `json:"qclass"`
// a qname to match, see qname definition
// #define MAX_DNS_NAME_LENGTH 256
Qname RRQname `json:"qname"`
}
func (*RRKey) AsRawString ¶
type RRMap ¶
type RRMap interface {
MapName() string
LoadPinnedMap() error
Close() error
Remove(qname RRQname, qtype uint16) error
Create(qname RRQname, qtype uint16, ttl uint32, ip netip.Addr) error
Update(qname RRQname, qtype uint16, ttl uint32, ip netip.Addr) error
Lookup(qname RRQname, qtype uint16) (RREntry, error)
Entries() ([]RREntry, error)
}
type RRQname ¶
type RRQname [48]byte
a length of array should be in sync with map in BPF program. I order to limit program variability is could be 256, 128, 96. 64, 48, 32
func (*RRQname) AsByteString ¶
type RRValueA ¶
type RRValueA struct {
// unsigned long s_addr, use As4() for
// ip4 address to fill
Addr [4]byte `json:"addr"`
// TTL for answer
TTL uint32 `json:"ttl"`
}
We have here ipv4 32bit value
func (*RRValueA) AsRawString ¶
type RRValueAAAA ¶
type RRValueAAAA struct {
// use As16() for conversion
Addr [16]byte `json:"addr"`
// TTL for answer
TTL uint32 `json:"ttl"`
}
func (*RRValueAAAA) AsRawString ¶
func (t *RRValueAAAA) AsRawString() string
type RuntimeConfigOptions ¶
type RuntimeConfigOptions struct {
BpfConstantBpfDyrun bool
}
type Switches ¶
type Switches struct {
// should it be global switch or local
Dryrun bool
}
command line switches
type TConfigControls ¶
type TConfigLoader ¶
type TConfigLoader struct {
// mode could be "primary" "secondary", auto"
Mode string `json:"mode" yaml:"mode"`
// hook options for "secondary" mode
Hook THookLoader `json:"hook" yaml:"hook"`
}
type TConfigNetdev ¶
type TConfigNetdev struct {
Address string `json:"address"`
Broadcast string `json:"broadcast"`
Flags []string `json:"flags"`
Group string `json:"group"`
Ifindex int `json:"ifindex"`
Ifname string `json:"ifname"`
Mtu int `json:"mtu"`
Operstate string `json:"operstate"`
Xdp *TConfigNetdevXdp `json:"xdp"`
}
type TConfigNetdevProg ¶
type TConfigNetdevXdp ¶
type TConfigNetdevXdp struct {
Mode int `json:"mode"`
Prog TConfigNetdevProg `json:"prog"`
Attached []TConfigNetdevXdp `json:"attached"`
}
type TConfigOptions ¶
type TConfigOptions struct {
// interface
Interface string `json:"interface" yaml:"interface"`
// requests DSTS for IP6 and IP4 dst addresses
// to match VS processing
Addrs []string `json:"addrs" yaml:"addrs"`
// I hope that we will need only one bpf program
// to handle traffic
Path string `json:"path" yaml:"path"`
// pinpath
PinPath string `json:"pinpath" yaml:"pinpath"`
// bpf option dryrun
BpfDryrun bool `json:"bpf-dryrun" yaml:"bpf-dryrun"`
// bpf option to enable xdpcap hook call
BpfXdpcap bool `json:"bpf-xdpcap" yaml:"bpf-xdpcap"`
// enable of disable bpf perf
BpfMetrics bool `json:"bpf-metrics" yaml:"bpf-metrics"`
// if xdp should generate random TTL (it could be
// used in ns-cache responses)
ResponseRandomTTL bool `json:"response-random-ttl" yaml:"response-random-ttl"`
// response flags, AA, RD, RA, MBZ
ResponseFlags []string `json:"response-flags" yaml:"response-flags"`
}
func (*TConfigOptions) String ¶
func (t *TConfigOptions) String() string
type TDnsDaddr4 ¶
type TDnsDaddr6 ¶
type THookLoader ¶
type TOffloaderPlugin ¶
type TOffloaderPlugin struct {
// some common attributes for all plugins, global
// configuration ref, name and type
plugins.Plugin
// contains filtered or unexported fields
}
func NewPlugin ¶
func NewPlugin(options *plugins.PluginOptions) (*TOffloaderPlugin, error)
func (*TOffloaderPlugin) GetXdpService ¶
func (t *TOffloaderPlugin) GetXdpService() *TXdpService
func (*TOffloaderPlugin) L ¶
func (t *TOffloaderPlugin) L() *TOffloaderPluginConfig
func (*TOffloaderPlugin) Monitor ¶
func (t *TOffloaderPlugin) Monitor(m *monitor.TMonitorPlugin)
func (*TOffloaderPlugin) MountBpffs ¶
func (t *TOffloaderPlugin) MountBpffs() error
func (*TOffloaderPlugin) Run ¶
func (t *TOffloaderPlugin) Run(ctx context.Context, overrides *plugins.OverrideOptions) error
func (*TOffloaderPlugin) SetBpfOptions ¶
func (t *TOffloaderPlugin) SetBpfOptions(ctx echo.Context) error
func (*TOffloaderPlugin) SetClientBpfOptions ¶
func (t *TOffloaderPlugin) SetClientBpfOptions(options *ControlBpfReq) error
func (*TOffloaderPlugin) SetupMethods ¶
func (t *TOffloaderPlugin) SetupMethods(group *echo.Group)
func (*TOffloaderPlugin) Stop ¶
func (t *TOffloaderPlugin) Stop() error
func (*TOffloaderPlugin) TickServer ¶
func (t *TOffloaderPlugin) TickServer(ctx context.Context) error
type TOffloaderPluginConfig ¶
type TOffloaderPluginConfig struct {
// could be disabled
Enabled bool `json:"enabled" yaml:"enabled"`
// bpf controls for some cases
Controls TConfigControls `json:"controls" yaml:"controls"`
// bpf xdp options
Options TConfigOptions `json:"options" yaml:"options"`
// XDP loader options, by default we have primary mode
Loader TConfigLoader `json:"loader" yaml:"loader"`
}
type TPerfValue ¶
type TPerfValue struct {
// a counter number in a cell of
// historgram (counts of time)
Counter uint64
}
type TXdpCiliumBinary ¶
type TXdpService ¶
type TXdpService struct {
// contains filtered or unexported fields
}
func NewXdpService ¶
func NewXdpService(p *TOffloaderPlugin) (*TXdpService, error)
func (*TXdpService) ApplyActions ¶
func (*TXdpService) AttachHook ¶
taken for xdpcap no good way to check if a program is already attached, as Create() doesn't work on prog array maps We could check if values are present for keys, but that's not atomic with writing a value anyways
func (*TXdpService) DetectLoaderMode ¶
func (t *TXdpService) DetectLoaderMode(netdev string) (int, error)
func (*TXdpService) GetConfiguredActions ¶
func (t *TXdpService) GetConfiguredActions(src map[string]TAddr, dst map[string]TAddr) map[int][]TAddr
T.B.D. adding value compare
func (*TXdpService) GetConfiguredIP ¶
func (t *TXdpService) GetConfiguredIP(name string) (map[string]TAddr, error)
func (*TXdpService) GetPassMaps ¶
func (*TXdpService) GetRuntimeConfigMap ¶
func (t *TXdpService) GetRuntimeConfigMap() ([]uint32, error)
func (*TXdpService) SecondaryAttachHook ¶
func (t *TXdpService) SecondaryAttachHook(fd int) error
func (*TXdpService) SetDryrun ¶
func (t *TXdpService) SetDryrun(dryrun bool) error
func (*TXdpService) Stop ¶
func (t *TXdpService) Stop() error
func (*TXdpService) SyncPassMap ¶
func (*TXdpService) SyncRuntimeConfigMap ¶
func (t *TXdpService) SyncRuntimeConfigMap(options *RuntimeConfigOptions) error
type TXdpServiceFlags ¶
type TXdpServiceFlags struct {
// some xdp attach flags
Flags link.XDPAttachFlags
}
Click to show internal directories.
Click to hide internal directories.