lbmap

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Maximum number of entries in each hashtable
	MaxEntries = 65536

	// MaxSeq is used by daemon for generating bpf define LB_RR_MAX_SEQ.
	MaxSeq = 31
)

Variables

View Source
var (
	Service4Map = bpf.NewMap("cilium_lb4_services",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(Service4Key{})),
		int(unsafe.Sizeof(Service4Value{})),
		MaxEntries,
		0, 0,
		func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) {
			svcKey, svcVal := Service4Key{}, Service4Value{}

			if err := bpf.ConvertKeyValue(key, value, &svcKey, &svcVal); err != nil {
				return nil, nil, err
			}

			return svcKey.ToNetwork(), svcVal.ToNetwork(), nil
		}).WithCache()
	Service4MapV2 = bpf.NewMap("cilium_lb4_services_v2",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(Service4KeyV2{})),
		int(unsafe.Sizeof(Service4ValueV2{})),
		MaxEntries,
		0, 0,
		func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) {
			svcKey, svcVal := Service4KeyV2{}, Service4ValueV2{}

			if err := bpf.ConvertKeyValue(key, value, &svcKey, &svcVal); err != nil {
				return nil, nil, err
			}

			return svcKey.ToNetwork(), svcVal.ToNetwork(), nil
		}).WithCache()
	Backend4Map = bpf.NewMap("cilium_lb4_backends",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(Backend4Key{})),
		int(unsafe.Sizeof(Backend4Value{})),
		MaxEntries,
		0, 0,
		func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) {
			backendKey, backendVal := Backend4Key{}, Backend4Value{}

			if err := bpf.ConvertKeyValue(key, value, &backendKey, &backendVal); err != nil {
				return nil, nil, err
			}

			return &backendKey, backendVal.ToNetwork(), nil
		}).WithCache()
	RevNat4Map = bpf.NewMap("cilium_lb4_reverse_nat",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(RevNat4Key{})),
		int(unsafe.Sizeof(RevNat4Value{})),
		MaxEntries,
		0, 0,
		func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) {
			var ukey uint16
			var revNat RevNat4Value

			if err := bpf.ConvertKeyValue(key, value, &ukey, &revNat); err != nil {
				return nil, nil, err
			}

			revKey := NewRevNat4Key(ukey)

			return revKey.ToNetwork(), revNat.ToNetwork(), nil
		}).WithCache()
	RRSeq4Map = bpf.NewMap("cilium_lb4_rr_seq",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(Service4Key{})),
		int(unsafe.Sizeof(RRSeqValue{})),
		maxFrontEnds,
		0, 0,
		func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) {
			svcKey, svcVal := Service4Key{}, RRSeqValue{}

			if err := bpf.ConvertKeyValue(key, value, &svcKey, &svcVal); err != nil {
				return nil, nil, err
			}

			return svcKey.ToNetwork(), &svcVal, nil
		}).WithCache()
	RRSeq4MapV2 = bpf.NewMap("cilium_lb4_rr_seq_v2",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(Service4KeyV2{})),
		int(unsafe.Sizeof(RRSeqValue{})),
		maxFrontEnds,
		0, 0,
		func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) {
			svcKey, rrSeqVal := Service4KeyV2{}, RRSeqValue{}

			if err := bpf.ConvertKeyValue(key, value, &svcKey, &rrSeqVal); err != nil {
				return nil, nil, err
			}

			return svcKey.ToNetwork(), &rrSeqVal, nil
		}).WithCache()
)
View Source
var (
	// Service6Map represents the BPF map for services in IPv6 load balancer
	Service6Map = bpf.NewMap("cilium_lb6_services",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(Service6Key{})),
		int(unsafe.Sizeof(Service6Value{})),
		MaxEntries,
		0, 0,
		func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) {
			svcKey, svcVal := Service6Key{}, Service6Value{}

			if err := bpf.ConvertKeyValue(key, value, &svcKey, &svcVal); err != nil {
				return nil, nil, err
			}

			return svcKey.ToNetwork(), svcVal.ToNetwork(), nil
		}).WithCache()
	Service6MapV2 = bpf.NewMap("cilium_lb6_services_v2",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(Service6KeyV2{})),
		int(unsafe.Sizeof(Service6ValueV2{})),
		MaxEntries,
		0, 0,
		func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) {
			svcKey, svcVal := Service6KeyV2{}, Service6ValueV2{}

			if err := bpf.ConvertKeyValue(key, value, &svcKey, &svcVal); err != nil {
				return nil, nil, err
			}

			return svcKey.ToNetwork(), svcVal.ToNetwork(), nil
		}).WithCache()
	Backend6Map = bpf.NewMap("cilium_lb6_backends",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(Backend6Key{})),
		int(unsafe.Sizeof(Backend6Value{})),
		MaxEntries,
		0, 0,
		func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) {
			backendKey, backendVal := Backend6Key{}, Backend6Value{}

			if err := bpf.ConvertKeyValue(key, value, &backendKey, &backendVal); err != nil {
				return nil, nil, err
			}

			return &backendKey, backendVal.ToNetwork(), nil
		}).WithCache()
	// RevNat6Map represents the BPF map for reverse NAT in IPv6 load balancer
	RevNat6Map = bpf.NewMap("cilium_lb6_reverse_nat",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(RevNat6Key{})),
		int(unsafe.Sizeof(RevNat6Value{})),
		MaxEntries,
		0, 0,
		func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) {
			var ukey uint16
			var revNat RevNat6Value

			if err := bpf.ConvertKeyValue(key, value, &ukey, &revNat); err != nil {
				return nil, nil, err
			}

			revKey := NewRevNat6Key(ukey)

			return revKey.ToNetwork(), revNat.ToNetwork(), nil
		}).WithCache()
	// RRSeq6Map represents the BPF map for wrr sequences in IPv6 load balancer
	RRSeq6Map = bpf.NewMap("cilium_lb6_rr_seq",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(Service6Key{})),
		int(unsafe.Sizeof(RRSeqValue{})),
		maxFrontEnds,
		0, 0,
		func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) {
			svcKey, svcVal := Service6Key{}, RRSeqValue{}

			if err := bpf.ConvertKeyValue(key, value, &svcKey, &svcVal); err != nil {
				return nil, nil, err
			}

			return svcKey.ToNetwork(), &svcVal, nil
		}).WithCache()
	// RRSeq6MapV2 represents the BPF map for wrr sequences in IPv6 load balancer
	RRSeq6MapV2 = bpf.NewMap("cilium_lb6_rr_seq_v2",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(Service6KeyV2{})),
		int(unsafe.Sizeof(RRSeqValue{})),
		maxFrontEnds,
		0, 0,
		func(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error) {
			svcKey, svcVal := Service6KeyV2{}, RRSeqValue{}

			if err := bpf.ConvertKeyValue(key, value, &svcKey, &svcVal); err != nil {
				return nil, nil, err
			}

			return svcKey.ToNetwork(), &svcVal, nil
		}).WithCache()
)

