Documentation
¶
Overview ¶
Package flow encaps RTE generic flow API.
This interface provides the ability to program packet matching and associated actions in hardware through flow rules.
Index ¶
- Variables
- func Destroy(port ethdev.Port, flow *Flow, flowErr *Error) error
- func Flush(port ethdev.Port, flowErr *Error) error
- func Isolate(port ethdev.Port, set int, flowErr *Error) error
- func Validate(port ethdev.Port, attr *Attr, pattern []Item, actions []Action, flowErr *Error) error
- type Action
- type ActionQueue
- type ActionRSS
- type ActionType
- type Attr
- type ConvOpType
- type Error
- type ErrorType
- type Flow
- type HashFunction
- type IPv4
- type IPv4Header
- type Item
- type ItemEth
- type ItemIPv4
- type ItemStruct
- type ItemType
- type ItemUDP
- type ItemVlan
- type UDPHeader
Constants ¶
This section is empty.
Variables ¶
var ( ErrTypeNone = registerErr(C.RTE_FLOW_ERROR_TYPE_NONE, "No error") ErrTypeUnspecified = registerErr(C.RTE_FLOW_ERROR_TYPE_UNSPECIFIED, "Cause unspecified") ErrTypeHandle = registerErr(C.RTE_FLOW_ERROR_TYPE_HANDLE, "Flow rule (handle)") ErrTypeAttrGroup = registerErr(C.RTE_FLOW_ERROR_TYPE_ATTR_GROUP, "Group field") ErrTypeAttrPriority = registerErr(C.RTE_FLOW_ERROR_TYPE_ATTR_PRIORITY, "Priority field") ErrTypeAttrIngress = registerErr(C.RTE_FLOW_ERROR_TYPE_ATTR_INGRESS, "Ingress field") ErrTypeAttrEgress = registerErr(C.RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, "Egress field") ErrTypeAttrTransfer = registerErr(C.RTE_FLOW_ERROR_TYPE_ATTR_TRANSFER, "Transfer field") ErrTypeAttr = registerErr(C.RTE_FLOW_ERROR_TYPE_ATTR, "Attributes structure") ErrTypeItemNum = registerErr(C.RTE_FLOW_ERROR_TYPE_ITEM_NUM, "Pattern length") ErrTypeItemSpec = registerErr(C.RTE_FLOW_ERROR_TYPE_ITEM_SPEC, "Item specification spec") ErrTypeItemLast = registerErr(C.RTE_FLOW_ERROR_TYPE_ITEM_LAST, "Item specification range") ErrTypeItemMask = registerErr(C.RTE_FLOW_ERROR_TYPE_ITEM_MASK, "Item specification mask") ErrTypeItem = registerErr(C.RTE_FLOW_ERROR_TYPE_ITEM, "Specific pattern item") ErrTypeActionNum = registerErr(C.RTE_FLOW_ERROR_TYPE_ACTION_NUM, "Number of actions") ErrTypeActionConf = registerErr(C.RTE_FLOW_ERROR_TYPE_ACTION_CONF, "Action configuration") ErrTypeAction = registerErr(C.RTE_FLOW_ERROR_TYPE_ACTION, "Specific action") )
Error types.
Functions ¶
func Destroy ¶
Destroy a flow rule on a given port.
Failure to destroy a flow rule handle may occur when other flow rules depend on it, and destroying it would result in an inconsistent state.
This function is only guaranteed to succeed if handles are destroyed in reverse order of their creation.
func Flush ¶
Flush destroys all flow rules associated with a port.
In the unlikely event of failure, handles are still considered destroyed and no longer valid but the port must be assumed to be in an inconsistent state.
func Isolate ¶ added in v0.0.8
Isolate restricts ingress traffic to the defined flow rules.
Isolated mode guarantees that all ingress traffic comes from defined flow rules only (current and future).
Besides making ingress more deterministic, it allows PMDs to safely reuse resources otherwise assigned to handle the remaining traffic, such as global RSS configuration settings, VLAN filters, MAC address entries, legacy filter API rules and so on in order to expand the set of possible flow rule types.
Calling this function as soon as possible after device initialization, ideally before the first call to rte_eth_dev_configure(), is recommended to avoid possible failures due to conflicting settings.
Once effective, leaving isolated mode may not be possible depending on PMD implementation.
port is the identifier of Ethernet device. Specify set to nonzero value to enter isolated mode, otherwise it marks the attempt to leave it. flowErr performs verbose error reporting if not NULL. PMDs initialize this structure in case of error only.
func Validate ¶
Validate checks whether a flow rule can be created on a given port.
The flow rule is validated for correctness and whether it could be accepted by the device given sufficient resources. The rule is checked against the current device mode and queue configuration. The flow rule may also optionally be validated against existing flow rules and device resources. This function has no effect on the target device.
The returned value is guaranteed to remain valid only as long as no successful calls to rte_flow_create() or rte_flow_destroy() are made in the meantime and no device parameter affecting flow rules in any way are modified, due to possible collisions or resource limitations (although in such cases EINVAL should not be returned).
Types ¶
type Action ¶
type Action interface {
// Pointer returns a valid C pointer to underlying struct.
Pointer() unsafe.Pointer
// Reload is used to apply changes so that the underlying struct
// reflects the up-to-date configuration.
Reload()
// Type returns implemented rte_flow_action_* struct.
Type() ActionType
}
Action is the definition of a single action.
A list of actions is terminated by a END action.
For simple actions without a configuration object, conf remains NULL.
type ActionQueue ¶
type ActionQueue struct {
Index uint16
// contains filtered or unexported fields
}
ActionQueue implements Action which assigns packets to a given queue index.
func (*ActionQueue) Reload ¶
func (action *ActionQueue) Reload()
Reload implements Action interface.
func (*ActionQueue) Type ¶
func (action *ActionQueue) Type() ActionType
Type implements Action interface.
type ActionRSS ¶
type ActionRSS struct {
Func HashFunction
Queues []uint16
Key []byte
Level uint32
Types uint64
// contains filtered or unexported fields
}
ActionRSS implements Receive-Side Scaling feature.
Similar to QUEUE, except RSS is additionally performed on packets to spread them among several queues according to the provided parameters.
Unlike global RSS settings used by other DPDK APIs, unsetting the types field does not disable RSS in a flow rule. Doing so instead requests safe unspecified "best-effort" settings from the underlying PMD, which depending on the flow rule, may result in anything ranging from empty (single queue) to all-inclusive RSS.
Note: RSS hash result is stored in the hash.rss mbuf field which overlaps hash.fdir.lo. Since the MARK action sets the hash.fdir.hi field only, both can be requested simultaneously.
func (*ActionRSS) Type ¶
func (action *ActionRSS) Type() ActionType
Type implements Action interface.
type ActionType ¶
type ActionType uint32
ActionType is the rte_flow_action type.
const ( /** * End marker for action lists. Prevents further processing of * actions, thereby ending the list. * * No associated configuration structure. */ ActionTypeEnd ActionType = C.RTE_FLOW_ACTION_TYPE_END /** * Used as a placeholder for convenience. It is ignored and simply * discarded by PMDs. * * No associated configuration structure. */ ActionTypeVoid ActionType = C.RTE_FLOW_ACTION_TYPE_VOID /** * Leaves traffic up for additional processing by subsequent flow * rules; makes a flow rule non-terminating. * * No associated configuration structure. */ ActionTypePassthru ActionType = C.RTE_FLOW_ACTION_TYPE_PASSTHRU /** * RTE_FLOW_ACTION_TYPE_JUMP * * Redirects packets to a group on the current device. * * See struct rte_flow_action_jump. */ ActionTypeJump ActionType = C.RTE_FLOW_ACTION_TYPE_JUMP /** * Attaches an integer value to packets and sets PKT_RX_FDIR and * PKT_RX_FDIR_ID mbuf flags. * * See struct rte_flow_action_mark. */ ActionTypeMark ActionType = C.RTE_FLOW_ACTION_TYPE_MARK /** * Flags packets. Similar to MARK without a specific value; only * sets the PKT_RX_FDIR mbuf flag. * * No associated configuration structure. */ ActionTypeFlag ActionType = C.RTE_FLOW_ACTION_TYPE_FLAG /** * Assigns packets to a given queue index. * * See struct rte_flow_action_queue. */ ActionTypeQueue ActionType = C.RTE_FLOW_ACTION_TYPE_QUEUE /** * Drops packets. * * PASSTHRU overrides this action if both are specified. * * No associated configuration structure. */ ActionTypeDrop ActionType = C.RTE_FLOW_ACTION_TYPE_DROP /** * Enables counters for this flow rule. * * These counters can be retrieved and reset through rte_flow_query(), * see struct rte_flow_query_count. * * See struct rte_flow_action_count. */ ActionTypeCount ActionType = C.RTE_FLOW_ACTION_TYPE_COUNT /** * Similar to QUEUE, except RSS is additionally performed on packets * to spread them among several queues according to the provided * parameters. * * See struct rte_flow_action_rss. */ ActionTypeRss ActionType = C.RTE_FLOW_ACTION_TYPE_RSS /** * Directs matching traffic to the physical function (PF) of the * current device. * * No associated configuration structure. */ ActionTypePf ActionType = C.RTE_FLOW_ACTION_TYPE_PF /** * Directs matching traffic to a given virtual function of the * current device. * * See struct rte_flow_action_vf. */ ActionTypeVf ActionType = C.RTE_FLOW_ACTION_TYPE_VF /** * Directs matching traffic to a given DPDK port ID. * * See struct rte_flow_action_port_id. */ ActionTypePortID ActionType = C.RTE_FLOW_ACTION_TYPE_PORT_ID /** * Traffic metering and policing (MTR). * * See struct rte_flow_action_meter. * See file rte_mtr.h for MTR object configuration. */ ActionTypeMeter ActionType = C.RTE_FLOW_ACTION_TYPE_METER /** * Redirects packets to security engine of current device for security * processing as specified by security session. * * See struct rte_flow_action_security. */ ActionTypeSecurity ActionType = C.RTE_FLOW_ACTION_TYPE_SECURITY /** * Implements OFPAT_DEC_NW_TTL ("decrement IP TTL") as defined by * the OpenFlow Switch Specification. * * No associated configuration structure. */ ActionTypeOfDecNwTTL ActionType = C.RTE_FLOW_ACTION_TYPE_OF_DEC_NW_TTL /** * Implements OFPAT_POP_VLAN ("pop the outer VLAN tag") as defined * by the OpenFlow Switch Specification. * * No associated configuration structure. */ ActionTypeOfPopVlan ActionType = C.RTE_FLOW_ACTION_TYPE_OF_POP_VLAN /** * Implements OFPAT_PUSH_VLAN ("push a new VLAN tag") as defined by * the OpenFlow Switch Specification. * * See struct rte_flow_action_of_push_vlan. */ ActionTypeOfPushVlan ActionType = C.RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN /** * Implements OFPAT_SET_VLAN_VID ("set the 802.1q VLAN id") as * defined by the OpenFlow Switch Specification. * * See struct rte_flow_action_of_set_vlan_vid. */ ActionTypeOfSetVlanVid ActionType = C.RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID /** * Implements OFPAT_SET_LAN_PCP ("set the 802.1q priority") as * defined by the OpenFlow Switch Specification. * * See struct rte_flow_action_of_set_vlan_pcp. */ ActionTypeOfSetVlanPcp ActionType = C.RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP /** * Implements OFPAT_POP_MPLS ("pop the outer MPLS tag") as defined * by the OpenFlow Switch Specification. * * See struct rte_flow_action_of_pop_mpls. */ ActionTypeOfPopMpls ActionType = C.RTE_FLOW_ACTION_TYPE_OF_POP_MPLS /** * Implements OFPAT_PUSH_MPLS ("push a new MPLS tag") as defined by * the OpenFlow Switch Specification. * * See struct rte_flow_action_of_push_mpls. */ ActionTypeOfPushMpls ActionType = C.RTE_FLOW_ACTION_TYPE_OF_PUSH_MPLS /** * Encapsulate flow in VXLAN tunnel as defined in * rte_flow_action_vxlan_encap action structure. * * See struct rte_flow_action_vxlan_encap. */ ActionTypeVxlanEncap ActionType = C.RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP /** * Decapsulate outer most VXLAN tunnel from matched flow. * * If flow pattern does not define a valid VXLAN tunnel (as specified by * RFC7348) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION * error. */ ActionTypeVxlanDecap ActionType = C.RTE_FLOW_ACTION_TYPE_VXLAN_DECAP /** * Encapsulate flow in NVGRE tunnel defined in the * rte_flow_action_nvgre_encap action structure. * * See struct rte_flow_action_nvgre_encap. */ ActionTypeNvgreEncap ActionType = C.RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP /** * Decapsulate outer most NVGRE tunnel from matched flow. * * If flow pattern does not define a valid NVGRE tunnel (as specified by * RFC7637) then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION * error. */ ActionTypeNvgreDecap ActionType = C.RTE_FLOW_ACTION_TYPE_NVGRE_DECAP /** * Add outer header whose template is provided in its data buffer * * See struct rte_flow_action_raw_encap. */ ActionTypeRawEncap ActionType = C.RTE_FLOW_ACTION_TYPE_RAW_ENCAP /** * Remove outer header whose template is provided in its data buffer. * * See struct rte_flow_action_raw_decap */ ActionTypeRawDecap ActionType = C.RTE_FLOW_ACTION_TYPE_RAW_DECAP /** * Modify IPv4 source address in the outermost IPv4 header. * * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4, * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. * * See struct rte_flow_action_set_ipv4. */ ActionTypeSetIPv4Src ActionType = C.RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC /** * Modify IPv4 destination address in the outermost IPv4 header. * * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4, * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. * * See struct rte_flow_action_set_ipv4. */ ActionTypeSetIPv4Dst ActionType = C.RTE_FLOW_ACTION_TYPE_SET_IPV4_DST /** * Modify IPv6 source address in the outermost IPv6 header. * * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6, * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. * * See struct rte_flow_action_set_ipv6. */ ActionTypeSetIPv6Src ActionType = C.RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC /** * Modify IPv6 destination address in the outermost IPv6 header. * * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6, * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. * * See struct rte_flow_action_set_ipv6. */ ActionTypeSetIPv6Dst ActionType = C.RTE_FLOW_ACTION_TYPE_SET_IPV6_DST /** * Modify source port number in the outermost TCP/UDP header. * * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a * RTE_FLOW_ERROR_TYPE_ACTION error. * * See struct rte_flow_action_set_tp. */ ActionTypeSetTpSrc ActionType = C.RTE_FLOW_ACTION_TYPE_SET_TP_SRC /** * Modify destination port number in the outermost TCP/UDP header. * * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_TCP * or RTE_FLOW_ITEM_TYPE_UDP, then the PMD should return a * RTE_FLOW_ERROR_TYPE_ACTION error. * * See struct rte_flow_action_set_tp. */ ActionTypeSetTpDst ActionType = C.RTE_FLOW_ACTION_TYPE_SET_TP_DST /** * Swap the source and destination MAC addresses in the outermost * Ethernet header. * * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH, * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. * * No associated configuration structure. */ ActionTypeMacSwap ActionType = C.RTE_FLOW_ACTION_TYPE_MAC_SWAP /** * Decrease TTL value directly * * No associated configuration structure. */ ActionTypeDecTTL ActionType = C.RTE_FLOW_ACTION_TYPE_DEC_TTL /** * Set TTL value * * See struct rte_flow_action_set_ttl */ ActionTypeSetTTL ActionType = C.RTE_FLOW_ACTION_TYPE_SET_TTL /** * Set source MAC address from matched flow. * * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH, * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. * * See struct rte_flow_action_set_mac. */ ActionTypeSetMacSrc ActionType = C.RTE_FLOW_ACTION_TYPE_SET_MAC_SRC /** * Set destination MAC address from matched flow. * * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_ETH, * the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. * * See struct rte_flow_action_set_mac. */ ActionTypeSetMacDst ActionType = C.RTE_FLOW_ACTION_TYPE_SET_MAC_DST )
Action type constants.
func (ActionType) Pointer ¶
func (t ActionType) Pointer() unsafe.Pointer
Pointer implements Action interface.
type Attr ¶
type Attr struct {
// Priority group.
Group uint32
// Rule priority level within group.
Priority uint32
// Rule applies to ingress traffic.
Ingress bool
// Rule applies to egress traffic.
Egress bool
// Instead of simply matching the properties of traffic as it
// would appear on a given DPDK port ID, enabling this attribute
// transfers a flow rule to the lowest possible level of any
// device endpoints found in the pattern.
//
// When supported, this effectively enables an application to
// re-route traffic not necessarily intended for it (e.g. coming
// from or addressed to different physical ports, VFs or
// applications) at the device level.
//
// It complements the behavior of some pattern items such as
// RTE_FLOW_ITEM_TYPE_PHY_PORT and is meaningless without them.
//
// When transferring flow rules, ingress and egress attributes
// keep their original meaning, as if processing traffic emitted
// or received by the application.
Transfer bool
}
Attr is Flow rule attributes.
Priorities are set on a per rule based within groups.
Lower values denote higher priority, the highest priority for a flow rule is 0, so that a flow that matches for than one rule, the rule with the lowest priority value will always be matched.
Although optional, applications are encouraged to group similar rules as much as possible to fully take advantage of hardware capabilities (e.g. optimized matching) and work around limitations (e.g. a single pattern type possibly allowed in a given group). Applications should be aware that groups are not linked by default, and that they must be explicitly linked by the application using the JUMP action.
Priority levels are arbitrary and up to the application, they do not need to be contiguous nor start from 0, however the maximum number varies between devices and may be affected by existing flow rules.
If a packet is matched by several rules of a given group for a given priority level, the outcome is undefined. It can take any path, may be duplicated or even cause unrecoverable errors.
Note that support for more than a single group and priority level is not guaranteed.
Flow rules can apply to inbound and/or outbound traffic (ingress/egress).
Several pattern items and actions are valid and can be used in both directions. Those valid for only one direction are described as such.
At least one direction must be specified.
Specifying both directions at once for a given rule is not recommended but may be valid in a few cases (e.g. shared counter).
type ConvOpType ¶
type ConvOpType uint32
ConvOpType represents conversion operation type.
const ( /** * No operation to perform. * * rte_flow_conv() simply returns 0. */ ConvOpNone ConvOpType = C.RTE_FLOW_CONV_OP_NONE /** * Convert attributes structure. * * This is a basic copy of an attributes structure. * * - @p src type: * @code const struct rte_flow_attr * @endcode * - @p dst type: * @code struct rte_flow_attr * @endcode */ ConvOpAttr ConvOpType = C.RTE_FLOW_CONV_OP_ATTR /** * Convert a single item. * * Duplicates @p spec, @p last and @p mask but not outside objects. * * - @p src type: * @code const struct rte_flow_item * @endcode * - @p dst type: * @code struct rte_flow_item * @endcode */ ConvOpItem ConvOpType = C.RTE_FLOW_CONV_OP_ITEM /** * Convert a single action. * * Duplicates @p conf but not outside objects. * * - @p src type: * @code const struct rte_flow_action * @endcode * - @p dst type: * @code struct rte_flow_action * @endcode */ ConvOpAction ConvOpType = C.RTE_FLOW_CONV_OP_ACTION /** * Convert an entire pattern. * * Duplicates all pattern items at once with the same constraints as * RTE_FLOW_CONV_OP_ITEM. * * - @p src type: * @code const struct rte_flow_item * @endcode * - @p dst type: * @code struct rte_flow_item * @endcode */ ConvOpPattern ConvOpType = C.RTE_FLOW_CONV_OP_PATTERN /** * Convert a list of actions. * * Duplicates the entire list of actions at once with the same * constraints as RTE_FLOW_CONV_OP_ACTION. * * - @p src type: * @code const struct rte_flow_action * @endcode * - @p dst type: * @code struct rte_flow_action * @endcode */ ConvOpActions ConvOpType = C.RTE_FLOW_CONV_OP_ACTIONS /** * Convert a complete flow rule description. * * Comprises attributes, pattern and actions together at once with * the usual constraints. * * - @p src type: * @code const struct rte_flow_conv_rule * @endcode * - @p dst type: * @code struct rte_flow_conv_rule * @endcode */ ConvOpRule ConvOpType = C.RTE_FLOW_CONV_OP_RULE /** * Convert item type to its name string. * * Writes a NUL-terminated string to @p dst. Like snprintf(), the * returned value excludes the terminator which is always written * nonetheless. * * - @p src type: * @code (const void *)enum rte_flow_item_type @endcode * - @p dst type: * @code char * @endcode **/ ConvOpItemName ConvOpType = C.RTE_FLOW_CONV_OP_ITEM_NAME /** * Convert action type to its name string. * * Writes a NUL-terminated string to @p dst. Like snprintf(), the * returned value excludes the terminator which is always written * nonetheless. * * - @p src type: * @code (const void *)enum rte_flow_action_type @endcode * - @p dst type: * @code char * @endcode **/ ConvOpActionName ConvOpType = C.RTE_FLOW_CONV_OP_ACTION_NAME /** * Convert item type to pointer to item name. * * Retrieves item name pointer from its type. The string itself is * not copied; instead, a unique pointer to an internal static * constant storage is written to @p dst. * * - @p src type: * @code (const void *)enum rte_flow_item_type @endcode * - @p dst type: * @code const char ** @endcode */ ConvOpItemNamePtr ConvOpType = C.RTE_FLOW_CONV_OP_ITEM_NAME_PTR /** * Convert action type to pointer to action name. * * Retrieves action name pointer from its type. The string itself is * not copied; instead, a unique pointer to an internal static * constant storage is written to @p dst. * * - @p src type: * @code (const void *)enum rte_flow_action_type @endcode * - @p dst type: * @code const char ** @endcode */ ConvOpActionNamePtr ConvOpType = C.RTE_FLOW_CONV_OP_ACTION_NAME_PTR )
Conversion operation types.
type Error ¶
type Error C.struct_rte_flow_error
Error is a verbose error structure definition.
This object is normally allocated by applications and set by PMDs, the message points to a constant string which does not need to be freed by the application, however its pointer can be considered valid only as long as its associated DPDK port remains configured. Closing the underlying device or unloading the PMD invalidates it.
Both cause and message may be NULL regardless of the error type.
type Flow ¶
type Flow C.struct_rte_flow
Flow is the opaque flow handle.
func Create ¶
func Create(port ethdev.Port, attr *Attr, pattern []Item, actions []Action, flowErr *Error) (*Flow, error)
Create a flow rule on a given port.
port is port identifier of Ethernet device. attr is the Flow rule attributes. pattern is a pattern specification (list terminated by the END pattern item). actions is Associated actions (list terminated by the END action). error is to Perform verbose error reporting if not NULL. PMDs initialize this structure in case of error only.
Returns a valid handle in case of success, NULL otherwise and rte_errno is set to the positive version of one of the error codes defined for rte_flow_validate().
type HashFunction ¶
type HashFunction uint32
HashFunction represents hash functions for RSS.
const ( HashFunctionDefault HashFunction = C.RTE_ETH_HASH_FUNCTION_DEFAULT // Default HashFunctionToeplitz HashFunction = C.RTE_ETH_HASH_FUNCTION_TOEPLITZ // Toeplitz. HashFunctionSimpleXor HashFunction = C.RTE_ETH_HASH_FUNCTION_SIMPLE_XOR // Simple XOR. HashFunctionSymmetricToeplitz HashFunction = C.RTE_ETH_HASH_FUNCTION_SYMMETRIC_TOEPLITZ // symmetrics toeplitz HashFunctionMax HashFunction = C.RTE_ETH_HASH_FUNCTION_MAX )
RSS hash function identifiers.
type IPv4Header ¶ added in v0.0.8
type IPv4Header struct {
VersionIHL uint8 /* Version and header length. */
ToS uint8 /* Type of service. */
TotalLength uint16 /* Length of packet. */
ID uint16 /* Packet ID. */
FragmentOffset uint16 /* Fragmentation offset. */
TTL uint8 /* Time to live. */
Proto uint8 /* Protocol ID. */
Checksum uint16 /* Header checksum. */
SrcAddr IPv4 /* Source address. */
DstAddr IPv4 /* Destination address. */
}
IPv4Header is the IPv4 header raw format.
type Item ¶
type Item struct {
Spec, Last, Mask ItemStruct
}
Item is the matching pattern item definition.
A pattern is formed by stacking items starting from the lowest protocol layer to match. This stacking restriction does not apply to meta items which can be placed anywhere in the stack without affecting the meaning of the resulting pattern.
Patterns are terminated by END items.
The spec field should be a valid pointer to a structure of the related item type. It may remain unspecified (NULL) in many cases to request broad (nonspecific) matching. In such cases, last and mask must also be set to NULL.
Optionally, last can point to a structure of the same type to define an inclusive range. This is mostly supported by integer and address fields, may cause errors otherwise. Fields that do not support ranges must be set to 0 or to the same value as the corresponding fields in spec.
Only the fields defined to nonzero values in the default masks (see rte_flow_item_{name}_mask constants) are considered relevant by default. This can be overridden by providing a mask structure of the same type with applicable bits set to one. It can also be used to partially filter out specific fields (e.g. as an alternate mean to match ranges of IP addresses).
Mask is a simple bit-mask applied before interpreting the contents of spec and last, which may yield unexpected results if not used carefully. For example, if for an IPv4 address field, spec provides 10.1.2.3, last provides 10.3.4.5 and mask provides 255.255.0.0, the effective range becomes 10.1.0.0 to 10.3.255.255.
Go: you may also specify ItemType as a Spec field if you don't want to specify any pattern for the item.
type ItemEth ¶
type ItemEth struct {
HasVlan bool
Src, Dst net.HardwareAddr
EtherType uint16
// contains filtered or unexported fields
}
ItemEth matches an Ethernet header.
Inside hdr field, the sub-field ether_type stands either for EtherType or TPID, depending on whether the item is followed by a VLAN item or not. If two VLAN items follow, the sub-field refers to the outer one, which, in turn, contains the inner TPID in the similar header field. The innermost VLAN item contains a layer-3 EtherType. All of that follows the order seen on the wire.
If the field in question contains a TPID value, only tagged packets with the specified TPID will match the pattern. Alternatively, it's possible to match any type of tagged packets by means of the field has_vlan rather than use the EtherType/TPID field. Also, it's possible to leave the two fields unused. If this is the case, both tagged and untagged packets will match the pattern.
type ItemIPv4 ¶
type ItemIPv4 struct {
Header IPv4Header
// contains filtered or unexported fields
}
ItemIPv4 matches an IPv4 header.
Note: IPv4 options are handled by dedicated pattern items.
type ItemStruct ¶
type ItemStruct interface {
// Pointer returns a valid C pointer to underlying struct.
Pointer() unsafe.Pointer
// Reload is used to apply changes so that the underlying struct
// reflects the up-to-date configuration.
Reload()
// Type returns implemented rte_flow_item_* struct.
Type() ItemType
// Mask returns pointer to rte_flow_item_*_mask variables. They
// should not be changed by user so Mask returns pointer to C
// struct.
Mask() unsafe.Pointer
}
ItemStruct should be implemented to specify in Item.
type ItemType ¶
type ItemType uint32
ItemType represents rte_flow_item type.
const ( /** * [META] * * End marker for item lists. Prevents further processing of items, * thereby ending the pattern. * * No associated specification structure. */ ItemTypeEnd ItemType = C.RTE_FLOW_ITEM_TYPE_END /** * [META] * * Used as a placeholder for convenience. It is ignored and simply * discarded by PMDs. * * No associated specification structure. */ ItemTypeVoid ItemType = C.RTE_FLOW_ITEM_TYPE_VOID /** * [META] * * Inverted matching, i.e. process packets that do not match the * pattern. * * No associated specification structure. */ ItemTypeInvert ItemType = C.RTE_FLOW_ITEM_TYPE_INVERT /** * Matches any protocol in place of the current layer, a single ANY * may also stand for several protocol layers. * * See struct rte_flow_item_any. */ ItemTypeAny ItemType = C.RTE_FLOW_ITEM_TYPE_ANY /** * [META] * * Matches traffic originating from (ingress) or going to (egress) a * given DPDK port ID. * * See struct rte_flow_item_port_id. */ ItemTypePortID ItemType = C.RTE_FLOW_ITEM_TYPE_PORT_ID /** * Matches a byte string of a given length at a given offset. * * See struct rte_flow_item_raw. */ ItemTypeRaw ItemType = C.RTE_FLOW_ITEM_TYPE_RAW /** * Matches an Ethernet header. * * See struct rte_flow_item_eth. */ ItemTypeEth ItemType = C.RTE_FLOW_ITEM_TYPE_ETH /** * Matches an 802.1Q/ad VLAN tag. * * See struct rte_flow_item_vlan. */ ItemTypeVlan ItemType = C.RTE_FLOW_ITEM_TYPE_VLAN /** * Matches an IPv4 header. * * See struct rte_flow_item_ipv4. */ ItemTypeIPv4 ItemType = C.RTE_FLOW_ITEM_TYPE_IPV4 /** * Matches an IPv6 header. * * See struct rte_flow_item_ipv6. */ ItemTypeIPv6 ItemType = C.RTE_FLOW_ITEM_TYPE_IPV6 /** * Matches an ICMP header. * * See struct rte_flow_item_icmp. */ ItemTypeICMP ItemType = C.RTE_FLOW_ITEM_TYPE_ICMP /** * Matches a UDP header. * * See struct rte_flow_item_udp. */ ItemTypeUDP ItemType = C.RTE_FLOW_ITEM_TYPE_UDP /** * Matches a TCP header. * * See struct rte_flow_item_tcp. */ ItemTypeTCP ItemType = C.RTE_FLOW_ITEM_TYPE_TCP /** * Matches a SCTP header. * * See struct rte_flow_item_sctp. */ ItemTypeSCTP ItemType = C.RTE_FLOW_ITEM_TYPE_SCTP /** * Matches a VXLAN header. * * See struct rte_flow_item_vxlan. */ ItemTypeVxlan ItemType = C.RTE_FLOW_ITEM_TYPE_VXLAN /** * Matches a E_TAG header. * * See struct rte_flow_item_e_tag. */ ItemTypeETag ItemType = C.RTE_FLOW_ITEM_TYPE_E_TAG /** * Matches a NVGRE header. * * See struct rte_flow_item_nvgre. */ ItemTypeNvgre ItemType = C.RTE_FLOW_ITEM_TYPE_NVGRE /** * Matches a MPLS header. * * See struct rte_flow_item_mpls. */ ItemTypeMpls ItemType = C.RTE_FLOW_ITEM_TYPE_MPLS /** * Matches a GRE header. * * See struct rte_flow_item_gre. */ ItemTypeGre ItemType = C.RTE_FLOW_ITEM_TYPE_GRE /** * [META] * * Fuzzy pattern match, expect faster than default. * * This is for device that support fuzzy matching option. * Usually a fuzzy matching is fast but the cost is accuracy. * * See struct rte_flow_item_fuzzy. */ ItemTypeFuzzy ItemType = C.RTE_FLOW_ITEM_TYPE_FUZZY /** * Matches a GTP header. * * Configure flow for GTP packets. * * See struct rte_flow_item_gtp. */ ItemTypeGtp ItemType = C.RTE_FLOW_ITEM_TYPE_GTP /** * Matches a GTP header. * * Configure flow for GTP-C packets. * * See struct rte_flow_item_gtp. */ ItemTypeGtpc ItemType = C.RTE_FLOW_ITEM_TYPE_GTPC /** * Matches a GTP header. * * Configure flow for GTP-U packets. * * See struct rte_flow_item_gtp. */ ItemTypeGtpu ItemType = C.RTE_FLOW_ITEM_TYPE_GTPU /** * Matches a ESP header. * * See struct rte_flow_item_esp. */ ItemTypeEsp ItemType = C.RTE_FLOW_ITEM_TYPE_ESP /** * Matches a GENEVE header. * * See struct rte_flow_item_geneve. */ ItemTypeGeneve ItemType = C.RTE_FLOW_ITEM_TYPE_GENEVE /** * Matches a VXLAN-GPE header. * * See struct rte_flow_item_vxlan_gpe. */ ItemTypeVxlanGpe ItemType = C.RTE_FLOW_ITEM_TYPE_VXLAN_GPE /** * Matches an ARP header for Ethernet/IPv4. * * See struct rte_flow_item_arp_eth_ipv4. */ ItemTypeArpEthIPv4 ItemType = C.RTE_FLOW_ITEM_TYPE_ARP_ETH_IPV4 /** * Matches the presence of any IPv6 extension header. * * See struct rte_flow_item_ipv6_ext. */ ItemTypeIPv6Ext ItemType = C.RTE_FLOW_ITEM_TYPE_IPV6_EXT /** * Matches any ICMPv6 header. * * See struct rte_flow_item_icmp6. */ ItemTypeICMP6 ItemType = C.RTE_FLOW_ITEM_TYPE_ICMP6 /** * Matches an ICMPv6 neighbor discovery solicitation. * * See struct rte_flow_item_icmp6_nd_ns. */ ItemTypeICMP6NdNs ItemType = C.RTE_FLOW_ITEM_TYPE_ICMP6_ND_NS /** * Matches an ICMPv6 neighbor discovery advertisement. * * See struct rte_flow_item_icmp6_nd_na. */ ItemTypeICMP6NdNa ItemType = C.RTE_FLOW_ITEM_TYPE_ICMP6_ND_NA /** * Matches the presence of any ICMPv6 neighbor discovery option. * * See struct rte_flow_item_icmp6_nd_opt. */ ItemTypeICMP6NdOpt ItemType = C.RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT /** * Matches an ICMPv6 neighbor discovery source Ethernet link-layer * address option. * * See struct rte_flow_item_icmp6_nd_opt_sla_eth. */ ItemTypeICMP6NdOptSLAEth ItemType = C.RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_SLA_ETH /** * Matches an ICMPv6 neighbor discovery target Ethernet link-layer * address option. * * See struct rte_flow_item_icmp6_nd_opt_tla_eth. */ ItemTypeICMP6NdOptTlaEth ItemType = C.RTE_FLOW_ITEM_TYPE_ICMP6_ND_OPT_TLA_ETH /** * Matches specified mark field. * * See struct rte_flow_item_mark. */ ItemTypeMark ItemType = C.RTE_FLOW_ITEM_TYPE_MARK /** * [META] * * Matches a metadata value specified in mbuf metadata field. * See struct rte_flow_item_meta. */ ItemTypeMeta ItemType = C.RTE_FLOW_ITEM_TYPE_META )
Flow item type constants.
type ItemUDP ¶
type ItemUDP struct {
Header UDPHeader
// contains filtered or unexported fields
}
ItemUDP matches an UDP header.
type ItemVlan ¶
type ItemVlan struct {
HasMoreVlan bool
TCI uint16
InnerType uint16
// contains filtered or unexported fields
}
ItemVlan matches an 802.1Q/ad VLAN tag.
The corresponding standard outer EtherType (TPID) values are RTE_ETHER_TYPE_VLAN or RTE_ETHER_TYPE_QINQ. It can be overridden by the preceding pattern item. If a VLAN item is present in the pattern, then only tagged packets will match the pattern. The field has_more_vlan can be used to match any type of tagged packets, instead of using the eth_proto field of hdr. If the eth_proto of hdr and has_more_vlan fields are not specified, then any tagged packets will match the pattern.