Documentation ¶
Overview ¶
Package flow implements a Lucius table that performs packet matches using an flow matching and satisfies the interface fwdtable.Table.
Index ¶
- type Desc
- type Entry
- type EntryKey
- type EntryQualifier
- type FieldDesc
- type FieldList
- func (l *FieldList) MakeEntryKey(fd *Desc) *EntryKey
- func (l *FieldList) MakeEntryQualifier(fd *Desc) (*EntryQualifier, error)
- func (l *FieldList) MakePacketKey(packet fwdpacket.Packet) PacketKey
- func (l *FieldList) MakePacketQualifier(packet fwdpacket.Packet) PacketQualifier
- func (l *FieldList) Size() int
- func (l *FieldList) String() string
- type Map
- func (m *Map) Add(fd *Desc, actions fwdaction.Actions) error
- func (m *Map) Cleanup()
- func (m *Map) Entries() []string
- func (m *Map) Find(fd *Desc) *Entry
- func (m *Map) Lookup(fd *Desc) fwdaction.Actions
- func (m *Map) Match(key PacketKey, qualifier PacketQualifier) (bool, *Desc, fwdaction.Actions)
- func (m *Map) Remove(fd *Desc) error
- type PacketKey
- type PacketQualifier
- type Table
- func (t *Table) AddEntry(ed *fwdpb.EntryDesc, ad []*fwdpb.ActionDesc) error
- func (t *Table) Cleanup()
- func (t *Table) Clear()
- func (t *Table) Entries() []string
- func (t *Table) Process(packet fwdpacket.Packet, _ fwdobject.Counters) (fwdaction.Actions, fwdaction.State)
- func (t *Table) RemoveEntry(ed *fwdpb.EntryDesc) error
- func (t *Table) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Desc ¶
type Desc struct {
// contains filtered or unexported fields
}
A Desc describes a packet flow by specifying keys and qualifiers. keys specify values of packet fields by describing the bits in them. qualifiers specify values of packet fields as a value in a fwdset.Set.
func NewDesc ¶
func NewDesc(ctx *fwdcontext.Context, keys []*fwdpb.PacketFieldMaskedBytes, qualifiers []*fwdpb.PacketFieldSet) (*Desc, error)
NewDesc creates a new Desc corresponding to the specified keys and qualifiers.
type Entry ¶
type Entry struct {
// contains filtered or unexported fields
}
A Entry associates a flow to a set of actions.
type EntryKey ¶
type EntryKey struct {
// contains filtered or unexported fields
}
An EntryKey describes packet fields in a FlowDesc which can be matched to specific masked values. An EntryKey is formed by concatenating the value and mask of the packet fields in the sequence described by a FieldList. Note that each field is padded to its maximum size. If the packet does not contain a field in the FieldList, the value is set to zero.
func (*EntryKey) Match ¶
Match returns true if a PacketKey matches the EntryKey. Note:
- If the length of the EntryKey is 0, then all packets match the key.
- The EntryKey and PacketKey are assumed to be formed from the same FieldList, non-existing fields are added as zeroes. Hence the length of the EntryKey must be equal to the length of the PacketKey.
type EntryQualifier ¶
type EntryQualifier struct {
// contains filtered or unexported fields
}
An EntryQualifier describes packet fields in a FlowDesc which can be matched to values in the specified forwarding set (fwdset.Set). Note that the qualifier holds references to the forwarding sets.
func (*EntryQualifier) Cleanup ¶
func (q *EntryQualifier) Cleanup()
Cleanup cleans up any references in the qualifier.
func (*EntryQualifier) Equal ¶
func (q *EntryQualifier) Equal(q2 *EntryQualifier) bool
Equal returns true if two qualifiers are equal. Two qualifiers are set to be equal if they contain the exact same set of fields, and each field is associated to the same set. Note that the contents of the sets are not matched.
func (*EntryQualifier) Match ¶
func (q *EntryQualifier) Match(p PacketQualifier) bool
Match returns true if a PacketQualifier matches the EntryQualifier. Note:
- If the length of the EntryQualifier is 0, then all packets match it.
- When creating qualifiers from a FieldList, non-existing fields are not added. Hence the length of the qualifiers may not match.
func (*EntryQualifier) String ¶
func (q *EntryQualifier) String() string
String returns the entry qualifier as a formatted string.
type FieldDesc ¶
type FieldDesc struct {
// contains filtered or unexported fields
}
A FieldDesc describes a set of fields.
type FieldList ¶
type FieldList struct {
// contains filtered or unexported fields
}
A FieldList is a sequence of field ids.
func NewFieldList ¶
NewFieldList creates a new FieldList from a set of fields.
func (*FieldList) MakeEntryKey ¶
MakeEntryKey creates an EntryKey for a FlowDesc. The EntryKey is formed by concatenating the value and mask of the fieldKey in the FlowDesc in the sequence specified by the FieldList.
func (*FieldList) MakeEntryQualifier ¶
func (l *FieldList) MakeEntryQualifier(fd *Desc) (*EntryQualifier, error)
MakeEntryQualifier creates an EntryQualifier for a FlowDesc. The EntryQualifier is formed by referencing the Set specified in the FlowDesc for each field in FieldList.
func (*FieldList) MakePacketKey ¶
MakePacketKey makes a PacketKey for the specified packet.
func (*FieldList) MakePacketQualifier ¶
func (l *FieldList) MakePacketQualifier(packet fwdpacket.Packet) PacketQualifier
MakePacketQualifier makes a PacketQualifier for the specified packet.
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
A Map maps flows to actions. It supports two methods for finding actions. - Lookup: Actions are found by looking up the flow in the hash table. - Match: Actions are found by sequentially matching flows to a specified key. A flow is said to match a key if it is equal to the key masked with the flow.
All flows in the map have an equal length.
func NewMap ¶
NewMap creates a new flow map using the specified bank, priority and fields for the keys and qualifiers.
func (*Map) Cleanup ¶
func (m *Map) Cleanup()
Cleanup removes all entries in the keyMap and releases the actions.
type PacketKey ¶
type PacketKey []byte
A PacketKey is a sequence of bytes formed by concatenating packet fields in a sequence specified by a FieldList. Note that each field is padded to its maximum size. If the packet does not contain a field in the FieldList, the value is set to zero.
type PacketQualifier ¶
A PacketQualifier is a set of packet fields as specified by a FieldList. Note that each field is padded to its maximum size. If the packet does not contain a field in the FieldList, the field is not added to the qualifier.
type Table ¶
A Table matches packet flows to actions. The table provisioning is modeled as a TCAM; it consists of multiple "banks" each of which contains a priority ordered set of flows. When a packet is processed by the table it is matched against flows in priority order within each bank.
There are two types of fields in the flow desc; keys and qualifiers.
- keys are fields whose values are described as a set of bits. The bits are expressed as the value and mask.
- qualifiers are fields whose values are described as one of the values in a precreated forwarding set.
The entries within the flow table are described using FieldDesc, formed by a union of all fields used in various flows in the table. The fields in the desc are learned as flow entries are added into the table. If the FieldDesc does not contain a field in a newly added flow entry, it is expanded and the flow table is rebuilt. Note that fields are never removed from the key desc. It is assumed that most flows within the table will have similar fields.
The flow table optimizes packet matching by computing FieldDesc for keys and qualifiers. For each packet, the qualifier and key is computed for all fields just once and then these are matched against all flows sequentially. This reduces the overhead of query the same field of the packet for each field.
func (*Table) AddEntry ¶
AddEntry adds or updates the actions associated with the specified flow entry.
func (*Table) Cleanup ¶
func (t *Table) Cleanup()
Cleanup releases all references held by the table and its entries.
func (*Table) Entries ¶
Entries lists all table entries in each bank in decreasing order of priority.
func (*Table) Process ¶
func (t *Table) Process(packet fwdpacket.Packet, _ fwdobject.Counters) (fwdaction.Actions, fwdaction.State)
Process matches the packet to the entries within the table to determine the actions to be performed. If the packet does not match any entries, the default actions are used. In case of errors, the packet is dropped.
func (*Table) RemoveEntry ¶
RemoveEntry removes the specified flow entry.