Documentation ¶
Overview ¶
Package ovs supplies some convenient functions to execute the ovs command.
Index ¶
- Constants
- Variables
- func AddFlows(bridge string, flows ...string) (err error)
- func AddPatchPort(bridge, patch, peerPatch string, ofport int) (err error)
- func AddPort(bridge, iface string, ofport int) (err error)
- func AddVxLANPort(bridge, port, localIP, remoteIP string, ofport int) (err error)
- func CreateBridge(name string, secureFailMode ...bool) (err error)
- func DelFlows(bridge string, matches ...string) (err error)
- func DelFlowsStrict(bridge string, priority int, matches ...string) (err error)
- func DelPort(bridge, port string) (err error)
- func DeleteBridge(name string) (err error)
- func GetAllFlows(bridge string, isName, isStats bool) (flows []string, err error)
- func IntToHexString(i int) string
- func IntToString(i int) string
- func ListAllOFPorts(bridge string) (map[string]int, error)
- func MustAddFlow(bridge, flow string)
- func MustAddPatchPort(bridge, patch, peerPatch string, ofport int)
- func MustAddPort(bridge, iface string, ofport int)
- func MustAddVxLANPort(bridge, port, localIP, remoteIP string, ofport int)
- func MustCreateBridge(name string, secureFailMode ...bool)
- func MustDelFlow(bridge, match string)
- func MustDelFlowStrict(bridge string, priority int, match string)
- func MustDelPort(bridge, iface string)
- func MustDeleteBridge(name string)
- func MustSetInterfaceUp(iface string)
- func PortRuleMasking(minPort, maxPort int) []string
- func SendARPRequest(bridge, output, inPort, srcMac, srcIP, dstIP string, vlanID ...uint16) (err error)
- func SetInterfaceUp(iface string) (err error)
- func StringToInt(s string) int
Examples ¶
Constants ¶
const ( ARP = 0x0806 IPv4 = 0x0800 IPv6 = 0x86dd )
L2 Data-Link Protocol Number
const ( ICMP = 1 TCP = 6 UDP = 17 GRE = 47 )
L3 IP Protocol Number
const ( DROP = "drop" LOCAL = "local" FLOOD = "flood" NORMAL = "normal" )
OVS Actions
const (
BroadcastMac = "ff:ff:ff:ff:ff:ff"
)
MAC address
Variables ¶
var ( IPCmd = "ip" OfctlCmd = "ovs-ofctl" VsctlCmd = "ovs-vsctl" )
Some linux commands.
Functions ¶
func AddPatchPort ¶ added in v0.5.0
AddPatchPort adds a patch port for the bridge, the peer patch of which is peerPatch.
func AddVxLANPort ¶ added in v0.5.0
AddVxLANPort add an VxLAN port into the bridge.
func CreateBridge ¶ added in v0.5.0
CreateBridge creates a new bridge named name if not exist.
If secureFailMode is true, set the fail mode of the bridge to "secure".
func DelFlowsStrict ¶
DelFlowsStrict deletes the flows with the option --strict.
func DeleteBridge ¶ added in v0.5.0
DeleteBridge deletes the bridge named name.
func GetAllFlows ¶
GetAllFlows returns the list of all the flows of the bridge.
func IntToHexString ¶ added in v0.5.0
IntToHexString converts the integer to string as the hexdecimal with the prefix "0x".
func IntToString ¶ added in v0.5.0
IntToString converts the integer to string as the decimal.
func ListAllOFPorts ¶ added in v0.5.0
ListAllOFPorts returns all the port names with its number on the bridge.
func MustAddFlow ¶
func MustAddFlow(bridge, flow string)
MustAddFlow is the same as AddFlows, but the program exits if there is an error.
func MustAddPatchPort ¶ added in v0.5.0
MustAddPatchPort is the same as AddPatchPort, but exit the program if failing.
func MustAddPort ¶ added in v0.5.0
MustAddPort is the same as AddPort, but exit the program if failing.
func MustAddVxLANPort ¶ added in v0.5.0
MustAddVxLANPort is the same as AddVxLANPort, but exit the program if failing.
func MustCreateBridge ¶ added in v0.5.0
MustCreateBridge is the same as CreateBridge, but exit the program if failing.
func MustDelFlow ¶
func MustDelFlow(bridge, match string)
MustDelFlow is the same as DelFlows, but the program exits if there is an error.
func MustDelFlowStrict ¶
MustDelFlowStrict is the same as DelFlowsStrict, but the program exits if there is an error.
func MustDelPort ¶ added in v0.5.0
func MustDelPort(bridge, iface string)
MustDelPort is the same as DelPort, but exit the program if failing.
func MustDeleteBridge ¶ added in v0.5.0
func MustDeleteBridge(name string)
MustDeleteBridge is the same as DeleteBridge, but exit the program if failing.
func MustSetInterfaceUp ¶ added in v0.5.0
func MustSetInterfaceUp(iface string)
MustSetInterfaceUp is the same as SetInterfaceUp, but exit the program if failing.
func PortRuleMasking ¶ added in v0.2.0
PortRuleMasking translates a range [port_min, port_max] into a set of bitwise matches.
Each match has the form 'port/mask'. The port and mask are 16-bit numbers written in hexadecimal prefixed by 0x. Each 1-bit in mask requires that the corresponding bit in port must match. Each 0-bit in mask causes the corresponding bit to be ignored.
Example ¶
ports := PortRuleMasking(1000, 1999) fmt.Println(len(ports)) fmt.Println(ports[0]) fmt.Println(ports[1]) fmt.Println(ports[2]) fmt.Println(ports[3]) fmt.Println(ports[4]) fmt.Println(ports[5]) fmt.Println(ports[6])
Output: 7 0x03e8/0xfff8 0x03f0/0xfff0 0x0400/0xfe00 0x0600/0xff00 0x0700/0xff80 0x0780/0xffc0 0x07c0/0xfff0
func SendARPRequest ¶
func SendARPRequest(bridge, output, inPort, srcMac, srcIP, dstIP string, vlanID ...uint16) (err error)
SendARPRequest sends the ARP request by the ovs bridge.
vlanID may be 0, which won't add the VLAN header into the ARP request packet.
func SetInterfaceUp ¶ added in v0.5.0
SetInterfaceUp sets up the interface.
func StringToInt ¶ added in v0.5.0
StringToInt parses the decimal or hexadecimal string to the integer, which will panic if failing.
Types ¶
This section is empty.