Functions

func AddBackendIDsToCache added in v1.5.0

func AddBackendIDsToCache(backendIDs map[BackendAddrID]loadbalancer.BackendID)

AddBackendIDsToCache populates the given backend IDs to the lbmap local cache.

func DeleteOrphanBackends added in v1.5.0

func DeleteOrphanBackends(releaseBackendID func(loadbalancer.BackendID)) []error

func DeleteOrphanServiceV2AndRevNAT added in v1.5.0

func DeleteOrphanServiceV2AndRevNAT(svc loadbalancer.L3n4AddrID, delRevNAT bool) error

DeleteOrphanServiceV2AndRevNAT removes the given service v2 without consulting or updating the service cache. Also, it removes the related revNAT entry if delRevNAT is set.

This function is used only when restoring services during the launch of cilium-agent, and it is used to remove v2 services which have no corresponding legacy ones (thus, no cache entries exist).

The function is a copy-paste of the daemon.svcDeleteBPFLegacy, and it will go away once we stop supporting the legacy svc.

func DeleteRevNATBPF added in v1.5.0

func DeleteRevNATBPF(id loadbalancer.ServiceID, isIPv6 bool) error

DeleteRevNATBPF deletes the revNAT entry from its corresponding BPF map (IPv4 or IPv6) with ID id. Returns an error if the deletion operation failed.

func DeleteRevNat

func DeleteRevNat(key RevNatKey) error

func DeleteService

func DeleteService(key ServiceKey) error

DeleteService deletes a legacy service from the lbmap. The given key has to be of the master service.

func DeleteServiceCache added in v1.5.0

func DeleteServiceCache(svc loadbalancer.L3n4AddrID)

DeleteServiceCache deletes the service cache.

func DeleteServiceV2 added in v1.5.0

func DeleteServiceV2(svc loadbalancer.L3n4AddrID, releaseBackendID func(loadbalancer.BackendID)) error

DeleteServiceV2 deletes a service from the lbmap and deletes backends of it if they are not used by any other service.

The given key has to be of the master service.

func DumpBackendMapsToUserspace added in v1.5.0

func DumpBackendMapsToUserspace() (map[BackendAddrID]*loadbalancer.LBBackEnd, error)

DumpBackendMapsToUserspace dumps the backend entries from the BPF maps.

func DumpRevNATMapsToUserspace added in v1.5.0

func DumpRevNATMapsToUserspace() (loadbalancer.RevNATMap, []error)

DumpRevNATMapsToUserspace dumps the contents of both the IPv6 and IPv4 revNAT BPF maps, and stores the contents of said dumps in a RevNATMap. Returns the errors that occurred while dumping the maps.

func DumpServiceMapsToUserspace added in v1.5.0

func DumpServiceMapsToUserspace() (loadbalancer.SVCMap, []*loadbalancer.LBSVC, []error)

DumpServiceMapsToUserspace dumps the contents of both the IPv6 and IPv4 service / loadbalancer BPF maps, and converts them to a SVCMap and slice of LBSVC. Returns the errors that occurred while dumping the maps.

func DumpServiceMapsToUserspaceV2 added in v1.5.0

func DumpServiceMapsToUserspaceV2() (loadbalancer.SVCMap, []*loadbalancer.LBSVC, []error)

DumpServiceMapsToUserspaceV2 dumps the services in the same way as DumpServiceMapsToUserspace.

func L3n4Addr2RevNatKeynValue

func L3n4Addr2RevNatKeynValue(svcID loadbalancer.ServiceID, feL3n4Addr loadbalancer.L3n4Addr) (RevNatKey, RevNatValue)

L3n4Addr2RevNatKeynValue converts the given L3n4Addr to a RevNatKey and RevNatValue.

func LBSVC2ServiceKeynValue

