engine

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Copyright 2024 Ella Networks

Copyright 2024 Ella Networks

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFlowReportRequest

func BuildFlowReportRequest(flow ebpf.N3N6EntrypointFlow, stats ebpf.N3N6EntrypointFlowStats) *models.FlowReportRequest

BuildFlowReportRequest converts an eBPF flow record to a FlowReportRequest without sending it. Used by the batch reporting path.

func SetN3InterfaceIndex

func SetN3InterfaceIndex(idx int)

SetN3InterfaceIndex records the N3 (radio-side) network interface index so that flow direction can be derived: ingress on N3 means uplink, otherwise downlink.

Types

type FteIDResourceManager

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

func NewFteIDResourceManager

func NewFteIDResourceManager(teidRange uint32) (*FteIDResourceManager, error)

func (*FteIDResourceManager) AllocateTEID

func (m *FteIDResourceManager) AllocateTEID(seID uint64) (uint32, error)

func (*FteIDResourceManager) ReleaseTEID

func (m *FteIDResourceManager) ReleaseTEID(seID uint64)

type PDRCreationContext

type PDRCreationContext struct {
	Session              *Session
	FteIDResourceManager *FteIDResourceManager
	TEIDCache            map[uint8]uint32
}

func NewPDRCreationContext

func NewPDRCreationContext(session *Session, resourceManager *FteIDResourceManager) *PDRCreationContext

func (*PDRCreationContext) ExtractPDR

func (pdrContext *PDRCreationContext) ExtractPDR(pdr models.PDR, spdrInfo *SPDRInfo, farMap map[uint32]ebpf.FarInfo, qerMap map[uint32]ebpf.QerInfo) error

ExtractPDR populates spdrInfo from a models.PDR, looking up the referenced FAR and QER from the provided maps.

type SMFReportHandler

type SMFReportHandler interface {
	HandleDownlinkDataReport(context.Context, *models.DownlinkDataReport) error
	HandleUsageReport(context.Context, *models.UsageReport) error
	SendFlowReports(context.Context, []*models.FlowReportRequest) error
}

SMFReportHandler is the callback interface the UPF uses to deliver reports (downlink data notifications, usage measurements, flow stats) back to the SMF.

type SPDRInfo

type SPDRInfo struct {
	PdrID     uint32
	PdrInfo   ebpf.PdrInfo
	TeID      uint32
	UEIP      netip.Addr
	Allocated bool
}

type SdfIndexAllocator

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

SdfIndexAllocator manages allocation of slots in the sdf_filters BPF array. Index 0 is permanently reserved as "no filter".

func NewSdfIndexAllocator

func NewSdfIndexAllocator(maxSlots uint32) *SdfIndexAllocator

func (*SdfIndexAllocator) Allocate

func (a *SdfIndexAllocator) Allocate() (uint32, error)

func (*SdfIndexAllocator) Release

func (a *SdfIndexAllocator) Release(idx uint32)

type Session

type Session struct {
	SEID uint64
	// contains filtered or unexported fields
}

func NewSession

func NewSession(seid uint64) *Session

func (*Session) GetFar

func (s *Session) GetFar(id uint32) ebpf.FarInfo

func (*Session) GetPDR

func (s *Session) GetPDR(id uint32) SPDRInfo

func (*Session) GetQer

func (s *Session) GetQer(id uint32) ebpf.QerInfo

GetQer returns the QER with the given ID.

func (*Session) HasPDR

func (s *Session) HasPDR(id uint32) bool

func (*Session) ListFARs

func (s *Session) ListFARs() map[uint32]ebpf.FarInfo

ListFARs returns a snapshot copy of the FAR map.

func (*Session) ListPDRs

func (s *Session) ListPDRs() map[uint32]SPDRInfo

ListPDRs returns a snapshot copy of the PDR map.

func (*Session) ListQERs

func (s *Session) ListQERs() map[uint32]ebpf.QerInfo

ListQERs returns a snapshot copy of the QER map.

