Documentation
¶
Overview ¶
Package fwdcontext contains routines for managing the context of the forwarding engine.
Index ¶
- type CPUPortSink
- type Context
- func (ctx *Context) CPUPortSink() CPUPortSink
- func (ctx *Context) Cleanup(ch chan bool, isPort func(*fwdpb.ObjectId) bool)
- func (ctx *Context) GetNotificationQueue() *queue.Queue
- func (ctx *Context) Notify(event *fwdpb.EventDesc) error
- func (ctx *Context) SetCPUPortSink(fn CPUPortSink, doneFn func()) error
- func (ctx *Context) SetNotification(call NotificationCallback) error
- func (ctx *Context) SetNotificationQueue(val *queue.Queue)
- func (ctx *Context) String() string
- type FakePortManager
- type NotificationCallback
- type Port
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CPUPortSink ¶ added in v0.4.0
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 ¶
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 ¶
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 ¶
GetNotificationQueue returns a pointer to the queue of notifications in the context.
func (*Context) Notify ¶
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 ¶
SetNotificationQueue sets the notification queue.
type FakePortManager ¶ added in v0.4.0
FakePortManager is an interface for creating custom ports for fwdpb FakePort.
type NotificationCallback ¶
An NotificationCallback generates events to a notification service.