flow

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package flow implements a Lucius table that performs packet matches using an flow matching and satisfies the interface fwdtable.Table.

Index

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.

func (*Desc) Equal

func (d *Desc) Equal(d2 *Desc) bool

Equal returns true if two flow desc are equal.

func (*Desc) Fields

func (d *Desc) Fields() (keys []fwdpacket.FieldID, qualifiers []fwdpacket.FieldID)

Fields returns the list of fields specified in the flow desc's keys and qualifiers.

func (*Desc) Hash

func (d *Desc) Hash() uint32

Hash returns a hash value for the flow desc.

func (*Desc) String

func (d *Desc) String() string

String formats a flow descriptor as a string.

type Entry

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

A Entry associates a flow to a set of actions.

func (*Entry) String

func (e *Entry) String() string

String returns the entry as a formatted string.

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) Equal

func (k *EntryKey) Equal(k2 *EntryKey) bool

Equal returns true if two flow keys are equal.

func (*EntryKey) Match

func (k *EntryKey) Match(p PacketKey) bool

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.

func (*EntryKey) String

func (k *EntryKey) String() string

String returns the entry key as a formatted string.

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.

func NewFieldDesc

func NewFieldDesc() *FieldDesc

NewFieldDesc creates a FieldDesc with no fields.

func (*FieldDesc) String

func (f *FieldDesc) String() string

String returns the FieldDesc formatted as a string.

func (*FieldDesc) Update

func (f *FieldDesc) Update(fields []fwdpacket.FieldID) bool

Update updates a FieldDesc with a set of fields. If new fields are added to the FieldDesc, update recomputes the field list and returns true.

type FieldList

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

A FieldList is a sequence of field ids.

func NewFieldList

func NewFieldList(fm map[fwdpacket.FieldID]bool) *FieldList

NewFieldList creates a new FieldList from a set of fields.

func (*FieldList) MakeEntryKey

func (l *FieldList) MakeEntryKey(fd *Desc) *EntryKey

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

func (l *FieldList) MakePacketKey(packet fwdpacket.Packet) PacketKey

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.

func (*FieldList) Size

func (l *FieldList) Size() int

Size returns the number of bytes required for all fields in the FieldList.

func (*FieldList) String

func (l *FieldList) String() string

String returns a FieldList formatted as a string.

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

func NewMap(keyFields, qualifierFields *FieldList, bankID, priority uint32) *Map

NewMap creates a new flow map using the specified bank, priority and fields for the keys and qualifiers.

func (*Map) Add

func (m *Map) Add(fd *Desc, actions fwdaction.Actions) error

Add associates a set of actions with the specified flow.

func (*Map) Cleanup

func (m *Map) Cleanup()

Cleanup removes all entries in the keyMap and releases the actions.

func (*Map) Entries

func (m *Map) Entries() []string

Entries lists all entries in the FlowMap.

func (*Map) Find

func (m *Map) Find(fd *Desc) *Entry

Find finds the flow and returns the entry if it is found.

func (*Map) Lookup

func (m *Map) Lookup(fd *Desc) fwdaction.Actions

Lookup returns the actions whose flow is equal to the specified flow.

func (*Map) Match

func (m *Map) Match(key PacketKey, qualifier PacketQualifier) (bool, *Desc, fwdaction.Actions)

Match returns the actions whose flow matches the specified packet.

func (*Map) Remove

func (m *Map) Remove(fd *Desc) error

Remove removes the specified flow from the .

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

type PacketQualifier map[fwdpacket.FieldID][]byte

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

type Table struct {
	fwdobject.Base
	// contains filtered or unexported fields
}

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

func (t *Table) AddEntry(ed *fwdpb.EntryDesc, ad []*fwdpb.ActionDesc) error

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) Clear

func (t *Table) Clear()

Clear removes all entries in the table.

func (*Table) Entries

func (t *Table) Entries() []string

Entries lists all table entries in each bank in decreasing order of priority.

func (*Table) Process

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

func (t *Table) RemoveEntry(ed *fwdpb.EntryDesc) error

RemoveEntry removes the specified flow entry.

func (*Table) String

func (t *Table) String() string

String returns the table as a formatted string.

Jump to

Keyboard shortcuts

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