ipsets

package
v0.0.0-...-d216c5d Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const IPSetEntrySize = 20

WARNING: must be kept in sync with the definitions in bpf/polprog/pol_prog_builder.go. WARNING: must be kept in sync with the definitions in bpf/include/policy.h. uint32 prefixLen HE 4 uint64 set_id BE +8 = 12 uint32 addr BE +4 = 16 uint16 port HE +2 = 18 uint8 proto +1 = 19 uint8 pad +1 = 20

View Source
const IPSetEntryV6Size = 32

WARNING: must be kept in sync with the definitions in bpf/polprog/pol_prog_builder.go. WARNING: must be kept in sync with the definitions in bpf/include/policy.h. uint32 prefixLen HE 4 uint64 set_id BE +8 = 12 4*uint32 addr BE +16 = 28 uint16 port HE +2 = 30 uint8 proto +1 = 31 uint8 pad +1 = 32

Variables

View Source
var DummyValue = []byte{1, 0, 0, 0}
View Source
var MapParameters = maps.MapParameters{
	Type:       "lpm_trie",
	KeySize:    IPSetEntrySize,
	ValueSize:  4,
	MaxEntries: 1024 * 1024,
	Name:       "cali_v4_ip_sets",
	Flags:      unix.BPF_F_NO_PREALLOC,
}
View Source
var MapV6Parameters = maps.MapParameters{
	Type:       "lpm_trie",
	KeySize:    IPSetEntryV6Size,
	ValueSize:  4,
	MaxEntries: 1024 * 1024,
	Name:       "cali_v6_ip_sets",
	Flags:      unix.BPF_F_NO_PREALLOC,
}

Functions

func Map

func Map() maps.Map

func MapMemIter

func MapMemIter(m MapMem) func(k, v []byte)

func MapMemV6Iter

func MapMemV6Iter(m MapMemV6) func(k, v []byte)

func MapV6

func MapV6() maps.Map

func NewBPFIPSets

func NewBPFIPSets(
	ipVersionConfig *ipsets.IPVersionConfig,
	ipSetIDAllocator *idalloc.IDAllocator,
	ipSetsMap maps.Map,
	entryFromBytes func([]byte) IPSetEntryInterface,
	protoIPSetMemberToBPFEntry func(uint64, string) IPSetEntryInterface,
	opRecorder logutils.OpRecorder,
) *bpfIPSets

func SetMapSize

func SetMapSize(size int)

func SetMapV6Size

func SetMapV6Size(size int)

Types

type IPSetEntry

type IPSetEntry [IPSetEntrySize]byte

func (IPSetEntry) Addr

func (e IPSetEntry) Addr() net.IP

func (IPSetEntry) AsBytes

func (e IPSetEntry) AsBytes() []byte

func (IPSetEntry) Port

func (e IPSetEntry) Port() uint16

func (IPSetEntry) PrefixLen

func (e IPSetEntry) PrefixLen() uint32

func (IPSetEntry) Protocol

func (e IPSetEntry) Protocol() uint8

func (IPSetEntry) SetID

func (e IPSetEntry) SetID() uint64

func (IPSetEntry) String

func (e IPSetEntry) String() string

type IPSetEntryInterface

type IPSetEntryInterface interface {
	SetID() uint64
	Addr() net.IP
	PrefixLen() uint32
	Protocol() uint8
	Port() uint16
	AsBytes() []byte
}

func IPSetEntryFromBytes

func IPSetEntryFromBytes(b []byte) IPSetEntryInterface

func IPSetEntryV6FromBytes

func IPSetEntryV6FromBytes(b []byte) IPSetEntryInterface

func MakeBPFIPSetEntry

func MakeBPFIPSetEntry(setID uint64, cidr ip.V4CIDR, port uint16, proto uint8) IPSetEntryInterface

func MakeBPFIPSetEntryV6

func MakeBPFIPSetEntryV6(setID uint64, cidr ip.V6CIDR, port uint16, proto uint8) IPSetEntryInterface

func ProtoIPSetMemberToBPFEntry

func ProtoIPSetMemberToBPFEntry(id uint64, member string) IPSetEntryInterface

func ProtoIPSetMemberToBPFEntryV6

func ProtoIPSetMemberToBPFEntryV6(id uint64, member string) IPSetEntryInterface

type IPSetEntryV6

type IPSetEntryV6 [IPSetEntryV6Size]byte

func (IPSetEntryV6) Addr

func (e IPSetEntryV6) Addr() net.IP

func (IPSetEntryV6) AsBytes

func (e IPSetEntryV6) AsBytes() []byte

func (IPSetEntryV6) Port

func (e IPSetEntryV6) Port() uint16

func (IPSetEntryV6) PrefixLen

func (e IPSetEntryV6) PrefixLen() uint32

func (IPSetEntryV6) Protocol

func (e IPSetEntryV6) Protocol() uint8

func (IPSetEntryV6) SetID

func (e IPSetEntryV6) SetID() uint64

func (IPSetEntryV6) String

func (e IPSetEntryV6) String() string

type MapMem

type MapMem map[IPSetEntry]struct{}

func (MapMem) String

func (m MapMem) String() string

type MapMemV6

type MapMemV6 map[IPSetEntryV6]struct{}

func (MapMemV6) String

func (m MapMemV6) String() string

Jump to

Keyboard shortcuts

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