ebpf

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseAllObjects

func CloseAllObjects(closers ...io.Closer) error

func Copy16Ip

func Copy16Ip[T ~[]byte](arr T) [16]byte

func LoadAllObjects

func LoadAllObjects(opts *ebpf.CollectionOptions, loaders ...Loader) error

func LoadIpEntrypoint

func LoadIpEntrypoint() (*ebpf.CollectionSpec, error)

LoadIpEntrypoint returns the embedded CollectionSpec for IpEntrypoint.

func LoadIpEntrypointObjects

func LoadIpEntrypointObjects(obj interface{}, opts *ebpf.CollectionOptions) error

LoadIpEntrypointObjects loads IpEntrypoint and converts it into a struct.

The following types are suitable as obj argument:

*IpEntrypointObjects
*IpEntrypointPrograms
*IpEntrypointMaps

See ebpf.CollectionSpec.LoadAndAssign documentation for details.

func LoadN3Entrypoint

func LoadN3Entrypoint() (*ebpf.CollectionSpec, error)

LoadN3Entrypoint returns the embedded CollectionSpec for N3Entrypoint.

func LoadN3EntrypointObjects

func LoadN3EntrypointObjects(obj interface{}, opts *ebpf.CollectionOptions) error

LoadN3EntrypointObjects loads N3Entrypoint and converts it into a struct.

The following types are suitable as obj argument:

*N3EntrypointObjects
*N3EntrypointPrograms
*N3EntrypointMaps

See ebpf.CollectionSpec.LoadAndAssign documentation for details.

func LoadN6Entrypoint

func LoadN6Entrypoint() (*ebpf.CollectionSpec, error)

LoadN6Entrypoint returns the embedded CollectionSpec for N6Entrypoint.

func LoadN6EntrypointObjects

func LoadN6EntrypointObjects(obj interface{}, opts *ebpf.CollectionOptions) error

LoadN6EntrypointObjects loads N6Entrypoint and converts it into a struct.

The following types are suitable as obj argument:

*N6EntrypointObjects
*N6EntrypointPrograms
*N6EntrypointMaps

See ebpf.CollectionSpec.LoadAndAssign documentation for details.

func LoadZeroEntrypoint

func LoadZeroEntrypoint() (*ebpf.CollectionSpec, error)

LoadZeroEntrypoint returns the embedded CollectionSpec for ZeroEntrypoint.

func LoadZeroEntrypointObjects

func LoadZeroEntrypointObjects(obj interface{}, opts *ebpf.CollectionOptions) error

LoadZeroEntrypointObjects loads ZeroEntrypoint and converts it into a struct.

The following types are suitable as obj argument:

*ZeroEntrypointObjects
*ZeroEntrypointPrograms
*ZeroEntrypointMaps

See ebpf.CollectionSpec.LoadAndAssign documentation for details.

func ResizeEbpfMap

func ResizeEbpfMap(eMap **ebpf.Map, eProg *ebpf.Program, newSize uint32) error

Types

type BpfObjects

type BpfObjects struct {
	IpEntrypointObjects

	FarIdTracker *IdTracker
	QerIdTracker *IdTracker
}

func NewBpfObjects

func NewBpfObjects() *BpfObjects

func (*BpfObjects) Close

func (bpfObjects *BpfObjects) Close() error

func (*BpfObjects) DeleteDownlinkPdrIp6

func (bpfObjects *BpfObjects) DeleteDownlinkPdrIp6(ipv6 net.IP) error

func (*BpfObjects) DeleteFar

func (bpfObjects *BpfObjects) DeleteFar(intenalId uint32) error
func (bpfObjects *BpfObjects) DeletePdrDownlink(ipv4 net.IP) error
func (bpfObjects *BpfObjects) DeletePdrUplink(teid uint32) error

func (*BpfObjects) DeleteQer

func (bpfObjects *BpfObjects) DeleteQer(internalId uint32) error

func (*BpfObjects) Load

func (bpfObjects *BpfObjects) Load() error

func (*BpfObjects) NewFar

func (bpfObjects *BpfObjects) NewFar(farInfo FarInfo) (uint32, error)

func (*BpfObjects) NewQer

func (bpfObjects *BpfObjects) NewQer(qerInfo QerInfo) (uint32, error)

func (*BpfObjects) PutDownlinkPdrIp6

func (bpfObjects *BpfObjects) PutDownlinkPdrIp6(ipv6 net.IP, pdrInfo PdrInfo) error
func (bpfObjects *BpfObjects) PutPdrDownlink(ipv4 net.IP, pdrInfo PdrInfo) error
func (bpfObjects *BpfObjects) PutPdrUplink(teid uint32, pdrInfo PdrInfo) error