func LBSVC2ServiceKeynValue(svc loadbalancer.LBSVC) (ServiceKey, []ServiceValue, error)

LBSVC2ServiceKeynValue transforms the SVC Cilium type into a bpf SVC type.

func LBSVC2ServiceKeynValuenBackendV2 added in v1.5.0

func LBSVC2ServiceKeynValuenBackendV2(svc *loadbalancer.LBSVC) (ServiceKeyV2, []ServiceValueV2, []Backend, error)

LBSVC2ServiceKeynValuenBackendValueV2 transforms the SVC Cilium type into a bpf SVC v2 type.

func RestoreService added in v1.5.0

func RestoreService(svc loadbalancer.LBSVC, v2Exists bool) error

RestoreService restores a single service in the cache. This is required to guarantee consistent backend ordering, slave slot and backend by backend address ID lookups.

func UpdateRevNat

func UpdateRevNat(key RevNatKey, value RevNatValue) error

func UpdateService

func UpdateService(fe ServiceKey, backends []ServiceValue,
	addRevNAT bool, revNATID int,
	isLegacySVCEnabled bool,
	acquireBackendID func(loadbalancer.L3n4Addr) (loadbalancer.BackendID, error),
	releaseBackendID func(loadbalancer.BackendID)) error

UpdateService adds or updates the given service in the bpf maps (in both - legacy and v2).

Types

type Backend added in v1.5.0

type Backend interface {
	// Return true if the value is of type IPv6
	IsIPv6() bool

	// Return the BPF map matching the type
	Map() *bpf.Map

	// Get backend identifier
	GetID() loadbalancer.BackendID

	// Get key of the backend entry
	GetKey() bpf.MapKey

	// Get value of the backend entry
	GetValue() BackendValue
}

Backend is the interface describing protocol independent backend used by services v2.

type Backend4 added in v1.5.0

type Backend4 struct {
	Key   *Backend4Key
	Value *Backend4Value
}

func NewBackend4 added in v1.5.0

func NewBackend4(id loadbalancer.BackendID, ip net.IP, port uint16, proto u8proto.U8proto) (*Backend4, error)

func (*Backend4) GetID added in v1.5.0

func (b *Backend4) GetID() loadbalancer.BackendID

func (*Backend4) GetKey added in v1.5.0

func (b *Backend4) GetKey() bpf.MapKey

func (*Backend4) GetValue added in v1.5.0

func (b *Backend4) GetValue() BackendValue

func (*Backend4) IsIPv6 added in v1.5.0

func (b *Backend4) IsIPv6() bool

func (*Backend4) Map added in v1.5.0

func (b *Backend4) Map() *bpf.Map

type Backend4Key added in v1.5.0

type Backend4Key struct {
	ID loadbalancer.BackendID
}

func NewBackend4Key added in v1.5.0

func NewBackend4Key(id loadbalancer.BackendID) *Backend4Key

func (*Backend4Key) GetID added in v1.5.0

func (k *Backend4Key) GetID() loadbalancer.BackendID

func (*Backend4Key) GetKeyPtr added in v1.5.0

func (k *Backend4Key) GetKeyPtr() unsafe.Pointer

func (*Backend4Key) Map added in v1.5.0

func (k *Backend4Key) Map() *bpf.Map

func (*Backend4Key) NewValue added in v1.5.0

func (k *Backend4Key) NewValue() bpf.MapValue

func (*Backend4Key) SetID added in v1.5.0

func (k *Backend4Key) SetID(id loadbalancer.BackendID)

func (*Backend4Key) String added in v1.5.0

func (k *Backend4Key) String() string

type Backend4Value added in v1.5.0

type Backend4Value struct {
	Address types.IPv4      `align:"address"`
	Port    uint16          `align:"port"`
	Proto   u8proto.U8proto `align:"proto"`
	Pad     uint8
}

Backend4Value must match 'struct lb4_backend' in "bpf/lib/common.h".

func NewBackend4Value added in v1.5.0

func NewBackend4Value(ip net.IP, port uint16, proto u8proto.U8proto) (*Backend4Value, error)

func (*Backend4Value) BackendAddrID added in v1.5.0

func (b *Backend4Value) BackendAddrID() BackendAddrID

func (*Backend4Value) GetAddress added in v1.5.0

func (b *Backend4Value) GetAddress() net.IP

func (*Backend4Value) GetPort added in v1.5.0

func (b *Backend4Value) GetPort() uint16

func (*Backend4Value) GetValuePtr added in v1.5.0

func (v *Backend4Value) GetValuePtr() unsafe.Pointer

func (*Backend4Value) String added in v1.5.0

func (v *Backend4Value) String() string

func (*Backend4Value) ToNetwork added in v1.5.0

func (v *Backend4Value) ToNetwork() BackendValue

type Backend6 added in v1.5.0

type Backend6 struct {
	Key   *Backend6Key
	Value *Backend6Value
}

func NewBackend6 added in v1.5.0

func NewBackend6(id loadbalancer.BackendID, ip net.IP, port uint16, proto u8proto.U8proto) (*Backend6, error)

func (*Backend6) GetID added in v1.5.0

func (b *Backend6) GetID() loadbalancer.BackendID

func (*Backend6) GetKey added in v1.5.0

func (b *Backend6) GetKey() bpf.MapKey

func (*Backend6) GetValue added in v1.5.0

func (b *Backend6) GetValue() BackendValue