func (*Session) NewQer

func (s *Session) NewQer(id uint32, qerInfo ebpf.QerInfo)

NewQer stores a QER by ID so that future PDR creation can look it up.

func (*Session) PolicyID

func (s *Session) PolicyID() int64

func (*Session) PutFar

func (s *Session) PutFar(id uint32, farInfo ebpf.FarInfo)

func (*Session) PutPDR

func (s *Session) PutPDR(id uint32, info SPDRInfo)

func (*Session) RemoveFar

func (s *Session) RemoveFar(id uint32)

func (*Session) RemovePDR

func (s *Session) RemovePDR(id uint32) SPDRInfo

func (*Session) SetPolicyID

func (s *Session) SetPolicyID(id int64)

type SessionEngine

type SessionEngine struct {
	BpfObjects           *ebpf.BpfObjects
	FteIDResourceManager *FteIDResourceManager
	SdfIndexAllocator    *SdfIndexAllocator
	// contains filtered or unexported fields
}

func NewSessionEngine

func NewSessionEngine(addr string, nodeID string, n3Ip string, advertisedN3Ip string, bpfObjects *ebpf.BpfObjects, resourceManager *FteIDResourceManager) (*SessionEngine, error)

func (*SessionEngine) AddSession

func (pc *SessionEngine) AddSession(seid uint64, session *Session)

func (*SessionEngine) DeleteSession

func (conn *SessionEngine) DeleteSession(ctx context.Context, req *models.DeleteRequest) error

DeleteSession deletes an existing UPF session by SEID.

func (*SessionEngine) EstablishSession

func (conn *SessionEngine) EstablishSession(ctx context.Context, req *models.EstablishRequest) (*models.EstablishResponse, error)

EstablishSession creates a new UPF session from typed Go structs, bypassing PFCP message encoding/decoding.

func (*SessionEngine) GetAdvertisedN3Address

func (pc *SessionEngine) GetAdvertisedN3Address() netip.Addr

func (*SessionEngine) GetSession

func (pc *SessionEngine) GetSession(seid uint64) *Session

func (*SessionEngine) InitializeFiltersFromDB

func (pc *SessionEngine) InitializeFiltersFromDB(ctx context.Context, dbInstance *db.Database) error

func (*SessionEngine) ListSessions

func (pc *SessionEngine) ListSessions() map[uint64]*Session

func (*SessionEngine) ModifySession

func (conn *SessionEngine) ModifySession(ctx context.Context, req *models.ModifyRequest) error

ModifySession modifies an existing UPF session from typed Go structs.

func (*SessionEngine) ReleaseResources

func (connection *SessionEngine) ReleaseResources(seID uint64)

func (*SessionEngine) SendDownlinkDataReport

func (conn *SessionEngine) SendDownlinkDataReport(ctx context.Context, smf SMFReportHandler, localSeid uint64, pdrid uint16, qfi uint8) error

func (*SessionEngine) SendUsageReport

func (conn *SessionEngine) SendUsageReport(ctx context.Context, smf SMFReportHandler, localSeid uint64, uvol uint64, dvol uint64) error

func (*SessionEngine) SetAdvertisedN3Address

func (pc *SessionEngine) SetAdvertisedN3Address(newN3Addr netip.Addr)

func (*SessionEngine) SetBPFObjects

func (pc *SessionEngine) SetBPFObjects(ctx context.Context, bpfObjects *ebpf.BpfObjects, dbInstance *db.Database)

func (*SessionEngine) UpdateFilters

func (conn *SessionEngine) UpdateFilters(_ context.Context, policyID int64, direction models.Direction, rules []models.FilterRule) error

UpdateFilters is an idempotent PUT-style operation for the sdf_filters BPF slot of a given (PolicyID, Direction) pair.

  • Non-empty rules: allocate or update the BPF slot, propagate to PDRs.
  • Empty rules: deallocate the slot and reset PDRs to NoFilterIndex.

Jump to

Keyboard shortcuts

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