lbmap

package
v0.8.1 Latest Latest
Warning

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

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

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 int the form of L3n4AddrID and backend int he 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) Convert

func (k *RevNat4Key) Convert() RevNatKey

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

type RevNat4Value

type RevNat4Value struct {
	Address types.IPv4
	Port    uint16
}

func NewRevNat4Value

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

func (*RevNat4Value) Convert

func (v *RevNat4Value) Convert() RevNatValue

func (*RevNat4Value) GetValuePtr

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

func (*RevNat4Value) String

func (v *RevNat4Value) String() string

type RevNat6Key

type RevNat6Key struct {
	Key uint16
}

func NewRevNat6Key

func NewRevNat6Key(value uint16) *RevNat6Key

func (*RevNat6Key) Convert

func (v *RevNat6Key) Convert() RevNatKey

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

type RevNat6Value

type RevNat6Value struct {
	Address types.IPv6
	Port    uint16
}

func NewRevNat6Value

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

func (*RevNat6Value) Convert

func (v *RevNat6Value) Convert() RevNatValue

func (*RevNat6Value) GetValuePtr

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

func (*RevNat6Value) String

func (v *RevNat6Value) String() string

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

	// Convert between host byte order and map byte order
	Convert() RevNatKey

	// Returns the key value
	GetKey() uint16
}

type RevNatValue

type RevNatValue interface {
	bpf.MapValue

	// Convert between host byte order and map byte order
	Convert() 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) Convert

func (k *Service4Key) Convert() ServiceKey

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

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

func (s *Service4Value) Convert() ServiceValue

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

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

func (k *Service6Key) Convert() ServiceKey

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

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

func (s *Service6Value) Convert() ServiceValue

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

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

	// Convert between host byte order and map byte order
	Convert() 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

	// Convert between host byte order and map byte order
	Convert() 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