func (*BpfObjects) ResizeAllMaps

func (bpfObjects *BpfObjects) ResizeAllMaps(qerMapSize uint32, farMapSize uint32, pdrMapSize uint32) error

func (*BpfObjects) UpdateDownlinkPdrIp6

func (bpfObjects *BpfObjects) UpdateDownlinkPdrIp6(ipv6 net.IP, pdrInfo PdrInfo) error

func (*BpfObjects) UpdateFar

func (bpfObjects *BpfObjects) UpdateFar(internalId uint32, farInfo FarInfo) error
func (bpfObjects *BpfObjects) UpdatePdrDownlink(ipv4 net.IP, pdrInfo PdrInfo) error
func (bpfObjects *BpfObjects) UpdatePdrUplink(teid uint32, pdrInfo PdrInfo) error

func (*BpfObjects) UpdateQer

func (bpfObjects *BpfObjects) UpdateQer(internalId uint32, qerInfo QerInfo) error

type FarInfo

type FarInfo struct {
	Action                uint8
	OuterHeaderCreation   uint8
	Teid                  uint32
	RemoteIP              uint32
	LocalIP               uint32
	TransportLevelMarking uint16
}

func (FarInfo) MarshalJSON

func (f FarInfo) MarshalJSON() ([]byte, error)

type ForwardingPlaneController

type ForwardingPlaneController interface {
	PutPdrUplink(teid uint32, pdrInfo PdrInfo) error
	PutPdrDownlink(ipv4 net.IP, pdrInfo PdrInfo) error
	UpdatePdrUplink(teid uint32, pdrInfo PdrInfo) error
	UpdatePdrDownlink(ipv4 net.IP, pdrInfo PdrInfo) error
	DeletePdrUplink(teid uint32) error
	DeletePdrDownlink(ipv4 net.IP) error
	PutDownlinkPdrIp6(ipv6 net.IP, pdrInfo PdrInfo) error
	UpdateDownlinkPdrIp6(ipv6 net.IP, pdrInfo PdrInfo) error
	DeleteDownlinkPdrIp6(ipv6 net.IP) error
	NewFar(farInfo FarInfo) (uint32, error)
	UpdateFar(internalId uint32, farInfo FarInfo) error
	DeleteFar(internalId uint32) error
	NewQer(qerInfo QerInfo) (uint32, error)
	UpdateQer(internalId uint32, qerInfo QerInfo) error
	DeleteQer(internalId uint32) error
}

type IdTracker

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

func NewIdTracker

func NewIdTracker(size uint32) *IdTracker

func (*IdTracker) GetNext

func (t *IdTracker) GetNext() (next uint32, err error)

func (*IdTracker) Release

func (t *IdTracker) Release(id uint32)

type IpEntrypointFarInfo

type IpEntrypointFarInfo struct {
	Action              uint8
	OuterHeaderCreation uint8

	Teid                  uint32
	Remoteip              uint32
	Localip               uint32
	TransportLevelMarking uint16
	// contains filtered or unexported fields
}

type IpEntrypointIn6Addr

type IpEntrypointIn6Addr struct{ In6U struct{ U6Addr8 [16]uint8 } }

type IpEntrypointMapSpecs

type IpEntrypointMapSpecs struct {
	FarMap            *ebpf.MapSpec `ebpf:"far_map"`
	PdrMapDownlinkIp4 *ebpf.MapSpec `ebpf:"pdr_map_downlink_ip4"`
	PdrMapDownlinkIp6 *ebpf.MapSpec `ebpf:"pdr_map_downlink_ip6"`
	PdrMapUplinkIp4   *ebpf.MapSpec `ebpf:"pdr_map_uplink_ip4"`
	QerMap            *ebpf.MapSpec `ebpf:"qer_map"`
	UpfExtStat        *ebpf.MapSpec `ebpf:"upf_ext_stat"`
	UpfPipeline       *ebpf.MapSpec `ebpf:"upf_pipeline"`
	UpfRouteStat      *ebpf.MapSpec `ebpf:"upf_route_stat"`
}

IpEntrypointMapSpecs contains maps before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type IpEntrypointMaps

type IpEntrypointMaps struct {
	FarMap            *ebpf.Map `ebpf:"far_map"`
	PdrMapDownlinkIp4 *ebpf.Map `ebpf:"pdr_map_downlink_ip4"`
	PdrMapDownlinkIp6 *ebpf.Map `ebpf:"pdr_map_downlink_ip6"`
	PdrMapUplinkIp4   *ebpf.Map `ebpf:"pdr_map_uplink_ip4"`
	QerMap            *ebpf.Map `ebpf:"qer_map"`
	UpfExtStat        *ebpf.Map `ebpf:"upf_ext_stat"`
	UpfPipeline       *ebpf.Map `ebpf:"upf_pipeline"`
	UpfRouteStat      *ebpf.Map `ebpf:"upf_route_stat"`
}

