Documentation ¶
Index ¶
- Constants
- Variables
- func AffinityMap() maps.Map
- func AffinityMapMemIter(m AffinityMapMem) func(k, v []byte)
- func AllNATsMsgMap() maps.Map
- func BackendMap() maps.MapWithExistsCheck
- func BackendMapMemIter(m BackendMapMem) func(k, v []byte)
- func FrontendMap() maps.MapWithExistsCheck
- func InstallConnectTimeLoadBalancer(cgroupv2 string, logLevel string, udpNotSeen time.Duration, excludeUDP bool) error
- func MapMemIter(m MapMem) func(k, v []byte)
- func ProgFileName(logLevel string, ipver int) string
- func RemoveConnectTimeLoadBalancer(cgroupv2 string) error
- func SendRecvMsgMap() maps.Map
- func SendRecvMsgMapMemIter(m SendRecvMsgMapMem) func(k, v []byte)
- func SetMapSizes(fsize, bsize, asize int)
- type AffinityKey
- type AffinityMapMem
- type AffinityValue
- type BackendKey
- type BackendMapMem
- type BackendValue
- type FrontEndAffinityKey
- type FrontendKey
- func (k FrontendKey) Addr() net.IP
- func (k FrontendKey) Affinitykey() []byte
- func (k FrontendKey) AsBytes() []byte
- func (k FrontendKey) Port() uint16
- func (k FrontendKey) PrefixLen() uint32
- func (k FrontendKey) Proto() uint8
- func (k FrontendKey) SrcCIDR() ip.CIDR
- func (k FrontendKey) SrcPrefixLen() uint32
- func (k FrontendKey) String() string
- type FrontendValue
- func (v FrontendValue) AffinityTimeout() time.Duration
- func (v FrontendValue) AsBytes() []byte
- func (v FrontendValue) Count() uint32
- func (v FrontendValue) Flags() uint32
- func (v FrontendValue) FlagsAsString() string
- func (v FrontendValue) ID() uint32
- func (v FrontendValue) LocalCount() uint32
- func (v FrontendValue) String() string
- type MapMem
- type SendRecvMsgKey
- type SendRecvMsgMapMem
- type SendRecvMsgValue
Constants ¶
const ( NATFlgExternalLocal = 0x1 NATFlgInternalLocal = 0x2 )
const BlackHoleCount uint32 = 0xffffffff
const ZeroCIDRPrefixLen = 56
(sizeof(addr) + sizeof(port) + sizeof(proto)) in bits
Variables ¶
var AffinityMapParameters = maps.MapParameters{
Type: "lru_hash",
KeySize: affinityKeySize,
ValueSize: affinityValueSize,
MaxEntries: 64 * 1024,
Name: "cali_v4_nat_aff",
}
AffinityMapParameters describe the AffinityMap
var BackendMapParameters = maps.MapParameters{ Type: "hash", KeySize: backendKeySize, ValueSize: backendValueSize, MaxEntries: 256 * 1024, Name: "cali_v4_nat_be", Flags: unix.BPF_F_NO_PREALLOC, }
var CTNATsMapParameters = maps.MapParameters{
Type: "lru_hash",
KeySize: ctNATsMsgKeySize,
ValueSize: sendRecvMsgValueSize,
MaxEntries: 10000,
Name: "cali_v4_ct_nats",
}
var FrontendMapParameters = maps.MapParameters{ Type: "lpm_trie", KeySize: frontendKeySize, ValueSize: frontendValueSize, MaxEntries: 64 * 1024, Name: "cali_v4_nat_fe", Flags: unix.BPF_F_NO_PREALLOC, Version: 3, }
var SendRecvMsgMapParameters = maps.MapParameters{
Type: "lru_hash",
KeySize: sendRecvMsgKeySize,
ValueSize: sendRecvMsgValueSize,
MaxEntries: 510000,
Name: "cali_v4_srmsg",
}
SendRecvMsgMapParameters define SendRecvMsgMap
var ZeroCIDR = ip.MustParseCIDROrIP("0.0.0.0/0").(ip.V4CIDR)
Functions ¶
func AffinityMapMemIter ¶
func AffinityMapMemIter(m AffinityMapMem) func(k, v []byte)
AffinityMapMemIter returns maps.MapIter that loads the provided AffinityMapMem
func AllNATsMsgMap ¶
func BackendMap ¶
func BackendMap() maps.MapWithExistsCheck
func BackendMapMemIter ¶
func BackendMapMemIter(m BackendMapMem) func(k, v []byte)
BackendMapMemIter returns maps.MapIter that loads the provided NATBackendMapMem
func FrontendMap ¶
func FrontendMap() maps.MapWithExistsCheck
func MapMemIter ¶
MapMemIter returns maps.MapIter that loads the provided NATMapMem
func ProgFileName ¶
func SendRecvMsgMap ¶
SendRecvMsgMap tracks reverse translations for sendmsg/recvmsg of unconnected UDP
func SendRecvMsgMapMemIter ¶
func SendRecvMsgMapMemIter(m SendRecvMsgMapMem) func(k, v []byte)
SendRecvMsgMapMemIter returns maps.MapIter that loads the provided SendRecvMsgMapMem
func SetMapSizes ¶
func SetMapSizes(fsize, bsize, asize int)
Types ¶
type AffinityKey ¶
type AffinityKey [affinityKeySize]byte
AffinityKey is a key into the affinity table that consist of FrontendKey and the client's IP
func NewAffinityKey ¶
func NewAffinityKey(clientIP net.IP, fEndKey FrontendKey) AffinityKey
NewAffinityKey create a new AffinityKey from a clientIP and FrontendKey
func (AffinityKey) AsBytes ¶
func (k AffinityKey) AsBytes() []byte
AsBytes returns the key as []byte
func (AffinityKey) ClientIP ¶
func (k AffinityKey) ClientIP() net.IP
ClientIP returns the ClientIP part of the key
func (AffinityKey) FrontendAffinityKey ¶
func (k AffinityKey) FrontendAffinityKey() FrontEndAffinityKey
FrontendKey returns the FrontendKey part of the key
func (AffinityKey) String ¶
func (k AffinityKey) String() string
type AffinityMapMem ¶
type AffinityMapMem map[AffinityKey]AffinityValue
AffinityMapMem represents affinity map in memory
func LoadAffinityMap ¶
func LoadAffinityMap(m maps.Map) (AffinityMapMem, error)
LoadAffinityMap loads affinity map into memory
type AffinityValue ¶
type AffinityValue [affinityValueSize]byte
AffinityValue represents a backend picked by the affinity and the timestamp of its creating
func NewAffinityValue ¶
func NewAffinityValue(ts uint64, backend BackendValue) AffinityValue
NewAffinityValue creates a value from a timestamp and a backend
func (AffinityValue) AsBytes ¶
func (v AffinityValue) AsBytes() []byte
AsBytes returns the value as []byte
func (AffinityValue) Backend ¶
func (v AffinityValue) Backend() BackendValue
Backend returns the backend the affinity ties the frontend + client to.
func (AffinityValue) String ¶
func (v AffinityValue) String() string
func (AffinityValue) Timestamp ¶
func (v AffinityValue) Timestamp() time.Duration
Timestamp returns the timestamp of the entry. It is generated by bpf_ktime_get_ns which returns the time since the system boot in nanoseconds - it is the monotonic clock reading, which is compatible with time operations in time package.
type BackendKey ¶
type BackendKey [backendKeySize]byte
func BackendKeyFromBytes ¶
func BackendKeyFromBytes(b []byte) BackendKey
func NewNATBackendKey ¶
func NewNATBackendKey(id, ordinal uint32) BackendKey
func (BackendKey) AsBytes ¶
func (k BackendKey) AsBytes() []byte
func (BackendKey) Count ¶
func (v BackendKey) Count() uint32
func (BackendKey) ID ¶
func (v BackendKey) ID() uint32
func (BackendKey) String ¶
func (v BackendKey) String() string
type BackendMapMem ¶
type BackendMapMem map[BackendKey]BackendValue
BackendMapMem represents a NATBackend loaded into memory
func LoadBackendMap ¶
func LoadBackendMap(m maps.Map) (BackendMapMem, error)
LoadBackendMap loads the NATBackend map into a go map or returns an error
func (BackendMapMem) Equal ¶
func (m BackendMapMem) Equal(cmp BackendMapMem) bool
Equal compares keys and values of the NATBackendMapMem
type BackendValue ¶
type BackendValue [backendValueSize]byte
func BackendValueFromBytes ¶
func BackendValueFromBytes(b []byte) BackendValue
func NewNATBackendValue ¶
func NewNATBackendValue(addr net.IP, port uint16) BackendValue
func (BackendValue) Addr ¶
func (k BackendValue) Addr() net.IP
func (BackendValue) AsBytes ¶
func (k BackendValue) AsBytes() []byte
func (BackendValue) Port ¶
func (k BackendValue) Port() uint16
func (BackendValue) String ¶
func (k BackendValue) String() string
type FrontEndAffinityKey ¶
type FrontEndAffinityKey [frontendAffKeySize]byte
func (FrontEndAffinityKey) Addr ¶
func (k FrontEndAffinityKey) Addr() net.IP
func (FrontEndAffinityKey) AsBytes ¶
func (k FrontEndAffinityKey) AsBytes() []byte
func (FrontEndAffinityKey) Port ¶
func (k FrontEndAffinityKey) Port() uint16
func (FrontEndAffinityKey) Proto ¶
func (k FrontEndAffinityKey) Proto() uint8
func (FrontEndAffinityKey) String ¶
func (k FrontEndAffinityKey) String() string
type FrontendKey ¶
type FrontendKey [frontendKeySize]byte
func FrontendKeyFromBytes ¶
func FrontendKeyFromBytes(b []byte) FrontendKey
func NewNATKeySrc ¶
func (FrontendKey) Addr ¶
func (k FrontendKey) Addr() net.IP
func (FrontendKey) Affinitykey ¶
func (k FrontendKey) Affinitykey() []byte
func (FrontendKey) AsBytes ¶
func (k FrontendKey) AsBytes() []byte
func (FrontendKey) Port ¶
func (k FrontendKey) Port() uint16
func (FrontendKey) PrefixLen ¶
func (k FrontendKey) PrefixLen() uint32
func (FrontendKey) Proto ¶
func (k FrontendKey) Proto() uint8
func (FrontendKey) SrcCIDR ¶
func (k FrontendKey) SrcCIDR() ip.CIDR
func (FrontendKey) SrcPrefixLen ¶
func (k FrontendKey) SrcPrefixLen() uint32
This function returns the Prefix length of the source CIDR
func (FrontendKey) String ¶
func (k FrontendKey) String() string
type FrontendValue ¶
type FrontendValue [frontendValueSize]byte
func FrontendValueFromBytes ¶
func FrontendValueFromBytes(b []byte) FrontendValue
func NewNATValue ¶
func NewNATValue(id uint32, count, local, affinityTimeo uint32) FrontendValue
func NewNATValueWithFlags ¶
func NewNATValueWithFlags(id uint32, count, local, affinityTimeo, flags uint32) FrontendValue
func (FrontendValue) AffinityTimeout ¶
func (v FrontendValue) AffinityTimeout() time.Duration
func (FrontendValue) AsBytes ¶
func (v FrontendValue) AsBytes() []byte
func (FrontendValue) Count ¶
func (v FrontendValue) Count() uint32
func (FrontendValue) Flags ¶
func (v FrontendValue) Flags() uint32
func (FrontendValue) FlagsAsString ¶
func (v FrontendValue) FlagsAsString() string
func (FrontendValue) ID ¶
func (v FrontendValue) ID() uint32
func (FrontendValue) LocalCount ¶
func (v FrontendValue) LocalCount() uint32
func (FrontendValue) String ¶
func (v FrontendValue) String() string
type MapMem ¶
type MapMem map[FrontendKey]FrontendValue
NATMapMem represents FrontendMap loaded into memory
func LoadFrontendMap ¶
LoadFrontendMap loads the NAT map into a go map or returns an error
type SendRecvMsgKey ¶
type SendRecvMsgKey [sendRecvMsgKeySize]byte
SendRecvMsgKey is the key for SendRecvMsgMap
func (SendRecvMsgKey) Cookie ¶
func (k SendRecvMsgKey) Cookie() uint64
Cookie returns the socket cookie part of the key that can be used to match the socket.
func (SendRecvMsgKey) IP ¶
func (k SendRecvMsgKey) IP() net.IP
IP returns the IP address part of the key
func (SendRecvMsgKey) Port ¶
func (k SendRecvMsgKey) Port() uint16
Port returns port converted to 16-bit host endianness
func (SendRecvMsgKey) String ¶
func (k SendRecvMsgKey) String() string
type SendRecvMsgMapMem ¶
type SendRecvMsgMapMem map[SendRecvMsgKey]SendRecvMsgValue
SendRecvMsgMapMem represents affinity map in memory
func LoadSendRecvMsgMap ¶
func LoadSendRecvMsgMap(m maps.Map) (SendRecvMsgMapMem, error)
LoadSendRecvMsgMap loads affinity map into memory
type SendRecvMsgValue ¶
type SendRecvMsgValue [sendRecvMsgValueSize]byte
SendRecvMsgValue is the value of SendRecvMsgMap
func (SendRecvMsgValue) IP ¶
func (v SendRecvMsgValue) IP() net.IP
IP returns the IP address part of the key
func (SendRecvMsgValue) Port ¶
func (v SendRecvMsgValue) Port() uint16
Port returns port converted to 16-bit host endianness
func (SendRecvMsgValue) String ¶
func (v SendRecvMsgValue) String() string