Documentation ¶
Index ¶
- Constants
- func GetMgmtAddress(ovsRunDir, brName string) string
- type Action
- type Bridge
- type BucketBuilder
- type CTAction
- type EntryType
- type Flow
- type FlowBuilder
- type FlowStates
- type Group
- type GroupIDType
- type IPRange
- type LearnAction
- type MissActionType
- type OFBridge
- func (b *OFBridge) AddFlowsInBundle(addflows []Flow, modFlows []Flow, delFlows []Flow) error
- func (b *OFBridge) AddOFEntriesInBundle(addEntries []OFEntry, modEntries []OFEntry, delEntries []OFEntry) error
- func (b *OFBridge) AddTLVMap(optClass uint16, optType uint8, optLength uint8, tunMetadataIndex uint16) error
- func (b *OFBridge) BuildPacketOut() PacketOutBuilder
- func (b *OFBridge) Connect(maxRetrySec int, connectionCh chan struct{}) error
- func (b *OFBridge) CreateGroup(id GroupIDType) Group
- func (b *OFBridge) CreateTable(id, next TableIDType, missAction MissActionType) Table
- func (b *OFBridge) DeleteFlowsByCookie(cookieID, cookieMask uint64) error
- func (b *OFBridge) DeleteGroup(id GroupIDType) bool
- func (b *OFBridge) DeleteTable(id TableIDType) bool
- func (b *OFBridge) Disconnect() error
- func (b *OFBridge) DumpFlows(cookieID, cookieMask uint64) (map[uint64]*FlowStates, error)
- func (b *OFBridge) DumpTableStatus() []TableStatus
- func (b *OFBridge) IsConnected() bool
- func (b *OFBridge) MaxRetry() int
- func (b *OFBridge) MultipartReply(sw *ofctrl.OFSwitch, rep *openflow13.MultipartReply)
- func (b *OFBridge) PacketRcvd(sw *ofctrl.OFSwitch, packet *ofctrl.PacketIn)
- func (b *OFBridge) RetryInterval() time.Duration
- func (b *OFBridge) SendPacketOut(packetOut *ofctrl.PacketOut) error
- func (b *OFBridge) SubscribePacketIn(reason uint8, ch chan *ofctrl.PacketIn) error
- func (b *OFBridge) SwitchConnected(sw *ofctrl.OFSwitch)
- func (b *OFBridge) SwitchDisconnected(sw *ofctrl.OFSwitch)
- type OFEntry
- type OFOperation
- type PacketOutBuilder
- type PortRange
- type Protocol
- type Range
- type Table
- type TableIDType
- type TableStatus
Constants ¶
const ( NxmFieldSrcMAC = "NXM_OF_ETH_SRC" NxmFieldDstMAC = "NXM_OF_ETH_DST" NxmFieldARPSha = "NXM_NX_ARP_SHA" NxmFieldARPTha = "NXM_NX_ARP_THA" NxmFieldARPSpa = "NXM_OF_ARP_SPA" NxmFieldARPTpa = "NXM_OF_ARP_TPA" NxmFieldCtLabel = "NXM_NX_CT_LABEL" NxmFieldCtMark = "NXM_NX_CT_MARK" NxmFieldARPOp = "NXM_OF_ARP_OP" NxmFieldReg = "NXM_NX_REG" NxmFieldTunMetadata = "NXM_NX_TUN_METADATA" NxmFieldIPToS = "NXM_OF_IP_TOS" NxmFieldXXReg = "NXM_NX_XXREG" )
Variables ¶
This section is empty.
Functions ¶
func GetMgmtAddress ¶ added in v0.7.0
Types ¶
type Action ¶
type Action interface { LoadARPOperation(value uint16) FlowBuilder LoadRegRange(regID int, value uint32, to Range) FlowBuilder LoadRange(name string, addr uint64, to Range) FlowBuilder Move(from, to string) FlowBuilder MoveRange(fromName, toName string, from, to Range) FlowBuilder Resubmit(port uint16, table TableIDType) FlowBuilder ResubmitToTable(table TableIDType) FlowBuilder CT(commit bool, tableID TableIDType, zone int) CTAction Drop() FlowBuilder Output(port int) FlowBuilder OutputFieldRange(from string, rng Range) FlowBuilder OutputRegRange(regID int, rng Range) FlowBuilder OutputInPort() FlowBuilder SetDstMAC(addr net.HardwareAddr) FlowBuilder SetSrcMAC(addr net.HardwareAddr) FlowBuilder SetARPSha(addr net.HardwareAddr) FlowBuilder SetARPTha(addr net.HardwareAddr) FlowBuilder SetARPSpa(addr net.IP) FlowBuilder SetARPTpa(addr net.IP) FlowBuilder SetSrcIP(addr net.IP) FlowBuilder SetDstIP(addr net.IP) FlowBuilder SetTunnelDst(addr net.IP) FlowBuilder DecTTL() FlowBuilder Normal() FlowBuilder Conjunction(conjID uint32, clauseID uint8, nClause uint8) FlowBuilder Group(id GroupIDType) FlowBuilder Learn(id TableIDType, priority uint16, idleTimeout, hardTimeout uint16, cookieID uint64) LearnAction GotoTable(table TableIDType) FlowBuilder SendToController(reason uint8) FlowBuilder Note(notes string) FlowBuilder }
type Bridge ¶
type Bridge interface { CreateTable(id, next TableIDType, missAction MissActionType) Table DeleteTable(id TableIDType) bool CreateGroup(id GroupIDType) Group DeleteGroup(id GroupIDType) bool DumpTableStatus() []TableStatus // DumpFlows queries the Openflow entries from OFSwitch. The filter of the query is Openflow cookieID; the result is // a map from flow cookieID to FlowStates. DumpFlows(cookieID, cookieMask uint64) (map[uint64]*FlowStates, error) // DeleteFlowsByCookie removes Openflow entries from OFSwitch. The removed Openflow entries use the specific CookieID. DeleteFlowsByCookie(cookieID, cookieMask uint64) error // AddFlowsInBundle syncs multiple Openflow entries in a single transaction. This operation could add new flows in // "addFlows", modify flows in "modFlows", and remove flows in "delFlows" in the same bundle. AddFlowsInBundle(addflows []Flow, modFlows []Flow, delFlows []Flow) error // AddOFEntriesInBundle syncs multiple Openflow entries(including Flow and Group) in a single transaction. This // operation could add new entries in "addEntries", modify entries in "modEntries", and remove entries in // "delEntries" in the same bundle. AddOFEntriesInBundle(addEntries []OFEntry, modEntries []OFEntry, delEntries []OFEntry) error // Connect initiates connection to the OFSwitch. It will block until the connection is established. connectCh is used to // send notification whenever the switch is connected or reconnected. Connect(maxRetrySec int, connectCh chan struct{}) error // Disconnect stops connection to the OFSwitch. Disconnect() error // IsConnected returns the OFSwitch's connection status. The result is true if the OFSwitch is connected. IsConnected() bool // SubscribePacketIn registers a consumer to listen to PacketIn messages matching the provided reason. When the // Bridge receives a PacketIn message with the specified reason, it sends the message to the consumer using the // provided channel. SubscribePacketIn(reason uint8, ch chan *ofctrl.PacketIn) error // AddTLVMap adds a TLV mapping with OVS field tun_metadataX. The value loaded in tun_metadataX is transported by // Geneve header with the specified <optClass, optType, optLength>. The value of OptLength must be a multiple of 4. // The value loaded into field tun_metadataX must fit within optLength bytes. AddTLVMap(optClass uint16, optType uint8, optLength uint8, tunMetadataIndex uint16) error // SendPacketOut sends a packetOut message to the OVS Bridge. SendPacketOut(packetOut *ofctrl.PacketOut) error // BuildPacketOut returns a new PacketOutBuilder. BuildPacketOut() PacketOutBuilder }
Bridge defines operations on an openflow bridge.
func NewOFBridge ¶ added in v0.2.0
type BucketBuilder ¶ added in v0.6.0
type BucketBuilder interface { Weight(val uint16) BucketBuilder LoadReg(regID int, data uint32) BucketBuilder LoadXXReg(regID int, data []byte) BucketBuilder LoadRegRange(regID int, data uint32, rng Range) BucketBuilder ResubmitToTable(tableID TableIDType) BucketBuilder Done() Group }
type CTAction ¶
type CTAction interface { LoadToMark(value uint32) CTAction LoadToLabelRange(value uint64, rng *Range) CTAction MoveToLabel(fromName string, fromRng, labelRng *Range) CTAction // NAT action translates the packet in the way that the connection was committed into the conntrack zone, e.g., if // a connection was committed with SNAT, the later packets would be translated with the earlier SNAT configurations. NAT() CTAction // SNAT actions is used to translate the source IP to a specific address or address in a pool when committing the // packet into the conntrack zone. If a single IP is used as the target address, StartIP and EndIP in the range // should be the same. portRange could be nil. SNAT(ipRange *IPRange, portRange *PortRange) CTAction // DNAT actions is used to translate the destination IP to a specific address or address in a pool when committing // the packet into the conntrack zone. If a single IP is used as the target address, StartIP and EndIP in the range // should be the same. portRange could be nil. DNAT(ipRange *IPRange, portRange *PortRange) CTAction CTDone() FlowBuilder }
type Flow ¶
type Flow interface { OFEntry // Returns the flow priority associated with OFEntry FlowPriority() uint16 FlowProtocol() Protocol MatchString() string // CopyToBuilder returns a new FlowBuilder that copies the matches of the Flow. // It copies the original actions of the Flow only if copyActions is set to true, and // resets the priority in the new FlowBuilder if the provided priority is not 0. CopyToBuilder(priority uint16, copyActions bool) FlowBuilder IsDropFlow() bool }
type FlowBuilder ¶
type FlowBuilder interface { MatchPriority(uint16) FlowBuilder MatchProtocol(name Protocol) FlowBuilder MatchReg(regID int, data uint32) FlowBuilder MatchXXReg(regID int, data []byte) FlowBuilder MatchRegRange(regID int, data uint32, rng Range) FlowBuilder MatchInPort(inPort uint32) FlowBuilder MatchDstIP(ip net.IP) FlowBuilder MatchDstIPNet(ipNet net.IPNet) FlowBuilder MatchSrcIP(ip net.IP) FlowBuilder MatchSrcIPNet(ipNet net.IPNet) FlowBuilder MatchDstMAC(mac net.HardwareAddr) FlowBuilder MatchSrcMAC(mac net.HardwareAddr) FlowBuilder MatchARPSha(mac net.HardwareAddr) FlowBuilder MatchARPTha(mac net.HardwareAddr) FlowBuilder MatchARPSpa(ip net.IP) FlowBuilder MatchARPTpa(ip net.IP) FlowBuilder MatchARPOp(op uint16) FlowBuilder MatchIPDscp(dscp uint8) FlowBuilder MatchCTStateNew(isSet bool) FlowBuilder MatchCTStateRel(isSet bool) FlowBuilder MatchCTStateRpl(isSet bool) FlowBuilder MatchCTStateEst(isSet bool) FlowBuilder MatchCTStateTrk(isSet bool) FlowBuilder MatchCTStateInv(isSet bool) FlowBuilder MatchCTMark(value uint32, mask *uint32) FlowBuilder MatchCTLabelRange(high, low uint64, bitRange Range) FlowBuilder MatchPktMark(value uint32, mask *uint32) FlowBuilder MatchConjID(value uint32) FlowBuilder MatchDstPort(port uint16, portMask *uint16) FlowBuilder MatchICMPv6Type(icmp6Type byte) FlowBuilder MatchICMPv6Code(icmp6Code byte) FlowBuilder MatchTunMetadata(index int, data uint32) FlowBuilder // MatchCTSrcIP matches the source IPv4 address of the connection tracker original direction tuple. MatchCTSrcIP(ip net.IP) FlowBuilder // MatchCTSrcIPNet matches the source IPv4 address of the connection tracker original direction tuple with IP masking. MatchCTSrcIPNet(ipnet net.IPNet) FlowBuilder // MatchCTDstIP matches the destination IPv4 address of the connection tracker original direction tuple. MatchCTDstIP(ip net.IP) FlowBuilder // MatchCTDstIP matches the destination IPv4 address of the connection tracker original direction tuple with IP masking. MatchCTDstIPNet(ipNet net.IPNet) FlowBuilder // MatchCTSrcPort matches the transport source port of the connection tracker original direction tuple. MatchCTSrcPort(port uint16) FlowBuilder // MatchCTDstPort matches the transport destination port of the connection tracker original direction tuple. MatchCTDstPort(port uint16) FlowBuilder // MatchCTProtocol matches the IP protocol type of the connection tracker original direction tuple. MatchCTProtocol(proto Protocol) FlowBuilder Cookie(cookieID uint64) FlowBuilder SetHardTimeout(timout uint16) FlowBuilder SetIdleTimeout(timeout uint16) FlowBuilder Action() Action Done() Flow }
type FlowStates ¶ added in v0.2.0
type Group ¶ added in v0.6.0
type Group interface { OFEntry ResetBuckets() Group Bucket() BucketBuilder }
type GroupIDType ¶ added in v0.6.0
type GroupIDType uint32
type LearnAction ¶ added in v0.6.0
type LearnAction interface { DeleteLearned() LearnAction MatchEthernetProtocolIP(isIPv6 bool) LearnAction MatchTransportDst(protocol Protocol) LearnAction MatchLearnedTCPDstPort() LearnAction MatchLearnedUDPDstPort() LearnAction MatchLearnedSCTPDstPort() LearnAction MatchLearnedTCPv6DstPort() LearnAction MatchLearnedUDPv6DstPort() LearnAction MatchLearnedSCTPv6DstPort() LearnAction MatchLearnedSrcIP() LearnAction MatchLearnedDstIP() LearnAction MatchLearnedSrcIPv6() LearnAction MatchLearnedDstIPv6() LearnAction MatchReg(regID int, data uint32, rng Range) LearnAction LoadReg(regID int, data uint32, rng Range) LearnAction LoadRegToReg(fromRegID, toRegID int, fromRng, toRng Range) LearnAction LoadXXRegToXXReg(fromRegID, toRegID int, fromRng, toRng Range) LearnAction SetDstMAC(mac net.HardwareAddr) LearnAction Done() FlowBuilder }
type MissActionType ¶
type MissActionType uint32
const ( TableMissActionDrop MissActionType = iota TableMissActionNormal TableMissActionNext TableMissActionNone )
type OFBridge ¶ added in v0.2.0
type OFBridge struct { // sync.RWMutex protects tableCache from concurrent modification and iteration. sync.RWMutex // contains filtered or unexported fields }
OFBridge implements openflow.Bridge.
func (*OFBridge) AddFlowsInBundle ¶ added in v0.3.0
func (*OFBridge) AddOFEntriesInBundle ¶ added in v0.6.0
func (*OFBridge) BuildPacketOut ¶ added in v0.7.0
func (b *OFBridge) BuildPacketOut() PacketOutBuilder
func (*OFBridge) Connect ¶ added in v0.2.0
Connect initiates the connection to the OFSwitch, and initializes ofTables after connected.
func (*OFBridge) CreateGroup ¶ added in v0.6.0
func (b *OFBridge) CreateGroup(id GroupIDType) Group
func (*OFBridge) CreateTable ¶ added in v0.2.0
func (b *OFBridge) CreateTable(id, next TableIDType, missAction MissActionType) Table
func (*OFBridge) DeleteFlowsByCookie ¶ added in v0.2.0
DeleteFlowsByCookie removes Openflow entries from OFSwitch. The removed Openflow entries use the specific CookieID.
func (*OFBridge) DeleteGroup ¶ added in v0.6.0
func (b *OFBridge) DeleteGroup(id GroupIDType) bool
func (*OFBridge) DeleteTable ¶ added in v0.2.0
func (b *OFBridge) DeleteTable(id TableIDType) bool
DeleteTable removes the table from ofctrl.OFSwitch, and remove from local cache.
func (*OFBridge) Disconnect ¶ added in v0.2.0
Disconnect stops connection to the OFSwitch.
func (*OFBridge) DumpFlows ¶ added in v0.2.0
func (b *OFBridge) DumpFlows(cookieID, cookieMask uint64) (map[uint64]*FlowStates, error)
DumpFlows queries the Openflow entries from OFSwitch, the filter of the query is Openflow cookieID. The result is a map from flow cookieID to FlowStates.
func (*OFBridge) DumpTableStatus ¶ added in v0.2.0
func (b *OFBridge) DumpTableStatus() []TableStatus
DumpTableStatus dumps table status from local cache.
func (*OFBridge) IsConnected ¶ added in v0.2.0
func (*OFBridge) MaxRetry ¶ added in v0.2.0
MaxRetry is a callback from OFController. It sets the max retry count that OFController attempts to connect to OFSwitch.
func (*OFBridge) MultipartReply ¶ added in v0.2.0
func (b *OFBridge) MultipartReply(sw *ofctrl.OFSwitch, rep *openflow13.MultipartReply)
MultipartReply is a callback when multipartReply message is received on ofctrl.OFSwitch is connected. Client uses this method to handle the reply message if it has customized MultipartRequest message.
func (*OFBridge) PacketRcvd ¶ added in v0.2.0
PacketRcvd is a callback when a packetIn is received on ofctrl.OFSwitch.
func (*OFBridge) RetryInterval ¶ added in v0.2.0
RetryInterval is a callback from OFController. It sets the interval in that the OFController will initiate next connection to OFSwitch if it fails this time.
func (*OFBridge) SendPacketOut ¶ added in v0.7.0
func (*OFBridge) SubscribePacketIn ¶ added in v0.7.0
func (*OFBridge) SwitchConnected ¶ added in v0.2.0
SwitchConnected is a callback when the remote OFSwitch is connected.
func (*OFBridge) SwitchDisconnected ¶ added in v0.2.0
type OFEntry ¶ added in v0.6.0
type OFEntry interface { Add() error Modify() error Delete() error Type() EntryType KeyString() string // Reset ensures that the entry is "correct" and that the Add / // Modify / Delete methods can be called on this object. This method // should be called if a reconnection event happened. Reset() // GetBundleMessage returns ofctrl.OpenFlowModMessage which can be used in Bundle messages. operation specifies what // operation is expected to be taken on the OFEntry. GetBundleMessage(operation OFOperation) (ofctrl.OpenFlowModMessage, error) }
type OFOperation ¶ added in v0.6.0
type OFOperation int
const ( AddMessage OFOperation = iota ModifyMessage DeleteMessage )
type PacketOutBuilder ¶ added in v0.7.0
type PacketOutBuilder interface { SetSrcMAC(mac net.HardwareAddr) PacketOutBuilder SetDstMAC(mac net.HardwareAddr) PacketOutBuilder SetSrcIP(ip net.IP) PacketOutBuilder SetDstIP(ip net.IP) PacketOutBuilder SetIPProtocol(protocol Protocol) PacketOutBuilder SetTTL(ttl uint8) PacketOutBuilder SetIPFlags(flags uint16) PacketOutBuilder SetTCPSrcPort(port uint16) PacketOutBuilder SetTCPDstPort(port uint16) PacketOutBuilder SetTCPFlags(flags uint8) PacketOutBuilder SetUDPSrcPort(port uint16) PacketOutBuilder SetUDPDstPort(port uint16) PacketOutBuilder SetICMPType(icmpType uint8) PacketOutBuilder SetICMPCode(icmpCode uint8) PacketOutBuilder SetICMPID(id uint16) PacketOutBuilder SetICMPSequence(seq uint16) PacketOutBuilder SetInport(inPort uint32) PacketOutBuilder SetOutport(outport uint32) PacketOutBuilder AddLoadAction(name string, data uint64, rng Range) PacketOutBuilder Done() *ofctrl.PacketOut }
type Protocol ¶ added in v0.6.0
type Protocol string
const ( ProtocolIP Protocol = "ip" ProtocolIPv6 Protocol = "ipv6" ProtocolARP Protocol = "arp" ProtocolTCP Protocol = "tcp" ProtocolTCPv6 Protocol = "tcpv6" ProtocolUDP Protocol = "udp" ProtocolUDPv6 Protocol = "udpv6" ProtocolSCTP Protocol = "sctp" ProtocolSCTPv6 Protocol = "sctpv6" ProtocolICMP Protocol = "icmp" ProtocolICMPv6 Protocol = "icmpv6" )
type Range ¶
type Range [2]uint32
func (*Range) ToNXRange ¶ added in v0.2.0
func (r *Range) ToNXRange() *openflow13.NXRange
type Table ¶
type Table interface { GetID() TableIDType BuildFlow(priority uint16) FlowBuilder GetMissAction() MissActionType Status() TableStatus GetNext() TableIDType }
type TableIDType ¶
type TableIDType uint8
const ( LastTableID TableIDType = 0xff TableIDAll = LastTableID )