diff --git a/VERSION b/VERSION index 62291ae2..1b0ae03b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v0.5.7 +v0.5.8 diff --git a/ofctrl/fgraphFlow.go b/ofctrl/fgraphFlow.go index 0a3c9b4b..532e4d1b 100644 --- a/ofctrl/fgraphFlow.go +++ b/ofctrl/fgraphFlow.go @@ -98,7 +98,7 @@ type FlowMatch struct { // additional Actions in flow's instruction set type FlowAction struct { - ActionType string // Type of action "setVlan", "setMetadata" + ActionType string // Type of action "setVlan", "writeMetadata" vlanId uint16 // Vlan Id in case of "setVlan" macAddr net.HardwareAddr // Mac address to set mplsEtherType uint16 // mpls ether type to push or pop @@ -106,7 +106,7 @@ type FlowAction struct { l4Port uint16 // Transport port to be set arpOper uint16 // Arp operation type to be set tunnelId uint64 // Tunnel Id (used for setting VNI) - metadata uint64 // Metadata in case of "setMetadata" + metadata uint64 // Metadata in case of "writeMetadata" metadataMask uint64 // Metadata mask dscp uint8 // DSCP field loadAct *NXLoadAction // Load data into OXM/NXM fields, one or more Actions @@ -843,12 +843,13 @@ func (self *Flow) installFlowActions(flowMod *openflow13.FlowMod, log.Debugf("flow install. Added setTunnelId Action: %+v", setTunnelAction) - case "setMetadata": - // Set Metadata instruction + case ActTypeWriteMetadata: + // Write Metadata instruction metadataInstr := openflow13.NewInstrWriteMetadata(flowAction.metadata, flowAction.metadataMask) // Add the instruction to flowmod flowMod.AddInstruction(metadataInstr) + log.Debugf("flow install. Added writeMetadata Action: %+v", metadataInstr) case ActTypeSetSrcIP: // Set IP src @@ -1584,10 +1585,11 @@ func (self *Flow) SetL4Field(port uint16, field string) error { return nil } -// Special actions on the flow to set metadata +// Special actions on the flow to write metadata +// Deprecated: use below WriteMetadata API instead of this one func (self *Flow) SetMetadata(metadata, metadataMask uint64) error { action := new(FlowAction) - action.ActionType = "setMetadata" + action.ActionType = ActTypeWriteMetadata action.metadata = metadata action.metadataMask = metadataMask @@ -1605,6 +1607,11 @@ func (self *Flow) SetMetadata(metadata, metadataMask uint64) error { return nil } +// Special actions on the flow to write metadata +func (self *Flow) WriteMetadata(metadata, metadataMask uint64) error { + return SetMetadata(metadata, metadataMask) +} + // Special actions on the flow to set vlan id func (self *Flow) SetTunnelId(tunnelId uint64) error { action := new(FlowAction) diff --git a/ofctrl/ofAction.go b/ofctrl/ofAction.go index 14dcabbb..3f5552d1 100644 --- a/ofctrl/ofAction.go +++ b/ofctrl/ofAction.go @@ -17,7 +17,8 @@ const ( ActTypeSetDstMac = "setMacDa" ActTypeSetSrcMac = "setMacSa" ActTypeSetTunnelID = "setTunnelId" - ActTypeMetatdata = "setMetadata" + ActTypeSetMetadata = "setMetadata" // use set_field + ActTypeWriteMetadata = "writeMetadata" // use writeMetadata instruction ActTypeSetSrcIP = "setIPSa" ActTypeSetDstIP = "setIPDa" ActTypeSetTunnelSrcIP = "setTunSa" @@ -160,6 +161,20 @@ func (a *SetTunnelIDAction) GetActionType() string { return ActTypeSetTunnelID } +type SetMetadataAction struct { + Metadata uint64 + MetadataMask *uint64 +} + +func (a *SetMetadataAction) GetActionMessage() openflow13.Action { + field := openflow13.NewMetadataField(a.Metadata, a.MetadataMask) + return openflow13.NewActionSetField(*field) +} + +func (a *SetMetadataAction) GetActionType() string { + return ActTypeSetMetadata +} + type SetTunnelDstAction struct { IP net.IP }