fwdcontext

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package fwdcontext contains routines for managing the context of the forwarding engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPUPortSink added in v0.4.0

type CPUPortSink func(*pktiopb.PacketOut) error

type Context

type Context struct {
	sync.RWMutex                  // Synchronization between provisioning and forwarding
	Objects      *fwdobject.Table // Set of all visible forwarding objects
	ID           string           // ID of the context
	Instance     string           // Name of the forwarding engine instance
	Attributes   fwdattribute.Set

	// FakePortManager is the implementation of the port creator for the Fake port type.
	FakePortManager FakePortManager
	// contains filtered or unexported fields
}

A Context encapsulates the state of an instance of the forwarding engine.

A context is the domain for synchronization. There are two users of context; provisioning and packet processing. Provisioning takes a rw lock on the context, and modifies objects within the context. Packet processing takes a read-lock on the context to process packets. Since provisioning and packet processing directly manipulate objects within the context, they must explicitly take the appropriate lock.

The context provides mechanisms to send notifications (notify) and packets (punt). Notify is non-blocking and sends notifications via an unbounded queue. Punt is a blocking call, and the caller is responsible for ordering and blocking guarantees.

func New

func New(id, instance string) *Context

New creates a new forwarding context with the specified id and fwd engine name. The id identifies the forwarding context in an forwarding engine instance, and the instance identifies the forwarding engine instance in the universe.

func (*Context) CPUPortSink added in v0.4.0

func (ctx *Context) CPUPortSink() CPUPortSink

PacketSink returns a handler to port control service

func (*Context) Cleanup

func (ctx *Context) Cleanup(ch chan bool, isPort func(*fwdpb.ObjectId) bool)

Cleanup cleans up the context. It first cleans up the objects that satisfy isPort. Then it unblocks the caller by sending a message on the channel. Then it cleans up the rest of the objects.

func (*Context) GetNotificationQueue

func (ctx *Context) GetNotificationQueue() *queue.Queue

GetNotificationQueue returns a pointer to the queue of notifications in the context.

func (*Context) Notify

func (ctx *Context) Notify(event *fwdpb.EventDesc) error

Notify enqueues a notification request if there is a notification service. This is a non-blocking call.

func (*Context) SetCPUPortSink added in v0.4.0

func (ctx *Context) SetCPUPortSink(fn CPUPortSink, doneFn func()) error

SetCPUPortSink sets the port control service for the context

func (*Context) SetNotification

func (ctx *Context) SetNotification(call NotificationCallback) error

SetNotification sets the notification service for the context. If the notification service is set to nil, notifications are disabled for the context.

func (*Context) SetNotificationQueue

func (ctx *Context) SetNotificationQueue(val *queue.Queue)

SetNotificationQueue sets the notification queue.

func (*Context) String

func (ctx *Context) String() string

String returns a formatted string representing the context.

type FakePortManager added in v0.4.0

type FakePortManager interface {
	CreatePort(string) (Port, error)
}

FakePortManager is an interface for creating custom ports for fwdpb FakePort.

type NotificationCallback

type NotificationCallback func(*fwdpb.EventDesc)

An NotificationCallback generates events to a notification service.

type Port added in v0.4.0

type Port interface {
	gopacket.PacketDataSource
	WritePacketData(data []byte) error
}

Port is an interface for reading and writing to a port.

Jump to

Keyboard shortcuts

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