IpEntrypointMaps contains all maps after they have been loaded into the kernel.

It can be passed to LoadIpEntrypointObjects or ebpf.CollectionSpec.LoadAndAssign.

func (*IpEntrypointMaps) Close

func (m *IpEntrypointMaps) Close() error

type IpEntrypointObjects

type IpEntrypointObjects struct {
	IpEntrypointPrograms
	IpEntrypointMaps
}

IpEntrypointObjects contains all objects after they have been loaded into the kernel.

It can be passed to LoadIpEntrypointObjects or ebpf.CollectionSpec.LoadAndAssign.

func (*IpEntrypointObjects) Close

func (o *IpEntrypointObjects) Close() error

type IpEntrypointPdrInfo

type IpEntrypointPdrInfo struct {
	FarId              uint32
	QerId              uint32
	OuterHeaderRemoval uint8
	SdfMode            uint8

	SdfRules struct {
		SdfFilter struct {
			Protocol uint8

			SrcAddr struct {
				Type uint8

				Ip   [16]byte /* uint128 */
				Mask [16]byte /* uint128 */
				// contains filtered or unexported fields
			}
			SrcPort struct {
				LowerBound uint16
				UpperBound uint16
			}

			DstAddr struct {
				Type uint8

				Ip   [16]byte /* uint128 */
				Mask [16]byte /* uint128 */
				// contains filtered or unexported fields
			}
			DstPort struct {
				LowerBound uint16
				UpperBound uint16
			}
			// contains filtered or unexported fields
		}
		OuterHeaderRemoval uint8

		FarId uint32
		QerId uint32
		// contains filtered or unexported fields
	}
	// contains filtered or unexported fields
}

func CombinePdrWithSdf

func CombinePdrWithSdf(defaultPdr *IpEntrypointPdrInfo, sdfPdr PdrInfo) IpEntrypointPdrInfo

func PreprocessPdrWithSdf

func PreprocessPdrWithSdf(lookup func(interface{}, interface{}) error, key interface{}, pdrInfo PdrInfo) (IpEntrypointPdrInfo, error)

func ToIpEntrypointPdrInfo

func ToIpEntrypointPdrInfo(defaultPdr PdrInfo) IpEntrypointPdrInfo

type IpEntrypointProgramSpecs

type IpEntrypointProgramSpecs struct {
	UpfIpEntrypointFunc *ebpf.ProgramSpec `ebpf:"upf_ip_entrypoint_func"`
}

IpEntrypointSpecs contains programs before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type IpEntrypointPrograms

type IpEntrypointPrograms struct {
	UpfIpEntrypointFunc *ebpf.Program `ebpf:"upf_ip_entrypoint_func"`
}

IpEntrypointPrograms contains all programs after they have been loaded into the kernel.

It can be passed to LoadIpEntrypointObjects or ebpf.CollectionSpec.LoadAndAssign.

func (*IpEntrypointPrograms) Close

func (p *IpEntrypointPrograms) Close() error

type IpEntrypointQerInfo

type IpEntrypointQerInfo struct {
	UlGateStatus uint8
	DlGateStatus uint8
	Qfi          uint8

	UlMaximumBitrate uint32
	DlMaximumBitrate uint32

	UlStart uint64
	DlStart uint64
	// contains filtered or unexported fields
}

type IpEntrypointRouteStat

type IpEntrypointRouteStat struct {
	FibLookupIp4Cache     uint64
	FibLookupIp4Ok        uint64
	FibLookupIp4ErrorDrop uint64
	FibLookupIp4ErrorPass uint64
	FibLookupIp6Cache     uint64
	FibLookupIp6Ok        uint64
	FibLookupIp6ErrorDrop uint64
	FibLookupIp6ErrorPass uint64
}

type IpEntrypointSpecs

type IpEntrypointSpecs struct {
	IpEntrypointProgramSpecs
	IpEntrypointMapSpecs
}

IpEntrypointSpecs contains maps and programs before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type IpEntrypointUpfStatistic