func (*Backend6) IsIPv6 added in v1.5.0

func (b *Backend6) IsIPv6() bool

func (*Backend6) Map added in v1.5.0

func (b *Backend6) Map() *bpf.Map

type Backend6Key added in v1.5.0

type Backend6Key struct {
	ID loadbalancer.BackendID
}

func NewBackend6Key added in v1.5.0

func NewBackend6Key(id loadbalancer.BackendID) *Backend6Key

func (*Backend6Key) GetID added in v1.5.0

func (k *Backend6Key) GetID() loadbalancer.BackendID

func (*Backend6Key) GetKeyPtr added in v1.5.0

func (k *Backend6Key) GetKeyPtr() unsafe.Pointer

func (*Backend6Key) Map added in v1.5.0

func (k *Backend6Key) Map() *bpf.Map

func (*Backend6Key) NewValue added in v1.5.0

func (k *Backend6Key) NewValue() bpf.MapValue

func (*Backend6Key) SetID added in v1.5.0

func (k *Backend6Key) SetID(id loadbalancer.BackendID)

func (*Backend6Key) String added in v1.5.0

func (k *Backend6Key) String() string

type Backend6Value added in v1.5.0

type Backend6Value struct {
	Address types.IPv6      `align:"address"`
	Port    uint16          `align:"port"`
	Proto   u8proto.U8proto `align:"proto"`
	Pad     uint8
}

Backend6Value must match 'struct lb6_backend' in "bpf/lib/common.h".

func NewBackend6Value added in v1.5.0

func NewBackend6Value(ip net.IP, port uint16, proto u8proto.U8proto) (*Backend6Value, error)

func (*Backend6Value) BackendAddrID added in v1.5.0

func (b *Backend6Value) BackendAddrID() BackendAddrID

func (*Backend6Value) GetAddress added in v1.5.0

func (b *Backend6Value) GetAddress() net.IP

func (*Backend6Value) GetPort added in v1.5.0

func (b *Backend6Value) GetPort() uint16

func (*Backend6Value) GetValuePtr added in v1.5.0

func (v *Backend6Value) GetValuePtr() unsafe.Pointer

func (*Backend6Value) String added in v1.5.0

func (v *Backend6Value) String() string

func (*Backend6Value) ToNetwork added in v1.5.0

func (v *Backend6Value) ToNetwork() BackendValue

type BackendAddrID added in v1.5.0

type BackendAddrID string

BackendAddrID is the type of a service endpoint's unique identifier which consists of "IP:PORT"

func (BackendAddrID) IsIPv6 added in v1.5.0

func (b BackendAddrID) IsIPv6() bool

IsIPv6 detects in a dirty way whether the given backend addr ID belongs to the ipv6 backend.

type BackendKey added in v1.5.0

type BackendKey interface {
	bpf.MapKey

	// Return the BPF map matching the type
	Map() *bpf.Map

	// Set backend identifier
	SetID(loadbalancer.BackendID)

	// Get backend identifier
	GetID() loadbalancer.BackendID
}

BackendKey is the interface describing protocol independent backend key.

type BackendValue added in v1.5.0

type BackendValue interface {
	bpf.MapValue

	// Get backend address
	GetAddress() net.IP

	// Get backend port
	GetPort() uint16

	// Get backend address identifier (string of IP:Port)
	BackendAddrID() BackendAddrID

	// Convert fields to network byte order.
	ToNetwork() BackendValue
}

BackendValue is the interface describing protocol independent backend value.

type RRSeqValue

type RRSeqValue struct {
	// Length of Generated sequence
	Count uint16

	// Generated Sequence
	Idx [MaxSeq]uint16
}

func (*RRSeqValue) GetValuePtr

func (s *RRSeqValue) GetValuePtr() unsafe.Pointer

func (*RRSeqValue) String added in v1.5.0

func (s *RRSeqValue) String() string

type RevNat4Key

type RevNat4Key struct {
	Key uint16
}

func NewRevNat4Key

func NewRevNat4Key(value uint16) *RevNat4Key

func (*RevNat4Key) GetKey

func (k *RevNat4Key) GetKey() uint16

func (*RevNat4Key) GetKeyPtr

func (k *RevNat4Key) GetKeyPtr() unsafe.Pointer

func (*RevNat4Key) IsIPv6

func (k *RevNat4Key) IsIPv6() bool

func (*RevNat4Key) Map

func (k *RevNat4Key) Map() *bpf.Map

func (*RevNat4Key) NewValue

func (k *RevNat4Key) NewValue() bpf.MapValue

func (*RevNat4Key) String

func (k *RevNat4Key) String() string

func (*RevNat4Key) ToNetwork added in v0.10.0

func (k *RevNat4Key) ToNetwork() RevNatKey

ToNetwork converts RevNat4Key to network byte order.

type RevNat4Value

type RevNat4Value struct {
	Address types.IPv4
	Port    uint16
}

func NewRevNat4Value

func NewRevNat4Value(ip net.IP, port uint16) *RevNat4Value

func (*RevNat4Value) GetValuePtr

func (v *RevNat4Value) GetValuePtr() unsafe.Pointer

func (*RevNat4Value) String

func (v *RevNat4Value) String() string

func (*RevNat4Value) ToNetwork added in v0.10.0

func (v *RevNat4Value) ToNetwork() RevNatValue

ToNetwork converts RevNat4Value to network byte order.

