Documentation ¶
Overview ¶
Package bridge implements an exact match table that operates on the packet's mac address. It contains mac entries that are either provisioned or learned from the processed packets. It emulates a small L2 learning bridge.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Table ¶
type Table struct { *exact.Table // exact table containing mac entries // contains filtered or unexported fields }
Table is a learning bridge table that learns source mac and input ports from packets and processes packets using their destination mac address. The table can contain two types of entries: - Static entries that are added via provisioning. - Dynamic entries that are learned from the packet's source mac address. The dynamic entries are learned as "best-effort" i.e. a packet is not dropped if its mac address cannot be learned. Learned entries are timed out if they are not used.
When processing packets, the table creates learn requests for the packet's source mac and input port and enqueues them to a channel. A goroutine monitors the channel and adds the corresponding entries. Before enqueuing a learn request, the process function checks if the mac address already exists. This prevents learning existing mac addresses continously. When a mac address is initially learned, it is possible to have more than one learn request for the same mac address. Hence the channel used for learning is buffered.
func (*Table) Cleanup ¶
func (t *Table) Cleanup()
Cleanup cleans up the exact match table and stops learning.
func (*Table) Learn ¶
Learn learns the source mac and input port of the packet.
Before creating a learn request for the packet, it looks up the key in the exact match table. This prevents the learn channel from being filled up by learn requests for pre-existing mac addresses. It is assumed that the caller already holds the context's read lock i.e. it is called from an action or table.
Since the fields learned from the packet occur concurrent to packet processing, it is important that the learnRequest does not contain references into the packet.