ovsdb

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: Apache-2.0 Imports: 47 Imported by: 3

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 NewProbe added in v0.21.0

func NewProbe(ctx tp.Context, bundle *probe.Bundle) (probe.Handler, error)

NewProbe returns a new OVSDB topology probe

func OvsMetadataDecoder added in v0.23.0

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

OvsMetadataDecoder implements a json message raw decoder

func Register added in v0.26.0

func Register()

Register registers graph metadata decoders

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(ctx tp.Context, bridge string, address string, tlsConfig *tls.Config) 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 {
	Ctx     tp.Context                    // Probe context
	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
	Handler *OvsOfProbeHandler            // 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(ctx tp.Context, host, bridge, uuid, address string, handler *OvsOfProbeHandler) *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 gendecoder

func (*OvsMetadata) GetField added in v0.23.0

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

func (*OvsMetadata) GetFieldBool added in v0.26.0

func (obj *OvsMetadata) GetFieldBool(key string) (bool, error)

func (*OvsMetadata) GetFieldInt64 added in v0.23.0

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

func (*OvsMetadata) GetFieldKeys added in v0.23.0

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

func (*OvsMetadata) GetFieldString added in v0.23.0

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

func (OvsMetadata) MarshalEasyJSON added in v0.26.0

func (v OvsMetadata) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (OvsMetadata) MarshalJSON added in v0.26.0

func (v OvsMetadata) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*OvsMetadata) MatchBool added in v0.26.0

func (obj *OvsMetadata) MatchBool(key string, predicate getter.BoolPredicate) bool

func (*OvsMetadata) MatchInt64 added in v0.26.0

func (obj *OvsMetadata) MatchInt64(key string, predicate getter.Int64Predicate) bool

func (*OvsMetadata) MatchString added in v0.26.0

func (obj *OvsMetadata) MatchString(key string, predicate getter.StringPredicate) bool

func (*OvsMetadata) UnmarshalEasyJSON added in v0.26.0

func (v *OvsMetadata) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*OvsMetadata) UnmarshalJSON added in v0.26.0

func (v *OvsMetadata) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type OvsOfProbeHandler added in v0.25.0

type OvsOfProbeHandler struct {
	sync.Mutex

	Ctx tp.Context // Probe context
	// contains filtered or unexported fields
}

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

func NewOvsOfProbeHandler added in v0.25.0

func NewOvsOfProbeHandler(cancelCtx context.Context, ctx tp.Context, host string, protocol string) (*OvsOfProbeHandler, error)

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

func (*OvsOfProbeHandler) OnOvsBridgeAdd added in v0.25.0

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

OnOvsBridgeAdd is called when a bridge is added

func (*OvsOfProbeHandler) OnOvsBridgeDel added in v0.25.0

func (o *OvsOfProbeHandler) OnOvsBridgeDel(uuid string)

OnOvsBridgeDel is called when a bridge is deleted

type Probe added in v0.21.0

type Probe struct {
	sync.Mutex
	Ctx     tp.Context
	OvsMon  *ovsdb.OvsMonitor
	Handler *OvsOfProbeHandler
	// contains filtered or unexported fields
}

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

func (*Probe) OnConnected added in v0.21.0

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

OnConnected event

func (*Probe) OnDisconnected added in v0.21.0

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

OnDisconnected event

func (*Probe) OnOvsBridgeAdd added in v0.21.0

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

OnOvsBridgeAdd event

func (*Probe) OnOvsBridgeDel added in v0.21.0

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

OnOvsBridgeDel event

func (*Probe) OnOvsBridgeUpdate added in v0.21.0

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

OnOvsBridgeUpdate event

func (*Probe) OnOvsInterfaceAdd added in v0.21.0

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

OnOvsInterfaceAdd event

func (*Probe) OnOvsInterfaceDel added in v0.21.0

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

OnOvsInterfaceDel event

func (*Probe) OnOvsInterfaceUpdate added in v0.21.0

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

OnOvsInterfaceUpdate event

func (*Probe) OnOvsPortAdd added in v0.21.0

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

OnOvsPortAdd event

func (*Probe) OnOvsPortDel added in v0.21.0

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

OnOvsPortDel event

func (*Probe) OnOvsPortUpdate added in v0.21.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.21.0

func (o *Probe) Start() error

Start the probe

func (*Probe) Stop added in v0.21.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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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