type RevNat6Key

type RevNat6Key struct {
	Key uint16
}

func NewRevNat6Key

func NewRevNat6Key(value uint16) *RevNat6Key

func (*RevNat6Key) GetKey

func (v *RevNat6Key) GetKey() uint16

func (*RevNat6Key) GetKeyPtr

func (v *RevNat6Key) GetKeyPtr() unsafe.Pointer

func (*RevNat6Key) IsIPv6

func (v *RevNat6Key) IsIPv6() bool

func (*RevNat6Key) Map

func (v *RevNat6Key) Map() *bpf.Map

func (*RevNat6Key) NewValue

func (v *RevNat6Key) NewValue() bpf.MapValue

func (*RevNat6Key) String

func (v *RevNat6Key) String() string

func (*RevNat6Key) ToNetwork added in v0.10.0

func (v *RevNat6Key) ToNetwork() RevNatKey

ToNetwork converts RevNat6Key to network byte order.

type RevNat6Value

type RevNat6Value struct {
	Address types.IPv6
	Port    uint16
}

func NewRevNat6Value

func NewRevNat6Value(ip net.IP, port uint16) *RevNat6Value

func (*RevNat6Value) GetValuePtr

func (v *RevNat6Value) GetValuePtr() unsafe.Pointer

func (*RevNat6Value) String

func (v *RevNat6Value) String() string

func (*RevNat6Value) ToNetwork added in v0.10.0

func (v *RevNat6Value) ToNetwork() RevNatValue

ToNetwork converts RevNat6Value to network byte order.

type RevNatKey

type RevNatKey interface {
	bpf.MapKey

	// Returns true if the key is of type IPv6
	IsIPv6() bool

	// Returns the BPF map matching the key type
	Map() *bpf.Map

	// ToNetwork converts fields to network byte order.
	ToNetwork() RevNatKey

	// Returns the key value
	GetKey() uint16
}

type RevNatValue

type RevNatValue interface {
	bpf.MapValue

	// ToNetwork converts fields to network byte order.
	ToNetwork() RevNatValue
}

type Service4Key

type Service4Key struct {
	Address types.IPv4 `align:"address"`
	Port    uint16     `align:"dport"`
	Slave   uint16     `align:"slave"`
}

Service4Key must match 'struct lb4_key' in "bpf/lib/common.h".

func NewService4Key

func NewService4Key(ip net.IP, port uint16, slave uint16) *Service4Key

func (*Service4Key) GetBackend

func (k *Service4Key) GetBackend() int

func (*Service4Key) GetKeyPtr

func (k *Service4Key) GetKeyPtr() unsafe.Pointer

func (*Service4Key) GetPort

func (k *Service4Key) GetPort() uint16

func (Service4Key) IsIPv6

func (k Service4Key) IsIPv6() bool

func (Service4Key) Map

func (k Service4Key) Map() *bpf.Map

func (*Service4Key) MapDelete

func (k *Service4Key) MapDelete() error

func (Service4Key) NewValue

func (k Service4Key) NewValue() bpf.MapValue

func (Service4Key) RRMap

func (k Service4Key) RRMap() *bpf.Map

func (*Service4Key) RevNatValue

func (k *Service4Key) RevNatValue() RevNatValue

func (*Service4Key) SetBackend

func (k *Service4Key) SetBackend(backend int)

func (*Service4Key) SetPort

func (k *Service4Key) SetPort(port uint16)

func (*Service4Key) String

func (k *Service4Key) String() string

func (*Service4Key) ToHost added in v0.10.0

func (k *Service4Key) ToHost() ServiceKey

ToHost converts Service4Key port to network byte order.

func (*Service4Key) ToNetwork added in v0.10.0

func (k *Service4Key) ToNetwork() ServiceKey

ToNetwork converts Service4Key port to network byte order.

type Service4KeyV2 added in v1.5.0

type Service4KeyV2 struct {
	Address types.IPv4 `align:"address"`
	Port    uint16     `align:"dport"`
	Slave   uint16     `align:"slave"`
	Proto   uint8      `align:"proto"`
	Pad     [3]uint8
}

Service4KeyV2 must match 'struct lb4_key_v2' in "bpf/lib/common.h".

func NewService4KeyV2 added in v1.5.0

func NewService4KeyV2(ip net.IP, port uint16, proto u8proto.U8proto, slave uint16) *Service4KeyV2

func (*Service4KeyV2) GetAddress added in v1.5.0

func (k *Service4KeyV2) GetAddress() net.IP

func (*Service4KeyV2) GetKeyPtr added in v1.5.0

func (k *Service4KeyV2) GetKeyPtr() unsafe.Pointer

func (*Service4KeyV2) GetPort added in v1.5.0

func (k *Service4KeyV2) GetPort() uint16

func (*Service4KeyV2) GetSlave added in v1.5.0

func (k *Service4KeyV2) GetSlave() int

func (*Service4KeyV2) IsIPv6 added in v1.5.0

func (k *Service4KeyV2) IsIPv6() bool

func (*Service4KeyV2) Map added in v1.5.0

func (k *Service4KeyV2) Map() *bpf.Map

func (*Service4KeyV2) MapDelete added in v1.5.0

func (k *Service4KeyV2) MapDelete() error

func (*Service4KeyV2) NewValue added in v1.5.0

func (k *Service4KeyV2) NewValue() bpf.MapValue

