ovsdb

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2019 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrGroupNotSupported is reported when group monitoring is not supported by ovs
	ErrGroupNotSupported = errors.New("Group monitoring is only possible on OpenFlow 1.5 and later because of an OVS bug")
)

Functions

func OvsMetadataDecoder added in v0.23.0

func OvsMetadataDecoder(raw json.RawMessage) (common.Getter, error)

OvsMetadataDecoder implements a json message raw decoder

Types

type BridgeOfProber added in v0.23.0

type BridgeOfProber interface {
	Monitor(ctx context.Context) error
	MonitorGroup() error
}

BridgeOfProber is the type of the probe retrieving Openflow rules on a Bridge.

func NewOfProbe added in v0.23.0

func NewOfProbe(bridge string, address string, g *graph.Graph, node *graph.Node) BridgeOfProber

NewOfProbe returns a new OpenFlow natively speaking probe

type Event

type Event struct {
	RawRule *RawRule           // The rule from the event
	Rules   []*jsonof.JSONRule // Rules found by ovs-ofctl matching the event rule filter.
	Date    int64              // the date of the event
	Action  string             // the action taken
	Bridge  string             // The bridge whtere it ocured
}

Event is an event as monitored by ovs-ofctl monitor <br> watch:

type Execute

type Execute interface {
	ExecCommand(string, ...string) ([]byte, error)
	ExecCommandPipe(context.Context, string, ...string) (io.Reader, Waiter, error)
}

Execute exposes an interface to command launch on the OS

type Match added in v0.23.0

type Match interface {
	of14.IMatchV3
}

Match is the interface of an OpenFlow match

type OfctlProbe added in v0.23.0

type OfctlProbe struct {
	Host       string                        // The global host
	Bridge     string                        // The bridge monitored
	UUID       string                        // The UUID of the bridge node
	Address    string                        // The address of the bridge if different from name
	BridgeNode *graph.Node                   // the bridge node on which the rule nodes are attached.
	OvsOfProbe *OvsOfProbe                   // Back pointer to the probe
	Rules      map[string][]*jsonof.JSONRule // The set of rules found so far grouped by rawUUID
	Groups     map[uint]*graph.Node          // The set of groups found so far
	// contains filtered or unexported fields
}

OfctlProbe describes an ovs-ofctl based OpenFlow rule prober. An important notion is the rawUUID of a rule or the UUID obtained by ignoring the priority from the rule filter. Several rules may differ only by their priority (and associated actions). In practice the highest priority hides the other rules. It is important to handle rules with the same rawUUID as a group because ovs-ofctl monitor does not report priorities.

func NewOfctlProbe added in v0.23.0

func NewOfctlProbe(host, bridge, uuid, address string, bridgeNode *graph.Node, o *OvsOfProbe) *OfctlProbe

NewOfctlProbe returns a new ovs-ofctl based OpenFlow probe

func (*OfctlProbe) Monitor added in v0.23.0

func (probe *OfctlProbe) Monitor(ctx context.Context) error

Monitor monitors the openflow rules of a bridge by launching a goroutine. The context is used to control the execution of the routine.

func (*OfctlProbe) MonitorGroup added in v0.23.0

func (probe *OfctlProbe) MonitorGroup() error

MonitorGroup monitors the openflow groups of a bridge by launching a goroutine. It uses OpenFlow 1.4 ForwardRequest command that is not directly available in ovs-ofctl

Note: Openflow15 is really needed. Receiving an insert_bucket on an OF14 monitor crashes the switch (yes, the switch itself) on OVS 2.9

type OvsMetadata added in v0.23.0

type OvsMetadata struct {
	OtherConfig      map[string]string         `json:"OtherConfig,omitempty"`
	Options          map[string]string         `json:"Options,omitempty"`
	Protocols        []string                  `json:"Protocols,omitempty"`
	DBVersion        string                    `json:"DBVersion,omitempty"`
	Version          string                    `json:"Version,omitempty"`
	Error            string                    `json:"Error,omitempty"`
	Metric           *topology.InterfaceMetric `json:"Metric,omitempty"`
	LastUpdateMetric *topology.InterfaceMetric `json:"LastUpdateMetric,omitempty"`
}

OvsMetadata describe Ovs metadata sub section easyjson:json

func (*OvsMetadata) GetField added in v0.23.0

func (o *OvsMetadata) GetField(key string) (interface{}, error)

GetField implements Getter interface

func (*OvsMetadata) GetFieldInt64 added in v0.23.0

func (o *OvsMetadata) GetFieldInt64(key string) (int64, error)

GetFieldInt64 implements Getter interface

func (*OvsMetadata) GetFieldKeys added in v0.23.0

func (o *OvsMetadata) GetFieldKeys() []string

GetFieldKeys returns the list of valid field of a Flow

func (*OvsMetadata) GetFieldString added in v0.23.0

func (o *OvsMetadata) GetFieldString(key string) (string, error)

GetFieldString implements Getter interface

type OvsOfProbe

type OvsOfProbe struct {
	sync.Mutex
	Host  string       // The host
	Graph *graph.Graph // The graph that will receive the rules found
	Root  *graph.Node  // The root node of the host in the graph

	Translation map[string]string // A translation table to find the url for a given bridge knowing its name
	Certificate string            // Path to the certificate used for authenticated communication with bridges
	PrivateKey  string            // Path of the private key authenticating the probe.
	CA          string            // Path of the certicate of the Certificate authority used for authenticated communication with bridges
	// contains filtered or unexported fields
}

OvsOfProbe is the type of the probe retrieving Openflow rules on an Open Vswitch

func NewOvsOfProbe

func NewOvsOfProbe(ctx context.Context, g *graph.Graph, root *graph.Node, host string) *OvsOfProbe