type IpEntrypointUpfStatistic struct {
	UpfCounters struct {
		RxArp      uint64
		RxIcmp     uint64
		RxIcmp6    uint64
		RxIp4      uint64
		RxIp6      uint64
		RxTcp      uint64
		RxUdp      uint64
		RxOther    uint64
		RxGtpEcho  uint64
		RxGtpPdu   uint64
		RxGtpOther uint64
		RxGtpUnexp uint64
	}
	UpfN3N6Counter struct {
		RxN3 uint64
		TxN3 uint64
		RxN6 uint64
		TxN6 uint64
	}
	XdpActions [8]uint64
}

type IpWMask

type IpWMask struct {
	Type uint8 // 0: any, 1: ip4, 2: ip6
	Ip   net.IP
	Mask net.IPMask
}

type Loader

type Loader struct {
	LoaderFunc
	// contains filtered or unexported fields
}

type LoaderFunc

type LoaderFunc func(obj interface{}, opts *ebpf.CollectionOptions) error

type N3EntrypointMapSpecs

type N3EntrypointMapSpecs struct {
	UpfPipeline *ebpf.MapSpec `ebpf:"upf_pipeline"`
}

N3EntrypointMapSpecs contains maps before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type N3EntrypointMaps

type N3EntrypointMaps struct {
	UpfPipeline *ebpf.Map `ebpf:"upf_pipeline"`
}

N3EntrypointMaps contains all maps after they have been loaded into the kernel.

It can be passed to LoadN3EntrypointObjects or ebpf.CollectionSpec.LoadAndAssign.

func (*N3EntrypointMaps) Close

func (m *N3EntrypointMaps) Close() error

type N3EntrypointObjects

type N3EntrypointObjects struct {
	N3EntrypointPrograms
	N3EntrypointMaps
}

N3EntrypointObjects contains all objects after they have been loaded into the kernel.

It can be passed to LoadN3EntrypointObjects or ebpf.CollectionSpec.LoadAndAssign.

func (*N3EntrypointObjects) Close

func (o *N3EntrypointObjects) Close() error

type N3EntrypointProgramSpecs

type N3EntrypointProgramSpecs struct {
	UpfN3EntrypointFunc *ebpf.ProgramSpec `ebpf:"upf_n3_entrypoint_func"`
}

N3EntrypointSpecs contains programs before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type N3EntrypointPrograms

type N3EntrypointPrograms struct {
	UpfN3EntrypointFunc *ebpf.Program `ebpf:"upf_n3_entrypoint_func"`
}

N3EntrypointPrograms contains all programs after they have been loaded into the kernel.

It can be passed to LoadN3EntrypointObjects or ebpf.CollectionSpec.LoadAndAssign.

func (*N3EntrypointPrograms) Close

func (p *N3EntrypointPrograms) Close() error

type N3EntrypointSpecs

type N3EntrypointSpecs struct {
	N3EntrypointProgramSpecs
	N3EntrypointMapSpecs
}

N3EntrypointSpecs contains maps and programs before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type N6EntrypointMapSpecs

type N6EntrypointMapSpecs struct {
	UpfPipeline *ebpf.MapSpec `ebpf:"upf_pipeline"`
}

N6EntrypointMapSpecs contains maps before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type N6EntrypointMaps

type N6EntrypointMaps struct {
	UpfPipeline *ebpf.Map `ebpf:"upf_pipeline"`
}

N6EntrypointMaps contains all maps after they have been loaded into the kernel.

It can be passed to LoadN6EntrypointObjects or ebpf.CollectionSpec.LoadAndAssign.

func (*N6EntrypointMaps) Close

func (m *N6EntrypointMaps) Close() error

type N6EntrypointObjects

type N6EntrypointObjects struct {
	N6EntrypointPrograms
	N6EntrypointMaps
}

N6EntrypointObjects contains all objects after they have been loaded into the kernel.

It can be passed to LoadN6EntrypointObjects or ebpf.CollectionSpec.LoadAndAssign.

func (*N6EntrypointObjects) Close

func (o *N6EntrypointObjects) Close() error

type N6EntrypointProgramSpecs

type N6EntrypointProgramSpecs struct {
	UpfN6EntrypointFunc *ebpf.ProgramSpec `ebpf:"upf_n6_entrypoint_func"`
}

N6EntrypointSpecs contains programs before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type N6EntrypointPrograms

type N6EntrypointPrograms struct {
	UpfN6EntrypointFunc *ebpf.Program `ebpf:"upf_n6_entrypoint_func"`
}

N6EntrypointPrograms contains all programs after they have been loaded into the kernel.

It can be passed to LoadN6EntrypointObjects or ebpf.CollectionSpec.LoadAndAssign.

func (*N6EntrypointPrograms) Close

func (p *N6EntrypointPrograms) Close() error

type N6EntrypointSpecs

type N6EntrypointSpecs struct {
	N6EntrypointProgramSpecs
	N6EntrypointMapSpecs
}