func (*Service4KeyV2) RRMap added in v1.5.0

func (k *Service4KeyV2) RRMap() *bpf.Map

func (*Service4KeyV2) SetSlave added in v1.5.0

func (k *Service4KeyV2) SetSlave(slave int)

func (*Service4KeyV2) String added in v1.5.0

func (k *Service4KeyV2) String() string

func (*Service4KeyV2) ToNetwork added in v1.5.0

func (k *Service4KeyV2) ToNetwork() ServiceKeyV2

type Service4Value

type Service4Value struct {
	Address types.IPv4 `align:"target"`
	Port    uint16     `align:"port"`
	Count   uint16     `align:"count"`
	RevNat  uint16     `align:"rev_nat_index"`
	Weight  uint16     `align:"weight"`
}

Service4Value must match 'struct lb4_service' in "bpf/lib/common.h".

func NewService4Value

func NewService4Value(count uint16, target net.IP, port uint16, revNat uint16, weight uint16) *Service4Value

func (*Service4Value) BackendAddrID added in v1.5.0

func (s *Service4Value) BackendAddrID() BackendAddrID

func (*Service4Value) GetCount

func (s *Service4Value) GetCount() int

func (*Service4Value) GetPort added in v1.5.0

func (s *Service4Value) GetPort() uint16

func (*Service4Value) GetValuePtr

func (s *Service4Value) GetValuePtr() unsafe.Pointer

func (*Service4Value) GetWeight

func (s *Service4Value) GetWeight() uint16

func (*Service4Value) IsIPv6 added in v1.5.0

func (s *Service4Value) IsIPv6() bool

func (*Service4Value) RevNatKey

func (s *Service4Value) RevNatKey() RevNatKey

func (*Service4Value) SetAddress

func (s *Service4Value) SetAddress(ip net.IP) error

func (*Service4Value) SetCount

func (s *Service4Value) SetCount(count int)

func (*Service4Value) SetPort

func (s *Service4Value) SetPort(port uint16)

func (*Service4Value) SetRevNat

func (s *Service4Value) SetRevNat(id int)

func (*Service4Value) SetWeight

func (s *Service4Value) SetWeight(weight uint16)

func (*Service4Value) String

func (s *Service4Value) String() string

func (*Service4Value) ToHost added in v0.10.0

func (s *Service4Value) ToHost() ServiceValue

ToHost converts Service4Value to host byte order.

func (*Service4Value) ToNetwork added in v0.10.0

func (s *Service4Value) ToNetwork() ServiceValue

ToNetwork converts Service4Value to network byte order.

type Service4ValueV2 added in v1.5.0

type Service4ValueV2 struct {
	BackendID uint32 `align:"backend_id"`
	Count     uint16 `align:"count"`
	RevNat    uint16 `align:"rev_nat_index"`
	Weight    uint16 `align:"weight"`
	Pad       uint16
}

Service4ValueV2 must match 'struct lb4_service_v2' in "bpf/lib/common.h".

func NewService4ValueV2 added in v1.5.0

func NewService4ValueV2(count uint16, backendID loadbalancer.BackendID, revNat uint16, weight uint16) *Service4ValueV2

func (*Service4ValueV2) GetBackendID added in v1.5.0

func (s *Service4ValueV2) GetBackendID() loadbalancer.BackendID

func (*Service4ValueV2) GetCount added in v1.5.0

func (s *Service4ValueV2) GetCount() int

func (*Service4ValueV2) GetRevNat added in v1.5.0

func (s *Service4ValueV2) GetRevNat() int

func (*Service4ValueV2) GetValuePtr added in v1.5.0

func (s *Service4ValueV2) GetValuePtr() unsafe.Pointer

func (*Service4ValueV2) GetWeight added in v1.5.0

func (s *Service4ValueV2) GetWeight() uint16

func (*Service4ValueV2) RevNatKey added in v1.5.0

func (s *Service4ValueV2) RevNatKey() RevNatKey

func (*Service4ValueV2) SetBackendID added in v1.5.0

func (s *Service4ValueV2) SetBackendID(id loadbalancer.BackendID)

func (*Service4ValueV2) SetCount added in v1.5.0

func (s *Service4ValueV2) SetCount(count int)

func (*Service4ValueV2) SetRevNat added in v1.5.0

func (s *Service4ValueV2) SetRevNat(id int)

func (*Service4ValueV2) SetWeight added in v1.5.0

func (s *Service4ValueV2) SetWeight(weight uint16)

func (*Service4ValueV2) String added in v1.5.0

func (s *Service4ValueV2) String() string

func (*Service4ValueV2) ToNetwork added in v1.5.0

func (s *Service4ValueV2) ToNetwork() ServiceValueV2

type Service6Key

type Service6Key struct {
	Address types.IPv6 `align:"address"`
	Port    uint16     `align:"dport"`
	Slave   uint16     `align:"slave"`
}

Service6Key must match 'struct lb6_key' in "bpf/lib/common.h".

func NewService6Key

func NewService6Key(ip net.IP, port uint16, slave uint16) *Service6Key

func (*Service6Key) GetBackend

func (k *Service6Key) GetBackend() int

func (*Service6Key) GetKeyPtr

func (k *Service6Key) GetKeyPtr() unsafe.Pointer

func (*Service6Key) GetPort

func (k *Service6Key) GetPort() uint16

func (Service6Key) IsIPv6

