ebpf

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: Apache-2.0 Imports: 14 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 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.

Types

type BpfObjects

type BpfObjects struct {
	N3EntrypointObjects
	N6EntrypointObjects

	FarIDTracker *IDTracker
	QerIDTracker *IDTracker
}

func NewBpfObjects

func NewBpfObjects(farMapSize uint32, qerMapSize uint32) *BpfObjects

func (*BpfObjects) Close

func (bpfObjects *BpfObjects) Close() error

func (*BpfObjects) DeleteDownlinkPdrIP6 added in v0.0.11

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

func (*BpfObjects) DeleteFar

func (bpfObjects *BpfObjects) DeleteFar(internalID 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 added in v0.0.11

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

func (bpfObjects *BpfObjects) UpdateFar(internalID uint32, farInfo FarInfo) 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 IDTracker added in v0.0.11

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

func NewIDTracker added in v0.0.11

func NewIDTracker(size uint32) *IDTracker

func (*IDTracker) GetNext added in v0.0.11

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

func (*IDTracker) Release added in v0.0.11

func (t *IDTracker) Release(id uint32)

type IPWMask added in v0.0.11

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 N3EntrypointFarInfo added in v0.0.8

type N3EntrypointFarInfo struct {
	Action              uint8
	OuterHeaderCreation uint8

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

type N3EntrypointIn6Addr added in v0.0.8

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

type N3EntrypointMapSpecs

type N3EntrypointMapSpecs struct {
	FarMap              *ebpf.MapSpec `ebpf:"far_map"`
	N3PdrMapDownlinkIp4 *ebpf.MapSpec `ebpf:"n3_pdr_map_downlink_ip4"`
	N3PdrMapDownlinkIp6 *ebpf.MapSpec `ebpf:"n3_pdr_map_downlink_ip6"`
	N3PdrMapUplinkIp4   *ebpf.MapSpec `ebpf:"n3_pdr_map_uplink_ip4"`
	QerMap              *ebpf.MapSpec `ebpf:"qer_map"`
	UpfN3Stat           *ebpf.MapSpec `ebpf:"upf_n3_stat"`
	UpfRouteStat        *ebpf.MapSpec `ebpf:"upf_route_stat"`
}

N3EntrypointMapSpecs contains maps before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type N3EntrypointMaps

type N3EntrypointMaps struct {
	FarMap              *ebpf.Map `ebpf:"far_map"`
	N3PdrMapDownlinkIp4 *ebpf.Map `ebpf:"n3_pdr_map_downlink_ip4"`
	N3PdrMapDownlinkIp6 *ebpf.Map `ebpf:"n3_pdr_map_downlink_ip6"`
	N3PdrMapUplinkIp4   *ebpf.Map `ebpf:"n3_pdr_map_uplink_ip4"`
	QerMap              *ebpf.Map `ebpf:"qer_map"`
	UpfN3Stat           *ebpf.Map `ebpf:"upf_n3_stat"`
	UpfRouteStat        *ebpf.Map `ebpf:"upf_route_stat"`
}

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 N3EntrypointN3PdrInfo added in v0.0.8

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

	N3SdfRules struct {
		N3SdfFilter 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 CombineN3PdrWithSdf added in v0.0.8

func CombineN3PdrWithSdf(defaultPdr *N3EntrypointN3PdrInfo, sdfPdr PdrInfo) N3EntrypointN3PdrInfo

func PreprocessN3PdrWithSdf added in v0.0.8

func PreprocessN3PdrWithSdf(lookup func(interface{}, interface{}) error, key interface{}, pdrInfo PdrInfo) (N3EntrypointN3PdrInfo, error)

func ToN3EntrypointPdrInfo added in v0.0.8

func ToN3EntrypointPdrInfo(defaultPdr PdrInfo) N3EntrypointN3PdrInfo

type N3EntrypointObjects

type N3EntrypointObjects struct {
	N3EntrypointPrograms
	N3EntrypointMaps
	N3EntrypointVariables
}

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"`
}

N3EntrypointProgramSpecs 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 N3EntrypointQerInfo added in v0.0.8

type N3EntrypointQerInfo struct {
	UlGateStatus uint8
	DlGateStatus uint8
	Qfi          uint8

	UlMaximumBitrate uint32
	DlMaximumBitrate uint32

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

type N3EntrypointRouteStat added in v0.0.8

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

type N3EntrypointSpecs

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

It can be passed ebpf.CollectionSpec.Assign.

type N3EntrypointUpfN3Statistic added in v0.0.8

type N3EntrypointUpfN3Statistic struct {
	UpfN3Counters struct{ UlBytes uint64 }
	UpfN3Counter  struct {
		RxN3 uint64
		TxN3 uint64
	}
	XdpActions [8]uint64
}

type N3EntrypointVariableSpecs added in v0.0.7

type N3EntrypointVariableSpecs struct {
}

N3EntrypointVariableSpecs contains global variables before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type N3EntrypointVariables added in v0.0.7

type N3EntrypointVariables struct {
}

N3EntrypointVariables contains all global variables after they have been loaded into the kernel.

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

type N6EntrypointFarInfo added in v0.0.8

type N6EntrypointFarInfo struct {
	Action              uint8
	OuterHeaderCreation uint8

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

type N6EntrypointIn6Addr added in v0.0.8

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

type N6EntrypointMapSpecs

type N6EntrypointMapSpecs 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"`
	UpfN6Stat         *ebpf.MapSpec `ebpf:"upf_n6_stat"`
	UpfRouteStat      *ebpf.MapSpec `ebpf:"upf_route_stat"`
}

N6EntrypointMapSpecs contains maps before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type N6EntrypointMaps

type N6EntrypointMaps 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"`
	UpfN6Stat         *ebpf.Map `ebpf:"upf_n6_stat"`
	UpfRouteStat      *ebpf.Map `ebpf:"upf_route_stat"`
}

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

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 N6EntrypointPdrInfo added in v0.0.8

type N6EntrypointPdrInfo 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 CombineN6PdrWithSdf added in v0.0.8

func CombineN6PdrWithSdf(defaultPdr *N6EntrypointPdrInfo, sdfPdr PdrInfo) N6EntrypointPdrInfo

func PreprocessN6PdrWithSdf added in v0.0.8

func PreprocessN6PdrWithSdf(lookup func(interface{}, interface{}) error, key interface{}, pdrInfo PdrInfo) (N6EntrypointPdrInfo, error)

func ToN6EntrypointPdrInfo added in v0.0.8

func ToN6EntrypointPdrInfo(defaultPdr PdrInfo) N6EntrypointPdrInfo

type N6EntrypointProgramSpecs

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

N6EntrypointProgramSpecs 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 N6EntrypointQerInfo added in v0.0.8

type N6EntrypointQerInfo struct {
	UlGateStatus uint8
	DlGateStatus uint8
	Qfi          uint8

	UlMaximumBitrate uint32
	DlMaximumBitrate uint32

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

type N6EntrypointRouteStat added in v0.0.8

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

type N6EntrypointSpecs

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

It can be passed ebpf.CollectionSpec.Assign.

type N6EntrypointUpfN6Statistic added in v0.0.8

type N6EntrypointUpfN6Statistic struct {
	UpfN6Counters struct{ DlBytes uint64 }
	UpfN6Counter  struct {
		RxN6 uint64
		TxN6 uint64
	}
	XdpActions [8]uint64
}

type N6EntrypointVariableSpecs added in v0.0.7

type N6EntrypointVariableSpecs struct {
}

N6EntrypointVariableSpecs contains global variables before they are loaded into the kernel.

It can be passed ebpf.CollectionSpec.Assign.

type N6EntrypointVariables added in v0.0.7

type N6EntrypointVariables struct {
}

N6EntrypointVariables contains all global variables after they have been loaded into the kernel.

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

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 UpfN3Counters added in v0.0.8

type UpfN3Counters 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
	UlBytes    uint64
}

type UpfStatistic

type UpfStatistic struct {
	N3Counters UpfN3Counters
	XdpStats   [5]uint64
}

type UpfXdpActionStatistic

type UpfXdpActionStatistic struct {
	BpfObjects *BpfObjects
}

func (*UpfXdpActionStatistic) GetN3Aborted added in v0.0.8

func (stat *UpfXdpActionStatistic) GetN3Aborted() uint64

func (*UpfXdpActionStatistic) GetN3Drop added in v0.0.8

func (stat *UpfXdpActionStatistic) GetN3Drop() uint64

func (*UpfXdpActionStatistic) GetN3Pass added in v0.0.8

func (stat *UpfXdpActionStatistic) GetN3Pass() uint64

func (*UpfXdpActionStatistic) GetN3Redirect added in v0.0.8

func (stat *UpfXdpActionStatistic) GetN3Redirect() uint64

func (*UpfXdpActionStatistic) GetN3Tx added in v0.0.8

func (stat *UpfXdpActionStatistic) GetN3Tx() uint64

func (*UpfXdpActionStatistic) GetN3UplinkThroughputStats added in v0.0.8

func (stat *UpfXdpActionStatistic) GetN3UplinkThroughputStats() uint64

func (*UpfXdpActionStatistic) GetN6Aborted added in v0.0.8

func (stat *UpfXdpActionStatistic) GetN6Aborted() uint64

func (*UpfXdpActionStatistic) GetN6DownlinkThroughputStats added in v0.0.8

func (stat *UpfXdpActionStatistic) GetN6DownlinkThroughputStats() uint64

func (*UpfXdpActionStatistic) GetN6Drop added in v0.0.8

func (stat *UpfXdpActionStatistic) GetN6Drop() uint64

func (*UpfXdpActionStatistic) GetN6Redirect added in v0.0.8

func (stat *UpfXdpActionStatistic) GetN6Redirect() uint64

func (*UpfXdpActionStatistic) GetN6Tx added in v0.0.8

func (stat *UpfXdpActionStatistic) GetN6Tx() uint64

Jump to

Keyboard shortcuts

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