lbmap

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// 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)
	RevNat4Map = bpf.NewMap("cilium_lb4_reverse_nat",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(RevNat4Key{})),
		int(unsafe.Sizeof(RevNat4Value{})),
		maxEntries, 0)
	RRSeq4Map = bpf.NewMap("cilium_lb4_rr_seq",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(Service4Key{})),
		int(unsafe.Sizeof(RRSeqValue{})),
		maxFrontEnds, 0)
)
View Source
var (
	Service6Map = bpf.NewMap("cilium_lb6_services",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(Service6Key{})),
		int(unsafe.Sizeof(Service6Value{})),
		maxEntries, 0)
	RevNat6Map = bpf.NewMap("cilium_lb6_reverse_nat",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(RevNat6Key{})),
		int(unsafe.Sizeof(RevNat6Value{})),
		maxEntries, 0)
	RRSeq6Map = bpf.NewMap("cilium_lb6_rr_seq",
		bpf.MapTypeHash,
		int(unsafe.Sizeof(Service6Key{})),
		int(unsafe.Sizeof(RRSeqValue{})),
		maxFrontEnds, 0)
)

Functions

func AddSVC2BPFMap

func AddSVC2BPFMap(fe ServiceKey, besValues []ServiceValue, addRevNAT bool, revNATID int) error

AddSVC2BPFMap adds the given bpf service to the bpf maps.

func DeleteRevNat

func DeleteRevNat(key RevNatKey) error

func DeleteService

func DeleteService(key ServiceKey) error

func L3n4Addr2RevNatKeynValue

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

L3n4Addr2RevNatKeynValue converts the given L3n4Addr to a RevNatKey and RevNatValue.

func LBSVC2ServiceKeynValue

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

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

func LookupAndDeleteServiceWeights

func LookupAndDeleteServiceWeights(key ServiceKey) error

LookupAndDeleteServiceWeights deletes entry from cilium_lb6_rr_seq or cilium_lb4_rr_seq

func RevNat4DumpParser

func RevNat4DumpParser(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error)

func RevNat4Value2L3n4Addr

func RevNat4Value2L3n4Addr(revNATV *RevNat4Value) (*types.L3n4Addr, error)

RevNat4Value2L3n4Addr converts the given RevNat4Value to a L3n4Addr.

func RevNat6DumpParser

func RevNat6DumpParser(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error)

func RevNat6Value2L3n4Addr

func RevNat6Value2L3n4Addr(revNATV *RevNat6Value) (*types.L3n4Addr, error)

RevNat6Value2L3n4Addr converts the given RevNat6Value to a L3n4Addr.

func RevNatValue2L3n4AddrID

func RevNatValue2L3n4AddrID(revNATKey RevNatKey, revNATValue RevNatValue) (*types.L3n4AddrID, error)

RevNatValue2L3n4AddrID converts the given RevNatKey and RevNatValue to a L3n4AddrID.

func Service4DumpParser

func Service4DumpParser(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error)

func Service4RRSeqDumpParser

func Service4RRSeqDumpParser(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error)

func Service6DumpParser

func Service6DumpParser(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error)

func Service6RRSeqDumpParser

func Service6RRSeqDumpParser(key []byte, value []byte) (bpf.MapKey, bpf.MapValue, error)

func ServiceKey2L3n4Addr

func ServiceKey2L3n4Addr(svcKey ServiceKey) (*types.L3n4Addr, error)

ServiceKey2L3n4Addr converts the given svcKey to a L3n4Addr.

func ServiceKeynValue2FEnBE

func ServiceKeynValue2FEnBE(svcKey ServiceKey, svcValue ServiceValue) (*types.L3n4AddrID, *types.LBBackEnd, error)

ServiceKeynValue2FEnBE converts the given svcKey and svcValue to a frontend in the form of L3n4AddrID and backend in the form of L3n4Addr.

func ServiceValue2LBBackEnd

func ServiceValue2LBBackEnd(svcKey ServiceKey, svcValue ServiceValue) (*types.LBBackEnd, error)

ServiceValue2LBBackEnd converts the svcValue to a LBBackEnd. The svcKey is necessary to determine which IP version svcValue is.

func UpdateRevNat

func UpdateRevNat(key RevNatKey, value RevNatValue) error

func UpdateService

func UpdateService(key ServiceKey, value ServiceValue) error

func UpdateServiceWeights

func UpdateServiceWeights(key ServiceKey, value *RRSeqValue) error

UpdateServiceWeights updates cilium_lb6_rr_seq or cilium_lb4_rr_seq bpf maps.

func UpdateWrrSeq

func UpdateWrrSeq(fe ServiceKey, weights []uint16) error

UpdateWrrSeq updates bpf map with the generated wrr sequence.

Types

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

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
}

func LookupRevNat

func LookupRevNat(key RevNatKey) (RevNatValue, error)

type Service4Key

type Service4Key struct {
	Address types.IPv4
	Port    uint16
	Slave   uint16
}

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 Service4Value

type Service4Value struct {
	Address types.IPv4
	Port    uint16
	Count   uint16
	RevNat  uint16
	Weight  uint16
}

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) GetCount

func (s *Service4Value) GetCount() int

func (*Service4Value) GetValuePtr

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

func (*Service4Value) GetWeight

func (s *Service4Value) GetWeight() uint16

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 Service6Key

type Service6Key struct {
	Address types.IPv6
	Port    uint16
	Slave   uint16
}

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 Service6Value

type Service6Value struct {
	Address types.IPv6
	Port    uint16
	Count   uint16
	RevNat  uint16
	Weight  uint16
}

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) GetCount

func (s *Service6Value) GetCount() int

func (*Service6Value) GetValuePtr

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

func (*Service6Value) GetWeight

func (s *Service6Value) GetWeight() uint16

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 ServiceKey

type ServiceKey interface {
	bpf.MapKey

	// Returns human readable string representation
	String() string

	// 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.

func L3n4Addr2ServiceKey

func L3n4Addr2ServiceKey(l3n4Addr types.L3n4Addr) ServiceKey

L3n4Addr2ServiceKey converts the given l3n4Addr to a ServiceKey with the slave ID set to 0.

type ServiceValue

type ServiceValue interface {
	bpf.MapValue

	// Returns human readable string representation
	String() string

	// 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)

	// 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
}

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

func LookupService

func LookupService(key ServiceKey) (ServiceValue, error)

Jump to

Keyboard shortcuts

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