func (k Service6Key) IsIPv6() bool

func (Service6Key) Map

func (k Service6Key) Map() *bpf.Map

func (Service6Key) NewValue

func (k Service6Key) NewValue() bpf.MapValue

func (Service6Key) RRMap

func (k Service6Key) RRMap() *bpf.Map

func (*Service6Key) RevNatValue

func (k *Service6Key) RevNatValue() RevNatValue

func (*Service6Key) SetBackend

func (k *Service6Key) SetBackend(backend int)

func (*Service6Key) SetPort

func (k *Service6Key) SetPort(port uint16)

func (*Service6Key) String

func (k *Service6Key) String() string

func (*Service6Key) ToHost added in v0.10.0

func (k *Service6Key) ToHost() ServiceKey

ToHost converts Service6Key to host byte order.

func (*Service6Key) ToNetwork added in v0.10.0

func (k *Service6Key) ToNetwork() ServiceKey

ToNetwork converts Service6Key to network byte order.

type Service6KeyV2 added in v1.5.0

type Service6KeyV2 struct {
	Address types.IPv6 `align:"address"`
	Port    uint16     `align:"dport"`
	Slave   uint16     `align:"slave"`
	Proto   uint8      `align:"proto"`
	Pad     [3]uint8
}

Service6KeyV2 must match 'struct lb6_key_v2' in "bpf/lib/common.h".

func NewService6KeyV2 added in v1.5.0

func NewService6KeyV2(ip net.IP, port uint16, proto u8proto.U8proto, slave uint16) *Service6KeyV2

func (*Service6KeyV2) GetAddress added in v1.5.0

func (k *Service6KeyV2) GetAddress() net.IP

func (*Service6KeyV2) GetKeyPtr added in v1.5.0

func (k *Service6KeyV2) GetKeyPtr() unsafe.Pointer

func (*Service6KeyV2) GetPort added in v1.5.0

func (k *Service6KeyV2) GetPort() uint16

func (*Service6KeyV2) GetSlave added in v1.5.0

func (k *Service6KeyV2) GetSlave() int

func (*Service6KeyV2) IsIPv6 added in v1.5.0

func (k *Service6KeyV2) IsIPv6() bool

func (*Service6KeyV2) Map added in v1.5.0

func (k *Service6KeyV2) Map() *bpf.Map

func (*Service6KeyV2) MapDelete added in v1.5.0

func (k *Service6KeyV2) MapDelete() error

func (*Service6KeyV2) NewValue added in v1.5.0

func (k *Service6KeyV2) NewValue() bpf.MapValue

func (*Service6KeyV2) RRMap added in v1.5.0

func (k *Service6KeyV2) RRMap() *bpf.Map

func (*Service6KeyV2) SetSlave added in v1.5.0

func (k *Service6KeyV2) SetSlave(slave int)

func (*Service6KeyV2) String added in v1.5.0

func (k *Service6KeyV2) String() string

func (*Service6KeyV2) ToNetwork added in v1.5.0

func (k *Service6KeyV2) ToNetwork() ServiceKeyV2

type Service6Value

type Service6Value struct {
	Address types.IPv6 `align:"target"`
	Port    uint16     `align:"port"`
	Count   uint16     `align:"count"`
	RevNat  uint16     `align:"rev_nat_index"`
	Weight  uint16     `align:"weight"`
}

Service6Value must match 'struct lb6_service' in "bpf/lib/common.h".

func NewService6Value

func NewService6Value(count uint16, target net.IP, port uint16, revNat uint16, weight uint16) *Service6Value

func (*Service6Value) BackendAddrID added in v1.5.0

func (s *Service6Value) BackendAddrID() BackendAddrID

func (*Service6Value) GetCount

func (s *Service6Value) GetCount() int

func (*Service6Value) GetPort added in v1.5.0

func (s *Service6Value) GetPort() uint16

func (*Service6Value) GetValuePtr

func (s *Service6Value) GetValuePtr() unsafe.Pointer

func (*Service6Value) GetWeight

func (s *Service6Value) GetWeight() uint16

func (*Service6Value) IsIPv6 added in v1.5.0

func (s *Service6Value) IsIPv6() bool

func (*Service6Value) RevNatKey

func (s *Service6Value) RevNatKey() RevNatKey

func (*Service6Value) SetAddress

func (s *Service6Value) SetAddress(ip net.IP) error

func (*Service6Value) SetCount

func (s *Service6Value) SetCount(count int)

func (*Service6Value) SetPort

func (s *Service6Value) SetPort(port uint16)

func (*Service6Value) SetRevNat

func (s *Service6Value) SetRevNat(id int)

func (*Service6Value) SetWeight

func (s *Service6Value) SetWeight(weight uint16)

func (*Service6Value) String

func (s *Service6Value) String() string

func (*Service6Value) ToHost added in v0.10.0

func (s *Service6Value) ToHost() ServiceValue

ToHost converts Service6Value ports to host byte order.

func (*Service6Value) ToNetwork added in v0.10.0

func (s *Service6Value) ToNetwork() ServiceValue

ToNetwork converts Service6Value ports to network byte order.

type Service6ValueV2 added in v1.5.0

type Service6ValueV2 struct {
	BackendID uint32 `align:"backend_id"`
	Count     uint16 `align:"count"`
	RevNat    uint16 `align:"rev_nat_index"`
	Weight    uint16 `align:"weight"`
	Pad       uint16
}

