maps

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package maps provides the logic for data and map management.

This package is responsible for managing the BPF maps, and the data that is stored in them. It is also responsible for the creation of the maps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatDNSName

func FormatDNSName(domain string) ([256]byte, error)

FormatDNSName takes a domain name in string format and returns a byte array containing the domain name in DNS format. The returned byte array is intended for use as a key in an eBPF map.

Parameters:

  • domain: A domain name in string format.

Returns:

  • A byte array containing the domain name in DNS format.
  • An error if the domain name is invalid.

func Ipv6ToInet6

func Ipv6ToInet6(ipv6Addr string) struct{ In6U struct{ U6Addr8 [16]uint8 } }

Ipv6ToInet6 takes an IPv6 address in string format and returns a struct containing the IPv6 address in byte format. The returned struct is intended for use as a key in an eBPF map.

Parameters:

  • ipv6Addr: An IPv6 address in string format.

Returns:

  • A struct containing a 128-bit IPv6 address in byte format.

func SidToInet6Sid

func SidToInet6Sid(sidList []string) ([10]struct{ In6U struct{ U6Addr8 [16]uint8 } }, error)

SidToInet6Sid takes a slice of IPv6 Segment IDs (SIDs) in string format and returns an array of 10 structs containing the IPv6 SIDs in reversed order. The returned array is intended for use in constructing the SID List for the Segment Routing Header (SRH) in IPv6 packets.

Specifically, the function performs the following:

  1. The first index [0] of the returned array is left empty. This is intended for the last hop, which should be sourced from the IPv6 destination address of the original packet.
  2. The remaining IPv6 SIDs are reversed, meaning that the last SID in the input slice becomes the first SID in the output array, the second to last becomes the second, and so on.

Parameters:

  • sidList: A slice of IPv6 SIDs in string format.

Returns:

  • An array of 10 structs, each containing a 128-bit IPv6 address in byte format.

Types

type ClientMap

type ClientMap struct {
	Outer   *OuterMap
	Inners  map[string]*InnerMap
	Lookup  *LookupMap
	Reverse *ReverseMap
	// contains filtered or unexported fields
}

func NewClientMap

func NewClientMap(bpf bpf.Bpf, bpfReader client.ClientBpfReader) (*ClientMap, error)

func (*ClientMap) BuildClientDataMap

func (cm *ClientMap) BuildClientDataMap() error

func (*ClientMap) Create

func (cm *ClientMap) Create() error

type InnerMap

type InnerMap struct {
	Map
	ID int
}

func NewInnerMap

func NewInnerMap(bpf bpf.Bpf, spec *ebpf.MapSpec) *InnerMap

func (*InnerMap) Build

func (im *InnerMap) Build() error

type LookupMap

type LookupMap struct {
	Map
}

func NewLookupMap

func NewLookupMap(bpf bpf.Bpf, spec *ebpf.MapSpec) *LookupMap

func (*LookupMap) BuildWith

func (lm *LookupMap) BuildWith(inners map[string]*InnerMap) error

type Map

type Map struct {
	// contains filtered or unexported fields
}

func NewMap

func NewMap(bpf bpf.Bpf, spec *ebpf.MapSpec) *Map

func (*Map) Lookup

func (m *Map) Lookup(key interface{}, value interface{}) error

Lookup looks up the value corresponding to the given key in the map.

Parameters:

  • key: The key to lookup.
  • value: The value to store the result in.

Returns:

  • An error if the map could not be opened or the lookup failed.

func (*Map) Open

func (m *Map) Open() error

Open opens the map.

Returns:

  • An error if the map could not be opened.

func (*Map) OpenOrCreate

func (m *Map) OpenOrCreate() error

OpenOrCreate opens or creates the map.

Returns:

  • An error if the map could not be opened or created.

func (*Map) UpdateInner

func (m *Map) UpdateInner(outerKey interface{}, innerKey interface{}, innerValue interface{}) error

UpdateInner updates the inner map corresponding to the given outer key with the given inner key and value.

Parameters:

  • outerKey: The key of the outer map.
  • innerKey: The key of the inner map.
  • innerValue: The value to update the inner map with.

Returns:

  • An error if the inner map could not be updated.

type OuterMap

type OuterMap struct {
	Map
}

func NewOuterMap

func NewOuterMap(bpf bpf.Bpf, spec *ebpf.MapSpec) *OuterMap

func (*OuterMap) BuildWith

func (om *OuterMap) BuildWith(inners map[string]*InnerMap) error

type ReverseMap

type ReverseMap struct {
	Map
}

func NewReverseMap

func NewReverseMap(bpf bpf.Bpf, spec *ebpf.MapSpec) *ReverseMap

func (*ReverseMap) BuildWith

func (rm *ReverseMap) BuildWith(inners map[string]*InnerMap) error

type ServerMap

type ServerMap struct {
	Lookup *Map
	// contains filtered or unexported fields
}

func NewServerMap

func NewServerMap(bpf bpf.Bpf) (*ServerMap, error)

func (*ServerMap) Create

func (sm *ServerMap) Create() error

type SidListData

type SidListData struct {
	SidlistSize uint32
	Sidlist     [10]struct{ In6U struct{ U6Addr8 [16]uint8 } }
}

func GenerateSidLookupValue

func GenerateSidLookupValue(sidList []string) (SidListData, error)

GenerateSidLookupValue takes a slice of IPv6 Segment IDs (SIDs) in string format and returns a SidListData struct containing the IPv6 SIDs in reversed order. The returned struct is intended for use as a value in an eBPF map.

Parameters:

  • sidList: A slice of IPv6 SIDs in string format.

Returns:

  • A SidListData struct containing the IPv6 SIDs in reversed order.

Jump to

Keyboard shortcuts

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