N6EntrypointSpecs contains maps and programs before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type PdrInfo

type PdrInfo struct {
	OuterHeaderRemoval uint8
	FarId              uint32
	QerId              uint32
	SdfFilter          *SdfFilter
}

type PortRange

type PortRange struct {
	LowerBound uint16
	UpperBound uint16
}

type QerInfo

type QerInfo struct {
	GateStatusUL uint8
	GateStatusDL uint8
	Qfi          uint8
	MaxBitrateUL uint32
	MaxBitrateDL uint32
	StartUL      uint64
	StartDL      uint64
}

type SdfFilter

type SdfFilter struct {
	Protocol     uint8 // 0: icmp, 1: ip, 2: tcp, 3: udp, 4: icmp6
	SrcAddress   IpWMask
	SrcPortRange PortRange
	DstAddress   IpWMask
	DstPortRange PortRange
}

func (*SdfFilter) String

func (sdfFilter *SdfFilter) String() string

type UpfCounters

type UpfCounters struct {
	RxArp      uint64
	RxIcmp     uint64
	RxIcmp6    uint64
	RxIp4      uint64
	RxIp6      uint64
	RxTcp      uint64
	RxUdp      uint64
	RxOther    uint64
	RxGtpEcho  uint64
	RxGtpPdu   uint64
	RxGtpOther uint64
	RxGtpUnexp uint64
}

func (*UpfCounters) Add

func (current *UpfCounters) Add(nnew UpfCounters)

type UpfStatistic

type UpfStatistic struct {
	Counters UpfCounters
	XdpStats [5]uint64
}

type UpfXdpActionStatistic

type UpfXdpActionStatistic struct {
	BpfObjects *BpfObjects
}

func (*UpfXdpActionStatistic) GetAborted

func (stat *UpfXdpActionStatistic) GetAborted() uint64

func (*UpfXdpActionStatistic) GetDrop

func (stat *UpfXdpActionStatistic) GetDrop() uint64

func (*UpfXdpActionStatistic) GetPass

func (stat *UpfXdpActionStatistic) GetPass() uint64

func (*UpfXdpActionStatistic) GetRedirect

func (stat *UpfXdpActionStatistic) GetRedirect() uint64

func (*UpfXdpActionStatistic) GetTx

func (stat *UpfXdpActionStatistic) GetTx() uint64

func (*UpfXdpActionStatistic) GetUpfExtStatField

func (stat *UpfXdpActionStatistic) GetUpfExtStatField() UpfCounters

Getters for the upf_ext_stat (upf_counters)

type ZeroEntrypointMapSpecs

type ZeroEntrypointMapSpecs struct {
}

ZeroEntrypointMapSpecs contains maps before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type ZeroEntrypointMaps

type ZeroEntrypointMaps struct {
}

ZeroEntrypointMaps contains all maps after they have been loaded into the kernel.

It can be passed to LoadZeroEntrypointObjects or ebpf.CollectionSpec.LoadAndAssign.

func (*ZeroEntrypointMaps) Close

func (m *ZeroEntrypointMaps) Close() error

type ZeroEntrypointObjects

type ZeroEntrypointObjects struct {
	ZeroEntrypointPrograms
	ZeroEntrypointMaps
}

ZeroEntrypointObjects contains all objects after they have been loaded into the kernel.

It can be passed to LoadZeroEntrypointObjects or ebpf.CollectionSpec.LoadAndAssign.

func (*ZeroEntrypointObjects) Close

func (o *ZeroEntrypointObjects) Close() error

type ZeroEntrypointProgramSpecs

type ZeroEntrypointProgramSpecs struct {
	UpfN3EntrypointFunc *ebpf.ProgramSpec `ebpf:"upf_n3_entrypoint_func"`
}

ZeroEntrypointSpecs contains programs before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type ZeroEntrypointPrograms

type ZeroEntrypointPrograms struct {
	UpfN3EntrypointFunc *ebpf.Program `ebpf:"upf_n3_entrypoint_func"`
}

ZeroEntrypointPrograms contains all programs after they have been loaded into the kernel.

It can be passed to LoadZeroEntrypointObjects or ebpf.CollectionSpec.LoadAndAssign.

func (*ZeroEntrypointPrograms) Close

func (p *ZeroEntrypointPrograms) Close() error

type ZeroEntrypointSpecs

type ZeroEntrypointSpecs struct {
	ZeroEntrypointProgramSpecs
	ZeroEntrypointMapSpecs
}

ZeroEntrypointSpecs contains maps and programs before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

Jump to

Keyboard shortcuts

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