Service6ValueV2 must match 'struct lb6_service_v2' in "bpf/lib/common.h".

func NewService6ValueV2 added in v1.5.0

func NewService6ValueV2(count uint16, backendID loadbalancer.BackendID, revNat uint16, weight uint16) *Service6ValueV2

func (*Service6ValueV2) GetBackendID added in v1.5.0

func (s *Service6ValueV2) GetBackendID() loadbalancer.BackendID

func (*Service6ValueV2) GetCount added in v1.5.0

func (s *Service6ValueV2) GetCount() int

func (*Service6ValueV2) GetRevNat added in v1.5.0

func (s *Service6ValueV2) GetRevNat() int

func (*Service6ValueV2) GetValuePtr added in v1.5.0

func (s *Service6ValueV2) GetValuePtr() unsafe.Pointer

func (*Service6ValueV2) GetWeight added in v1.5.0

func (s *Service6ValueV2) GetWeight() uint16

func (*Service6ValueV2) RevNatKey added in v1.5.0

func (s *Service6ValueV2) RevNatKey() RevNatKey

func (*Service6ValueV2) SetBackendID added in v1.5.0

func (s *Service6ValueV2) SetBackendID(id loadbalancer.BackendID)

func (*Service6ValueV2) SetCount added in v1.5.0

func (s *Service6ValueV2) SetCount(count int)

func (*Service6ValueV2) SetRevNat added in v1.5.0

func (s *Service6ValueV2) SetRevNat(id int)

func (*Service6ValueV2) SetWeight added in v1.5.0

func (s *Service6ValueV2) SetWeight(weight uint16)

func (*Service6ValueV2) String added in v1.5.0

func (s *Service6ValueV2) String() string

func (*Service6ValueV2) ToNetwork added in v1.5.0

func (s *Service6ValueV2) ToNetwork() ServiceValueV2

type ServiceKey

type ServiceKey interface {
	bpf.MapKey

	// Returns true if the key is of type IPv6
	IsIPv6() bool

	// Returns the BPF map matching the key type
	Map() *bpf.Map

	// Returns the BPF Weighted Round Robin map matching the key type
	RRMap() *bpf.Map

	// Returns a RevNatValue matching a ServiceKey
	RevNatValue() RevNatValue

	// Returns the port set in the key or 0
	GetPort() uint16

	// Set the backend index (master: 0, backend: nth backend)
	SetBackend(int)

	// Return backend index
	GetBackend() int

	// ToNetwork converts fields to network byte order.
	ToNetwork() ServiceKey

	// ToHost converts fields to host byte order.
	ToHost() ServiceKey
}

ServiceKey is the interface describing protocol independent key for services map.

type ServiceKeyV2 added in v1.5.0

type ServiceKeyV2 interface {
	bpf.MapKey

	// Return true if the key is of type IPv6
	IsIPv6() bool

	// Return the BPF map matching the key type
	Map() *bpf.Map

	// Return the BPF Weighted Round Robin map matching the key type
	RRMap() *bpf.Map

	// Set slave slot for the key
	SetSlave(slave int)

	// Get slave slot of the key
	GetSlave() int

	// Get frontend IP address
	GetAddress() net.IP

	// Get frontend port
	GetPort() uint16

	// Delete entry identified with the key from the matching map
	MapDelete() error

	// ToNetwork converts fields to network byte order.
	ToNetwork() ServiceKeyV2
}

ServiceKey is the interface describing protocol independent key for services map v2.

NOTE: ServiceKeyV2.String() output should match output of corresponding ServiceKey.String()!

type ServiceValue

type ServiceValue interface {
	bpf.MapValue

	// Returns a RevNatKey matching a ServiceValue
	RevNatKey() RevNatKey

	// Set the number of backends
	SetCount(int)

	// Get the number of backends
	GetCount() int

	// Set address to map to (left blank for master)
	SetAddress(net.IP) error

	// Set port to map to (left blank for master)
	SetPort(uint16)

	// Get the port number
	GetPort() uint16

	// Set reverse NAT identifier
	SetRevNat(int)

	// Set Weight
	SetWeight(uint16)

	// Get Weight
	GetWeight() uint16

	// ToNetwork converts fields to network byte order.
	ToNetwork() ServiceValue

	// ToHost converts fields to host byte order.
	ToHost() ServiceValue

	// Get BackendAddrID of the service value
	BackendAddrID() BackendAddrID

	// Returns true if the value is of type IPv6
	IsIPv6() bool
}

ServiceValue is the interface describing protocol independent value for services map.

type ServiceValueV2 added in v1.5.0

type ServiceValueV2 interface {
	bpf.MapValue

	// Set the number of backends
	SetCount(int)

	// Get the number of backends
	GetCount() int

	// Set reverse NAT identifier
	SetRevNat(int)

	// Get reverse NAT identifier
	GetRevNat() int

	// Set weight
	SetWeight(uint16)

	// Get weight
	GetWeight() uint16

	// Set backend identifier
	SetBackendID(id loadbalancer.BackendID)

	// Get backend identifier
	GetBackendID() loadbalancer.BackendID

	// Returns a RevNatKey matching a ServiceValue
	RevNatKey() RevNatKey

	// Convert fields to network byte order.
	ToNetwork() ServiceValueV2
}

ServiceValue is the interface describing protocol independent value for services map v2.

Jump to

Keyboard shortcuts

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