NewOvsOfProbe creates a new probe associated to a given graph, root node and host.

func (*OvsOfProbe) OnOvsBridgeAdd

func (o *OvsOfProbe) OnOvsBridgeAdd(bridgeNode *graph.Node)

OnOvsBridgeAdd is called when a bridge is added

func (*OvsOfProbe) OnOvsBridgeDel

func (o *OvsOfProbe) OnOvsBridgeDel(uuid string)

OnOvsBridgeDel is called when a bridge is deleted

type Probe added in v0.22.0

type Probe struct {
	sync.Mutex
	Graph      *graph.Graph
	Root       *graph.Node
	OvsMon     *ovsdb.OvsMonitor
	OvsOfProbe *OvsOfProbe
	// contains filtered or unexported fields
}

Probe describes a probe that reads OVS database and updates the graph

func NewProbe added in v0.22.0

func NewProbe(g *graph.Graph, n *graph.Node, p string, t string, enableStats bool) *Probe

NewProbe creates a new graph OVS database probe

func NewProbeFromConfig added in v0.22.0

func NewProbeFromConfig(g *graph.Graph, n *graph.Node, address string, enableStats bool) (*Probe, error)

NewProbeFromConfig creates a new probe based on configuration

func (*Probe) OnConnected added in v0.22.0

func (o *Probe) OnConnected(monitor *ovsdb.OvsMonitor)

OnConnected event

func (*Probe) OnDisconnected added in v0.22.0

func (o *Probe) OnDisconnected(monitor *ovsdb.OvsMonitor)

OnDisconnected event

func (*Probe) OnOvsBridgeAdd added in v0.22.0

func (o *Probe) OnOvsBridgeAdd(monitor *ovsdb.OvsMonitor, uuid string, row *libovsdb.RowUpdate)

OnOvsBridgeAdd event

func (*Probe) OnOvsBridgeDel added in v0.22.0

func (o *Probe) OnOvsBridgeDel(monitor *ovsdb.OvsMonitor, uuid string, row *libovsdb.RowUpdate)

OnOvsBridgeDel event

func (*Probe) OnOvsBridgeUpdate added in v0.22.0

func (o *Probe) OnOvsBridgeUpdate(monitor *ovsdb.OvsMonitor, uuid string, row *libovsdb.RowUpdate)

OnOvsBridgeUpdate event

func (*Probe) OnOvsInterfaceAdd added in v0.22.0

func (o *Probe) OnOvsInterfaceAdd(monitor *ovsdb.OvsMonitor, uuid string, row *libovsdb.RowUpdate)

OnOvsInterfaceAdd event

func (*Probe) OnOvsInterfaceDel added in v0.22.0

func (o *Probe) OnOvsInterfaceDel(monitor *ovsdb.OvsMonitor, uuid string, row *libovsdb.RowUpdate)

OnOvsInterfaceDel event

func (*Probe) OnOvsInterfaceUpdate added in v0.22.0

func (o *Probe) OnOvsInterfaceUpdate(monitor *ovsdb.OvsMonitor, uuid string, row *libovsdb.RowUpdate)

OnOvsInterfaceUpdate event

func (*Probe) OnOvsPortAdd added in v0.22.0

func (o *Probe) OnOvsPortAdd(monitor *ovsdb.OvsMonitor, uuid string, row *libovsdb.RowUpdate)

OnOvsPortAdd event

func (*Probe) OnOvsPortDel added in v0.22.0

func (o *Probe) OnOvsPortDel(monitor *ovsdb.OvsMonitor, uuid string, row *libovsdb.RowUpdate)

OnOvsPortDel event

func (*Probe) OnOvsPortUpdate added in v0.22.0

func (o *Probe) OnOvsPortUpdate(monitor *ovsdb.OvsMonitor, uuid string, row *libovsdb.RowUpdate)

OnOvsPortUpdate event

func (*Probe) OnOvsUpdate added in v0.22.0

func (o *Probe) OnOvsUpdate(monitor *ovsdb.OvsMonitor, row *libovsdb.RowUpdate)

OnOvsUpdate event

func (*Probe) Start added in v0.22.0

func (o *Probe) Start()

Start the probe

func (*Probe) Stop added in v0.22.0

func (o *Probe) Stop()

Stop the probe

type RawRule added in v0.23.0

type RawRule struct {
	Cookie   uint64 // cookie value of the rule
	Table    int    // table containing the rule
	Priority int    // priority of rule
	Filter   string // all the filters as a comma separated string
	UUID     string // Unique id
}

RawRule is an OpenFlow rule in a switch captured as an event.

type RealExecute

type RealExecute struct{}

RealExecute is the actual implementation given below. It can be overridden for tests.

func (RealExecute) ExecCommand

func (r RealExecute) ExecCommand(com string, args ...string) ([]byte, error)

ExecCommand executes a command on a host

func (RealExecute) ExecCommandPipe

func (r RealExecute) ExecCommandPipe(ctx context.Context, com string, args ...string) (io.Reader, Waiter, error)

ExecCommandPipe executes a command on a host and gives back a pipe to control it.

type Stats added in v0.23.0

type Stats struct {
	PacketCount int64
	ByteCount   int64
	FlowCount   int64
	Duration    time.Duration
	IdleTime    time.Duration
}

Stats holds the statistics of an OpenFlow rule

type Waiter added in v0.23.0

type Waiter interface {
	Wait() error
}

Waiter exposes an interface with a simple Wait method

Source Files

  • of10.go
  • of12.go
  • of13.go
  • of14.go
  • of15.go
  • ofctl.go
  • ofnative.go
  • ovs_of.go
  • ovsdb.go

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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