Documentation ¶
Overview ¶
Package ovs is a client library for Open vSwitch which enables programmatic control of the virtual switch.
Index ¶
- Constants
- Variables
- func IsPortNotExist(err error) bool
- func SetState(state CTState) string
- func SetTCPFlag(flag TCPFlag) string
- func UnsetState(state CTState) string
- func UnsetTCPFlag(flag TCPFlag) string
- type Action
- func Conjunction(id int, dimensionNumber int, dimensionSize int) Action
- func ConnectionTracking(args string) Action
- func DecTTL() Action
- func Drop() Action
- func Flood() Action
- func InPort() Action
- func Load(value string, field string) Action
- func Local() Action
- func ModDataLinkDestination(addr net.HardwareAddr) Action
- func ModDataLinkSource(addr net.HardwareAddr) Action
- func ModNetworkDestination(ip net.IP) Action
- func ModNetworkSource(ip net.IP) Action
- func ModTransportDestinationPort(port uint16) Action
- func ModTransportSourcePort(port uint16) Action
- func ModVLANVID(vid int) Action
- func Move(src string, dst string) Action
- func Normal() Action
- func Output(port int) Action
- func Resubmit(port int, table int) Action
- func ResubmitPort(port int) Action
- func SetField(value string, field string) Action
- func SetTunnel(tunnelID uint64) Action
- func StripVLAN() Action
- type BitRange
- type BridgeOptions
- type CTState
- type Client
- type Error
- type ExecFunc
- type FailMode
- type Flow
- type FlowError
- type FlowStats
- type FlowTransaction
- type InterfaceOptions
- type InterfaceType
- type Match
- func ARPOperation(oper uint16) Match
- func ARPSourceHardwareAddress(addr net.HardwareAddr) Match
- func ARPSourceProtocolAddress(ip string) Match
- func ARPTargetHardwareAddress(addr net.HardwareAddr) Match
- func ARPTargetProtocolAddress(ip string) Match
- func ConjunctionID(id uint32) Match
- func ConnectionTrackingMark(mark, mask uint32) Match
- func ConnectionTrackingState(state ...string) Match
- func ConnectionTrackingZone(zone uint16) Match
- func DataLinkDestination(addr string) Match
- func DataLinkSource(addr string) Match
- func DataLinkType(etherType uint16) Match
- func DataLinkVLAN(vid int) Match
- func ICMPType(typ uint8) Match
- func IPv6Destination(ip string) Match
- func IPv6Source(ip string) Match
- func NeighborDiscoverySourceLinkLayer(addr net.HardwareAddr) Match
- func NeighborDiscoveryTarget(ip string) Match
- func NeighborDiscoveryTargetLinkLayer(addr net.HardwareAddr) Match
- func NetworkDestination(ip string) Match
- func NetworkProtocol(num uint8) Match
- func NetworkSource(ip string) Match
- func TCPFlags(flags ...string) Match
- func TransportDestinationMaskedPort(port uint16, mask uint16) Match
- func TransportDestinationPort(port uint16) Match
- func TransportSourceMaskedPort(port uint16, mask uint16) Match
- func TransportSourcePort(port uint16) Match
- func TunnelID(id uint64) Match
- func TunnelIDWithMask(id, mask uint64) Match
- func VLANTCI(tci, mask uint16) Match
- type MatchFlow
- type MatchFlowError
- type OpenFlowService
- func (o *OpenFlowService) AddFlow(bridge string, flow *Flow) error
- func (o *OpenFlowService) AddFlowBundle(bridge string, fn func(tx *FlowTransaction) error) error
- func (o *OpenFlowService) DelFlows(bridge string, flow *MatchFlow) error
- func (o *OpenFlowService) DumpAggregate(bridge string, flow *MatchFlow) (*FlowStats, error)
- func (o *OpenFlowService) DumpFlows(bridge string) ([]*Flow, error)
- func (o *OpenFlowService) DumpPort(bridge string, port string) (*PortStats, error)
- func (o *OpenFlowService) DumpPorts(bridge string) ([]*PortStats, error)
- func (o *OpenFlowService) DumpTables(bridge string) ([]*Table, error)
- func (o *OpenFlowService) ModPort(bridge string, port string, action PortAction) error
- type OptionFunc
- func Debug(enable bool) OptionFunc
- func Exec(fn ExecFunc) OptionFunc
- func FlowFormat(format string) OptionFunc
- func Pipe(fn PipeFunc) OptionFunc
- func Protocols(versions []string) OptionFunc
- func SetSSLParam(pkey string, cert string, cacert string) OptionFunc
- func SetTCPParam(addr string) OptionFunc
- func Sudo() OptionFunc
- func Timeout(seconds int) OptionFunc
- type PipeFunc
- type PortAction
- type PortRange
- type PortStats
- type PortStatsReceive
- type PortStatsTransmit
- type Protocol
- type TCPFlag
- type Table
- type TransportPortRanger
- type VSwitchGetService
- type VSwitchService
- func (v *VSwitchService) AddBridge(bridge string) error
- func (v *VSwitchService) AddPort(bridge string, port string) error
- func (v *VSwitchService) DeleteBridge(bridge string) error
- func (v *VSwitchService) DeletePort(bridge string, port string) error
- func (v *VSwitchService) GetController(bridge string) (string, error)
- func (v *VSwitchService) GetFailMode(bridge string) (FailMode, error)
- func (v *VSwitchService) ListBridges() ([]string, error)
- func (v *VSwitchService) ListPorts(bridge string) ([]string, error)
- func (v *VSwitchService) PortToBridge(port string) (string, error)
- func (v *VSwitchService) SetController(bridge string, address string) error
- func (v *VSwitchService) SetFailMode(bridge string, mode FailMode) error
- type VSwitchSetService
Constants ¶
const ( // FlowFormatNXMTableID is a flow format which allows Nicira Extended match // with the ability to place a flow in a specific table. FlowFormatNXMTableID = "NXM+table_id" // FlowFormatOXMOpenFlow14 is a flow format which allows Open vSwitch // extensible match. FlowFormatOXMOpenFlow14 = "OXM-OpenFlow14" )
const ( ProtocolOpenFlow10 = "OpenFlow10" ProtocolOpenFlow11 = "OpenFlow11" ProtocolOpenFlow12 = "OpenFlow12" ProtocolOpenFlow13 = "OpenFlow13" ProtocolOpenFlow14 = "OpenFlow14" ProtocolOpenFlow15 = "OpenFlow15" )
Protocol constants for use with Protocols and BridgeOptions.
const ( // DefaultIngressRatePolicing is used to disable the ingress policing, // which is the default behavior. DefaultIngressRatePolicing = int64(-1) // DefaultIngressBurstPolicing is to change the ingress policing // burst to the default size, 1000 kb. DefaultIngressBurstPolicing = int64(-1) )
const (
// AnyTable is a special table value to match flows in any table.
AnyTable = -1
)
const ( // PortLOCAL is a special in_port value which refers to the local port // of an OVS bridge. PortLOCAL = -1 )
const VLANNone = 0xffff
VLANNone is a special value which indicates that DataLinkVLAN should only match packets with no VLAN tag specified.
Variables ¶
var ( // ErrInvalidFlowStats is returned when flow statistics from 'ovs-ofctl // dump-aggregate' do not match the expected output format. ErrInvalidFlowStats = errors.New("invalid flow statistics") )
var ( // ErrInvalidPortRange is returned when there's a port range that invalid. ErrInvalidPortRange = errors.New("invalid port range") )
var ( // ErrInvalidPortStats is returned when port statistics from 'ovs-ofctl // dump-ports' do not match the expected output format. ErrInvalidPortStats = errors.New("invalid port statistics") )
var ( // ErrInvalidTable is returned when tables from 'ovs-ofctl dump-tables' // do not match the expected output format. ErrInvalidTable = errors.New("invalid openflow table") )
Functions ¶
func IsPortNotExist ¶
IsPortNotExist checks if err is of type Error and is caused by asking OVS for information regarding a non-existent port.
func SetState ¶
SetState sets the specified CTState flag. This helper should be used with ConnectionTrackingState.
func SetTCPFlag ¶
SetTCPFlag sets the specified TCPFlag. This helper should be used with TCPFlags.
func UnsetState ¶
UnsetState unsets the specified CTState flag. This helper should be used with ConnectionTrackingState.
func UnsetTCPFlag ¶
UnsetTCPFlag unsets the specified TCPFlag. This helper should be used with TCPFlags.
Types ¶
type Action ¶
type Action interface { encoding.TextMarshaler fmt.GoStringer }
An Action is a type which can be marshaled into an OpenFlow action. Actions can be used with Flows to perform operations when the Flow matches an input packet.
Actions must also implement fmt.GoStringer for code generation purposes.
func Conjunction ¶
Conjunction associates a flow with a certain conjunction ID to match on more than one dimension across multiple set matches.
func ConnectionTracking ¶
ConnectionTracking sends a packet through the host's connection tracker.
func Drop ¶
func Drop() Action
Drop immediately discards the packet. It must be the only Action specified when used.
func Flood ¶
func Flood() Action
Flood outputs the packet on all switch ports other than the port on which it was received, which have flooding enabled.
func InPort ¶
func InPort() Action
InPort outputs the packet on the port from which it was received.
func Load ¶
Load loads the specified value into the specified field. If either string is empty, an error is returned.
func Local ¶
func Local() Action
Local outputs the packet on the local port, which corresponds to the network device that has the same name as the bridge.
func ModDataLinkDestination ¶
func ModDataLinkDestination(addr net.HardwareAddr) Action
ModDataLinkDestination modifies the data link destination of a packet.
func ModDataLinkSource ¶
func ModDataLinkSource(addr net.HardwareAddr) Action
ModDataLinkSource modifies the data link source of a packet.
func ModNetworkDestination ¶
ModNetworkDestination modifies the destination IPv4 address of a packet.
func ModNetworkSource ¶
ModNetworkSource modifies the source IPv4 address of a packet.
func ModTransportDestinationPort ¶
ModTransportDestinationPort modifies the destination port of a packet.
func ModTransportSourcePort ¶
ModTransportSourcePort modifies the source port of a packet.
func ModVLANVID ¶
ModVLANVID modifies the VLAN ID (VID) on a packet. It adds a VLAN tag if one is not already present. vid must be a valid VLAN VID, within the range of 0 to 4095.
func Move ¶
Move copies the named bits from field src to field dst. If either string is empty, an error is returned.
func Normal ¶
func Normal() Action
Normal subjects the packet to the device's normal L2/L3 processing.
func Output ¶
Output outputs the packet to the specified switch port. Use InPortLocal to output the packet to the LOCAL port. port must either be a non-negative integer.
func Resubmit ¶
Resubmit resubmits a packet for further processing by matching flows with the specified port and table. If port or table are zero, they are set to empty in the output Action. If both are zero, an error is returned.
func ResubmitPort ¶
ResubmitPort resubmits a packet into the current table with its context modified to look like it originated from the specified openflow port ID.
func SetField ¶
SetField overwrites the specified field with the specified value. If either string is empty, an error is returned.
type BitRange ¶
A BitRange is a representation of a range of values from base value with a bitmask applied.
type BridgeOptions ¶
type BridgeOptions struct { // Protocols specifies the OpenFlow protocols the bridge should use. Protocols []string // Hwaddr specifies the MAC address of the Internal bridge interface. Hwaddr string }
An BridgeOptions enables configuration of a bridge.
type CTState ¶
type CTState string
CTState is a connection tracking state, which can be used with the ConnectionTrackingState function.
const ( CTStateNew CTState = "new" CTStateEstablished CTState = "est" CTStateRelated CTState = "rel" CTStateReply CTState = "rpl" CTStateInvalid CTState = "inv" CTStateTracked CTState = "trk" )
List of common CTState constants available in OVS 2.5. Reference the ovs-ofctl man-page for a description of each one.
type Client ¶
type Client struct { // OpenFlow wraps functionality of the 'ovs-ofctl' binary. OpenFlow *OpenFlowService // VSwitch wraps functionality of the 'ovs-vsctl' binary. VSwitch *VSwitchService // contains filtered or unexported fields }
A Client is a client type which enables programmatic control of Open vSwitch.
func New ¶
func New(options ...OptionFunc) *Client
New creates a new Client with zero or more OptionFunc configurations applied.
type Error ¶
An Error is an error returned when shelling out to an Open vSwitch control program. It captures the combined stdout and stderr as well as the exit code.
type ExecFunc ¶
An ExecFunc is a function which accepts input arguments and returns raw byte output and an error. ExecFuncs are swappable to enable testing without OVS installed.
type FailMode ¶
type FailMode string
A FailMode is a failure mode which Open vSwitch uses when it cannot contact a controller.
type Flow ¶
type Flow struct { Priority int Protocol Protocol InPort int Matches []Match Table int IdleTimeout int Cookie uint64 Actions []Action }
A Flow is an OpenFlow flow meant for adding flows to a software bridge. It can be marshaled to and from its textual form for use with Open vSwitch.
func (*Flow) MarshalText ¶
MarshalText marshals a Flow into its textual form.
func (*Flow) UnmarshalText ¶
UnmarshalText unmarshals flow text into a Flow.
type FlowError ¶
type FlowError struct { // Str indicates the string, if any, that caused the flow to // fail while unmarshaling. Str string // Err indicates the error that halted flow marshaling or unmarshaling. Err error }
A FlowError is an error encountered while marshaling or unmarshaling a Flow.
type FlowStats ¶
FlowStats contains a variety of statistics about an Open vSwitch port, including its port ID and numbers about packet receive and transmit operations.
func (*FlowStats) UnmarshalText ¶
UnmarshalText unmarshals a FlowStats from textual form.
type FlowTransaction ¶
type FlowTransaction struct {
// contains filtered or unexported fields
}
A FlowTransaction is a transaction used when adding or deleting multiple flows using an Open vSwitch flow bundle.
func (*FlowTransaction) Add ¶
func (tx *FlowTransaction) Add(flows ...*Flow)
Add pushes zero or more Flows on to the transaction, to be added by Open vSwitch. If any of the flows are invalid, Add becomes a no-op and the error will be surfaced when Commit is called.
func (*FlowTransaction) Commit ¶
func (tx *FlowTransaction) Commit() error
Commit finalizes an AddFlowTransaction, returning any errors that may have occurred while adding flows. Commit must be called at the end of a successful transaction, but may return an error if one was encountered during a call to Add.
func (*FlowTransaction) Delete ¶
func (tx *FlowTransaction) Delete(flows ...*MatchFlow)
Delete pushes zero or more MatchFlows on to the transaction, to be deleted by Open vSwitch. If any of the flows are invalid, Delete becomes a no-op and the error will be surfaced when Commit is called.
func (*FlowTransaction) Discard ¶
func (tx *FlowTransaction) Discard(err error) error
Discard discards the contents of an AddFlowTransaction, returning an error wrapping the input error. Discard should be called if any operations fail in the middle of an AddFlowTransaction function.
type InterfaceOptions ¶
type InterfaceOptions struct { // Type specifies the Open vSwitch interface type. Type InterfaceType // Peer specifies an interface to peer with when creating a patch interface. Peer string // IngressRatePolicing specifies the maximum rate for data received on // this interface in kbps. Data received faster than this rate is dropped. // Set to 0 (the default) to disable policing. IngressRatePolicing int64 // IngressBurstPolicing specifies the maximum burst size for data received on // this interface in kb. The default burst size if set to 0 is 1000 kb. // This value has no effect if IngressRatePolicing is set to 0. Specifying // a larger burst size lets the algorithm be more forgiving, which is important // for protocols like TCP that react severely to dropped packets. The burst // size should be at least the size of the interface's MTU. Specifying a // value that is numerically at least as large as 10% of IngressRatePolicing // helps TCP come closer to achieving the full rate. IngressBurstPolicing int64 // RemoteIP can be populated when the interface is a tunnel interface type // for example "stt" or "vxlan". It specifies the remote IP address with which to // form tunnels when traffic is sent to this port. Optionally it could be set to // "flow" which expects the flow to set tunnel destination. RemoteIP string // Key can be populated when the interface is a tunnel interface type // for example "stt" or "vxlan". It specifies the tunnel ID to attach to // tunneled traffic leaving this interface. Optionally it could be set to // "flow" which expects the flow to set tunnel ID. Key string }
An InterfaceOptions struct enables configuration of an Interface.
type InterfaceType ¶
type InterfaceType string
An InterfaceType is a network interface type recognized by Open vSwitch.
const ( InterfaceTypeGRE InterfaceType = "gre" InterfaceTypeInternal InterfaceType = "internal" InterfaceTypePatch InterfaceType = "patch" InterfaceTypeSTT InterfaceType = "stt" InterfaceTypeVXLAN InterfaceType = "vxlan" )
InterfaceType constants which can be used in OVS configurations.
type Match ¶
type Match interface { encoding.TextMarshaler fmt.GoStringer }
A Match is a type which can be marshaled into an OpenFlow packet matching statement. Matches can be used with Flows to match specific packet types and fields.
Matches must also implement fmt.GoStringer for code generation purposes.
func ARPOperation ¶
ARPOperation matches packets with the specified ARP operation matching oper.
func ARPSourceHardwareAddress ¶
func ARPSourceHardwareAddress(addr net.HardwareAddr) Match
ARPSourceHardwareAddress matches packets with an ARP source hardware address (SHA) matching addr.
func ARPSourceProtocolAddress ¶
ARPSourceProtocolAddress matches packets with an ARP source protocol address (SPA) IPv4 address or IPv4 CIDR block matching addr.
func ARPTargetHardwareAddress ¶
func ARPTargetHardwareAddress(addr net.HardwareAddr) Match
ARPTargetHardwareAddress matches packets with an ARP target hardware address (THA) matching addr.
func ARPTargetProtocolAddress ¶
ARPTargetProtocolAddress matches packets with an ARP target protocol address (TPA) IPv4 address or IPv4 CIDR block matching addr.
func ConjunctionID ¶
ConjunctionID matches flows that have matched all dimension of a conjunction inside of the openflow table.
func ConnectionTrackingMark ¶
ConnectionTrackingMark matches a metadata associated with a connection tracking entry
func ConnectionTrackingState ¶
ConnectionTrackingState matches packets using their connection state, when connection tracking is enabled on the host. Use the SetState and UnsetState functions to populate the parameter list for this function.
func ConnectionTrackingZone ¶
ConnectionTrackingZone is a mechanism to define separate connection tracking contexts.
func DataLinkDestination ¶
DataLinkDestination matches packets with a destination hardware address and optional wildcard mask matching addr.
func DataLinkSource ¶
DataLinkSource matches packets with a source hardware address and optional wildcard mask matching addr.
func DataLinkType ¶
DataLinkType matches packets with the specified EtherType.
func DataLinkVLAN ¶
DataLinkVLAN matches packets with the specified VLAN ID matching vid.
func IPv6Destination ¶
IPv6Destination matches packets with a destination IPv6 address or IPv6 CIDR block matching ip.
func IPv6Source ¶
IPv6Source matches packets with a source IPv6 address or IPv6 CIDR block matching ip.
func NeighborDiscoverySourceLinkLayer ¶
func NeighborDiscoverySourceLinkLayer(addr net.HardwareAddr) Match
NeighborDiscoverySourceLinkLayer matches packets with an IPv6 neighbor solicitation source link-layer address matching addr.
func NeighborDiscoveryTarget ¶
NeighborDiscoveryTarget matches packets with an IPv6 neighbor discovery target IPv6 address or IPv6 CIDR block matching ip.
func NeighborDiscoveryTargetLinkLayer ¶
func NeighborDiscoveryTargetLinkLayer(addr net.HardwareAddr) Match
NeighborDiscoveryTargetLinkLayer matches packets with an IPv6 neighbor solicitation target link-layer address matching addr.
func NetworkDestination ¶
NetworkDestination matches packets with a destination IPv4 address or IPv4 CIDR block matching ip.
func NetworkProtocol ¶
NetworkProtocol matches packets with the specified IP or IPv6 protocol number matching num. For example, specifying 1 when a Flow's Protocol is IPv4 matches ICMP packets, or 58 when Protocol is IPv6 matches ICMPv6 packets.
func NetworkSource ¶
NetworkSource matches packets with a source IPv4 address or IPv4 CIDR block matching ip.
func TCPFlags ¶
TCPFlags matches packets using their enabled TCP flags, when matching TCP flags on a TCP segment. Use the SetTCPFlag and UnsetTCPFlag functions to populate the parameter list for this function.
func TransportDestinationMaskedPort ¶
TransportDestinationMaskedPort matches packets with a transport layer (TCP/UDP) destination port matching a masked port range.
func TransportDestinationPort ¶
TransportDestinationPort matches packets with a transport layer (TCP/UDP) destination port matching port.
func TransportSourceMaskedPort ¶
TransportSourceMaskedPort matches packets with a transport layer (TCP/UDP) source port matching a masked port range.
func TransportSourcePort ¶
TransportSourcePort matches packets with a transport layer (TCP/UDP) source port matching port.
func TunnelIDWithMask ¶
TunnelIDWithMask returns a Match with specified ID and mask.
type MatchFlow ¶
type MatchFlow struct { Protocol Protocol InPort int Matches []Match Table int // Cookie indicates a cookie value to use when matching flows. Cookie uint64 // CookieMask is a mask used alongside Cookie to enable matching flows // which match a mask. If CookieMask is not set, Cookie will be matched // exactly. CookieMask uint64 }
A MatchFlow is an OpenFlow flow intended for flow deletion. It can be marshaled to its textual form for use with Open vSwitch.
func (*MatchFlow) MarshalText ¶
MarshalText marshals a MatchFlow into its textual form.
type MatchFlowError ¶
type MatchFlowError struct { // Str indicates the string, if any, that caused the flow to // fail while unmarshaling. Str string // Err indicates the error that halted flow marshaling or unmarshaling. Err error }
A MatchFlowError is an error encountered while marshaling or unmarshaling a MatchFlow.
func (*MatchFlowError) Error ¶
func (e *MatchFlowError) Error() string
Error returns the string representation of a MatchFlowError.
type OpenFlowService ¶
type OpenFlowService struct {
// contains filtered or unexported fields
}
An OpenFlowService is used in a Client to execute 'ovs-ofctl' commands.
func (*OpenFlowService) AddFlow ¶
func (o *OpenFlowService) AddFlow(bridge string, flow *Flow) error
AddFlow adds a Flow to a bridge attached to Open vSwitch.
func (*OpenFlowService) AddFlowBundle ¶
func (o *OpenFlowService) AddFlowBundle(bridge string, fn func(tx *FlowTransaction) error) error
AddFlowBundle creates an Open vSwitch flow bundle and enables adding and removing flows to and from the specified bridge using a FlowTransaction. This function enables atomic addition and deletion of flows to and from Open vSwitch.
func (*OpenFlowService) DelFlows ¶
func (o *OpenFlowService) DelFlows(bridge string, flow *MatchFlow) error
DelFlows removes flows that match MatchFlow from a bridge attached to Open vSwitch.
If flow is nil, all flows will be deleted from the specified bridge.
func (*OpenFlowService) DumpAggregate ¶
func (o *OpenFlowService) DumpAggregate(bridge string, flow *MatchFlow) (*FlowStats, error)
DumpAggregate retrieves statistics about the specified flow attached to the specified bridge.
func (*OpenFlowService) DumpFlows ¶
func (o *OpenFlowService) DumpFlows(bridge string) ([]*Flow, error)
DumpFlows retrieves statistics about all flows for the specified bridge. If a table has no active flows and has not been used for a lookup or matched by an incoming packet, it is filtered from the output.
func (*OpenFlowService) DumpPort ¶
func (o *OpenFlowService) DumpPort(bridge string, port string) (*PortStats, error)
DumpPort retrieves statistics about the specified port attached to the specified bridge.
func (*OpenFlowService) DumpPorts ¶
func (o *OpenFlowService) DumpPorts(bridge string) ([]*PortStats, error)
DumpPorts retrieves statistics about all ports attached to the specified bridge.
func (*OpenFlowService) DumpTables ¶
func (o *OpenFlowService) DumpTables(bridge string) ([]*Table, error)
DumpTables retrieves statistics about all tables for the specified bridge. If a table has no active flows and has not been used for a lookup or matched by an incoming packet, it is filtered from the output.
func (*OpenFlowService) ModPort ¶
func (o *OpenFlowService) ModPort(bridge string, port string, action PortAction) error
ModPort modifies the specified characteristics for the specified port.
type OptionFunc ¶
type OptionFunc func(c *Client)
An OptionFunc is a function which can apply configuration to a Client.
func Debug ¶
func Debug(enable bool) OptionFunc
Debug returns an OptionFunc which enables debugging output for the Client type.
func Exec ¶
func Exec(fn ExecFunc) OptionFunc
Exec returns an OptionFunc which sets an ExecFunc for use with a Client. This function should typically only be used in tests.
func FlowFormat ¶
func FlowFormat(format string) OptionFunc
FlowFormat specifies the flow format to be used when shelling to 'ovs-ofctl'.
func Pipe ¶
func Pipe(fn PipeFunc) OptionFunc
Pipe returns an OptionFunc which sets a PipeFunc for use with a Client. This function should typically only be used in tests.
func Protocols ¶
func Protocols(versions []string) OptionFunc
Protocols specifies one or more OpenFlow protocol versions to be used when shelling to 'ovs-ofctl'.
func SetSSLParam ¶
func SetSSLParam(pkey string, cert string, cacert string) OptionFunc
SetSSLParam configures SSL authentication using a private key, certificate, and CA certificate for use with ovs-ofctl.
func SetTCPParam ¶
func SetTCPParam(addr string) OptionFunc
SetTCPParam configures the OVSDB connection using a TCP format ip:port for use with all ovs-vsctl commands.
func Sudo ¶
func Sudo() OptionFunc
Sudo specifies that "sudo" should be prefixed to all OVS commands.
func Timeout ¶
func Timeout(seconds int) OptionFunc
Timeout returns an OptionFunc which sets a timeout in seconds for all Open vSwitch interactions.
type PipeFunc ¶
A PipeFunc is a function which accepts an input stdin stream, command, and arguments, and returns command output and an error. PipeFuncs are swappable to enable testing without OVS installed.
type PortAction ¶
type PortAction string
A PortAction is a port actions to change the port characteristics of the specific port through the ModPort API.
const ( PortActionUp PortAction = "up" PortActionDown PortAction = "down" PortActionSTP PortAction = "stp" PortActionNoSTP PortAction = "no-stp" PortActionReceive PortAction = "receive" PortActionNoReceive PortAction = "no-receive" PortActionReceiveSTP PortAction = "receive-stp" PortActionNoReceiveSTP PortAction = "no-receive-stp" PortActionForward PortAction = "forward" PortActionNoForward PortAction = "no-forward" PortActionFlood PortAction = "flood" PortActionNoFlood PortAction = "no-flood" PortActionPacketIn PortAction = "packet-in" PortActionNoPacketIn PortAction = "no-packet-in" )
PortAction constants for ModPort API.
type PortRange ¶
An PortRange represents a range of ports expressed in 16 bit integers. The start and end values of this range are inclusive.
func (*PortRange) BitwiseMatch ¶
BitwiseMatch returns an array of BitRanges that represent the range of integers in the PortRange.
type PortStats ¶
type PortStats struct { // PortID specifies the OVS port ID which this PortStats refers to. PortID int // Received and Transmitted contain information regarding the number // of received and transmitted packets, bytes, etc. // OVS stores all of these counters as uint64 values. Received PortStatsReceive Transmitted PortStatsTransmit }
PortStats contains a variety of statistics about an Open vSwitch port, including its port ID and numbers about packet receive and transmit operations.
func (*PortStats) UnmarshalText ¶
UnmarshalText unmarshals a PortStats from textual form as output by 'ovs-ofctl dump-ports':
port 1: rx pkts=0, bytes=0, drop=0, errs=0, frame=0, over=0, crc=0 tx pkts=0, bytes=0, drop=0, errs=0, coll=0
type PortStatsReceive ¶
type PortStatsReceive struct { Packets uint64 Bytes uint64 Dropped uint64 Errors uint64 Frame uint64 Over uint64 CRC uint64 }
PortStatsReceive contains information regarding the number of received packets, bytes, etc.
type PortStatsTransmit ¶
type PortStatsTransmit struct { Packets uint64 Bytes uint64 Dropped uint64 Errors uint64 Collisions uint64 }
PortStatsTransmit contains information regarding the number of transmitted packets, bytes, etc.
type Protocol ¶
type Protocol string
A Protocol is an OpenFlow protocol designation accepted by Open vSwitch.
const ( ProtocolARP Protocol = "arp" ProtocolICMPv4 Protocol = "icmp" ProtocolICMPv6 Protocol = "icmp6" ProtocolIPv4 Protocol = "ip" ProtocolIPv6 Protocol = "ipv6" ProtocolTCPv4 Protocol = "tcp" ProtocolTCPv6 Protocol = "tcp6" ProtocolUDPv4 Protocol = "udp" ProtocolUDPv6 Protocol = "udp6" )
Protocol constants which can be used in OVS flow configurations.
type TCPFlag ¶
type TCPFlag string
TCPFlag represents a flag in the TCP header, which can be used with the TCPFlags function.
type Table ¶
type Table struct { ID int Name string Wild string Max int Active int Lookup uint64 Matched uint64 }
A Table is an Open vSwitch table.
func (*Table) UnmarshalText ¶
UnmarshalText unmarshals a Table from textual form as output by 'ovs-ofctl dump-tables':
0: classifier: wild=0x3fffff, max=1000000, active=0 lookup=0, matched=0
type TransportPortRanger ¶
A TransportPortRanger represents a port range that can be expressed as an array of bitwise matches.
func TransportDestinationPortRange ¶
func TransportDestinationPortRange(startPort uint16, endPort uint16) TransportPortRanger
TransportDestinationPortRange represent a port range intended for a transport protocol destination port.
func TransportSourcePortRange ¶
func TransportSourcePortRange(startPort uint16, endPort uint16) TransportPortRanger
TransportSourcePortRange represent a port range intended for a transport protocol source port.
type VSwitchGetService ¶
type VSwitchGetService struct {
// contains filtered or unexported fields
}
A VSwitchGetService is used in a VSwitchService to execute 'ovs-vsctl get' subcommands.
func (*VSwitchGetService) Bridge ¶
func (v *VSwitchGetService) Bridge(bridge string) (BridgeOptions, error)
Bridge gets configuration for a bridge and returns the values through a BridgeOptions struct.
type VSwitchService ¶
type VSwitchService struct { // Get wraps functionality of the 'ovs-vsctl get' subcommand. Get *VSwitchGetService // Set wraps functionality of the 'ovs-vsctl set' subcommand. Set *VSwitchSetService // contains filtered or unexported fields }
A VSwitchService is used in a Client to execute 'ovs-vsctl' commands.
func (*VSwitchService) AddBridge ¶
func (v *VSwitchService) AddBridge(bridge string) error
AddBridge attaches a bridge to Open vSwitch. The bridge may or may not already exist.
func (*VSwitchService) AddPort ¶
func (v *VSwitchService) AddPort(bridge string, port string) error
AddPort attaches a port to a bridge on Open vSwitch. The port may or may not already exist.
func (*VSwitchService) DeleteBridge ¶
func (v *VSwitchService) DeleteBridge(bridge string) error
DeleteBridge detaches a bridge from Open vSwitch. The bridge may or may not already exist.
func (*VSwitchService) DeletePort ¶
func (v *VSwitchService) DeletePort(bridge string, port string) error
DeletePort detaches a port from a bridge on Open vSwitch. The port may or may not already exist.
func (*VSwitchService) GetController ¶
func (v *VSwitchService) GetController(bridge string) (string, error)
GetController gets the controller address for this bridge.
func (*VSwitchService) GetFailMode ¶
func (v *VSwitchService) GetFailMode(bridge string) (FailMode, error)
GetFailMode gets the FailMode for the specified bridge.
func (*VSwitchService) ListBridges ¶
func (v *VSwitchService) ListBridges() ([]string, error)
ListBridges lists the bridges in Open vSwitch.
func (*VSwitchService) ListPorts ¶
func (v *VSwitchService) ListPorts(bridge string) ([]string, error)
ListPorts lists the ports in Open vSwitch.
func (*VSwitchService) PortToBridge ¶
func (v *VSwitchService) PortToBridge(port string) (string, error)
PortToBridge attempts to determine which bridge a port is attached to. If port does not exist, an error will be returned, which can be checked using IsPortNotExist.
func (*VSwitchService) SetController ¶
func (v *VSwitchService) SetController(bridge string, address string) error
SetController sets the controller for this bridge so that ovs-ofctl can use this address to communicate.
func (*VSwitchService) SetFailMode ¶
func (v *VSwitchService) SetFailMode(bridge string, mode FailMode) error
SetFailMode sets the specified FailMode for the specified bridge.
type VSwitchSetService ¶
type VSwitchSetService struct {
// contains filtered or unexported fields
}
A VSwitchSetService is used in a VSwitchService to execute 'ovs-vsctl set' subcommands.
func (*VSwitchSetService) Bridge ¶
func (v *VSwitchSetService) Bridge(bridge string, options BridgeOptions) error
Bridge sets configuration for a bridge using the values from a BridgeOptions struct.
func (*VSwitchSetService) Interface ¶
func (v *VSwitchSetService) Interface(ifi string, options InterfaceOptions) error
Interface sets configuration for an interface using the values from an InterfaceOptions struct.