ethdev: introduce conntrack flow action and item
RFC 1/1 ethdev: introduce conntrack flow action and item
This commit introduced the conntrack action and item.
Usually the HW offloading is stateless. For some stateful offloading like a TCP connection, HW module will help provide the ability of a full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow the application should add the conntrack action and in the following flow(s) the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack action context correctly, information from packets of both directions are required.
The conntrack action should be created on one port and supply the peer port as a parameter to the action. After context creating, it could only be used between the ports (dual-port mode) or a single port. The application should modify the action via action_ctx_update interface before each use in dual-port mode, in order to set the correct direction for the following rte flow.
Query will be supported via action_ctx_query interface, about the current packets information and connection status.
For the packets received during the conntrack setup, it is suggested to re-inject the packets in order to take full advantage of the conntrack. Only the valid packets should pass the conntrack, packets with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Testpmd command line example:
set conntrack [index] enable is 1 last_seq is xxx last ack is xxx / ... / orig_dir win_scale is xxx sent_end is xxx max_win is xxx ... / rply_dir ... / end
flow action_ctx [CTX] create ingress ... / conntrack is [index] / end flow create 0 group X ingress patterns ... / tcp / end actions action_ctx [CTX] / jump group Y / end
flow create 0 group Y ingress patterns ... / ct is [Valid] / end actions queue index [hairpin queue] / end
--- lib/librte_ethdev/rte_flow.h | 191 +++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+)
lib/librte_ethdev/rte_flow.h +191 -0
@@ -550,6 +550,15 @@ enum rte_flow_item_type {* See struct rte_flow_item_geneve_opt */ RTE_FLOW_ITEM_TYPE_GENEVE_OPT , + +/** +* [META] +* +* Matches conntrack state. +* +* See struct rte_flow_item_conntrack. +*/ + RTE_FLOW_ITEM_TYPE_CONNTRACK, };/**
@@ -1654,6 +1663,49 @@ rte_flow_item_geneve_opt_mask = { };#endif +/** +* The packet is with valid. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_STATE_VALID (1 << 0) +/** +* The state of the connection was changed. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_STATE_CHANGED (1 << 1) +/** +* Error state was detected on this packet for this connection. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_ERROR (1 << 2) +/** +* The HW connection tracking module is disabled. +* It can be due to application command or an invalid state. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_DISABLED (1 << 3) +/** +* The packet contains some bad field(s). +*/ +#define RTE_FLOW_CONNTRACK_FLAG_BAD_PKT (1 << 4) + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ITEM_TYPE_CONNTRACK +* +* Matches the state of a packet after it passed the connection tracking +* examination. The state is a bit mask of one RTE_FLOW_CONNTRACK_FLAG* +* or a reasonable combination of these bits. +*/ +struct rte_flow_item_conntrack { +uint32_t flags; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */ +#ifndef __cplusplus +static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = { + .flags =0xffffffff , +}; +#endif +/** * Matching pattern item definition. *
@@ -2236,6 +2288,17 @@ enum rte_flow_action_type {* See struct rte_flow_action_modify_field. */ RTE_FLOW_ACTION_TYPE_MODIFY_FIELD , + +/** +* [META] +* +* Enable tracking a TCP connection state. +* +* Send packet to HW connection tracking module for examination. +* +* See struct rte_flow_action_conntrack. +*/ + RTE_FLOW_ACTION_TYPE_CONNTRACK, };/**
@@ -2828,6 +2891,134 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +/** +* The state of a TCP connection. +*/ +enum rte_flow_conntrack_state { +RTE_FLOW_CONNTRACK_STATE_SYN_RECV , +/**< SYN-ACK packet was seen. */ +RTE_FLOW_CONNTRACK_STATE_ESTABLISHED , +/**< 3-way handshark was done. */ +RTE_FLOW_CONNTRACK_STATE_FIN_WAIT , +/**< First FIN packet was received to close the connection. */ +RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT , +/**< First FIN was ACKed. */ +RTE_FLOW_CONNTRACK_STATE_LAST_ACK , +/**< After second FIN, waiting for the last ACK. */ +RTE_FLOW_CONNTRACK_STATE_TIME_WAIT , +/**< Second FIN was ACKed, connection was closed. */ +}; + +/** +* The last passed TCP packet flags of a connection. +*/ +enum rte_flow_conntrack_index { +RTE_FLOW_CONNTRACK_INDEX_NONE =0 ,/**< No Flag. */ +RTE_FLOW_CONNTRACK_INDEX_SYN = (1 <<0 ),/**< With SYN flag. */ +RTE_FLOW_CONNTRACK_INDEX_SYN_ACK = (1 <<1 ),/**< With SYN+ACK flag. */ +RTE_FLOW_CONNTRACK_INDEX_FIN = (1 <<2 ),/**< With FIN flag. */ +RTE_FLOW_CONNTRACK_INDEX_ACK = (1 <<3 ),/**< With ACK flag. */ +RTE_FLOW_CONNTRACK_INDEX_RST = (1 <<4 ),/**< With RST flag. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* Configuration parameters for each direction of a TCP connection. +*/ +struct rte_flow_tcp_dir_param { +uint32_t scale:4 ;/**< TCP window scaling factor, 0xF to disable. */ +uint32_t close_initiated:1 ;/**< The FIN was sent by this direction. */ +uint32_t last_ack_seen:1 ; +/**< An ACK packet has been received by this side. */ +uint32_t data_unacked:1 ; +/**< If set, indicates that there is unacked data of the connection. */ +uint32_t sent_end; +/**< Maximal value of sequence + payload length over sent +* packets (next ACK from the opposite direction). +*/ +uint32_t reply_end; +/**< Maximal value of (ACK + window size) over received packet + length +* over sent packet (maximal sequence could be sent). +*/ +uint32_t max_win; +/**< Maximal value of actual window size over sent packets. */ +uint32_t max_ack; +/**< Maximal value of ACK over sent packets. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Configuration and initial state for the connection tracking module. +* This structure could be used for both setting and query. +*/ +struct rte_flow_action_conntrack { +uint16_t peer_port;/**< The peer port number, can be the same port. */ +uint32_t is_original_dir:1 ; +/**< Direction of this connection when creating a flow, the value only +* affects the subsequent flows creation. +*/ +uint32_t enable:1 ; +/**< Enable / disable the conntrack HW module. When disabled, the +* result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED. +* In this state the HW will act as passthrough. +*/ +uint32_t live_connection:1 ; +/**< At least one ack was seen, after the connection was established. */ +uint32_t selective_ack:1 ; +/**< Enable selective ACK on this connection. */ +uint32_t challenge_ack_passed:1 ; +/**< A challenge ack has passed. */ +uint32_t last_direction:1 ; +/**< 1: The last packet is seen that comes from the original direction. +* 0: From the reply direction. +*/ +uint32_t liberal_mode:1 ; +/**< No TCP check will be done except the state change. */ +enum rte_flow_conntrack_state state; +/**< The current state of the connection. */ +uint8_t max_ack_window; +/**< Scaling factor for maximal allowed ACK window. */ +uint8_t retransmission_limit; +/**< Maximal allowed number of retransmission times. */ +struct rte_flow_tcp_dir_param original_dir; +/**< TCP parameters of the original direction. */ +struct rte_flow_tcp_dir_param reply_dir; +/**< TCP parameters of the reply direction. */ +uint16_t last_window; +/**< The window value of the last packet passed this conntrack. */ +enum rte_flow_conntrack_index last_index; +uint32_t last_seq; +/**< The sequence of the last packet passed this conntrack. */ +uint32_t last_ack; +/**< The acknowledgement of the last packet passed this conntrack. */ +uint32_t last_end; +/**< The total value ACK + payload length of the last packet passed +* this conntrack. +*/ +}; + +/** +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Wrapper structure for the context update interface. +* Ports cannot support updating, and the only valid solution is to +* destroy the old context and create a new one instead. +*/ +struct rte_flow_modify_conntrack { +struct rte_flow_action_conntrack new_ct; +/**< New connection tracking parameters to be updated. */ +uint32_t direction:1 ;/**< The direction field will be updated. */ +uint32_t state:1 ; +/**< All the other fields except direction will be updated. */ +uint32_t reserved:30 ;/**< Reserved bits for the future usage. */ +}; +/** * Field IDs for MODIFY_FIELD action. */
Signature · 1 line
2.19.0.windows.1
Quoted 15 lines · Bing Zhao
This commit introduced the conntrack action and item.
Usually the HW offloading is stateless. For some stateful offloading like a TCP connection, HW module will help provide the ability of a full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow the application should add the conntrack action and in the following flow(s) the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack action context correctly, information from packets of both directions are required.
Quoted 6 lines
The conntrack action should be created on one port and supply the peer port as a parameter to the action. After context creating, it could only be used between the ports (dual-port mode) or a single port. The application should modify the action via
action_ctx_updateinterface before each use in dual-port mode, in order to set the correct direction for the following rte flow.
Sorry, but "update interface before each use" sounds frightening. May be I simply don't understand all
reasons behind.
Quoted 46 lines
Query will be supported via
action_ctx_queryinterface, about the current packets information and connection status.For the packets received during the conntrack setup, it is suggested to re-inject the packets in order to take full advantage of the conntrack. Only the valid packets should pass the conntrack, packets with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Testpmd command line example:
set conntrack [index] enable is 1
last_seqis xxx last ack is xxx / ... /orig_dirwin_scaleis xxxsent_endis xxxmax_winis xxx ... /rply_dir... / end
flowaction_ctx[CTX] create ingress ... / conntrack is [index] / end flow create 0 group X ingress patterns ... / tcp / end actionsaction_ctx[CTX] / jump group Y / end
flow create 0 group Y ingress patterns ... / ct is [Valid] / end actions queue index [hairpin queue] / endSigned-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_flow.h | 191 +++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+)lib/librte_ethdev/rte_flow.h +9
-0@@ -550,6 +550,15 @@ enum rte_flow_item_type {* See struct rte_flow_item_geneve_opt */ RTE_FLOW_ITEM_TYPE_GENEVE_OPT , + +/** +* [META] +* +* Matches conntrack state. +* +* See struct rte_flow_item_conntrack. +*/ + RTE_FLOW_ITEM_TYPE_CONNTRACK, };/**
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = { · line 1669
Quoted 7 lines
lib/librte_ethdev/rte_flow.h +4
-0@@ -1654,6 +1663,49 @@ rte_flow_item_geneve_opt_mask = { };#endif +/** +* The packet is with valid. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_STATE_VALID (1 << 0)
It sounds like conntrack state is valid, but not packet is valid from conntrack point of view. May be:RTE_FLOW_CONNTRACK_FLAG_PKT_VALID? Or _VALID_PKT to go with _BAD_PKT.
Quoted 61 lines
lib/librte_ethdev/rte_flow.h +50
-0+/** +* The state of the connection was changed. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_STATE_CHANGED (1 << 1) +/** +* Error state was detected on this packet for this connection. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_ERROR (1 << 2) +/** +* The HW connection tracking module is disabled. +* It can be due to application command or an invalid state. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_DISABLED (1 << 3) +/** +* The packet contains some bad field(s). +*/ +#define RTE_FLOW_CONNTRACK_FLAG_BAD_PKT (1 << 4) + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ITEM_TYPE_CONNTRACK +* +* Matches the state of a packet after it passed the connection tracking +* examination. The state is a bit mask of one RTE_FLOW_CONNTRACK_FLAG* +* or a reasonable combination of these bits. +*/ +struct rte_flow_item_conntrack { +uint32_t flags; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */ +#ifndef __cplusplus +static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = { + .flags =0xffffffff , +}; +#endif +/** * Matching pattern item definition. * @@ -2236,6 +2288,17 @@ enum rte_flow_action_type {* See struct rte_flow_action_modify_field. */ RTE_FLOW_ACTION_TYPE_MODIFY_FIELD , + +/** +* [META] +* +* Enable tracking a TCP connection state. +* +* Send packet to HW connection tracking module for examination. +* +* See struct rte_flow_action_conntrack. +*/ + RTE_FLOW_ACTION_TYPE_CONNTRACK, };/**
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2899
Quoted 9 lines
lib/librte_ethdev/rte_flow.h +6
-0@@ -2828,6 +2891,134 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +/** +* The state of a TCP connection. +*/ +enum rte_flow_conntrack_state { +RTE_FLOW_CONNTRACK_STATE_SYN_RECV , +/**< SYN-ACK packet was seen. */
May I suggest to put comments before enum member. IMHO it is more readable. Comment after makes sense if it is on the same line, otherwise, it is better to use comments before code.
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+RTE_FLOW_CONNTRACK_STATE_ESTABLISHED , +/**< 3-way handshark was done. */ +RTE_FLOW_CONNTRACK_STATE_FIN_WAIT , +/**< First FIN packet was received to close the connection. */ + RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT, +/**< First FIN was ACKed. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2915
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+RTE_FLOW_CONNTRACK_STATE_LAST_ACK , +/**< After second FIN, waiting for the last ACK. */ + RTE_FLOW_CONNTRACK_STATE_TIME_WAIT, + /**< Second FIN was ACKed, connection was closed. */ +}; + +/** +* The last passed TCP packet flags of a connection. +*/ +enum rte_flow_conntrack_index {
Sorry, I don't understand why it is named conntrack_index.
Quoted 9 lines
lib/librte_ethdev/rte_flow.h +9
-0+RTE_FLOW_CONNTRACK_INDEX_NONE =0 ,/**< No Flag. */ +RTE_FLOW_CONNTRACK_INDEX_SYN = (1 <<0 ),/**< With SYN flag. */ +RTE_FLOW_CONNTRACK_INDEX_SYN_ACK = (1 <<1 ),/**< With SYN+ACK flag. */ +RTE_FLOW_CONNTRACK_INDEX_FIN = (1 <<2 ),/**< With FIN flag. */ +RTE_FLOW_CONNTRACK_INDEX_ACK = (1 <<3 ),/**< With ACK flag. */ + RTE_FLOW_CONNTRACK_INDEX_RST = (1 << 4), /**< With RST flag. */ +}; + +/**
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2934
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* Configuration parameters for each direction of a TCP connection. +*/ +struct rte_flow_tcp_dir_param { +uint32_t scale:4 ;/**< TCP window scaling factor, 0xF to disable. */ +uint32_t close_initiated:1 ;/**< The FIN was sent by this direction. */ +uint32_t last_ack_seen:1 ; +/**< An ACK packet has been received by this side. */
Same here about comments after fields.
Quoted 21 lines
lib/librte_ethdev/rte_flow.h +21
-0+ uint32_t data_unacked:1; +/**< If set, indicates that there is unacked data of the connection. */ +uint32_t sent_end; +/**< Maximal value of sequence + payload length over sent +* packets (next ACK from the opposite direction). +*/ +uint32_t reply_end; +/**< Maximal value of (ACK + window size) over received packet + length +* over sent packet (maximal sequence could be sent). +*/ +uint32_t max_win; +/**< Maximal value of actual window size over sent packets. */ +uint32_t max_ack; +/**< Maximal value of ACK over sent packets. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_CONNTRACK
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2965
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* +* Configuration and initial state for the connection tracking module. +* This structure could be used for both setting and query. +*/ +struct rte_flow_action_conntrack { +uint16_t peer_port;/**< The peer port number, can be the same port. */ +uint32_t is_original_dir:1 ; +/**< Direction of this connection when creating a flow, the value only +* affects the subsequent flows creation. +*/
and here tool
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2970
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+ uint32_t enable:1; +/**< Enable / disable the conntrack HW module. When disabled, the +* result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED. +* In this state the HW will act as passthrough. +*/
Does it disable entire conntrack HW module for all flows? It sounds like this. If so - confusing.
Quoted 35 lines
lib/librte_ethdev/rte_flow.h +35
-0+ uint32_t live_connection:1; +/**< At least one ack was seen, after the connection was established. */ + uint32_t selective_ack:1; +/**< Enable selective ACK on this connection. */ + uint32_t challenge_ack_passed:1; +/**< A challenge ack has passed. */ + uint32_t last_direction:1; +/**< 1: The last packet is seen that comes from the original direction. +* 0: From the reply direction. +*/ + uint32_t liberal_mode:1; +/**< No TCP check will be done except the state change. */ +enum rte_flow_conntrack_state state; +/**< The current state of the connection. */ +uint8_t max_ack_window; +/**< Scaling factor for maximal allowed ACK window. */ +uint8_t retransmission_limit; +/**< Maximal allowed number of retransmission times. */ +struct rte_flow_tcp_dir_param original_dir; +/**< TCP parameters of the original direction. */ +struct rte_flow_tcp_dir_param reply_dir; +/**< TCP parameters of the reply direction. */ +uint16_t last_window; +/**< The window value of the last packet passed this conntrack. */ +enum rte_flow_conntrack_index last_index; +uint32_t last_seq; +/**< The sequence of the last packet passed this conntrack. */ +uint32_t last_ack; +/**< The acknowledgement of the last packet passed this conntrack. */ +uint32_t last_end; +/**< The total value ACK + payload length of the last packet passed +* this conntrack. +*/ +}; +
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3015
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+/** +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Wrapper structure for the context update interface. +* Ports cannot support updating, and the only valid solution is to +* destroy the old context and create a new one instead. +*/ +struct rte_flow_modify_conntrack { +struct rte_flow_action_conntrack new_ct; +/**< New connection tracking parameters to be updated. */
and here
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +6
-0+ uint32_t direction:1; /**< The direction field will be updated. */ + uint32_t state:1; +/**< All the other fields except direction will be updated. */ + uint32_t reserved:30; /**< Reserved bits for the future usage. */ +}; +/** * Field IDs for MODIFY_FIELD action. */
Hi Andrew,
Sorry for the late reply.
Quoted 37 lines
-----Original Message-----
From: Andrew Rybchenko <[email protected]>
Sent: Monday, March 22, 2021 11:17 PM
To: Bing Zhao <[email protected]>; Ori Kam <[email protected]>; NBU- Contact-Thomas Monjalon <[email protected]>; [email protected]
Cc: [email protected]
Subject: Re: [RFC] ethdev: introduce conntrack flow action and itemExternal email: Use caution opening links or attachments
Quoted 3 lines · Bing Zhao
This commit introduced the conntrack action and item.
Usually the HW offloading is stateless. For some stateful
offloading
Quoted 1 line
like a TCP connection, HW module will help provide the ability of
a
Quoted 4 lines
full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow the application should
add
Quoted 4 lines
the conntrack action and in the following flow(s) the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack
action
Quoted 4 lines
context correctly, information from packets of both directions are required.
The conntrack action should be created on one port and supply the
peer
Quoted 1 line
port as a parameter to the action. After context creating, it
could
Quoted 1 line
only be used between the ports (dual-port mode) or a single port.
Quoted 8 lines
The
Quoted 1 line
application should modify the action via
action_ctx_updateinterface
Quoted 2 lines
before each use in dual-port mode, in order to set the correct direction for the following rte flow.
Sorry, but "update interface before each use" sounds frightening. May be I simply don't understand all reasons behind.
Sorry for the uncleared description and the "each use in dual-port mode" should be "single-port mode". It is a suggestion but not a must, depending on the HW. But usually, since connection tracking is a bi-directional action and should be used by original and reply direction flows. For dual-ports mode, usually the original traffic and reply traffic will come from different ports, the SW could distinguish them implicitly.
But in single-port mode, like in a gateway scenario, all the traffic are ingress and go into the same port, it is hard to distinguish the direction.
The update of the action will be just in SW level, or maybe in the HW level, depends on the NIC features.
If the next several flows to be created with this action context are for the same direction, then there is no need to call such API. Only when using it for an opposite direction, the interface will be called.
Also, if some changing of the action context is needed, like the seq/ACK/window, then the interface is also needed.
Quoted 15 lines
Quoted 5 lines
Query will be supported via
action_ctx_queryinterface, about the current packets information and connection status.For the packets received during the conntrack setup, it is
suggested
Quoted 2 lines
to re-inject the packets in order to take full advantage of the conntrack. Only the valid packets should pass the conntrack,
packets
Quoted 6 lines
with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Testpmd command line example:
set conntrack [index] enable is 1
last_seqis xxx last ack is xxx
Quoted 10 lines
/
Quoted 1 line
... /
orig_dirwin_scaleis xxxsent_endis xxxmax_winis xxx .../
Quoted 2 lines
rply_dir... / end flowaction_ctx[CTX] create ingress ... / conntrack is [index] / end flow create 0 group X ingresspatterns ...
Quoted 1 line
/ tcp / end actions
action_ctx[CTX] / jump group Y / end flowcreate
Quoted 2 lines
0 group Y ingress patterns ... / ct is [Valid] / end actions queue index [hairpin queue] / end
@Andrew @Ori
Is such command line interface OK from your points of view?
Quoted 30 lines
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = { };
Quoted 28 lines
Signed-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_flow.h | 191 +++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+)(quoted diff) +0
-0
b/lib/librte_ethdev/rte_flow.hindex669e677e91..b2e4f0751a100644lib/librte_ethdev/rte_flow.h +9
-0@@ -550,6 +550,15 @@ enum rte_flow_item_type {* See struct rte_flow_item_geneve_opt */ RTE_FLOW_ITEM_TYPE_GENEVE_OPT , + +/** +* [META] +* +* Matches conntrack state. +* +* See struct rte_flow_item_conntrack. +*/ + RTE_FLOW_ITEM_TYPE_CONNTRACK, };/** @@ -1654,6 +1663,49 @@ rte_flow_item_geneve_opt_mask = { };#endif
Quoted 1 line
Quoted 8 lines
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = { · line 1669
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+/** +* The packet is with valid. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_STATE_VALID (1 << 0)It sounds like conntrack state is valid, but not packet is valid from conntrack point of view. May be:
RTE_FLOW_CONNTRACK_FLAG_PKT_VALID? Or_VALID_PKTto go with_BAD_PKT.
The original idea of this is the state is valid after the packet integrity checking.
1. if some fields of the packet itself has an error, _BAD_PKT, and the packet will not be checked by the HW. Then
2. if passed the HW connection tracking module, it should be considered _VALID.
3. if not passed the HW module checking, e.g., out of window, then it should be considered INVALID state or ERROR state. But yes, the name should be more clear to describe themselves.
Quoted 69 lines
Quoted 12 lines
lib/librte_ethdev/rte_flow.h +11
-0+/** +* The state of the connection was changed. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_STATE_CHANGED (1 << 1) +/** +* Error state was detected on this packet for this connection. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_ERROR (1 << 2) +/** +* The HW connection tracking module is disabled. +* It can be due to application command or an invalid state. lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = {
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+*/ +#define RTE_FLOW_CONNTRACK_FLAG_DISABLED (1 << 3) +/** +* The packet contains some bad field(s). +*/ +#define RTE_FLOW_CONNTRACK_FLAG_BAD_PKT (1 << 4) + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
Quoted 24 lines
+ *
+ *RTE_FLOW_ITEM_TYPE_CONNTRACK
+ *
+ * Matches the state of a packet after it passed the connectionlib/librte_ethdev/rte_flow.h +16
-0+tracking +* examination. The state is a bit mask of one +RTE_FLOW_CONNTRACK_FLAG* +* or a reasonable combination of these bits. +*/ +struct rte_flow_item_conntrack { +uint32_t flags; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */ #ifndef +__cplusplusstatic const struct rte_flow_item_conntrack +rte_flow_item_conntrack_mask = { + .flags =0xffffffff , +}; +#endif +/** * Matching pattern item definition. * lib/librte_ethdev/rte_flow.h enum rte_flow_action_type { · line 2297
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +7
-0@@ -2236,6 +2288,17 @@ enum rte_flow_action_type {* See struct rte_flow_action_modify_field. */ RTE_FLOW_ACTION_TYPE_MODIFY_FIELD, + +/** +* [META] +* +* Enable tracking a TCP connection state. +* +* Send packet to HW connection tracking module for examination.
Quoted 11 lines
lib/librte_ethdev/rte_flow.h +4
-0+* +* See struct rte_flow_action_conntrack. +*/ + RTE_FLOW_ACTION_TYPE_CONNTRACK, };/** @@ -2828,6 +2891,134 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ;
Quoted 10 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2899
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+/** +* The state of a TCP connection. +*/ +enum rte_flow_conntrack_state { +RTE_FLOW_CONNTRACK_STATE_SYN_RECV , +/**< SYN-ACK packet was seen. */ May I suggest to put comments before enum member. IMHO it is more readable. Comment after makes sense if it is on the same line, otherwise, it is better to use comments before code.
Sure, I will change it in the patch itself.
Quoted 6 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +4
-0+RTE_FLOW_CONNTRACK_STATE_ESTABLISHED , +/**< 3-way handshark was done. */ + RTE_FLOW_CONNTRACK_STATE_FIN_WAIT, +/**< First FIN packet was received to close the connection. */
Quoted 13 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2915
Quoted 11 lines
lib/librte_ethdev/rte_flow.h +11
-0+RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT , +/**< First FIN was ACKed. */ +RTE_FLOW_CONNTRACK_STATE_LAST_ACK , +/**< After second FIN, waiting for the last ACK. */ + RTE_FLOW_CONNTRACK_STATE_TIME_WAIT, + /**< Second FIN was ACKed, connection was closed. */ }; + +/** +* The last passed TCP packet flags of a connection. +*/ +enum rte_flow_conntrack_index {Sorry, I don't understand why it is named
conntrack_index.
May flag will be a better name instead of index? Or any other suggestion?
Quoted 24 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2916
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +2
-0+RTE_FLOW_CONNTRACK_INDEX_NONE =0 ,/**< No Flag. */ + RTE_FLOW_CONNTRACK_INDEX_SYN = (1 << 0), /**< With SYN flag.*/
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2917
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ RTE_FLOW_CONNTRACK_INDEX_SYN_ACK = (1 << 1), /**< WithSYN+ACK flag. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2918
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ RTE_FLOW_CONNTRACK_INDEX_FIN = (1 << 2), /**< With FIN flag.*/
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2919
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ RTE_FLOW_CONNTRACK_INDEX_ACK = (1 << 3), /**< With ACK flag.*/
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2920
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ RTE_FLOW_CONNTRACK_INDEX_RST = (1 << 4), /**< With RST flag.*/
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2927
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+* +* Configuration parameters for each direction of a TCP connection.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+*/ +struct rte_flow_tcp_dir_param { +uint32_t scale:4 ;/**< TCP window scaling factor, 0xF to
Quoted 7 lines
disable. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2931
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ uint32_t close_initiated:1; /**< The FIN was sent by thisdirection. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2934
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+ uint32_t last_ack_seen:1; +/**< An ACK packet has been received by this side. */ Same here about comments after fields.
Will change them all.
Quoted 32 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2935
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +2
-0+ uint32_t data_unacked:1; +/**< If set, indicates that there is unacked data of the connection. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+uint32_t sent_end; +/**< Maximal value of sequence + payload length over sent +* packets (next ACK from the opposite direction). +*/ +uint32_t reply_end; +/**< Maximal value of (ACK + window size) over received packet + length
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+* over sent packet (maximal sequence could be sent). +*/ +uint32_t max_win; +/**< Maximal value of actual window size over sent packets. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+uint32_t max_ack; +/**< Maximal value of ACK over sent packets. */ }; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+* +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Configuration and initial state for the connection tracking module.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+* This structure could be used for both setting and query. +*/ +struct rte_flow_action_conntrack { +uint16_t peer_port;/**< The peer port number, can be the
Quoted 8 lines
same port. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2961
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+ uint32_t is_original_dir:1; +/**< Direction of this connection when creating a flow, the value only
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2963
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+* affects the subsequent flows creation. +*/ and here tool
Will change them all in the patch.
Quoted 10 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2965
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +2
-0+ uint32_t enable:1; +/**< Enable / disable the conntrack HW module. When disabled, the
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2970
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+* result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED. +* In this state the HW will act as passthrough. +*/ Does it disable entire conntrack HW module for all flows? It sounds like this. If so - confusing.
Yes, for all the flows that using this connection tracking context. But for the remaining flows which use other CT contexts, they will not be impacted.
Quoted 48 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2970
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +2
-0+ uint32_t live_connection:1; +/**< At least one ack was seen, after the connection was established. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+ uint32_t selective_ack:1; +/**< Enable selective ACK on this connection. */ + uint32_t challenge_ack_passed:1; +/**< A challenge ack has passed. */ + uint32_t last_direction:1; +/**< 1: The last packet is seen that comes from the original direction.
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+* 0: From the reply direction. +*/ + uint32_t liberal_mode:1; +/**< No TCP check will be done except the state change. */ +enum rte_flow_conntrack_state state; +/**< The current state of the connection. */ lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+uint8_t max_ack_window; +/**< Scaling factor for maximal allowed ACK window. */ +uint8_t retransmission_limit; +/**< Maximal allowed number of retransmission times. */ +struct rte_flow_tcp_dir_param original_dir; +/**< TCP parameters of the original direction. */ +struct rte_flow_tcp_dir_param reply_dir; +/**< TCP parameters of the reply direction. */ +uint16_t last_window; +/**< The window value of the last packet passed this conntrack. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+enum rte_flow_conntrack_index last_index; +uint32_t last_seq; +/**< The sequence of the last packet passed this conntrack. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2997
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+uint32_t last_ack; +/**< The acknowledgement of the last packet passed this conntrack. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2999
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+uint32_t last_end; +/**< The total value ACK + payload length of the last packet passed
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 9 lines
lib/librte_ethdev/rte_flow.h +9
-0+* this conntrack. +*/ +}; + +/** +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Wrapper structure for the context update interface. +* Ports cannot support updating, and the only valid solution is to
Quoted 7 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3015
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+* destroy the old context and create a new one instead. +*/ +struct rte_flow_modify_conntrack { +struct rte_flow_action_conntrack new_ct; +/**< New connection tracking parameters to be updated. */ and here
Will change them all in the formal patch.
Quoted 14 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3014
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +1
-0+ uint32_t direction:1; /**< The direction field will beupdated. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3016
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+ uint32_t state:1; +/**< All the other fields except direction will be updated. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3017
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ uint32_t reserved:30; /**< Reserved bits for the futureusage.
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +2
-0+*/ }; +/** * Field IDs for MODIFY_FIELD action. */
Quoted 83 lines · Bing Zhao
This commit introduced the conntrack action and item.
Usually the HW offloading is stateless. For some stateful offloading like a TCP connection, HW module will help provide the ability of a full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow the application should add the conntrack action and in the following flow(s) the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack action context correctly, information from packets of both directions are required.
The conntrack action should be created on one port and supply the peer port as a parameter to the action. After context creating, it could only be used between the ports (dual-port mode) or a single port. The application should modify the action via
action_ctx_updateinterface before each use in dual-port mode, in order to set the correct direction for the following rte flow.Query will be supported via
action_ctx_queryinterface, about the current packets information and connection status.For the packets received during the conntrack setup, it is suggested to re-inject the packets in order to take full advantage of the conntrack. Only the valid packets should pass the conntrack, packets with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Testpmd command line example:
set conntrack [index] enable is 1
last_seqis xxx last ack is xxx / ... /orig_dirwin_scaleis xxxsent_endis xxxmax_winis xxx ... /rply_dir... / end
flowaction_ctx[CTX] create ingress ... / conntrack is [index] / end flow create 0 group X ingress patterns ... / tcp / end actionsaction_ctx[CTX] / jump group Y / end
flow create 0 group Y ingress patterns ... / ct is [Valid] / end actions queue index [hairpin queue] / endSigned-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_flow.h | 191 +++++++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+)lib/librte_ethdev/rte_flow.h +20
-0@@ -550,6 +550,15 @@ enum rte_flow_item_type {* See struct rte_flow_item_geneve_opt */ RTE_FLOW_ITEM_TYPE_GENEVE_OPT , + +/** +* [META] +* +* Matches conntrack state. +* +* See struct rte_flow_item_conntrack. +*/ + RTE_FLOW_ITEM_TYPE_CONNTRACK, };/** @@ -1654,6 +1663,49 @@ rte_flow_item_geneve_opt_mask = { };#endif +/** +* The packet is with valid. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_STATE_VALID (1 << 0) +/** +* The state of the connection was changed. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_STATE_CHANGED (1 << 1) +/** +* Error state was detected on this packet for this connection. +*/
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = { · line 1686
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+#define RTE_FLOW_CONNTRACK_FLAG_ERROR (1 << 2) +/** +* The HW connection tracking module is disabled. +* It can be due to application command or an invalid state. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_DISABLED (1 << 3) +/** +* The packet contains some bad field(s). +*/ +#define RTE_FLOW_CONNTRACK_FLAG_BAD_PKT (1 << 4)
Why not an enum? We could use the bits, but group them under an enum?
Quoted 102 lines
lib/librte_ethdev/rte_flow.h +88
-0+ +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ITEM_TYPE_CONNTRACK +* +* Matches the state of a packet after it passed the connection tracking +* examination. The state is a bit mask of one RTE_FLOW_CONNTRACK_FLAG* +* or a reasonable combination of these bits. +*/ +struct rte_flow_item_conntrack { +uint32_t flags; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */ +#ifndef __cplusplus +static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = { + .flags =0xffffffff , +}; +#endif +/** * Matching pattern item definition. * @@ -2236,6 +2288,17 @@ enum rte_flow_action_type {* See struct rte_flow_action_modify_field. */ RTE_FLOW_ACTION_TYPE_MODIFY_FIELD , + +/** +* [META] +* +* Enable tracking a TCP connection state. +* +* Send packet to HW connection tracking module for examination. +* +* See struct rte_flow_action_conntrack. +*/ + RTE_FLOW_ACTION_TYPE_CONNTRACK, };/** @@ -2828,6 +2891,134 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +/** +* The state of a TCP connection. +*/ +enum rte_flow_conntrack_state { +RTE_FLOW_CONNTRACK_STATE_SYN_RECV , +/**< SYN-ACK packet was seen. */ +RTE_FLOW_CONNTRACK_STATE_ESTABLISHED , +/**< 3-way handshark was done. */ +RTE_FLOW_CONNTRACK_STATE_FIN_WAIT , +/**< First FIN packet was received to close the connection. */ +RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT , +/**< First FIN was ACKed. */ +RTE_FLOW_CONNTRACK_STATE_LAST_ACK , +/**< After second FIN, waiting for the last ACK. */ +RTE_FLOW_CONNTRACK_STATE_TIME_WAIT , +/**< Second FIN was ACKed, connection was closed. */ +}; + +/** +* The last passed TCP packet flags of a connection. +*/ +enum rte_flow_conntrack_index { +RTE_FLOW_CONNTRACK_INDEX_NONE =0 ,/**< No Flag. */ +RTE_FLOW_CONNTRACK_INDEX_SYN = (1 <<0 ),/**< With SYN flag. */ +RTE_FLOW_CONNTRACK_INDEX_SYN_ACK = (1 <<1 ),/**< With SYN+ACK flag. */ +RTE_FLOW_CONNTRACK_INDEX_FIN = (1 <<2 ),/**< With FIN flag. */ +RTE_FLOW_CONNTRACK_INDEX_ACK = (1 <<3 ),/**< With ACK flag. */ +RTE_FLOW_CONNTRACK_INDEX_RST = (1 <<4 ),/**< With RST flag. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* Configuration parameters for each direction of a TCP connection. +*/ +struct rte_flow_tcp_dir_param { +uint32_t scale:4 ;/**< TCP window scaling factor, 0xF to disable. */ +uint32_t close_initiated:1 ;/**< The FIN was sent by this direction. */ +uint32_t last_ack_seen:1 ; +/**< An ACK packet has been received by this side. */ +uint32_t data_unacked:1 ; +/**< If set, indicates that there is unacked data of the connection. */ +uint32_t sent_end; +/**< Maximal value of sequence + payload length over sent +* packets (next ACK from the opposite direction). +*/ +uint32_t reply_end; +/**< Maximal value of (ACK + window size) over received packet + length +* over sent packet (maximal sequence could be sent). +*/ +uint32_t max_win; +/**< Maximal value of actual window size over sent packets. */ +uint32_t max_ack; +/**< Maximal value of ACK over sent packets. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2958
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Configuration and initial state for the connection tracking module. +* This structure could be used for both setting and query.
Can we split the structure into set and query.
Some of the fields seem to be relevant for a query. Also the names will be simpler and easier to understand that way.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2970
Quoted 12 lines
lib/librte_ethdev/rte_flow.h +12
-0+*/ +struct rte_flow_action_conntrack { +uint16_t peer_port;/**< The peer port number, can be the same port. */ +uint32_t is_original_dir:1 ; +/**< Direction of this connection when creating a flow, the value only +* affects the subsequent flows creation. +*/ +uint32_t enable:1 ; +/**< Enable / disable the conntrack HW module. When disabled, the +* result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED. +* In this state the HW will act as passthrough. +*/
We should be able to enable the block in HW implicitly based on the rte_flow_create.
I don't think this is needed.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2983
Quoted 13 lines
lib/librte_ethdev/rte_flow.h +13
-0+ uint32_t live_connection:1; +/**< At least one ack was seen, after the connection was established. */ + uint32_t selective_ack:1; +/**< Enable selective ACK on this connection. */ + uint32_t challenge_ack_passed:1; +/**< A challenge ack has passed. */ + uint32_t last_direction:1; +/**< 1: The last packet is seen that comes from the original direction. +* 0: From the reply direction. +*/ + uint32_t liberal_mode:1; +/**< No TCP check will be done except the state change. */ +enum rte_flow_conntrack_state state;
initial_state or cur_state?
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2995
Quoted 12 lines
lib/librte_ethdev/rte_flow.h +12
-0+/**< The current state of the connection. */ +uint8_t max_ack_window; +/**< Scaling factor for maximal allowed ACK window. */ +uint8_t retransmission_limit; +/**< Maximal allowed number of retransmission times. */ +struct rte_flow_tcp_dir_param original_dir; +/**< TCP parameters of the original direction. */ +struct rte_flow_tcp_dir_param reply_dir; +/**< TCP parameters of the reply direction. */ +uint16_t last_window; +/**< The window value of the last packet passed this conntrack. */ +enum rte_flow_conntrack_index last_index;
Do you mean rte_flow_conntrack_last_state - as in last state as seen by HW block?
Or maybe it is the TCP flag and not state?
Quoted 7 lines
lib/librte_ethdev/rte_flow.h +7
-0+uint32_t last_seq; +/**< The sequence of the last packet passed this conntrack. */ +uint32_t last_ack; +/**< The acknowledgement of the last packet passed this conntrack. */ +uint32_t last_end; +/**< The total value ACK + payload length of the last packet passed +* this conntrack.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3012
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+*/ +}; + +/** +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Wrapper structure for the context update interface. +* Ports cannot support updating, and the only valid solution is to +* destroy the old context and create a new one instead. +*/
In that case why not destroy the flow and create a new one?
Quoted 15 lines
lib/librte_ethdev/rte_flow.h +9
-1+struct rte_flow_modify_conntrack { +struct rte_flow_action_conntrack new_ct; +/**< New connection tracking parameters to be updated. */ +uint32_t direction:1 ;/**< The direction field will be updated. */ +uint32_t state:1 ; +/**< All the other fields except direction will be updated. */ +uint32_t reserved:30 ;/**< Reserved bits for the future usage. */ +}; +/** * Field IDs for MODIFY_FIELD action. */ --2.19.0.windows.1
Hello,
Quoted 111 lines
-----Original Message-----
From: Ajit Khaparde <[email protected]>
Sent: Wednesday, March 24, 2021 7:27 AM
To: Bing Zhao <[email protected]>
Cc: Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>; dpdk-dev <[email protected]>
Subject: Re: [dpdk-dev] [RFC] ethdev: introduce conntrack flow action and itemQuoted 4 lines · Bing Zhao
This commit introduced the conntrack action and item.
Usually the HW offloading is stateless. For some stateful
offloading
Quoted 1 line
like a TCP connection, HW module will help provide the ability of
a
Quoted 4 lines
full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow the application should
add
Quoted 5 lines
the conntrack action and in the following flow(s) the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack action context correctly, information from packets of both
directions
Quoted 6 lines
are required.
The conntrack action should be created on one port and supply the peer port as a parameter to the action. After context creating, it could only be used between the ports (dual-port mode) or a single port. The application should modify the action via
action_ctx_updateQuoted 7 lines
interface before each use in dual-port mode, in order to set the correct direction for the following rte flow.
Query will be supported via
action_ctx_queryinterface, about the current packets information and connection status.For the packets received during the conntrack setup, it is
suggested
Quoted 2 lines
to re-inject the packets in order to take full advantage of the conntrack. Only the valid packets should pass the conntrack,
packets
Quoted 6 lines
with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Testpmd command line example:
set conntrack [index] enable is 1
last_seqis xxx last ack is xxx/
Quoted 1 line
... /
orig_dirwin_scaleis xxxsent_endis xxxmax_winis xxx .../
Quoted 2 lines
rply_dir... / end
flowaction_ctx[CTX] create ingress ... / conntrack is [index] /end
Quoted 1 line
flow create 0 group X ingress patterns ... / tcp / end actions
action_ctx[CTX]Quoted 2 lines
/ jump group Y / end
flow create 0 group Y ingress patterns ... / ct is [Valid] / endactions
Quoted 5 lines
queue index [hairpin queue] / end
Signed-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_flow.h | 191+++++++++++++++++++++++++++++++++++
Review
Quoted 3 lines
1 file changed, 191 insertions(+)(quoted diff) +0
-0
b/lib/librte_ethdev/rte_flow.hQuoted 37 lines
index
669e677e91..b2e4f0751a100644lib/librte_ethdev/rte_flow.h +23
-0@@ -550,6 +550,15 @@ enum rte_flow_item_type {* See struct rte_flow_item_geneve_opt */ RTE_FLOW_ITEM_TYPE_GENEVE_OPT , + +/** +* [META] +* +* Matches conntrack state. +* +* See struct rte_flow_item_conntrack. +*/ + RTE_FLOW_ITEM_TYPE_CONNTRACK, };/** @@ -1654,6 +1663,49 @@ rte_flow_item_geneve_opt_mask = { };#endif +/** +* The packet is with valid. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_STATE_VALID (1 << 0) +/** +* The state of the connection was changed. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_STATE_CHANGED (1 << 1) +/** +* Error state was detected on this packet for this connection. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_ERROR (1 << 2) +/** +* The HW connection tracking module is disabled.
Quoted 9 lines
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = { · line 1686
Quoted 7 lines
lib/librte_ethdev/rte_flow.h +7
-0+* It can be due to application command or an invalid state. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_DISABLED (1 << 3) +/** +* The packet contains some bad field(s). +*/ +#define RTE_FLOW_CONNTRACK_FLAG_BAD_PKT (1 << 4)Why not an enum? We could use the bits, but group them under an enum?
It could be. BTW, is there any convention to describe when to use #define macros and when to use enum types?
Quoted 130 lines
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+ +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+* +* RTE_FLOW_ITEM_TYPE_CONNTRACK +* +* Matches the state of a packet after it passed the connection tracking
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = { · line 1695
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+* examination. The state is a bit mask of one RTE_FLOW_CONNTRACK_FLAG*
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = {
Quoted 9 lines
lib/librte_ethdev/rte_flow.h +9
-0+* or a reasonable combination of these bits. +*/ +struct rte_flow_item_conntrack { +uint32_t flags; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */ +#ifndef __cplusplus +static const struct rte_flow_item_conntrack
rte_flow_item_conntrack_mask= {Quoted 8 lines
lib/librte_ethdev/rte_flow.h +4
-0+ .flags = 0xffffffff, +}; +#endif +/** * Matching pattern item definition. * lib/librte_ethdev/rte_flow.h enum rte_flow_action_type { · line 2297
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +7
-0@@ -2236,6 +2288,17 @@ enum rte_flow_action_type {* See struct rte_flow_action_modify_field. */ RTE_FLOW_ACTION_TYPE_MODIFY_FIELD, + +/** +* [META] +* +* Enable tracking a TCP connection state. +* +* Send packet to HW connection tracking module for examination.
Quoted 11 lines
lib/librte_ethdev/rte_flow.h +4
-0+* +* See struct rte_flow_action_conntrack. +*/ + RTE_FLOW_ACTION_TYPE_CONNTRACK, };/** @@ -2828,6 +2891,134 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ;lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2903
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+/** +* The state of a TCP connection. +*/ +enum rte_flow_conntrack_state { +RTE_FLOW_CONNTRACK_STATE_SYN_RECV , +/**< SYN-ACK packet was seen. */ +RTE_FLOW_CONNTRACK_STATE_ESTABLISHED , +/**< 3-way handshark was done. */ +RTE_FLOW_CONNTRACK_STATE_FIN_WAIT , +/**< First FIN packet was received to close the connection. */
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT , +/**< First FIN was ACKed. */ + RTE_FLOW_CONNTRACK_STATE_LAST_ACK, +/**< After second FIN, waiting for the last ACK. */ lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+ RTE_FLOW_CONNTRACK_STATE_TIME_WAIT, +/**< Second FIN was ACKed, connection was closed. */ +}; + +/** +* The last passed TCP packet flags of a connection. +*/ +enum rte_flow_conntrack_index { +RTE_FLOW_CONNTRACK_INDEX_NONE =0 ,/**< No Flag. */ +RTE_FLOW_CONNTRACK_INDEX_SYN = (1 <<0 ),/**< With SYN flag. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2918
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ RTE_FLOW_CONNTRACK_INDEX_SYN_ACK = (1 << 1), /**< WithSYN+ACK flag. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2919
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ RTE_FLOW_CONNTRACK_INDEX_FIN = (1 << 2), /**< With FINflag. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2920
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ RTE_FLOW_CONNTRACK_INDEX_ACK = (1 << 3), /**< With ACKflag. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2921
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ RTE_FLOW_CONNTRACK_INDEX_RST = (1 << 4), /**< With RSTflag. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2928
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+* +* Configuration parameters for each direction of a TCP connection.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+*/ +struct rte_flow_tcp_dir_param { +uint32_t scale:4 ;/**< TCP window scaling factor, 0xF to disable. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2932
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ uint32_t close_initiated:1; /**< The FIN was sent by thisdirection. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+ uint32_t last_ack_seen:1; +/**< An ACK packet has been received by this side. */ + uint32_t data_unacked:1; +/**< If set, indicates that there is unacked data of the connection. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+uint32_t sent_end; +/**< Maximal value of sequence + payload length over sent +* packets (next ACK from the opposite direction). +*/ +uint32_t reply_end; +/**< Maximal value of (ACK + window size) over received packet + length
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+* over sent packet (maximal sequence could be sent). +*/ +uint32_t max_win; +/**< Maximal value of actual window size over sent packets. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 7 lines
lib/librte_ethdev/rte_flow.h +7
-0+uint32_t max_ack; +/**< Maximal value of ACK over sent packets. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+* +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Configuration and initial state for the connection tracking
Quoted 6 lines
module.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2958
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+* This structure could be used for both setting and query. Can we split the structure into set and query.
Some of the fields seem to be relevant for a query. Also the names will be simpler and easier to understand that way.
To my understanding, it may be better to have all of them in a single structure. Different HW may have different ability for querying, and most of the fields are used both for query and create/update. If some field is not supported for querying, the PMD could return the default value, e.g., 0. And if we split query and create/update:
1. Query struct may also needs to be the UNION of different HW's query capacity
2. the 2 structures will have a lot of common fields (most of them)
Quoted 47 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+*/ +struct rte_flow_action_conntrack { +uint16_t peer_port;/**< The peer port number, can be the same port. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2963
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+ uint32_t is_original_dir:1; +/**< Direction of this connection when creating a flow, the value only
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+* affects the subsequent flows creation. +*/ + uint32_t enable:1; +/**< Enable / disable the conntrack HW module. When disabled, the
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2970
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+* result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED. +* In this state the HW will act as passthrough. +*/ We should be able to enable the block in HW implicitly based on the
rte_flow_create.
I don't think this is needed.lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2972
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+ uint32_t live_connection:1; +/**< At least one ack was seen, after the connection was established. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+ uint32_t selective_ack:1; +/**< Enable selective ACK on this connection. */ + uint32_t challenge_ack_passed:1; +/**< A challenge ack has passed. */ + uint32_t last_direction:1; +/**< 1: The last packet is seen that comes from the original direction.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2983
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+* 0: From the reply direction. +*/ + uint32_t liberal_mode:1; +/**< No TCP check will be done except the state change. */ +enum rte_flow_conntrack_state state;
initial_stateorcur_state?lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 11 lines
lib/librte_ethdev/rte_flow.h +11
-0+/**< The current state of the connection. */ +uint8_t max_ack_window; +/**< Scaling factor for maximal allowed ACK window. */ +uint8_t retransmission_limit; +/**< Maximal allowed number of retransmission times. */ +struct rte_flow_tcp_dir_param original_dir; +/**< TCP parameters of the original direction. */ +struct rte_flow_tcp_dir_param reply_dir; +/**< TCP parameters of the reply direction. */ +uint16_t last_window; +/**< The window value of the last packet passed this
Quoted 5 lines
conntrack. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2995
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+enum rte_flow_conntrack_index last_index;Do you mean
rte_flow_conntrack_last_state- as in last state as seen by HW block?
Or maybe it is the TCP flag and not state?
They are a little different. It should be the 2nd, the TCP flag of the last packets passed the connection tracking module, not the connection state.
Quoted 20 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2997
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +2
-0+uint32_t last_seq; +/**< The sequence of the last packet passed this conntrack. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2999
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+uint32_t last_ack; +/**< The acknowledgement of the last packet passed this conntrack. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3001
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+uint32_t last_end; +/**< The total value ACK + payload length of the last packet passed
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 9 lines
lib/librte_ethdev/rte_flow.h +9
-0+* this conntrack. +*/ +}; + +/** +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Wrapper structure for the context update interface. +* Ports cannot support updating, and the only valid solution is to
Quoted 3 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3012
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+* destroy the old context and create a new one instead. +*/ In that case why not destroy the flow and create a new one?
I may not quite understand your question but will try to answer a bit more detailed and please comment.
The connection tracking action context will be created before any flow creation, then it will be used by the flows:
1. Conntrack action will be used for the flows of bi-directional traffic, and when creating it, the information of TCP packets from both directions are needed.
2. This conntrack action could be used for multiple flows over single port or dual ports.
3. The flow could be destroyed w/o destroy the action and then it could be reused by a new flow(if needed).
4. One direction flow could be destroyed w/o destroying the opposite direction flow.
So if the user want to destroy the action context, it should call the destroy interface directly. The action context will be still "alive" after one flow that using it is destroyed. It couldn't be destroyed together with the flow.
Quoted 19 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +4
-0+struct rte_flow_modify_conntrack { +struct rte_flow_action_conntrack new_ct; +/**< New connection tracking parameters to be updated. */ +uint32_t direction:1 ;/**< The direction field will be updated. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3018
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+ uint32_t state:1; +/**< All the other fields except direction will be updated. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3019
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ uint32_t reserved:30; /**< Reserved bits for the futureusage. */
Quoted 8 lines
lib/librte_ethdev/rte_flow.h +2
-1+}; +/** * Field IDs for MODIFY_FIELD action. */ --2.19.0.windows.1
PATCH 1/1 ethdev: introduce conntrack flow action and item
In reply to Bing ZhaoThis commit introduced the conntrack action and item.
Usually the HW offloading is stateless. For some stateful offloading like a TCP connection, HW module will help provide the ability of a full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow the application should add the conntrack action and in the following flow(s) the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack action context correctly, information from packets of both directions are required.
The conntrack action should be created on one port and supply the peer port as a parameter to the action. After context creating, it could only be used between the ports (dual-port mode) or a single port. The application should modify the action via the API "action_handle_update" only when before using it to create a flow with opposite direction. This will help the driver to recognize the direction of the flow to be created, especially in single port mode. The traffic from both directions will go through the same port if the application works as an "forwarding engine" but not a end point. There is no need to call the update interface if the subsequent flows have nothing to be changed.
Query will be supported via action_ctx_query interface, about the current packets information and connection status. Tha fields query capabilities depends on the HW.
For the packets received during the conntrack setup, it is suggested to re-inject the packets in order to take full advantage of the conntrack. Only the valid packets should pass the conntrack, packets with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Naming and definition:
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/netfilter/nf_conntrack_tcp.h
https://elixir.bootlin.com/linux/latest/source/net/netfilter/nf_conntrack_proto_tcp.c
Other reference:
https://www.usenix.org/legacy/events/sec01/invitedtalks/rooij.pdf
--- lib/librte_ethdev/rte_flow.h | 195 +++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+)
lib/librte_ethdev/rte_flow.h +195 -0
@@ -551,6 +551,15 @@ enum rte_flow_item_type {* See struct rte_flow_item_geneve_opt */ RTE_FLOW_ITEM_TYPE_GENEVE_OPT , + +/** +* [META] +* +* Matches conntrack state. +* +* See struct rte_flow_item_conntrack. +*/ + RTE_FLOW_ITEM_TYPE_CONNTRACK, };/**
@@ -1685,6 +1694,51 @@ rte_flow_item_geneve_opt_mask = { };#endif +/** +* The packet is with valid state after conntrack checking. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_VALID (1 << 0) +/** +* The state of the connection was changed. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_CHANGED (1 << 1) +/** +* Error is detected on this packet for this connection and +* an invalid state is set. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_INVAL (1 << 2) +/** +* The HW connection tracking module is disabled. +* It can be due to application command or an invalid state. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_HW_DISABLED (1 << 3) +/** +* The packet contains some bad field(s) and cannot continue +* with the conntrack module checking. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_BAD (1 << 4) + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ITEM_TYPE_CONNTRACK +* +* Matches the state of a packet after it passed the connection tracking +* examination. The state is a bit mask of one RTE_FLOW_CONNTRACK_FLAG* +* or a reasonable combination of these bits. +*/ +struct rte_flow_item_conntrack { +uint32_t flags; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */ +#ifndef __cplusplus +static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = { + .flags =0xffffffff , +}; +#endif +/** * Matching pattern item definition. *
@@ -2267,6 +2321,17 @@ enum rte_flow_action_type {* See struct rte_flow_action_modify_field. */ RTE_FLOW_ACTION_TYPE_MODIFY_FIELD , + +/** +* [META] +* +* Enable tracking a TCP connection state. +* +* Send packet to HW connection tracking module for examination. +* +* See struct rte_flow_action_conntrack. +*/ + RTE_FLOW_ACTION_TYPE_CONNTRACK, };/**
@@ -2859,6 +2924,136 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +/** +* The state of a TCP connection. +*/ +enum rte_flow_conntrack_state { +/**< SYN-ACK packet was seen. */ +RTE_FLOW_CONNTRACK_STATE_SYN_RECV , +/**< 3-way handshark was done. */ +RTE_FLOW_CONNTRACK_STATE_ESTABLISHED , +/**< First FIN packet was received to close the connection. */ +RTE_FLOW_CONNTRACK_STATE_FIN_WAIT , +/**< First FIN was ACKed. */ +RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT , +/**< Second FIN was received, waiting for the last ACK. */ +RTE_FLOW_CONNTRACK_STATE_LAST_ACK , +/**< Second FIN was ACKed, connection was closed. */ +RTE_FLOW_CONNTRACK_STATE_TIME_WAIT , +}; + +/** +* The last passed TCP packet flags of a connection. +*/ +enum rte_flow_conntrack_tcp_last_index { +RTE_FLOW_CONNTRACK_FLAG_NONE =0 ,/**< No Flag. */ +RTE_FLOW_CONNTRACK_FLAG_SYN = (1 <<0 ),/**< With SYN flag. */ +RTE_FLOW_CONNTRACK_FLAG_SYNACK = (1 <<1 ),/**< With SYN+ACK flag. */ +RTE_FLOW_CONNTRACK_FLAG_FIN = (1 <<2 ),/**< With FIN flag. */ +RTE_FLOW_CONNTRACK_FLAG_ACK = (1 <<3 ),/**< With ACK flag. */ +RTE_FLOW_CONNTRACK_FLAG_RST = (1 <<4 ),/**< With RST flag. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* Configuration parameters for each direction of a TCP connection. +*/ +struct rte_flow_tcp_dir_param { +uint32_t scale:4 ;/**< TCP window scaling factor, 0xF to disable. */ +uint32_t close_initiated:1 ;/**< The FIN was sent by this direction. */ +/**< An ACK packet has been received by this side. */ +uint32_t last_ack_seen:1 ; +/**< If set, indicates that there is unacked data of the connection. */ +uint32_t data_unacked:1 ; +/**< Maximal value of sequence + payload length over sent +* packets (next ACK from the opposite direction). +*/ +uint32_t sent_end; +/**< Maximal value of (ACK + window size) over received packet + length +* over sent packet (maximal sequence could be sent). +*/ +uint32_t reply_end; +/**< Maximal value of actual window size over sent packets. */ +uint32_t max_win; +/**< Maximal value of ACK over sent packets. */ +uint32_t max_ack; +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Configuration and initial state for the connection tracking module. +* This structure could be used for both setting and query. +*/ +struct rte_flow_action_conntrack { +uint16_t peer_port;/**< The peer port number, can be the same port. */ +/**< Direction of this connection when creating a flow, the value only +* affects the subsequent flows creation. +*/ +uint32_t is_original_dir:1 ; +/**< Enable / disable the conntrack HW module. When disabled, the +* result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED. +* In this state the HW will act as passthrough. +* It only affects this conntrack object in the HW without any effect +* to the other objects. +*/ +uint32_t enable:1 ; +/**< At least one ack was seen, after the connection was established. */ +uint32_t live_connection:1 ; +/**< Enable selective ACK on this connection. */ +uint32_t selective_ack:1 ; +/**< A challenge ack has passed. */ +uint32_t challenge_ack_passed:1 ; +/**< 1: The last packet is seen that comes from the original direction. +* 0: From the reply direction. +*/ +uint32_t last_direction:1 ; +/**< No TCP check will be done except the state change. */ +uint32_t liberal_mode:1 ; +/**< The current state of the connection. */ +enum rte_flow_conntrack_state state; +/**< Scaling factor for maximal allowed ACK window. */ +uint8_t max_ack_window; +/**< Maximal allowed number of retransmission times. */ +uint8_t retransmission_limit; +/**< TCP parameters of the original direction. */ +struct rte_flow_tcp_dir_param original_dir; +/**< TCP parameters of the reply direction. */ +struct rte_flow_tcp_dir_param reply_dir; +/**< The window value of the last packet passed this conntrack. */ +uint16_t last_window; +enum rte_flow_conntrack_tcp_last_index last_index; +/**< The sequence of the last packet passed this conntrack. */ +uint32_t last_seq; +/**< The acknowledgement of the last packet passed this conntrack. */ +uint32_t last_ack; +/**< The total value ACK + payload length of the last packet passed +* this conntrack. +*/ +uint32_t last_end; +}; + +/** +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Wrapper structure for the context update interface. +* Ports cannot support updating, and the only valid solution is to +* destroy the old context and create a new one instead. +*/ +struct rte_flow_modify_conntrack { +/**< New connection tracking parameters to be updated. */ +struct rte_flow_action_conntrack new_ct; +uint32_t direction:1 ;/**< The direction field will be updated. */ +/**< All the other fields except direction will be updated. */ +uint32_t state:1 ; +uint32_t reserved:30 ;/**< Reserved bits for the future usage. */ +}; +/** * Field IDs for MODIFY_FIELD action. */
Signature · 1 line
2.30.0.windows.2
Hi Bing
I'm fine with this patch but you are missing the documentation part:
1. doc/guides/prog_guide/rte_flow.rst
2. doc/guides/rel_notes/release_21_05.rst
Quoted 291 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Saturday, April 10, 2021 4:47 PM
To: Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon
Subject: [PATCH] ethdev: introduce conntrack flow action and itemThis commit introduced the conntrack action and item.
Usually the HW offloading is stateless. For some stateful offloading like a TCP connection, HW module will help provide the ability of a full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow the application should add the conntrack action and in the following flow(s) the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack action context correctly, information from packets of both directions are required.
The conntrack action should be created on one port and supply the peer port as a parameter to the action. After context creating, it could only be used between the ports (dual-port mode) or a single port. The application should modify the action via the API "
action_handle_update" only when before using it to create a flow with opposite direction. This will help the driver to recognize the direction of the flow to be created, especially in single port mode. The traffic from both directions will go through the same port if the application works as an "forwarding engine" but not a end point. There is no need to call the update interface if the subsequent flows have nothing to be changed.Query will be supported via
action_ctx_queryinterface, about the current packets information and connection status. Tha fields query capabilities depends on the HW.For the packets received during the conntrack setup, it is suggested to re-inject the packets in order to take full advantage of the conntrack. Only the valid packets should pass the conntrack, packets with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Naming and definition:
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/netfilter/nf_conntrack_tcp.h
https://elixir.bootlin.com/linux/latest/source/net/netfilter/nf_conntrack_proto_tcp.cOther reference:
https://www.usenix.org/legacy/events/sec01/invitedtalks/rooij.pdfSigned-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_flow.h | 195 +++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+)lib/librte_ethdev/rte_flow.h +54
-0@@ -551,6 +551,15 @@ enum rte_flow_item_type {* See struct rte_flow_item_geneve_opt */ RTE_FLOW_ITEM_TYPE_GENEVE_OPT , + +/** +* [META] +* +* Matches conntrack state. +* +* See struct rte_flow_item_conntrack. +*/ + RTE_FLOW_ITEM_TYPE_CONNTRACK, };/** @@ -1685,6 +1694,51 @@ rte_flow_item_geneve_opt_mask = { };#endif +/** +* The packet is with valid state after conntrack checking. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_VALID (1 << 0) +/** +* The state of the connection was changed. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_CHANGED (1 << 1) +/** +* Error is detected on this packet for this connection and +* an invalid state is set. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_INVAL (1 << 2) +/** +* The HW connection tracking module is disabled. +* It can be due to application command or an invalid state. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_HW_DISABLED (1 << 3) +/** +* The packet contains some bad field(s) and cannot continue +* with the conntrack module checking. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_BAD (1 << 4) + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ITEM_TYPE_CONNTRACK +* +* Matches the state of a packet after it passed the connection tracking +* examination. The state is a bit mask of one RTE_FLOW_CONNTRACK_FLAG* +* or a reasonable combination of these bits. +*/ +struct rte_flow_item_conntrack { +uint32_t flags; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */ +#ifndef __cplusplus +static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = { + .flags =0xffffffff , +}; +#endif +/** * Matching pattern item definition. *
lib/librte_ethdev/rte_flow.h +36
-0@@ -2267,6 +2321,17 @@ enum rte_flow_action_type {* See struct rte_flow_action_modify_field. */ RTE_FLOW_ACTION_TYPE_MODIFY_FIELD , + +/** +* [META] +* +* Enable tracking a TCP connection state. +* +* Send packet to HW connection tracking module for examination. +* +* See struct rte_flow_action_conntrack. +*/ + RTE_FLOW_ACTION_TYPE_CONNTRACK, };/** @@ -2859,6 +2924,136 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +/** +* The state of a TCP connection. +*/ +enum rte_flow_conntrack_state { +/**< SYN-ACK packet was seen. */ +RTE_FLOW_CONNTRACK_STATE_SYN_RECV , +/**< 3-way handshark was done. */ +RTE_FLOW_CONNTRACK_STATE_ESTABLISHED , +/**< First FIN packet was received to close the connection. */ +RTE_FLOW_CONNTRACK_STATE_FIN_WAIT , +/**< First FIN was ACKed. */ +RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT , +/**< Second FIN was received, waiting for the last ACK. */ +RTE_FLOW_CONNTRACK_STATE_LAST_ACK , +/**< Second FIN was ACKed, connection was closed. */ +RTE_FLOW_CONNTRACK_STATE_TIME_WAIT , +}; + +/** +* The last passed TCP packet flags of a connection. +*/ +enum rte_flow_conntrack_tcp_last_index { +RTE_FLOW_CONNTRACK_FLAG_NONE =0 ,/**< No Flag. */ +RTE_FLOW_CONNTRACK_FLAG_SYN = (1 <<0 ),/**< With SYN flag. */ +RTE_FLOW_CONNTRACK_FLAG_SYNACK = (1 <<1 ),/**< With SYN+ACK flag. */
lib/librte_ethdev/rte_flow.h +23
-0+RTE_FLOW_CONNTRACK_FLAG_FIN = (1 <<2 ),/**< With FIN flag. */ +RTE_FLOW_CONNTRACK_FLAG_ACK = (1 <<3 ),/**< With ACK flag. */ + RTE_FLOW_CONNTRACK_FLAG_RST = (1 << 4), /**< With RST flag. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* Configuration parameters for each direction of a TCP connection. +*/ +struct rte_flow_tcp_dir_param { +uint32_t scale:4 ;/**< TCP window scaling factor, 0xF to disable. */ +uint32_t close_initiated:1 ;/**< The FIN was sent by this direction. */ +/**< An ACK packet has been received by this side. */ +uint32_t last_ack_seen:1 ; +/**< If set, indicates that there is unacked data of the connection. */ +uint32_t data_unacked:1 ; +/**< Maximal value of sequence + payload length over sent +* packets (next ACK from the opposite direction). +*/ +uint32_t sent_end; +/**< Maximal value of (ACK + window size) over received packet + length
lib/librte_ethdev/rte_flow.h +20
-0+* over sent packet (maximal sequence could be sent). +*/ +uint32_t reply_end; +/**< Maximal value of actual window size over sent packets. */ +uint32_t max_win; +/**< Maximal value of ACK over sent packets. */ +uint32_t max_ack; +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Configuration and initial state for the connection tracking module. +* This structure could be used for both setting and query. +*/ +struct rte_flow_action_conntrack { +uint16_t peer_port;/**< The peer port number, can be the same port. */
lib/librte_ethdev/rte_flow.h +12
-0+/**< Direction of this connection when creating a flow, the value only +* affects the subsequent flows creation. +*/ + uint32_t is_original_dir:1; +/**< Enable / disable the conntrack HW module. When disabled, the +* result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED. +* In this state the HW will act as passthrough. +* It only affects this conntrack object in the HW without any effect +* to the other objects. +*/ + uint32_t enable:1; +/**< At least one ack was seen, after the connection was established. */
lib/librte_ethdev/rte_flow.h +50
-1+ uint32_t live_connection:1; +/**< Enable selective ACK on this connection. */ + uint32_t selective_ack:1; +/**< A challenge ack has passed. */ + uint32_t challenge_ack_passed:1; +/**< 1: The last packet is seen that comes from the original direction. +* 0: From the reply direction. +*/ + uint32_t last_direction:1; +/**< No TCP check will be done except the state change. */ + uint32_t liberal_mode:1; +/**< The current state of the connection. */ +enum rte_flow_conntrack_state state; +/**< Scaling factor for maximal allowed ACK window. */ +uint8_t max_ack_window; +/**< Maximal allowed number of retransmission times. */ +uint8_t retransmission_limit; +/**< TCP parameters of the original direction. */ +struct rte_flow_tcp_dir_param original_dir; +/**< TCP parameters of the reply direction. */ +struct rte_flow_tcp_dir_param reply_dir; +/**< The window value of the last packet passed this conntrack. */ +uint16_t last_window; +enum rte_flow_conntrack_tcp_last_index last_index; +/**< The sequence of the last packet passed this conntrack. */ +uint32_t last_seq; +/**< The acknowledgement of the last packet passed this conntrack. */ +uint32_t last_ack; +/**< The total value ACK + payload length of the last packet passed +* this conntrack. +*/ +uint32_t last_end; +}; + +/** +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Wrapper structure for the context update interface. +* Ports cannot support updating, and the only valid solution is to +* destroy the old context and create a new one instead. +*/ +struct rte_flow_modify_conntrack { +/**< New connection tracking parameters to be updated. */ +struct rte_flow_action_conntrack new_ct; +uint32_t direction:1 ;/**< The direction field will be updated. */ +/**< All the other fields except direction will be updated. */ +uint32_t state:1 ; +uint32_t reserved:30 ;/**< Reserved bits for the future usage. */ +}; +/** * Field IDs for MODIFY_FIELD action. */ --2.30.0.windows.2
Hi Ori,
Quoted 10 lines
-----Original Message-----
From: Ori Kam <[email protected]>
Sent: Friday, April 16, 2021 12:25 AM
To: Bing Zhao <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: RE: [PATCH] ethdev: introduce conntrack flow action and item
Quoted 4 lines
Hi Bing
I'm fine with this patch but you are missing the documentation part:
1.doc/guides/prog_guide/rte_flow.rst
2.doc/guides/rel_notes/release_21_05.rst
Thanks for the comments and reminding. I will update the doc in the next version v3. For v2, only testpmd CLI part is appended.
It may need the reviewers help to review and confirm if my current CLI proposal is OK.
Quoted 372 lines
Quoted 10 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Saturday, April 10, 2021 4:47 PM
To: Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon
Subject: [PATCH] ethdev: introduce conntrack flow action and itemThis commit introduced the conntrack action and item.
Usually the HW offloading is stateless. For some stateful
offloading
Quoted 1 line
like a TCP connection, HW module will help provide the ability of
a
Quoted 4 lines
full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow the application should
add
Quoted 4 lines
the conntrack action and in the following flow(s) the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack
action
Quoted 4 lines
context correctly, information from packets of both directions are required.
The conntrack action should be created on one port and supply the
peer
Quoted 1 line
port as a parameter to the action. After context creating, it
could
Quoted 1 line
only be used between the ports (dual-port mode) or a single port.
The
Quoted 2 lines
application should modify the action via the API "
action_handle_update" only when before using it to create a flowwith
Quoted 2 lines
opposite direction. This will help the driver to recognize the direction of the flow to be created, especially in single port
mode.
Quoted 1 line
The traffic from both directions will go through the same port if
the
Quoted 2 lines
application works as an "forwarding engine" but not a end point. There is no need to call the update interface if the subsequent
flows
Quoted 4 lines
have nothing to be changed.
Query will be supported via
action_ctx_queryinterface, about the current packets information and connection status. Tha fieldsquery
Quoted 3 lines
capabilities depends on the HW.
For the packets received during the conntrack setup, it is
suggested
Quoted 2 lines
to re-inject the packets in order to take full advantage of the conntrack. Only the valid packets should pass the conntrack,
packets
Quoted 5 lines
with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Naming and definition:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fel
ixQuoted 1 line
ir.bootlin.com%2Flinux%2Flatest%2Fsource%2Finclude%2Fuapi%2Flinux%2F ne
Quoted 1 line
tfilter%2Fnf_co&data=04%7C01%7Cbingz%40nvidia.com%7C84e54f991016 4c
Quoted 1 line
7214a008d9002afd2e%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C6375 41
Quoted 1 line
006893523890%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2l uM
Quoted 1 line
zIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=d8QRJrA51j64m8VPY fV
Quoted 3 lines
pATTl5JrkD0nSUpQOZKco8T4%3D&reserved=0
nntrack_tcp.hhttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fel
ixQuoted 1 line
ir.bootlin.com%2Flinux%2Flatest%2Fsource%2Fnet%2Fnetfilter%2Fnf_conn tr
Quoted 1 line
ack_proto_&data=04%7C01%7Cbingz%40nvidia.com%7C84e54f9910164c721 4a
Quoted 1 line
008d9002afd2e%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637541006 89
Quoted 1 line
3523890%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIi LC
Quoted 1 line
JBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=lkZO7RQQsu3I1E0JWPhKWZ rA
Quoted 5 lines
VpOjlwWLA8WpJQUlme0%3D&reserved=0
tcp.cOther reference:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fww
w.Quoted 1 line
usenix.org%2Flegacy%2Fevents%2Fsec01%2Finvitedtalks%2Frooij.pdf& da
Quoted 1 line
ta=04%7C01%7Cbingz%40nvidia.com%7C84e54f9910164c7214a008d9002afd2e%7 C4
Quoted 1 line
3083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637541006893523890%7CUnkno wn
Quoted 1 line
%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWw
iLCJ
Quoted 1 line
XVCI6Mn0%3D%7C1000&sdata=nsVJW1dJVZVRLBmkSnTtHBatAsavvEvL9vHFkIR IY
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = { };
Quoted 29 lines
8o%3D&reserved=0
Signed-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_flow.h | 195 +++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+)(quoted diff) +0
-0
b/lib/librte_ethdev/rte_flow.hindex6cc57136ac..d506377f7e100644lib/librte_ethdev/rte_flow.h +9
-0@@ -551,6 +551,15 @@ enum rte_flow_item_type {* See struct rte_flow_item_geneve_opt */ RTE_FLOW_ITEM_TYPE_GENEVE_OPT , + +/** +* [META] +* +* Matches conntrack state. +* +* See struct rte_flow_item_conntrack. +*/ + RTE_FLOW_ITEM_TYPE_CONNTRACK, };/** @@ -1685,6 +1694,51 @@ rte_flow_item_geneve_opt_mask = { };#endif
Quoted 18 lines
lib/librte_ethdev/rte_flow.h +17
-0+/** +* The packet is with valid state after conntrack checking. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_VALID (1 << 0) +/** +* The state of the connection was changed. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_CHANGED (1 << 1) +/** +* Error is detected on this packet for this connection and +* an invalid state is set. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_INVAL (1 << 2) +/** +* The HW connection tracking module is disabled. +* It can be due to application command or an invalid state. +*/ lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = {
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+#define RTE_FLOW_CONNTRACK_FLAG_HW_DISABLED (1 << 3) +/** +* The packet contains some bad field(s) and cannot continue +* with the conntrack module checking. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_BAD (1 << 4) + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
Quoted 25 lines
lib/librte_ethdev/rte_flow.h +20
-0+* +* RTE_FLOW_ITEM_TYPE_CONNTRACK +* +* Matches the state of a packet after it passed the connection +tracking +* examination. The state is a bit mask of one +RTE_FLOW_CONNTRACK_FLAG* +* or a reasonable combination of these bits. +*/ +struct rte_flow_item_conntrack { +uint32_t flags; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */ #ifndef +__cplusplusstatic const struct rte_flow_item_conntrack +rte_flow_item_conntrack_mask = { + .flags =0xffffffff , +}; +#endif +/** * Matching pattern item definition. * lib/librte_ethdev/rte_flow.h enum rte_flow_action_type { · line 2330
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +7
-0@@ -2267,6 +2321,17 @@ enum rte_flow_action_type {* See struct rte_flow_action_modify_field. */ RTE_FLOW_ACTION_TYPE_MODIFY_FIELD, + +/** +* [META] +* +* Enable tracking a TCP connection state. +* +* Send packet to HW connection tracking module for examination.
Quoted 37 lines
lib/librte_ethdev/rte_flow.h +29
-0+* +* See struct rte_flow_action_conntrack. +*/ + RTE_FLOW_ACTION_TYPE_CONNTRACK, };/** @@ -2859,6 +2924,136 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_shared_action ; +/** +* The state of a TCP connection. +*/ +enum rte_flow_conntrack_state { +/**< SYN-ACK packet was seen. */ +RTE_FLOW_CONNTRACK_STATE_SYN_RECV , +/**< 3-way handshark was done. */ +RTE_FLOW_CONNTRACK_STATE_ESTABLISHED , +/**< First FIN packet was received to close the connection. */ +RTE_FLOW_CONNTRACK_STATE_FIN_WAIT , +/**< First FIN was ACKed. */ +RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT , +/**< Second FIN was received, waiting for the last ACK. */ +RTE_FLOW_CONNTRACK_STATE_LAST_ACK , +/**< Second FIN was ACKed, connection was closed. */ +RTE_FLOW_CONNTRACK_STATE_TIME_WAIT , +}; + +/** +* The last passed TCP packet flags of a connection. +*/ +enum rte_flow_conntrack_tcp_last_index { +RTE_FLOW_CONNTRACK_FLAG_NONE =0 ,/**< No Flag. */ +RTE_FLOW_CONNTRACK_FLAG_SYN = (1 <<0 ),/**< With SYN flag. */ +RTE_FLOW_CONNTRACK_FLAG_SYNACK = (1 <<1 ),/**< With SYN+ACK flag. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+RTE_FLOW_CONNTRACK_FLAG_FIN = (1 <<2 ),/**< With FIN flag. */ +RTE_FLOW_CONNTRACK_FLAG_ACK = (1 <<3 ),/**< With ACK flag. */ + RTE_FLOW_CONNTRACK_FLAG_RST = (1 << 4), /**< With RST flag.*/ };
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+ +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
Quoted 2 lines
+ *
+ * Configuration parameters for each direction of a TCPconnection.
lib/librte_ethdev/rte_flow.h
Quoted 3 lines
+ */
lib/librte_ethdev/rte_flow.h +2
-0+struct rte_flow_tcp_dir_param { +uint32_t scale:4 ;/**< TCP window scaling factor, 0xF to disable. */
lib/librte_ethdev/rte_flow.h
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ uint32_t close_initiated:1; /**< The FIN was sent by thisdirection. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+/**< An ACK packet has been received by this side. */ + uint32_t last_ack_seen:1; +/**< If set, indicates that there is unacked data of the connection. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+ uint32_t data_unacked:1; +/**< Maximal value of sequence + payload length over sent +* packets (next ACK from the opposite direction). +*/ +uint32_t sent_end; +/**< Maximal value of (ACK + window size) over received packet +
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 13 lines
length
lib/librte_ethdev/rte_flow.h +12
-0+* over sent packet (maximal sequence could be sent). +*/ +uint32_t reply_end; +/**< Maximal value of actual window size over sent packets. */ +uint32_t max_win; +/**< Maximal value of ACK over sent packets. */ +uint32_t max_ack; +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
Quoted 4 lines
+ *
+ *RTE_FLOW_ACTION_TYPE_CONNTRACK
+ *
+ * Configuration and initial state for the connection trackingmodule.
lib/librte_ethdev/rte_flow.h
Quoted 4 lines
+ * This structure could be used for both setting and query.
+ */lib/librte_ethdev/rte_flow.h +2
-0+struct rte_flow_action_conntrack { +uint16_t peer_port;/**< The peer port number, can be the same port.
lib/librte_ethdev/rte_flow.h
Quoted 2 lines
*/
lib/librte_ethdev/rte_flow.h +1
-0+/**< Direction of this connection when creating a flow, the value only
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+* affects the subsequent flows creation. +*/ + uint32_t is_original_dir:1; +/**< Enable / disable the conntrack HW module. When disabled, the
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+* result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED. +* In this state the HW will act as passthrough. +* It only affects this conntrack object in the HW without any effect
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+* to the other objects. +*/ + uint32_t enable:1; +/**< At least one ack was seen, after the connection was established.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 7 lines
*/
lib/librte_ethdev/rte_flow.h +6
-0+ uint32_t live_connection:1; +/**< Enable selective ACK on this connection. */ + uint32_t selective_ack:1; +/**< A challenge ack has passed. */ + uint32_t challenge_ack_passed:1; +/**< 1: The last packet is seen that comes from the original direction.
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+* 0: From the reply direction. +*/ + uint32_t last_direction:1; +/**< No TCP check will be done except the state change. */ + uint32_t liberal_mode:1; +/**< The current state of the connection. */ lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+enum rte_flow_conntrack_state state; +/**< Scaling factor for maximal allowed ACK window. */ +uint8_t max_ack_window; +/**< Maximal allowed number of retransmission times. */ +uint8_t retransmission_limit; +/**< TCP parameters of the original direction. */ +struct rte_flow_tcp_dir_param original_dir; +/**< TCP parameters of the reply direction. */ +struct rte_flow_tcp_dir_param reply_dir; +/**< The window value of the last packet passed this conntrack. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+uint16_t last_window; +enum rte_flow_conntrack_tcp_last_index last_index; +/**< The sequence of the last packet passed this conntrack. */ +uint32_t last_seq; +/**< The acknowledgement of the last packet passed this conntrack. */
lib/librte_ethdev/rte_flow.h
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+uint32_t last_ack; +/**< The total value ACK + payload length of the last packet passed
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* this conntrack. +*/ +uint32_t last_end; +}; + +/** +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Wrapper structure for the context update interface. +* Ports cannot support updating, and the only valid solution is to
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 6 lines
+ * destroy the old context and create a new one instead.
+ */lib/librte_ethdev/rte_flow.h +4
-0+struct rte_flow_modify_conntrack { +/**< New connection tracking parameters to be updated. */ +struct rte_flow_action_conntrack new_ct; +uint32_t direction:1 ;/**< The direction field will be updated. */
Quoted 10 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+/**< All the other fields except direction will be updated. */ + uint32_t state:1; + uint32_t reserved:30; /**< Reserved bits for the future usage.*/ };
Quoted 6 lines
+
/**
* Field IDs forMODIFY_FIELDaction.
*/
--
2.30.0.windows.2
BR. Bing
v2 cover ethdev: introduce conntrack flow action and item
In reply to Bing ZhaoDepends-on: series-16419 ("Change shared action API to action handle API")
This patch set includes the conntrack action and item definitions as well as the testpmd CLI proposal.
---
v2: add testpmd CLI proposal
---
Bing Zhao (2):
ethdev: introduce conntrack flow action and item app/testpmd: add CLI for conntrack
app/test-pmd/cmdline.c | 354 +++++++++++++++++++++++++++++++++++ app/test-pmd/cmdline_flow.c | 92 +++++++++ app/test-pmd/config.c | 65 ++++++- app/test-pmd/testpmd.h | 2 + lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 195 +++++++++++++++++++ 6 files changed, 709 insertions(+), 1 deletion(-)
Signature · 1 line
2.19.0.windows.1
PATCH v2 1/2 ethdev: introduce conntrack flow action and item
This commit introduced the conntrack action and item.
Usually the HW offloading is stateless. For some stateful offloading like a TCP connection, HW module will help provide the ability of a full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow the application should add the conntrack action and in the following flow(s) the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack action context correctly, information from packets of both directions are required.
The conntrack action should be created on one port and supply the peer port as a parameter to the action. After context creating, it could only be used between the ports (dual-port mode) or a single port. The application should modify the action via the API "action_handle_update" only when before using it to create a flow with opposite direction. This will help the driver to recognize the direction of the flow to be created, especially in single port mode. The traffic from both directions will go through the same port if the application works as an "forwarding engine" but not a end point. There is no need to call the update interface if the subsequent flows have nothing to be changed.
Query will be supported via action_ctx_query interface, about the current packets information and connection status. Tha fields query capabilities depends on the HW.
For the packets received during the conntrack setup, it is suggested to re-inject the packets in order to take full advantage of the conntrack. Only the valid packets should pass the conntrack, packets with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Naming and definition:
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/netfilter/nf_conntrack_tcp.h
https://elixir.bootlin.com/linux/latest/source/net/netfilter/nf_conntrack_proto_tcp.c
Other reference:
https://www.usenix.org/legacy/events/sec01/invitedtalks/rooij.pdf
--- lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 195 +++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+)
lib/librte_ethdev/rte_flow.c +2 -0
@@ -98,6 +98,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {MK_FLOW_ITEM (PFCP ,sizeof (struct rte_flow_item_pfcp )),MK_FLOW_ITEM (ECPRI ,sizeof (struct rte_flow_item_ecpri )),MK_FLOW_ITEM (GENEVE_OPT ,sizeof (struct rte_flow_item_geneve_opt )), + MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)), };/** Generate flow_action[] entry. */
@@ -186,6 +187,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {* indirect action handle. */ MK_FLOW_ACTION (INDIRECT ,0 ), + MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)), };int
lib/librte_ethdev/rte_flow.h +195 -0
219 lines not on this page · raw message
Signature · 1 line
2.19.0.windows.1
15/04/2021 18:41, Bing Zhao:
Quoted 10 lines
This commit introduced the conntrack action and item.
Usually the HW offloading is stateless. For some stateful offloading like a TCP connection, HW module will help provide the ability of a full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow the application should add the conntrack action and in the following flow(s) the application should use the conntrack item to match on the result.
You probably mean "flow rule", not "traffic flow". Please make it clear to avoid confusion.
Quoted 4 lines
A TCP connection has two directions traffic. To set a conntrack action context correctly, information from packets of both directions are required.
Quoted 11 lines
The conntrack action should be created on one port and supply the peer port as a parameter to the action. After context creating, it could only be used between the ports (dual-port mode) or a single port. The application should modify the action via the API "
action_handle_update" only when before using it to create a flow with opposite direction. This will help the driver to recognize the direction of the flow to be created, especially in single port mode. The traffic from both directions will go through the same port if the application works as an "forwarding engine" but not a end point. There is no need to call the update interface if the subsequent flows have nothing to be changed.
I am not sure this is a feature description for the commit log or an usage explanation for the doc.
In any case, please distinguish "ethdev port" and "TCP port" to avoid confusion.
Quoted 6 lines
Query will be supported via
action_ctx_queryinterface, about the current packets information and connection status. Tha fields query capabilities depends on the HW.For the packets received during the conntrack setup, it is suggested to re-inject the packets in order to take full advantage of the
What do you mean by "full advantage"?
It is counter-intuitive to re-inject for offloading. Does it improve the performance?
Quoted 5 lines
conntrack. Only the valid packets should pass the conntrack, packets with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Naming and definition:
You mean naming is inspired from Linux?
Quoted 7 lines
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/netfilter/nf_conntrack_tcp.h
https://elixir.bootlin.com/linux/latest/source/net/netfilter/nf_conntrack_proto_tcp.cOther reference:
https://www.usenix.org/legacy/events/sec01/invitedtalks/rooij.pdfSigned-off-by Bing Zhao <[email protected]>
[...]
lib/librte_ethdev/rte_flow.h enum rte_flow_item_type { · line 560
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+/** +* [META] +* +* Matches conntrack state. +* +* See struct rte_flow_item_conntrack.
Please use @see for hyperlink in doxygen.
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +2
-0+*/ + RTE_FLOW_ITEM_TYPE_CONNTRACK, };
[...]
Quoted 2 lines
+/**
+ * The packet is with valid state after conntrack checking.
"is with valid state" looks strange.
I propose "The packet is valid after conntrack checking."
Quoted 2 lines
+ */
+#defineRTE_FLOW_CONNTRACK_FLAG_PKT_STATE_VALID(1 << 0)
Please use RTE_BIT32().
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = { · line 1709
Quoted 9 lines
lib/librte_ethdev/rte_flow.h +9
-0+/** +* The state of the connection was changed. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_CHANGED (1 << 1) +/** +* Error is detected on this packet for this connection and +* an invalid state is set. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_INVAL (1 << 2)
"INVAL" is strange. Can we add the missing 2 characters? RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_INVALID
On a related note, do we really need the word FLAG?
And it is conflicting with the prefix in
enum rte_flow_conntrack_tcp_last_index
I think RTE_FLOW_CONNTRACK_PKT_STATE_ is a good prefix, long enough.
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = { · line 1714
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+/** +* The HW connection tracking module is disabled. +* It can be due to application command or an invalid state. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_HW_DISABLED (1 << 3)
This one does not have PKT in its name.
And it is limiting to HW, while the driver could implement conntrack in SW. I propose RTE_FLOW_CONNTRACK_PKT_DISABLED
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+/** +* The packet contains some bad field(s) and cannot continue +* with the conntrack module checking. +*/
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = { · line 1728
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+#define RTE_FLOW_CONNTRACK_FLAG_PKT_BAD (1 << 4) + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ITEM_TYPE_CONNTRACK +* +* Matches the state of a packet after it passed the connection tracking +* examination. The state is a bit mask of one RTE_FLOW_CONNTRACK_FLAG*
s/bit mask/bitmap/ ?
RTE_FLOW_CONNTRACK_PKT_STATE_*
otherwise it is messed with rte_flow_conntrack_tcp_last_index
Quoted 5 lines
+ * or a reasonable combination of these bits.
+ */lib/librte_ethdev/rte_flow.h +3
-0+struct rte_flow_item_conntrack { +uint32_t flags; +};
[...]
lib/librte_ethdev/rte_flow.h enum rte_flow_action_type { · line 2340
Quoted 7 lines
lib/librte_ethdev/rte_flow.h +7
-0+ +/** +* [META] +* +* Enable tracking a TCP connection state. +* +* Send packet to HW connection tracking module for examination.
Not necessarily HW.
No packet is sent.
I think you can remove this sentence completely.
Review
Quoted 2 lines
(quoted diff) +2
-0+ * + * See struct rte_flow_action_conntrack.
@see
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +2
-0+*/ + RTE_FLOW_ACTION_TYPE_CONNTRACK, };/**
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2949
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +7
-0@@ -2875,6 +2940,136 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_action_handle ; +/** +* The state of a TCP connection. +*/ +enum rte_flow_conntrack_state { +/**< SYN-ACK packet was seen. */ +RTE_FLOW_CONNTRACK_STATE_SYN_RECV , +/**< 3-way handshark was done. */
s/handshark/handshake/
Quoted 12 lines
lib/librte_ethdev/rte_flow.h +12
-0+RTE_FLOW_CONNTRACK_STATE_ESTABLISHED , +/**< First FIN packet was received to close the connection. */ +RTE_FLOW_CONNTRACK_STATE_FIN_WAIT , +/**< First FIN was ACKed. */ +RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT , +/**< Second FIN was received, waiting for the last ACK. */ +RTE_FLOW_CONNTRACK_STATE_LAST_ACK , +/**< Second FIN was ACKed, connection was closed. */ + RTE_FLOW_CONNTRACK_STATE_TIME_WAIT, +}; + +/**
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2971
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* The last passed TCP packet flags of a connection. +*/ +enum rte_flow_conntrack_tcp_last_index { +RTE_FLOW_CONNTRACK_FLAG_NONE =0 ,/**< No Flag. */ +RTE_FLOW_CONNTRACK_FLAG_SYN = (1 <<0 ),/**< With SYN flag. */ +RTE_FLOW_CONNTRACK_FLAG_SYNACK = (1 <<1 ),/**< With SYN+ACK flag. */ +RTE_FLOW_CONNTRACK_FLAG_FIN = (1 <<2 ),/**< With FIN flag. */ +RTE_FLOW_CONNTRACK_FLAG_ACK = (1 <<3 ),/**< With ACK flag. */ +RTE_FLOW_CONNTRACK_FLAG_RST = (1 <<4 ),/**< With RST flag. */ +};
Please use RTE_BIT32().
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2982
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* Configuration parameters for each direction of a TCP connection. +*/ +struct rte_flow_tcp_dir_param { +uint32_t scale:4 ;/**< TCP window scaling factor, 0xF to disable. */ +uint32_t close_initiated:1 ;/**< The FIN was sent by this direction. */ +/**< An ACK packet has been received by this side. */
Move all comments on their own line before the struct member. Comment should then start with /**
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2984
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+ uint32_t last_ack_seen:1; +/**< If set, indicates that there is unacked data of the connection. */
not sure what means "unacked data of the connection"
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2997
Quoted 13 lines
lib/librte_ethdev/rte_flow.h +13
-0+ uint32_t data_unacked:1; +/**< Maximal value of sequence + payload length over sent +* packets (next ACK from the opposite direction). +*/ +uint32_t sent_end; +/**< Maximal value of (ACK + window size) over received packet + length +* over sent packet (maximal sequence could be sent). +*/ +uint32_t reply_end; +/**< Maximal value of actual window size over sent packets. */ +uint32_t max_win; +/**< Maximal value of ACK over sent packets. */ +uint32_t max_ack;
Not sure about the word "over" in above definitions.
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +*
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3013
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Configuration and initial state for the connection tracking module. +* This structure could be used for both setting and query. +*/ +struct rte_flow_action_conntrack { +uint16_t peer_port;/**< The peer port number, can be the same port. */ +/**< Direction of this connection when creating a flow, the value only +* affects the subsequent flows creation. +*/
As for rte_flow_tcp_dir_param, better to move comments before, on their own line.
Quoted 58 lines
lib/librte_ethdev/rte_flow.h +58
-0+ uint32_t is_original_dir:1; +/**< Enable / disable the conntrack HW module. When disabled, the +* result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED. +* In this state the HW will act as passthrough. +* It only affects this conntrack object in the HW without any effect +* to the other objects. +*/ + uint32_t enable:1; +/**< At least one ack was seen, after the connection was established. */ + uint32_t live_connection:1; +/**< Enable selective ACK on this connection. */ + uint32_t selective_ack:1; +/**< A challenge ack has passed. */ + uint32_t challenge_ack_passed:1; +/**< 1: The last packet is seen that comes from the original direction. +* 0: From the reply direction. +*/ + uint32_t last_direction:1; +/**< No TCP check will be done except the state change. */ + uint32_t liberal_mode:1; +/**< The current state of the connection. */ +enum rte_flow_conntrack_state state; +/**< Scaling factor for maximal allowed ACK window. */ +uint8_t max_ack_window; +/**< Maximal allowed number of retransmission times. */ +uint8_t retransmission_limit; +/**< TCP parameters of the original direction. */ +struct rte_flow_tcp_dir_param original_dir; +/**< TCP parameters of the reply direction. */ +struct rte_flow_tcp_dir_param reply_dir; +/**< The window value of the last packet passed this conntrack. */ +uint16_t last_window; +enum rte_flow_conntrack_tcp_last_index last_index; +/**< The sequence of the last packet passed this conntrack. */ +uint32_t last_seq; +/**< The acknowledgement of the last packet passed this conntrack. */ +uint32_t last_ack; +/**< The total value ACK + payload length of the last packet passed +* this conntrack. +*/ +uint32_t last_end; +}; + +/** +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Wrapper structure for the context update interface. +* Ports cannot support updating, and the only valid solution is to +* destroy the old context and create a new one instead. +*/ +struct rte_flow_modify_conntrack { +/**< New connection tracking parameters to be updated. */ +struct rte_flow_action_conntrack new_ct; +uint32_t direction:1 ;/**< The direction field will be updated. */ +/**< All the other fields except direction will be updated. */ +uint32_t state:1 ; +uint32_t reserved:30 ;/**< Reserved bits for the future usage. */ +};
Hi Thomas,
Thanks for your comments. Almost all the comments are addressed. PSB.
Quoted 24 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Friday, April 16, 2021 6:50 PM
To: Bing Zhao <[email protected]>
Cc: Ori Kam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v2 1/2] ethdev: introduce conntrack flow action and itemExternal email: Use caution opening links or attachments
15/04/2021 18:41, Bing Zhao:
Quoted 3 lines
This commit introduced the conntrack action and item.
Usually the HW offloading is stateless. For some stateful
offloading
Quoted 1 line
like a TCP connection, HW module will help provide the ability of
a
Quoted 3 lines
full offloading w/o SW participation after the connection was established.
Quoted 7 lines
Quoted 1 line
The basic usage is that in the first flow the application should
add
Quoted 2 lines
the conntrack action and in the following flow(s) the application should use the conntrack item to match on the result.
You probably mean "flow rule", not "traffic flow". Please make it clear to avoid confusion.
Done
Quoted 22 lines
Quoted 2 lines
A TCP connection has two directions traffic. To set a conntrack
action
Quoted 4 lines
context correctly, information from packets of both directions are required.
The conntrack action should be created on one port and supply the
peer
Quoted 1 line
port as a parameter to the action. After context creating, it
could
Quoted 1 line
only be used between the ports (dual-port mode) or a single port.
The
Quoted 2 lines
application should modify the action via the API "
action_handle_update" only when before using it to create a flowwith
Quoted 2 lines
opposite direction. This will help the driver to recognize the direction of the flow to be created, especially in single port
mode.
Quoted 1 line
The traffic from both directions will go through the same port if
the
Quoted 2 lines
application works as an "forwarding engine" but not a end point. There is no need to call the update interface if the subsequent
Quoted 7 lines
flows
Quoted 1 line
have nothing to be changed.
I am not sure this is a feature description for the commit log or an usage explanation for the doc.
In any case, please distinguish "ethdev port" and "TCP port" to avoid confusion.
Changed, thanks.
Quoted 6 lines
Quoted 3 lines
Query will be supported via
action_ctx_queryinterface, about the current packets information and connection status. Tha fieldsquery
Quoted 2 lines
capabilities depends on the HW.
Quoted 7 lines
Quoted 1 line
For the packets received during the conntrack setup, it is
suggested
Quoted 1 line
to re-inject the packets in order to take full advantage of the
What do you mean by "full advantage"?
It is counter-intuitive to re-inject for offloading. Does it improve the performance?
No, it is not for the performance but for the functionality correctness. Before the CT established, some data+ack packets may already be received by the SW, and the application will use the initial information to setup a conntrack. It may result into some error checking for the following packets. By re-injecting the packets already received by SW before the established CT, it will make the HW have all the packets information and check the following packets correctly.
Quoted 9 lines
Quoted 2 lines
conntrack. Only the valid packets should pass the conntrack,
packets
Quoted 4 lines
with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Naming and definition:
You mean naming is inspired from Linux?
The naming and critical fields definition. The original idea are from the paper listed below (correct me if I was wrong), and there is some well-known definition in this area, to my understanding, it would be better to follow it.
Quoted 73 lines
Quoted 2 lines
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fel
ixQuoted 1 line
ir.bootlin.com%2Flinux%2Flatest%2Fsource%2Finclude%2Fuapi%2Flinux%2F ne
Quoted 1 line
tfilter%2Fnf_conntrack_tcp.h&data=04%7C01%7Cbingz%40nvidia.com%7 Ca
Quoted 1 line
d68b128653e4428da6e08d900c56373%7C43083d15727340c1b7db39efd9ccc17a%7 C0
Quoted 1 line
%7C1%7C637541670056627642%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw
MDAi
Quoted 1 line
LCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=kCn9 kF
Quoted 2 lines
bi7yWrd7A94zFibvQEB97phXXUudSA%2BhAueTU%3D&reserved=0
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fel
ixQuoted 1 line
ir.bootlin.com%2Flinux%2Flatest%2Fsource%2Fnet%2Fnetfilter%2Fnf_conn tr
Quoted 1 line
ack_proto_tcp.c&data=04%7C01%7Cbingz%40nvidia.com%7Cad68b128653e 44
Quoted 1 line
28da6e08d900c56373%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C1%7C6375 41
Quoted 1 line
670056627642%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2l uM
Quoted 1 line
zIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Ajs9NtCaEpG2Kfnjy t5
Quoted 4 lines
X8uwOFo2HyfMdWZbx%2BHkbvX8%3D&reserved=0
Other reference:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fww
w.Quoted 1 line
usenix.org%2Flegacy%2Fevents%2Fsec01%2Finvitedtalks%2Frooij.pdf& da
Quoted 1 line
ta=04%7C01%7Cbingz%40nvidia.com%7Cad68b128653e4428da6e08d900c56373%7 C4
Quoted 1 line
3083d15727340c1b7db39efd9ccc17a%7C0%7C1%7C637541670056627642%7CUnkno wn
Quoted 1 line
%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWw
iLCJ
Quoted 1 line
XVCI6Mn0%3D%7C1000&sdata=987HVU%2FefoJ40%2B6aM0Q1RVxcGH5nVJS4bzy 4A
Quoted 3 lines
4ZoYSE%3D&reserved=0
Signed-off-by Bing Zhao <[email protected]>[...]
lib/librte_ethdev/rte_flow.h enum rte_flow_item_type { · line 560
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+/** +* [META] +* +* Matches conntrack state. +* +* See struct rte_flow_item_conntrack. Please use @see for hyperlink in doxygen.
lib/librte_ethdev/rte_flow.h enum rte_flow_item_type { · line 563
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +2
-0+*/ + RTE_FLOW_ITEM_TYPE_CONNTRACK, };
Quoted 6 lines
[...]
Quoted 2 lines
+/**
+ * The packet is with valid state after conntrack checking."is with valid state" looks strange.
I propose "The packet is valid after conntrack checking."
Done
Quoted 5 lines
Quoted 3 lines
+ */
+#defineRTE_FLOW_CONNTRACK_FLAG_PKT_STATE_VALID(1 << 0)Please use
RTE_BIT32().
Done
Quoted 14 lines
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = { · line 1709
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +9
-0+/** +* The state of the connection was changed. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_CHANGED (1 << 1) +/** +* Error is detected on this packet for this connection and +* an invalid state is set. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_INVAL (1 << 2)"INVAL" is strange. Can we add the missing 2 characters?
RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_INVALID
Quoted 5 lines
On a related note, do we really need the word FLAG? And it is conflicting with the prefix in enum
rte_flow_conntrack_tcp_last_indexI thinkRTE_FLOW_CONNTRACK_PKT_STATE_is a good prefix, long enough.
Done
Quoted 11 lines
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = { · line 1714
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+/** +* The HW connection tracking module is disabled. +* It can be due to application command or an invalid state. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_HW_DISABLED (1 << 3)This one does not have PKT in its name.
And it is limiting to HW, while the driver could implement conntrack in SW.
I proposeRTE_FLOW_CONNTRACK_PKT_DISABLED
Done
Quoted 10 lines
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = {
Quoted 9 lines
lib/librte_ethdev/rte_flow.h +9
-0+/** +* The packet contains some bad field(s) and cannot continue +* with the conntrack module checking. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_BAD (1 << 4) + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
Quoted 9 lines
Review
Quoted 7 lines
+ *
+ *RTE_FLOW_ITEM_TYPE_CONNTRACK
+ *
+ * Matches the state of a packet after it passed the connection(quoted diff) +3
-0+tracking + * examination. The state is a bit mask of one +RTE_FLOW_CONNTRACK_FLAG*s/bit mask/bitmap/ ?
Done
Quoted 17 lines
RTE_FLOW_CONNTRACK_PKT_STATE_*
otherwise it is messed withrte_flow_conntrack_tcp_last_indexQuoted 5 lines
+ * or a reasonable combination of these bits.
+ */lib/librte_ethdev/rte_flow.h +3
-0+struct rte_flow_item_conntrack { +uint32_t flags; +};[...]
lib/librte_ethdev/rte_flow.h enum rte_flow_action_type {
Quoted 7 lines
lib/librte_ethdev/rte_flow.h +7
-0+ +/** +* [META] +* +* Enable tracking a TCP connection state. +* +* Send packet to HW connection tracking module for
Quoted 6 lines
examination.
Not necessarily HW.
No packet is sent.
I think you can remove this sentence completely.
Done
Quoted 14 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ * + * See struct rte_flow_action_conntrack.@see
Quoted 9 lines
lib/librte_ethdev/rte_flow.h +2
-0+*/ + RTE_FLOW_ACTION_TYPE_CONNTRACK, };/** @@ -2875,6 +2940,136 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_action_handle ;
Quoted 10 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2949
Quoted 7 lines
lib/librte_ethdev/rte_flow.h +7
-0+/** +* The state of a TCP connection. +*/ +enum rte_flow_conntrack_state { +/**< SYN-ACK packet was seen. */ +RTE_FLOW_CONNTRACK_STATE_SYN_RECV , +/**< 3-way handshark was done. */ s/handshark/handshake/
Done
Quoted 22 lines
Review struct rte_flow_action_set_dscp { · line 2951
Quoted 2 lines
(quoted diff) +2
-0+ RTE_FLOW_CONNTRACK_STATE_ESTABLISHED, + /**< First FIN packet was received to close the connection.*/
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+RTE_FLOW_CONNTRACK_STATE_FIN_WAIT , +/**< First FIN was ACKed. */ +RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT , +/**< Second FIN was received, waiting for the last ACK. */ + RTE_FLOW_CONNTRACK_STATE_LAST_ACK,lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+/**< Second FIN was ACKed, connection was closed. */ + RTE_FLOW_CONNTRACK_STATE_TIME_WAIT, +}; + +/** +* The last passed TCP packet flags of a connection. +*/ +enum rte_flow_conntrack_tcp_last_index { +RTE_FLOW_CONNTRACK_FLAG_NONE =0 ,/**< No Flag. */ +RTE_FLOW_CONNTRACK_FLAG_SYN = (1 <<0 ),/**< With SYN flag. */
Review struct rte_flow_action_set_dscp { · line 2967
Quoted 1 line
(quoted diff) +1
-0+ RTE_FLOW_CONNTRACK_FLAG_SYNACK = (1 << 1), /**< With SYN+ACKflag. */
Review struct rte_flow_action_set_dscp { · line 2968
Quoted 1 line
(quoted diff) +1
-0+ RTE_FLOW_CONNTRACK_FLAG_FIN = (1 << 2), /**< With FIN flag.
Quoted 9 lines
*/
Review struct rte_flow_action_set_dscp { · line 2969
Quoted 1 line
(quoted diff) +1
-0+ RTE_FLOW_CONNTRACK_FLAG_ACK = (1 << 3), /**< With ACK flag.*/
Review struct rte_flow_action_set_dscp { · line 2970
Quoted 1 line
(quoted diff) +1
-0+ RTE_FLOW_CONNTRACK_FLAG_RST = (1 << 4), /**< With RST flag.*/
Review struct rte_flow_action_set_dscp { · line 2971
Quoted 1 line
(quoted diff) +1
-0+};Please use
RTE_BIT32().
Done
Quoted 10 lines
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
Review struct rte_flow_action_set_dscp { · line 2976
Quoted 2 lines
(quoted diff) +2
-0+ * + * Configuration parameters for each direction of a TCPconnection.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+*/ +struct rte_flow_tcp_dir_param { +uint32_t scale:4 ;/**< TCP window scaling factor, 0xF to
Quoted 8 lines
disable. */
Review struct rte_flow_action_set_dscp { · line 2980
Quoted 1 line
(quoted diff) +1
-0+ uint32_t close_initiated:1; /**< The FIN was sent by thisdirection. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2982
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+/**< An ACK packet has been received by this side. */ Move all comments on their own line before the struct member. Comment should then start with /**
All done, BTW, I see in the current code, the format "/**<" is used in a lot of parts.
Quoted 5 lines
Review struct rte_flow_action_set_dscp { · line 2984
Quoted 3 lines
(quoted diff) +3
-0+ uint32_t last_ack_seen:1; + /**< If set, indicates that there is unacked data of the + connection. */not sure what means "unacked data of the connection"
Updated the description, it means some packets were sent but not all of them are ACKed.
Quoted 12 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 7 lines
lib/librte_ethdev/rte_flow.h +6
-0+ uint32_t data_unacked:1; +/**< Maximal value of sequence + payload length over sent +* packets (next ACK from the opposite direction). +*/ +uint32_t sent_end; +/**< Maximal value of (ACK + window size) over received packet + length
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+* over sent packet (maximal sequence could be sent). +*/ +uint32_t reply_end; +/**< Maximal value of actual window size over sent packets.
Quoted 6 lines
*/
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2997
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+uint32_t max_win; +/**< Maximal value of ACK over sent packets. */ +uint32_t max_ack;Not sure about the word "over" in above definitions.
Changed to "in"
Quoted 88 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +5
-0+}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+* +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Configuration and initial state for the connection tracking module.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+* This structure could be used for both setting and query. +*/ +struct rte_flow_action_conntrack { +uint16_t peer_port;/**< The peer port number, can be the same port. */
Review struct rte_flow_action_set_dscp { · line 3011
Quoted 1 line
(quoted diff) +1
-0+ /**< Direction of this connection when creating a flow, thevalue only
Review struct rte_flow_action_set_dscp { · line 3013
Quoted 2 lines
(quoted diff) +2
-0+ * affects the subsequent flows creation. + */As for
rte_flow_tcp_dir_param, better to move comments before, on their own line.Review struct rte_flow_action_set_dscp { · line 3015
Quoted 2 lines
(quoted diff) +2
-0+ uint32_t is_original_dir:1; + /**< Enable / disable the conntrack HW module. When disabled,the
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+* result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED. +* In this state the HW will act as passthrough. +* It only affects this conntrack object in the HW without any effect
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+* to the other objects. +*/ + uint32_t enable:1; +/**< At least one ack was seen, after the connection was established. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+ uint32_t live_connection:1; +/**< Enable selective ACK on this connection. */ + uint32_t selective_ack:1; +/**< A challenge ack has passed. */ + uint32_t challenge_ack_passed:1; +/**< 1: The last packet is seen that comes from the original direction.
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+* 0: From the reply direction. +*/ + uint32_t last_direction:1; +/**< No TCP check will be done except the state change. */ + uint32_t liberal_mode:1; +/**< The current state of the connection. */ lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+enum rte_flow_conntrack_state state; +/**< Scaling factor for maximal allowed ACK window. */ +uint8_t max_ack_window; +/**< Maximal allowed number of retransmission times. */ +uint8_t retransmission_limit; +/**< TCP parameters of the original direction. */ +struct rte_flow_tcp_dir_param original_dir; +/**< TCP parameters of the reply direction. */ +struct rte_flow_tcp_dir_param reply_dir; +/**< The window value of the last packet passed this conntrack. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+uint16_t last_window; +enum rte_flow_conntrack_tcp_last_index last_index; +/**< The sequence of the last packet passed this conntrack. */
Review struct rte_flow_action_set_dscp { · line 3049
Quoted 2 lines
(quoted diff) +2
-0+ uint32_t last_seq; + /**< The acknowledgement of the last packet passed thisconntrack. */
Review struct rte_flow_action_set_dscp { · line 3051
Quoted 2 lines
(quoted diff) +2
-0+ uint32_t last_ack; + /**< The total value ACK + payload length of the last packetpassed
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* this conntrack. +*/ +uint32_t last_end; +}; + +/** +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Wrapper structure for the context update interface. +* Ports cannot support updating, and the only valid solution is to
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+* destroy the old context and create a new one instead. +*/ +struct rte_flow_modify_conntrack { +/**< New connection tracking parameters to be updated. */ +struct rte_flow_action_conntrack new_ct; +uint32_t direction:1 ;/**< The direction field will be
Quoted 9 lines
updated. */
Review struct rte_flow_action_set_dscp { · line 3068
Quoted 1 line
(quoted diff) +1
-0+ /**< All the other fields except direction will be updated.*/
Review struct rte_flow_action_set_dscp { · line 3070
Quoted 2 lines
(quoted diff) +2
-0+ uint32_t state:1; + uint32_t reserved:30; /**< Reserved bits for the futureusage.
Quoted 1 line
(quoted diff) +1
-0+*/ };
Thanks
Hi Bing,
One more thought, PSB
Best,
Ori
Quoted 230 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, April 15, 2021 7:41 PM
To: Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: [PATCH v2 1/2] ethdev: introduce conntrack flow action and itemThis commit introduced the conntrack action and item.
Usually the HW offloading is stateless. For some stateful offloading like a TCP connection, HW module will help provide the ability of a full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow the application should add the conntrack action and in the following flow(s) the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack action context correctly, information from packets of both directions are required.
The conntrack action should be created on one port and supply the peer port as a parameter to the action. After context creating, it could only be used between the ports (dual-port mode) or a single port. The application should modify the action via the API "
action_handle_update" only when before using it to create a flow with opposite direction. This will help the driver to recognize the direction of the flow to be created, especially in single port mode. The traffic from both directions will go through the same port if the application works as an "forwarding engine" but not a end point. There is no need to call the update interface if the subsequent flows have nothing to be changed.Query will be supported via
action_ctx_queryinterface, about the current packets information and connection status. Tha fields query capabilities depends on the HW.For the packets received during the conntrack setup, it is suggested to re-inject the packets in order to take full advantage of the conntrack. Only the valid packets should pass the conntrack, packets with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Naming and definition:
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/netfilter/nf_conntrack_tcp.h
https://elixir.bootlin.com/linux/latest/source/net/netfilter/nf_conntrack_proto_tcp.cOther reference:
https://www.usenix.org/legacy/events/sec01/invitedtalks/rooij.pdfSigned-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 195 +++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+)lib/librte_ethdev/rte_flow.c +1
-0@@ -98,6 +98,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {MK_FLOW_ITEM (PFCP ,sizeof (struct rte_flow_item_pfcp )),MK_FLOW_ITEM (ECPRI ,sizeof (struct rte_flow_item_ecpri )),MK_FLOW_ITEM (GENEVE_OPT ,sizeof (struct rte_flow_item_geneve_opt )), +MK_FLOW_ITEM (CONNTRACK ,sizeof (uint32_t )), };/** Generate flow_action[] entry. */
lib/librte_ethdev/rte_flow.c +1
-0@@ -186,6 +187,7 @@ static const struct rte_flow_desc_datarte_flow_desc_action[] = { * indirect action handle. */ MK_FLOW_ACTION (INDIRECT ,0 ), +MK_FLOW_ACTION (CONNTRACK ,sizeof (struct rte_flow_action_conntrack)), };int
lib/librte_ethdev/rte_flow.h +54
-0@@ -551,6 +551,15 @@ enum rte_flow_item_type {* See struct rte_flow_item_geneve_opt */ RTE_FLOW_ITEM_TYPE_GENEVE_OPT , + +/** +* [META] +* +* Matches conntrack state. +* +* See struct rte_flow_item_conntrack. +*/ + RTE_FLOW_ITEM_TYPE_CONNTRACK, };/** @@ -1685,6 +1694,51 @@ rte_flow_item_geneve_opt_mask = { };#endif +/** +* The packet is with valid state after conntrack checking. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_VALID (1 << 0) +/** +* The state of the connection was changed. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_CHANGED (1 << 1) +/** +* Error is detected on this packet for this connection and +* an invalid state is set. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_INVAL (1 << 2) +/** +* The HW connection tracking module is disabled. +* It can be due to application command or an invalid state. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_HW_DISABLED (1 << 3) +/** +* The packet contains some bad field(s) and cannot continue +* with the conntrack module checking. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_BAD (1 << 4) + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ITEM_TYPE_CONNTRACK +* +* Matches the state of a packet after it passed the connection tracking +* examination. The state is a bit mask of one RTE_FLOW_CONNTRACK_FLAG* +* or a reasonable combination of these bits. +*/ +struct rte_flow_item_conntrack { +uint32_t flags; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */ +#ifndef __cplusplus +static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = { + .flags =0xffffffff , +}; +#endif +/** * Matching pattern item definition. *
lib/librte_ethdev/rte_flow.h +36
-0@@ -2277,6 +2331,17 @@ enum rte_flow_action_type {* same port or across different ports. */ RTE_FLOW_ACTION_TYPE_INDIRECT , + +/** +* [META] +* +* Enable tracking a TCP connection state. +* +* Send packet to HW connection tracking module for examination. +* +* See struct rte_flow_action_conntrack. +*/ + RTE_FLOW_ACTION_TYPE_CONNTRACK, };/** @@ -2875,6 +2940,136 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_action_handle ; +/** +* The state of a TCP connection. +*/ +enum rte_flow_conntrack_state { +/**< SYN-ACK packet was seen. */ +RTE_FLOW_CONNTRACK_STATE_SYN_RECV , +/**< 3-way handshark was done. */ +RTE_FLOW_CONNTRACK_STATE_ESTABLISHED , +/**< First FIN packet was received to close the connection. */ +RTE_FLOW_CONNTRACK_STATE_FIN_WAIT , +/**< First FIN was ACKed. */ +RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT , +/**< Second FIN was received, waiting for the last ACK. */ +RTE_FLOW_CONNTRACK_STATE_LAST_ACK , +/**< Second FIN was ACKed, connection was closed. */ +RTE_FLOW_CONNTRACK_STATE_TIME_WAIT , +}; + +/** +* The last passed TCP packet flags of a connection. +*/ +enum rte_flow_conntrack_tcp_last_index { +RTE_FLOW_CONNTRACK_FLAG_NONE =0 ,/**< No Flag. */ +RTE_FLOW_CONNTRACK_FLAG_SYN = (1 <<0 ),/**< With SYN flag. */ +RTE_FLOW_CONNTRACK_FLAG_SYNACK = (1 <<1 ),/**< With SYN+ACK flag. */
lib/librte_ethdev/rte_flow.h +23
-0+RTE_FLOW_CONNTRACK_FLAG_FIN = (1 <<2 ),/**< With FIN flag. */ +RTE_FLOW_CONNTRACK_FLAG_ACK = (1 <<3 ),/**< With ACK flag. */ + RTE_FLOW_CONNTRACK_FLAG_RST = (1 << 4), /**< With RST flag. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* Configuration parameters for each direction of a TCP connection. +*/ +struct rte_flow_tcp_dir_param { +uint32_t scale:4 ;/**< TCP window scaling factor, 0xF to disable. */ +uint32_t close_initiated:1 ;/**< The FIN was sent by this direction. */ +/**< An ACK packet has been received by this side. */ +uint32_t last_ack_seen:1 ; +/**< If set, indicates that there is unacked data of the connection. */ +uint32_t data_unacked:1 ; +/**< Maximal value of sequence + payload length over sent +* packets (next ACK from the opposite direction). +*/ +uint32_t sent_end; +/**< Maximal value of (ACK + window size) over received packet + length
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2993
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+* over sent packet (maximal sequence could be sent). +*/ +uint32_t reply_end;
This comment is for all members that are part of the packet,
Do you think it should be in network order?
I can see the advantage in both ways nice I assume the app needs this data in host byte-order but since in most other cases we use network byte-order to set values that are coming from the packet itself maybe it is better to use network byte-order (will also save the conversion)
Quoted 86 lines
lib/librte_ethdev/rte_flow.h +17
-0+/**< Maximal value of actual window size over sent packets. */ +uint32_t max_win; +/**< Maximal value of ACK over sent packets. */ +uint32_t max_ack; +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Configuration and initial state for the connection tracking module. +* This structure could be used for both setting and query. +*/ +struct rte_flow_action_conntrack { +uint16_t peer_port;/**< The peer port number, can be the same port. */
lib/librte_ethdev/rte_flow.h +12
-0+/**< Direction of this connection when creating a flow, the value only +* affects the subsequent flows creation. +*/ + uint32_t is_original_dir:1; +/**< Enable / disable the conntrack HW module. When disabled, the +* result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED. +* In this state the HW will act as passthrough. +* It only affects this conntrack object in the HW without any effect +* to the other objects. +*/ + uint32_t enable:1; +/**< At least one ack was seen, after the connection was established. */
lib/librte_ethdev/rte_flow.h +50
-1+ uint32_t live_connection:1; +/**< Enable selective ACK on this connection. */ + uint32_t selective_ack:1; +/**< A challenge ack has passed. */ + uint32_t challenge_ack_passed:1; +/**< 1: The last packet is seen that comes from the original direction. +* 0: From the reply direction. +*/ + uint32_t last_direction:1; +/**< No TCP check will be done except the state change. */ + uint32_t liberal_mode:1; +/**< The current state of the connection. */ +enum rte_flow_conntrack_state state; +/**< Scaling factor for maximal allowed ACK window. */ +uint8_t max_ack_window; +/**< Maximal allowed number of retransmission times. */ +uint8_t retransmission_limit; +/**< TCP parameters of the original direction. */ +struct rte_flow_tcp_dir_param original_dir; +/**< TCP parameters of the reply direction. */ +struct rte_flow_tcp_dir_param reply_dir; +/**< The window value of the last packet passed this conntrack. */ +uint16_t last_window; +enum rte_flow_conntrack_tcp_last_index last_index; +/**< The sequence of the last packet passed this conntrack. */ +uint32_t last_seq; +/**< The acknowledgement of the last packet passed this conntrack. */ +uint32_t last_ack; +/**< The total value ACK + payload length of the last packet passed +* this conntrack. +*/ +uint32_t last_end; +}; + +/** +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Wrapper structure for the context update interface. +* Ports cannot support updating, and the only valid solution is to +* destroy the old context and create a new one instead. +*/ +struct rte_flow_modify_conntrack { +/**< New connection tracking parameters to be updated. */ +struct rte_flow_action_conntrack new_ct; +uint32_t direction:1 ;/**< The direction field will be updated. */ +/**< All the other fields except direction will be updated. */ +uint32_t state:1 ; +uint32_t reserved:30 ;/**< Reserved bits for the future usage. */ +}; +/** * Field IDs for MODIFY_FIELD action. */ --2.19.0.windows.1
Hi Ori,
My comments are inline, PSB.
Quoted 324 lines
-----Original Message-----
From: Ori Kam <[email protected]>
Sent: Friday, April 16, 2021 8:42 PM
To: Bing Zhao <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v2 1/2] ethdev: introduce conntrack flow action and itemHi Bing,
One more thought, PSB
Best,
OriQuoted 8 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, April 15, 2021 7:41 PM
To: Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: [PATCH v2 1/2] ethdev: introduce conntrack flow actionand
Quoted 5 lines
item
This commit introduced the conntrack action and item.
Usually the HW offloading is stateless. For some stateful
offloading
Quoted 1 line
like a TCP connection, HW module will help provide the ability of
a
Quoted 4 lines
full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow the application should
add
Quoted 4 lines
the conntrack action and in the following flow(s) the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack
action
Quoted 4 lines
context correctly, information from packets of both directions are required.
The conntrack action should be created on one port and supply the
peer
Quoted 1 line
port as a parameter to the action. After context creating, it
could
Quoted 1 line
only be used between the ports (dual-port mode) or a single port.
The
Quoted 2 lines
application should modify the action via the API "
action_handle_update" only when before using it to create a flowwith
Quoted 2 lines
opposite direction. This will help the driver to recognize the direction of the flow to be created, especially in single port
mode.
Quoted 1 line
The traffic from both directions will go through the same port if
the
Quoted 2 lines
application works as an "forwarding engine" but not a end point. There is no need to call the update interface if the subsequent
flows
Quoted 4 lines
have nothing to be changed.
Query will be supported via
action_ctx_queryinterface, about the current packets information and connection status. Tha fieldsquery
Quoted 3 lines
capabilities depends on the HW.
For the packets received during the conntrack setup, it is
suggested
Quoted 2 lines
to re-inject the packets in order to take full advantage of the conntrack. Only the valid packets should pass the conntrack,
packets
Quoted 5 lines
with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Naming and definition:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fel
ixQuoted 1 line
ir.bootlin.com%2Flinux%2Flatest%2Fsource%2Finclude%2Fuapi%2Flinux%2F ne
Quoted 1 line
tfilter%2Fnf_co&data=04%7C01%7Cbingz%40nvidia.com%7C29da48bebdc9 44
Quoted 1 line
b0127508d900d4f89a%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C6375 41
Quoted 1 line
736960852707%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2l uM
Quoted 1 line
zIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=%2Bbsd48yNzMbhUyp In
Quoted 3 lines
kol%2B7LskVzx1WHj%2Fkd%2Fu0zks0A%3D&reserved=0
nntrack_tcp.hhttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fel
ixQuoted 1 line
ir.bootlin.com%2Flinux%2Flatest%2Fsource%2Fnet%2Fnetfilter%2Fnf_conn tr
Quoted 1 line
ack_proto_&data=04%7C01%7Cbingz%40nvidia.com%7C29da48bebdc944b01 27
Quoted 1 line
508d900d4f89a%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637541736 96
Quoted 1 line
0852707%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIi LC
Quoted 1 line
JBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=CwKk%2FgQWxRY22%2BAaCF OP
Quoted 5 lines
1TbGphcqURrBFSf4NupMPPA%3D&reserved=0
tcp.cOther reference:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fww
w.Quoted 1 line
usenix.org%2Flegacy%2Fevents%2Fsec01%2Finvitedtalks%2Frooij.pdf& da
Quoted 1 line
ta=04%7C01%7Cbingz%40nvidia.com%7C29da48bebdc944b0127508d900d4f89a%7 C4
Quoted 1 line
3083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637541736960852707%7CUnkno wn
Quoted 1 line
%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWw
iLCJ
Quoted 1 line
XVCI6Mn0%3D%7C1000&sdata=geKUBifelEBuFzQviu%2FPeV19DOjWzZAbdAlo% 2B
Quoted 14 lines
cVX%2FXs%3D&reserved=0
Signed-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 195 +++++++++++++++++++++++++++++++++++ 2 files changed, 197 insertions(+)(quoted diff) +0
-0
b/lib/librte_ethdev/rte_flow.cindex27a161559d..0af601d508100644lib/librte_ethdev/rte_flow.c static const struct rte_flow_desc_data · line 101
Quoted 4 lines
lib/librte_ethdev/rte_flow.c +0
-0@@ -98,6 +98,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {MK_FLOW_ITEM (PFCP ,sizeof (struct rte_flow_item_pfcp )),MK_FLOW_ITEM (ECPRI ,sizeof (struct rte_flow_item_ecpri )), MK_FLOW_ITEM(GENEVE_OPT, sizeof(struct
rte_flow_item_geneve_opt)),lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = { };
Quoted 35 lines
lib/librte_ethdev/rte_flow.c +1
-0+ MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)), };/** Generate flow_action[] entry. */
lib/librte_ethdev/rte_flow.c +1
-0@@ -186,6 +187,7 @@ static const struct rte_flow_desc_datarte_flow_desc_action[] = { * indirect action handle. */ MK_FLOW_ACTION (INDIRECT ,0 ), +MK_FLOW_ACTION (CONNTRACK ,sizeof (struct rte_flow_action_conntrack)), };int
(quoted diff) +0
-0
b/lib/librte_ethdev/rte_flow.hindex91ae25b1da..024d1a2026100644lib/librte_ethdev/rte_flow.h +9
-0@@ -551,6 +551,15 @@ enum rte_flow_item_type {* See struct rte_flow_item_geneve_opt */ RTE_FLOW_ITEM_TYPE_GENEVE_OPT , + +/** +* [META] +* +* Matches conntrack state. +* +* See struct rte_flow_item_conntrack. +*/ + RTE_FLOW_ITEM_TYPE_CONNTRACK, };/** @@ -1685,6 +1694,51 @@ rte_flow_item_geneve_opt_mask = { };#endif
Quoted 18 lines
lib/librte_ethdev/rte_flow.h +17
-0+/** +* The packet is with valid state after conntrack checking. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_VALID (1 << 0) +/** +* The state of the connection was changed. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_CHANGED (1 << 1) +/** +* Error is detected on this packet for this connection and +* an invalid state is set. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_STATE_INVAL (1 << 2) +/** +* The HW connection tracking module is disabled. +* It can be due to application command or an invalid state. +*/ lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = {
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+#define RTE_FLOW_CONNTRACK_FLAG_HW_DISABLED (1 << 3) +/** +* The packet contains some bad field(s) and cannot continue +* with the conntrack module checking. +*/ +#define RTE_FLOW_CONNTRACK_FLAG_PKT_BAD (1 << 4) + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
Quoted 25 lines
lib/librte_ethdev/rte_flow.h +20
-0+* +* RTE_FLOW_ITEM_TYPE_CONNTRACK +* +* Matches the state of a packet after it passed the connection +tracking +* examination. The state is a bit mask of one +RTE_FLOW_CONNTRACK_FLAG* +* or a reasonable combination of these bits. +*/ +struct rte_flow_item_conntrack { +uint32_t flags; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */ #ifndef +__cplusplusstatic const struct rte_flow_item_conntrack +rte_flow_item_conntrack_mask = { + .flags =0xffffffff , +}; +#endif +/** * Matching pattern item definition. * lib/librte_ethdev/rte_flow.h enum rte_flow_action_type { · line 2340
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +7
-0@@ -2277,6 +2331,17 @@ enum rte_flow_action_type {* same port or across different ports. */ RTE_FLOW_ACTION_TYPE_INDIRECT, + +/** +* [META] +* +* Enable tracking a TCP connection state. +* +* Send packet to HW connection tracking module for examination.
Quoted 37 lines
lib/librte_ethdev/rte_flow.h +29
-0+* +* See struct rte_flow_action_conntrack. +*/ + RTE_FLOW_ACTION_TYPE_CONNTRACK, };/** @@ -2875,6 +2940,136 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_action_handle ; +/** +* The state of a TCP connection. +*/ +enum rte_flow_conntrack_state { +/**< SYN-ACK packet was seen. */ +RTE_FLOW_CONNTRACK_STATE_SYN_RECV , +/**< 3-way handshark was done. */ +RTE_FLOW_CONNTRACK_STATE_ESTABLISHED , +/**< First FIN packet was received to close the connection. */ +RTE_FLOW_CONNTRACK_STATE_FIN_WAIT , +/**< First FIN was ACKed. */ +RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT , +/**< Second FIN was received, waiting for the last ACK. */ +RTE_FLOW_CONNTRACK_STATE_LAST_ACK , +/**< Second FIN was ACKed, connection was closed. */ +RTE_FLOW_CONNTRACK_STATE_TIME_WAIT , +}; + +/** +* The last passed TCP packet flags of a connection. +*/ +enum rte_flow_conntrack_tcp_last_index { +RTE_FLOW_CONNTRACK_FLAG_NONE =0 ,/**< No Flag. */ +RTE_FLOW_CONNTRACK_FLAG_SYN = (1 <<0 ),/**< With SYN flag. */ +RTE_FLOW_CONNTRACK_FLAG_SYNACK = (1 <<1 ),/**< With SYN+ACK flag. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+RTE_FLOW_CONNTRACK_FLAG_FIN = (1 <<2 ),/**< With FIN flag. */ +RTE_FLOW_CONNTRACK_FLAG_ACK = (1 <<3 ),/**< With ACK flag. */ + RTE_FLOW_CONNTRACK_FLAG_RST = (1 << 4), /**< With RST flag.*/ };
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+ +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
Quoted 2 lines
+ *
+ * Configuration parameters for each direction of a TCPconnection.
lib/librte_ethdev/rte_flow.h
Quoted 3 lines
+ */
lib/librte_ethdev/rte_flow.h +2
-0+struct rte_flow_tcp_dir_param { +uint32_t scale:4 ;/**< TCP window scaling factor, 0xF to disable. */
lib/librte_ethdev/rte_flow.h
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+ uint32_t close_initiated:1; /**< The FIN was sent by thisdirection. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+/**< An ACK packet has been received by this side. */ + uint32_t last_ack_seen:1; +/**< If set, indicates that there is unacked data of the connection. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+ uint32_t data_unacked:1; +/**< Maximal value of sequence + payload length over sent +* packets (next ACK from the opposite direction). +*/ +uint32_t sent_end; +/**< Maximal value of (ACK + window size) over received packet +
Quoted 7 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2993
Quoted 4 lines
length
lib/librte_ethdev/rte_flow.h +3
-0+* over sent packet (maximal sequence could be sent). +*/ +uint32_t reply_end;This comment is for all members that are part of the packet, Do you think it should be in network order?
Almost none of the fields are part of the packet. Indeed, most of them are calculated from the packets information. So I prefer to keep the host order easy for using and keep all the fields of the whole structure the same endianness format.
What do you think?
Quoted 5 lines
I can see the advantage in both ways nice I assume the app needs this data in host byte-order but since in most other cases we use network byte-order to set values that are coming from the packet itself maybe it is better to use network byte-order (will also save the conversion)
Only the seq/ack/window in the common part are part of the packets, others are not.
BTW, should we support liberal mode separately for both direction as some "half-duplex". One direction could work normally and the opposite direct will work in the liberal mode?
Quoted 90 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +9
-0+/**< Maximal value of actual window size over sent packets. */ +uint32_t max_win; +/**< Maximal value of ACK over sent packets. */ +uint32_t max_ack; +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
Quoted 4 lines
+ *
+ *RTE_FLOW_ACTION_TYPE_CONNTRACK
+ *
+ * Configuration and initial state for the connection trackingmodule.
lib/librte_ethdev/rte_flow.h
Quoted 4 lines
+ * This structure could be used for both setting and query.
+ */lib/librte_ethdev/rte_flow.h +2
-0+struct rte_flow_action_conntrack { +uint16_t peer_port;/**< The peer port number, can be the same port.
lib/librte_ethdev/rte_flow.h
Quoted 2 lines
*/
lib/librte_ethdev/rte_flow.h +1
-0+/**< Direction of this connection when creating a flow, the value only
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+* affects the subsequent flows creation. +*/ + uint32_t is_original_dir:1; +/**< Enable / disable the conntrack HW module. When disabled, the
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+* result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED. +* In this state the HW will act as passthrough. +* It only affects this conntrack object in the HW without any effect
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+* to the other objects. +*/ + uint32_t enable:1; +/**< At least one ack was seen, after the connection was established.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 7 lines
*/
lib/librte_ethdev/rte_flow.h +6
-0+ uint32_t live_connection:1; +/**< Enable selective ACK on this connection. */ + uint32_t selective_ack:1; +/**< A challenge ack has passed. */ + uint32_t challenge_ack_passed:1; +/**< 1: The last packet is seen that comes from the original direction.
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+* 0: From the reply direction. +*/ + uint32_t last_direction:1; +/**< No TCP check will be done except the state change. */ + uint32_t liberal_mode:1; +/**< The current state of the connection. */ lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+enum rte_flow_conntrack_state state; +/**< Scaling factor for maximal allowed ACK window. */ +uint8_t max_ack_window; +/**< Maximal allowed number of retransmission times. */ +uint8_t retransmission_limit; +/**< TCP parameters of the original direction. */ +struct rte_flow_tcp_dir_param original_dir; +/**< TCP parameters of the reply direction. */ +struct rte_flow_tcp_dir_param reply_dir; +/**< The window value of the last packet passed this conntrack. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+uint16_t last_window; +enum rte_flow_conntrack_tcp_last_index last_index; +/**< The sequence of the last packet passed this conntrack. */ +uint32_t last_seq; +/**< The acknowledgement of the last packet passed this conntrack. */
lib/librte_ethdev/rte_flow.h
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+uint32_t last_ack; +/**< The total value ACK + payload length of the last packet passed
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* this conntrack. +*/ +uint32_t last_end; +}; + +/** +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Wrapper structure for the context update interface. +* Ports cannot support updating, and the only valid solution is to
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 6 lines
+ * destroy the old context and create a new one instead.
+ */lib/librte_ethdev/rte_flow.h +4
-0+struct rte_flow_modify_conntrack { +/**< New connection tracking parameters to be updated. */ +struct rte_flow_action_conntrack new_ct; +uint32_t direction:1 ;/**< The direction field will be updated. */
Quoted 10 lines
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+/**< All the other fields except direction will be updated. */ + uint32_t state:1; + uint32_t reserved:30; /**< Reserved bits for the future usage.*/ };
Quoted 6 lines
+
/**
* Field IDs forMODIFY_FIELDaction.
*/
--
2.19.0.windows.1
BR. Bing
Quoted 30 lines
Quoted 30 lines
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+ +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
Quoted 2 lines
+ *
+ * Configuration parameters for each direction of a TCPconnection.
Review
Quoted 3 lines
+ */
(quoted diff) +2
-0+struct rte_flow_tcp_dir_param { + uint32_t scale:4; /**< TCP window scaling factor, 0xF todisable. */
Quoted 1 line
+
uint32_tclose_initiated:1; /**< The FIN was sent by thisdirection. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+/**< An ACK packet has been received by this side. */ + uint32_t last_ack_seen:1; +/**< If set, indicates that there is unacked data of the connection. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+ uint32_t data_unacked:1; +/**< Maximal value of sequence + payload length over sent +* packets (next ACK from the opposite direction). +*/ +uint32_t sent_end; +/**< Maximal value of (ACK + window size) over received packet +
Quoted 4 lines
length
lib/librte_ethdev/rte_flow.h +3
-0+* over sent packet (maximal sequence could be sent). +*/ +uint32_t reply_end;
Quoted 6 lines
Quoted 2 lines
This comment is for all members that are part of the packet, Do you think it should be in network order?
Almost none of the fields are part of the packet. Indeed, most of them are calculated from the packets information. So I prefer to keep the host order easy for using and keep all the fields of the whole structure the same endianness format.
What do you think?
Can you mention it in the documentation and comments?
That all the values are in host byte order and need to be converted to network byte order if the HW needs it that way
Hi Ajit,
Quoted 48 lines
-----Original Message-----
From: Ajit Khaparde <[email protected]>
Sent: Saturday, April 17, 2021 5:47 AM
To: Bing Zhao <[email protected]>
Cc: Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 1/2] ethdev: introduce conntrack flow action and itemQuoted 17 lines
Quoted 17 lines
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+ +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
Quoted 2 lines
+ *
+ * Configuration parameters for each direction of a TCPconnection.
Review
Quoted 3 lines
+ */
(quoted diff) +2
-0+struct rte_flow_tcp_dir_param { + uint32_t scale:4; /**< TCP window scaling factor, 0xF todisable. */
Quoted 1 line
+
uint32_tclose_initiated:1; /**< The FIN was sent by thisdirection. */
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+/**< An ACK packet has been received by this side. */ + uint32_t last_ack_seen:1; +/**< If set, indicates that there is unacked data of the Quoted 7 lines
Quoted 7 lines
connection. */
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+ uint32_t data_unacked:1; +/**< Maximal value of sequence + payload length over sent +* packets (next ACK from the opposite direction). +*/ +uint32_t sent_end; +/**< Maximal value of (ACK + window size) over received packet
Quoted 7 lines
Quoted 7 lines
+
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2993
Quoted 4 lines
length
lib/librte_ethdev/rte_flow.h +3
-0+* over sent packet (maximal sequence could be sent). +*/ +uint32_t reply_end;This comment is for all members that are part of the packet, Do
you
Quoted 3 lines
Quoted 1 line
think it should be in network order?
Almost none of the fields are part of the packet. Indeed, most of
them are calculated from the packets information. So I prefer to keep the host order easy for using and
Quoted 8 lines
Quoted 1 line
keep all the fields of the whole structure the same endianness
format.
Quoted 1 line
What do you think?
Can you mention it in the documentation and comments? That all the values are in host byte order and need to be converted to
network byte order if the HW needs it that way
Sure, I think it would be better to add it in the documentation. What do you think?
BR. Bing
Quoted 55 lines · Bing Zhao
Hi Ajit,
Quoted 52 lines
-----Original Message-----
From: Ajit Khaparde <[email protected]>
Sent: Saturday, April 17, 2021 5:47 AM
To: Bing Zhao <[email protected]>
Cc: Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2 1/2] ethdev: introduce conntrack flow action and itemQuoted 17 lines
Quoted 17 lines
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = {
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+ +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice
Quoted 2 lines
+ *
+ * Configuration parameters for each direction of a TCPconnection.
Review
Quoted 3 lines
+ */
(quoted diff) +2
-0+struct rte_flow_tcp_dir_param { + uint32_t scale:4; /**< TCP window scaling factor, 0xF todisable. */
Quoted 1 line
+
uint32_tclose_initiated:1; /**< The FIN was sent by thisdirection. */
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+/**< An ACK packet has been received by this side. */ + uint32_t last_ack_seen:1; +/**< If set, indicates that there is unacked data of the Quoted 7 lines
Quoted 7 lines
connection. */
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+ uint32_t data_unacked:1; +/**< Maximal value of sequence + payload length over sent +* packets (next ACK from the opposite direction). +*/ +uint32_t sent_end; +/**< Maximal value of (ACK + window size) over received packet
Quoted 7 lines
Quoted 7 lines
+
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2993
Quoted 4 lines
length
lib/librte_ethdev/rte_flow.h +3
-0+* over sent packet (maximal sequence could be sent). +*/ +uint32_t reply_end;This comment is for all members that are part of the packet, Do
you
Quoted 3 lines
Quoted 1 line
think it should be in network order?
Almost none of the fields are part of the packet. Indeed, most of
them are calculated from the packets information. So I prefer to keep the host order easy for using and
Quoted 1 line
keep all the fields of the whole structure the same endianness
format.
Quoted 1 line
What do you think?
Quoted 7 lines
Quoted 4 lines
Can you mention it in the documentation and comments? That all the values are in host byte order and need to be converted to
network byte order if the HW needs it that waySure, I think it would be better to add it in the documentation. What do you think?
Documentation - yes.
In the comments of the structure in the header file - if possible.
Quoted 2 lines
BR. Bing
PATCH v2 2/2 app/testpmd: add CLI for conntrack
In reply to Bing ZhaoThe command line for testing connection tracking is added. To create a conntrack object, 3 parts are needed.
set conntrack com peer ...
set conntrack orig scale ...
set conntrack rply scale ...
This will create a full conntrack action structure for the indirect action. After the indirect action handle of "conntrack" created, it could be used in the flow creation. Before updating, the same structure is also needed together with the update command "conntrack_update" to update the "dir" or "ctx".
After the flow with conntrack action created, the packet should jump to the next flow for the result checking with conntrack item. The state is defined with bits and a valid combination could be supported.
--- app/test-pmd/cmdline.c | 354 ++++++++++++++++++++++++++++++++++++ app/test-pmd/cmdline_flow.c | 92 ++++++++++ app/test-pmd/config.c | 65 ++++++- app/test-pmd/testpmd.h | 2 + 4 files changed, 512 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +354 -0
@@ -13618,6 +13618,358 @@ cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { }, }; +/** Set connection tracking object common details */ +struct cmd_set_conntrack_common_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t conntrack; +cmdline_fixed_string_t common; +cmdline_fixed_string_t peer; +cmdline_fixed_string_t is_orig; +cmdline_fixed_string_t enable; +cmdline_fixed_string_t live; +cmdline_fixed_string_t sack; +cmdline_fixed_string_t cack; +cmdline_fixed_string_t last_dir; +cmdline_fixed_string_t liberal; +cmdline_fixed_string_t state; +cmdline_fixed_string_t max_ack_win; +cmdline_fixed_string_t retrans; +cmdline_fixed_string_t last_win; +cmdline_fixed_string_t last_seq; +cmdline_fixed_string_t last_ack; +cmdline_fixed_string_t last_end; +cmdline_fixed_string_t last_index; +uint8_t stat; +uint8_t factor; +uint16_t peer_port; +uint32_t is_original; +uint32_t en; +uint32_t is_live; +uint32_t s_ack; +uint32_t c_ack; +uint32_t ld; +uint32_t lb; +uint8_t re_num; +uint8_t li; +uint16_t lw; +uint32_t ls; +uint32_t la; +uint32_t le; +}; + +cmdline_parse_token_string_t cmd_set_conntrack_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + set,"set" ); +cmdline_parse_token_string_t cmd_set_conntrack_conntrack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + conntrack,"conntrack" ); +cmdline_parse_token_string_t cmd_set_conntrack_conntrack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + common,"com" ); +cmdline_parse_token_string_t cmd_set_conntrack_common_peer = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + peer,"peer" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + peer_port,RTE_UINT16 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + is_orig,"is_orig" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + is_original,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_enable = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + enable,"enable" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + en,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_live = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + live,"live" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_live_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + is_live,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_sack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + sack,"sack" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + s_ack,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_cack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + cack,"cack" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + c_ack,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_dir,"last_dir" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + ld,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_liberal = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + liberal,"liberal" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + lb,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_state = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + state,"state" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_state_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + stat,RTE_UINT8 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + max_ack_win,"max_ack_win" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + factor,RTE_UINT8 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_retrans = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + retrans,"r_lim" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + re_num,RTE_UINT8 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_win = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_win,"last_win" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + lw,RTE_UINT16 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_seq,"last_seq" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + ls,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_ack,"last_ack" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + la,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_end,"last_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + le,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_index = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_index,"last_index" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + li,RTE_UINT8 ); + +static void cmd_set_conntrack_common_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_conntrack_common_result *res = parsed_result; + +/* No need to swap to big endian. */ + conntrack_context.peer_port = res->peer_port; + conntrack_context.is_original_dir = res->is_original; + conntrack_context.enable = res->en; + conntrack_context.live_connection = res->is_live; + conntrack_context.selective_ack = res->s_ack; + conntrack_context.challenge_ack_passed = res->c_ack; + conntrack_context.last_direction = res->ld; + conntrack_context.liberal_mode = res->lb; + conntrack_context.state = (enum rte_flow_conntrack_state )res->stat; + conntrack_context.max_ack_window = res->factor; + conntrack_context.retransmission_limit = res->re_num; + conntrack_context.last_window = res->lw; + conntrack_context.last_index = + (enum rte_flow_conntrack_tcp_last_index )res->li; + conntrack_context.last_seq = res->ls; + conntrack_context.last_ack = res->la; + conntrack_context.last_end = res->le; +} + +cmdline_parse_inst_t cmd_set_conntrack_common = { + .f = cmd_set_conntrack_common_parsed, + .data =NULL , + .help_str ="set conntrack com peer <port_id> is_orig <dir> enable <en>" +" live <ack_seen> sack <en> cack <passed> last_dir <dir>" +" liberal <en> state <s> max_ack_win <factor> r_lim <num>" +" last_win <win> last_seq <seq> last_ack <ack> last_end <end>" +" last_index <flag>" , + .tokens = { + (void *)&cmd_set_conntrack_set, + (void *)&cmd_set_conntrack_conntrack, + (void *)&cmd_set_conntrack_common_peer, + (void *)&cmd_set_conntrack_common_peer_value, + (void *)&cmd_set_conntrack_common_is_orig, + (void *)&cmd_set_conntrack_common_is_orig_value, + (void *)&cmd_set_conntrack_common_enable, + (void *)&cmd_set_conntrack_common_enable_value, + (void *)&cmd_set_conntrack_common_live, + (void *)&cmd_set_conntrack_common_live_value, + (void *)&cmd_set_conntrack_common_sack, + (void *)&cmd_set_conntrack_common_sack_value, + (void *)&cmd_set_conntrack_common_cack, + (void *)&cmd_set_conntrack_common_cack_value, + (void *)&cmd_set_conntrack_common_last_dir, + (void *)&cmd_set_conntrack_common_last_dir_value, + (void *)&cmd_set_conntrack_common_liberal, + (void *)&cmd_set_conntrack_common_liberal_value, + (void *)&cmd_set_conntrack_common_state, + (void *)&cmd_set_conntrack_common_state_value, + (void *)&cmd_set_conntrack_common_max_ackwin, + (void *)&cmd_set_conntrack_common_max_ackwin_value, + (void *)&cmd_set_conntrack_common_retrans, + (void *)&cmd_set_conntrack_common_retrans_value, + (void *)&cmd_set_conntrack_common_last_win, + (void *)&cmd_set_conntrack_common_last_win_value, + (void *)&cmd_set_conntrack_common_last_seq, + (void *)&cmd_set_conntrack_common_last_seq_value, + (void *)&cmd_set_conntrack_common_last_ack, + (void *)&cmd_set_conntrack_common_last_ack_value, + (void *)&cmd_set_conntrack_common_last_end, + (void *)&cmd_set_conntrack_common_last_end_value, + (void *)&cmd_set_conntrack_common_last_index, + (void *)&cmd_set_conntrack_common_last_index_value, +NULL , + }, +}; + +/** Set connection tracking object both directions' details */ +struct cmd_set_conntrack_dir_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t conntrack; +cmdline_fixed_string_t dir; +cmdline_fixed_string_t scale; +cmdline_fixed_string_t fin; +cmdline_fixed_string_t ack_seen; +cmdline_fixed_string_t unack; +cmdline_fixed_string_t sent_end; +cmdline_fixed_string_t reply_end; +cmdline_fixed_string_t max_win; +cmdline_fixed_string_t max_ack; +uint32_t factor; +uint32_t f; +uint32_t as; +uint32_t un; +uint32_t se; +uint32_t re; +uint32_t mw; +uint32_t ma; +}; + +cmdline_parse_token_string_t cmd_set_conntrack_dir_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + set,"set" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + conntrack,"conntrack" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_dir = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + dir,"orig#rply" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_scale = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + scale,"scale" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + factor,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_fin = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + fin,"fin" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + f,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + ack_seen,"acked" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + as,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + unack,"unack_data" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + un,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + sent_end,"sent_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + se,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + reply_end,"reply_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + re,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + max_win,"max_win" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + mw,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + max_ack,"max_ack" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + ma,RTE_UINT32 ); + +static void cmd_set_conntrack_dir_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_conntrack_dir_result *res = parsed_result; +struct rte_flow_tcp_dir_param *dir =NULL ; + +if (strcmp (res->dir,"orig" ) ==0 ) + dir = &conntrack_context.original_dir; +else if (strcmp (res->dir,"rply" ) ==0 ) + dir = &conntrack_context.reply_dir; +else +return ; + dir->scale = res->factor; + dir->close_initiated = res->f; + dir->last_ack_seen = res->as; + dir->data_unacked = res->un; + dir->sent_end = res->se; + dir->reply_end = res->re; + dir->max_ack = res->ma; + dir->max_win = res->mw; +} + +cmdline_parse_inst_t cmd_set_conntrack_dir = { + .f = cmd_set_conntrack_dir_parsed, + .data =NULL , + .help_str ="set conntrack orig|rply scale <factor> fin <sent>" +" acked <seen> unack_data <unack> sent_end <sent>" +" reply_end <reply> max_win <win> max_ack <ack>" , + .tokens = { + (void *)&cmd_set_conntrack_set, + (void *)&cmd_set_conntrack_conntrack, + (void *)&cmd_set_conntrack_dir_dir, + (void *)&cmd_set_conntrack_dir_scale, + (void *)&cmd_set_conntrack_dir_scale_value, + (void *)&cmd_set_conntrack_dir_fin, + (void *)&cmd_set_conntrack_dir_fin_value, + (void *)&cmd_set_conntrack_dir_ack, + (void *)&cmd_set_conntrack_dir_ack_value, + (void *)&cmd_set_conntrack_dir_unack_data, + (void *)&cmd_set_conntrack_dir_unack_data_value, + (void *)&cmd_set_conntrack_dir_sent_end, + (void *)&cmd_set_conntrack_dir_sent_end_value, + (void *)&cmd_set_conntrack_dir_reply_end, + (void *)&cmd_set_conntrack_dir_reply_end_value, + (void *)&cmd_set_conntrack_dir_max_win, + (void *)&cmd_set_conntrack_dir_max_win_value, + (void *)&cmd_set_conntrack_dir_max_ack, + (void *)&cmd_set_conntrack_dir_max_ack_value, +NULL , + }, +}; +/* Strict link priority scheduling mode setting */ static void cmd_strict_link_prio_parsed(
@@ -17117,6 +17469,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, + (cmdline_parse_inst_t *)&cmd_set_conntrack_common, + (cmdline_parse_inst_t *)&cmd_set_conntrack_dir, (cmdline_parse_inst_t *)&cmd_ddp_add, (cmdline_parse_inst_t *)&cmd_ddp_del, (cmdline_parse_inst_t *)&cmd_ddp_get_list,
app/test-pmd/cmdline_flow.c +92 -0
152 lines not on this page · raw message
app/test-pmd/config.c +64 -1
87 lines not on this page · raw message
app/test-pmd/testpmd.h +2 -0
@@ -630,6 +630,8 @@ extern struct mplsoudp_decap_conf mplsoudp_decap_conf;extern enum rte_eth_rx_mq_mode rx_mq_mode; +extern struct rte_flow_action_conntrack conntrack_context; +static inline unsigned int lcore_num (void ) {
Signature · 1 line
2.19.0.windows.1
Re: [dpdk-dev] [PATCH v2 2/2] app/testpmd: add CLI for conntrack
Hi Bing,
1. you are missing the documentation patch. doc/guides/testpmd_app_ug/testpmd_funcs.rst please make sure that you add examples at the and of fil. you can see example in the integrity patch.
Quoted 16 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, April 15, 2021 7:41 PM
Subject: [PATCH v2 2/2] app/testpmd: add CLI for conntrackThe command line for testing connection tracking is added. To create a conntrack object, 3 parts are needed.
set conntrack com peer ...
set conntrack orig scale ...
set conntrack rply scale ...
This will create a full conntrack action structure for the indirect action. After the indirect action handle of "conntrack" created, it could be used in the flow creation. Before updating, the same structure is also needed together with the update command "conntrack_update" to update the "dir" or "ctx".
Quoted 5 lines
After the flow with conntrack action created, the packet should jump to the next flow for the result checking with conntrack item. The state is defined with bits and a valid combination could be supported.
Can you please add more detail examples?
Also what is the command to update and use the connection tracking action and item.
Quoted 44 lines
Signed-off-by Bing Zhao <[email protected]>--- app/test-pmd/cmdline.c | 354 ++++++++++++++++++++++++++++++++++++ app/test-pmd/cmdline_flow.c | 92 ++++++++++ app/test-pmd/config.c | 65 ++++++- app/test-pmd/testpmd.h | 2 + 4 files changed, 512 insertions(+), 1 deletion(-)app/test-pmd/cmdline.c +27
-0@@ -13618,6 +13618,358 @@ cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { }, }; +/** Set connection tracking object common details */ +struct cmd_set_conntrack_common_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t conntrack; +cmdline_fixed_string_t common; +cmdline_fixed_string_t peer; +cmdline_fixed_string_t is_orig; +cmdline_fixed_string_t enable; +cmdline_fixed_string_t live; +cmdline_fixed_string_t sack; +cmdline_fixed_string_t cack; +cmdline_fixed_string_t last_dir; +cmdline_fixed_string_t liberal; +cmdline_fixed_string_t state; +cmdline_fixed_string_t max_ack_win; +cmdline_fixed_string_t retrans; +cmdline_fixed_string_t last_win; +cmdline_fixed_string_t last_seq; +cmdline_fixed_string_t last_ack; +cmdline_fixed_string_t last_end; +cmdline_fixed_string_t last_index; +uint8_t stat; +uint8_t factor; +uint16_t peer_port; +uint32_t is_original; +uint32_t en; +uint32_t is_live;
app/test-pmd/cmdline.c cmdline_parse_inst_t · line 13658
Quoted 10 lines
app/test-pmd/cmdline.c +10
-0+uint32_t s_ack; +uint32_t c_ack; +uint32_t ld; +uint32_t lb; +uint8_t re_num; +uint8_t li; +uint16_t lw; +uint32_t ls; +uint32_t la; +uint32_t le;
Why not use full names?
Quoted 636 lines
app/test-pmd/cmdline.c +10
-0+}; + +cmdline_parse_token_string_t cmd_set_conntrack_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + set,"set" ); +cmdline_parse_token_string_t cmd_set_conntrack_conntrack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + conntrack,"conntrack" ); +cmdline_parse_token_string_t cmd_set_conntrack_conntrack = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +3
-0+ common, "com"); +cmdline_parse_token_string_t cmd_set_conntrack_common_peer = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ peer, "peer"); +cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + peer_port,RTE_UINT16 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ is_orig, "is_orig"); +cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + is_original,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_enable = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ enable, "enable"); +cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + en,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_live = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ live, "live"); +cmdline_parse_token_num_t cmd_set_conntrack_common_live_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + is_live,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_sack = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ sack, "sack"); +cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + s_ack,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_cack = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ cack, "cack"); +cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + c_ack,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ last_dir, "last_dir"); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + ld,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_liberal = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ liberal, "liberal"); +cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + lb,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_state = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ state, "state"); +cmdline_parse_token_num_t cmd_set_conntrack_common_state_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + stat,RTE_UINT8 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +2
-0+ max_ack_win, "max_ack_win"); +cmdline_parse_token_num_t
cmd_set_conntrack_common_max_ackwin_value=app/test-pmd/cmdline.c +4
-0+ TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + factor, RTE_UINT8); +cmdline_parse_token_string_t cmd_set_conntrack_common_retrans = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ retrans, "r_lim"); +cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + re_num,RTE_UINT8 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_win = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ last_win, "last_win"); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + lw,RTE_UINT16 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ last_seq, "last_seq"); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + ls,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ last_ack, "last_ack"); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + la,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_end = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ last_end, "last_end"); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + le,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_index = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +2
-0+ last_index, "last_index"); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value=
app/test-pmd/cmdline.c +33
-0+ TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + li, RTE_UINT8); + +static void cmd_set_conntrack_common_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_conntrack_common_result *res = parsed_result; + +/* No need to swap to big endian. */ + conntrack_context.peer_port = res->peer_port; + conntrack_context.is_original_dir = res->is_original; + conntrack_context.enable = res->en; + conntrack_context.live_connection = res->is_live; + conntrack_context.selective_ack = res->s_ack; + conntrack_context.challenge_ack_passed = res->c_ack; + conntrack_context.last_direction = res->ld; + conntrack_context.liberal_mode = res->lb; + conntrack_context.state = (enum rte_flow_conntrack_state )res->stat; + conntrack_context.max_ack_window = res->factor; + conntrack_context.retransmission_limit = res->re_num; + conntrack_context.last_window = res->lw; + conntrack_context.last_index = + (enum rte_flow_conntrack_tcp_last_index )res->li; + conntrack_context.last_seq = res->ls; + conntrack_context.last_ack = res->la; + conntrack_context.last_end = res->le; +} + +cmdline_parse_inst_t cmd_set_conntrack_common = { + .f = cmd_set_conntrack_common_parsed, + .data =NULL , + .help_str = "set conntrack com peer <port_id> is_orig <dir> enable<en>"
app/test-pmd/cmdline.c +3
-0+" live <ack_seen> sack <en> cack <passed> last_dir <dir>" +" liberal <en> state <s> max_ack_win <factor> r_lim <num>" + " last_win <win> last_seq <seq> last_ack <ack> last_end<end>"
app/test-pmd/cmdline.c +176
-0+ " last_index <flag>", + .tokens = { + (void *)&cmd_set_conntrack_set, + (void *)&cmd_set_conntrack_conntrack, + (void *)&cmd_set_conntrack_common_peer, + (void *)&cmd_set_conntrack_common_peer_value, + (void *)&cmd_set_conntrack_common_is_orig, + (void *)&cmd_set_conntrack_common_is_orig_value, + (void *)&cmd_set_conntrack_common_enable, + (void *)&cmd_set_conntrack_common_enable_value, + (void *)&cmd_set_conntrack_common_live, + (void *)&cmd_set_conntrack_common_live_value, + (void *)&cmd_set_conntrack_common_sack, + (void *)&cmd_set_conntrack_common_sack_value, + (void *)&cmd_set_conntrack_common_cack, + (void *)&cmd_set_conntrack_common_cack_value, + (void *)&cmd_set_conntrack_common_last_dir, + (void *)&cmd_set_conntrack_common_last_dir_value, + (void *)&cmd_set_conntrack_common_liberal, + (void *)&cmd_set_conntrack_common_liberal_value, + (void *)&cmd_set_conntrack_common_state, + (void *)&cmd_set_conntrack_common_state_value, + (void *)&cmd_set_conntrack_common_max_ackwin, + (void *)&cmd_set_conntrack_common_max_ackwin_value, + (void *)&cmd_set_conntrack_common_retrans, + (void *)&cmd_set_conntrack_common_retrans_value, + (void *)&cmd_set_conntrack_common_last_win, + (void *)&cmd_set_conntrack_common_last_win_value, + (void *)&cmd_set_conntrack_common_last_seq, + (void *)&cmd_set_conntrack_common_last_seq_value, + (void *)&cmd_set_conntrack_common_last_ack, + (void *)&cmd_set_conntrack_common_last_ack_value, + (void *)&cmd_set_conntrack_common_last_end, + (void *)&cmd_set_conntrack_common_last_end_value, + (void *)&cmd_set_conntrack_common_last_index, + (void *)&cmd_set_conntrack_common_last_index_value, + NULL, + }, +}; + +/** Set connection tracking object both directions' details */ +struct cmd_set_conntrack_dir_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t conntrack; +cmdline_fixed_string_t dir; +cmdline_fixed_string_t scale; +cmdline_fixed_string_t fin; +cmdline_fixed_string_t ack_seen; +cmdline_fixed_string_t unack; +cmdline_fixed_string_t sent_end; +cmdline_fixed_string_t reply_end; +cmdline_fixed_string_t max_win; +cmdline_fixed_string_t max_ack; +uint32_t factor; +uint32_t f; +uint32_t as; +uint32_t un; +uint32_t se; +uint32_t re; +uint32_t mw; +uint32_t ma; +}; + +cmdline_parse_token_string_t cmd_set_conntrack_dir_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + set,"set" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + conntrack,"conntrack" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_dir = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + dir,"orig#rply" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_scale = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + scale,"scale" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + factor,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_fin = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + fin,"fin" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + f,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + ack_seen,"acked" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + as,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + unack,"unack_data" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + un,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + sent_end,"sent_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + se,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + reply_end,"reply_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + re,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + max_win,"max_win" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + mw,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + max_ack,"max_ack" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + ma,RTE_UINT32 ); + +static void cmd_set_conntrack_dir_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_conntrack_dir_result *res = parsed_result; +struct rte_flow_tcp_dir_param *dir =NULL ; + +if (strcmp (res->dir,"orig" ) ==0 ) + dir = &conntrack_context.original_dir; +else if (strcmp (res->dir,"rply" ) ==0 ) + dir = &conntrack_context.reply_dir; +else +return ; + dir->scale = res->factor; + dir->close_initiated = res->f; + dir->last_ack_seen = res->as; + dir->data_unacked = res->un; + dir->sent_end = res->se; + dir->reply_end = res->re; + dir->max_ack = res->ma; + dir->max_win = res->mw; +} + +cmdline_parse_inst_t cmd_set_conntrack_dir = { + .f = cmd_set_conntrack_dir_parsed, + .data =NULL , + .help_str ="set conntrack orig|rply scale <factor> fin <sent>" +" acked <seen> unack_data <unack> sent_end <sent>" +" reply_end <reply> max_win <win> max_ack <ack>" , + .tokens = { + (void *)&cmd_set_conntrack_set, + (void *)&cmd_set_conntrack_conntrack, + (void *)&cmd_set_conntrack_dir_dir, + (void *)&cmd_set_conntrack_dir_scale, + (void *)&cmd_set_conntrack_dir_scale_value, + (void *)&cmd_set_conntrack_dir_fin, + (void *)&cmd_set_conntrack_dir_fin_value, + (void *)&cmd_set_conntrack_dir_ack, + (void *)&cmd_set_conntrack_dir_ack_value, + (void *)&cmd_set_conntrack_dir_unack_data, + (void *)&cmd_set_conntrack_dir_unack_data_value, + (void *)&cmd_set_conntrack_dir_sent_end, + (void *)&cmd_set_conntrack_dir_sent_end_value, + (void *)&cmd_set_conntrack_dir_reply_end, + (void *)&cmd_set_conntrack_dir_reply_end_value, + (void *)&cmd_set_conntrack_dir_max_win, + (void *)&cmd_set_conntrack_dir_max_win_value, + (void *)&cmd_set_conntrack_dir_max_ack, + (void *)&cmd_set_conntrack_dir_max_ack_value, +NULL , + }, +}; +/* Strict link priority scheduling mode setting */ static void cmd_strict_link_prio_parsed(@@ -17117,6 +17469,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, + (cmdline_parse_inst_t *)&cmd_set_conntrack_common, + (cmdline_parse_inst_t *)&cmd_set_conntrack_dir, (cmdline_parse_inst_t *)&cmd_ddp_add, (cmdline_parse_inst_t *)&cmd_ddp_del, (cmdline_parse_inst_t *)&cmd_ddp_get_list,app/test-pmd/cmdline_flow.c +17
-0@@ -289,6 +289,7 @@ enum index {ITEM_GENEVE_OPT_TYPE ,ITEM_GENEVE_OPT_LENGTH ,ITEM_GENEVE_OPT_DATA , +ITEM_CONNTRACK ,/* Validate/create actions. */ ACTIONS,@@ -427,6 +428,10 @@ enum index {ACTION_MODIFY_FIELD_SRC_OFFSET ,ACTION_MODIFY_FIELD_SRC_VALUE ,ACTION_MODIFY_FIELD_WIDTH , +ACTION_CONNTRACK , +ACTION_CONNTRACK_UPDATE , +ACTION_CONNTRACK_UPDATE_DIR , + ACTION_CONNTRACK_UPDATE_CTX, };/** Maximum size for pattern in struct rte_flow_item_raw. */ @@ -565,6 +570,8 @@ struct mplsoudp_encap_conf mplsoudp_encap_conf;struct mplsoudp_decap_conf mplsoudp_decap_conf; +struct rte_flow_action_conntrack conntrack_context; +#define ACTION_SAMPLE_ACTIONS_NUM 10#define RAW_SAMPLE_CONFS_MAX_NUM 8/** Storage for struct rte_flow_action_sample including external data. */ @@ -956,6 +963,7 @@ static const enum index next_item[] = {ITEM_PFCP ,ITEM_ECPRI ,ITEM_GENEVE_OPT , +ITEM_CONNTRACK ,END_SET , ZERO, };@@ -1370,6 +1378,8 @@ static const enum index next_action[] = {ACTION_SAMPLE ,ACTION_INDIRECT ,ACTION_MODIFY_FIELD , +ACTION_CONNTRACK , +ACTION_CONNTRACK_UPDATE , ZERO, };@@ -1638,6 +1648,13 @@ static const enum index action_modify_field_src[] = { ZERO, }; +static const enum index action_update_conntrack[] = { +ACTION_CONNTRACK_UPDATE_DIR , +ACTION_CONNTRACK_UPDATE_CTX , +ACTION_NEXT , +ZERO , +}; + static int parse_set_raw_encap_decap(struct context *, const struct token *, const char *, unsigned int,app/test-pmd/cmdline_flow.c +4
-0void *, unsigned int);@@ -1728,6 +1745,10 @@ static int parse_vc_modify_field_id(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); +static int +parse_vc_action_conntrack_update (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size); static int parse_destroy(struct context *, const struct token *, const char *, unsigned int,app/test-pmd/cmdline_flow.c +7
-0void *, unsigned int);@@ -3373,6 +3394,13 @@ static const struct token token_list[] = { (sizeof (struct rte_flow_item_geneve_opt ), ITEM_GENEVE_OPT_DATA_SIZE)), }, + [ITEM_CONNTRACK] = { + .name = "conntrack", + .help = "conntrack state", + .next =NEXT (NEXT_ENTRY (ITEM_NEXT ),NEXT_ENTRY (UNSIGNED ), + item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)), + },/* Validate/create actions. */ app/test-pmd/cmdline_flow.c +64
-0[ACTIONS] = { .name = "actions",@@ -4471,6 +4499,34 @@ static const struct token token_list[] = { .call = parse_vc_action_sample_index, .comp = comp_set_sample_index, }, + [ACTION_CONNTRACK] = { + .name = "conntrack", + .help = "create a conntrack object", + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .priv =PRIV_ACTION (CONNTRACK , + sizeof(struct rte_flow_action_conntrack)), + .call = parse_vc, + }, + [ACTION_CONNTRACK_UPDATE] = { + .name = "conntrack_update", + .help = "update a conntrack object", + .next = NEXT(action_update_conntrack), + .priv =PRIV_ACTION (CONNTRACK , + sizeof(struct rte_flow_modify_conntrack)), + .call = parse_vc, + }, + [ACTION_CONNTRACK_UPDATE_DIR] = { + .name = "dir", + .help = "update a conntrack object direction", + .next = NEXT(action_update_conntrack), + .call = parse_vc_action_conntrack_update, + }, + [ACTION_CONNTRACK_UPDATE_CTX] = { + .name = "ctx", + .help = "update a conntrack object context", + .next = NEXT(action_update_conntrack), + .call = parse_vc_action_conntrack_update, + },/* Indirect action destroy arguments. */ [INDIRECT_ACTION_DESTROY_ID] = { .name = "action_id",@@ -6277,6 +6333,42 @@ parse_vc_modify_field_id(struct context *ctx, conststruct token *token, return len; } +/** Parse the conntrack update, not a rte_flow_action. */ +static int +parse_vc_action_conntrack_update (struct context *ctx,const struct token *token, +const char *str,unsigned int len,void *buf, +unsigned int size) +{ +struct buffer *out = buf; +struct rte_flow_modify_conntrack *ct_modify =NULL ; + + (void )size; +if (ctx->curr !=ACTION_CONNTRACK_UPDATE_CTX && + ctx->curr !=ACTION_CONNTRACK_UPDATE_DIR ) +return -1 ; +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; + ct_modify = (struct rte_flow_modify_conntrack *)out->args.vc.data; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (ctx->curr ==ACTION_CONNTRACK_UPDATE_DIR ) { + ct_modify->new_ct.is_original_dir = + conntrack_context.is_original_dir; + ct_modify->direction =1 ; + }else { +uint32_t old_dir; + + old_dir = ct_modify->new_ct.is_original_dir; +memcpy (&ct_modify->new_ct, &conntrack_context, +sizeof (conntrack_context)); + ct_modify->new_ct.is_original_dir = old_dir; + ct_modify->state =1 ; + } +return len; +} +/** Parse tokens for destroy command. */ static int
parse_destroy(struct context *ctx, const struct token *token,app/test-pmd/config.c +5
-0@@ -1483,6 +1483,11 @@ port_action_handle_create(portid_t port_id,uint32_t id, pia->age_type =ACTION_AGE_CONTEXT_TYPE_INDIRECT_ACTION ; age->context = &pia->age_type; + }else if (action->type ==RTE_FLOW_ACTION_TYPE_CONNTRACK ) { +struct rte_flow_action_conntrack *ct = + (struct rte_flow_action_conntrack *)(uintptr_t )(action->conf); + +memcpy (ct, &conntrack_context,sizeof (*ct)); }app/test-pmd/config.c +14
-1/* Poisoning to make sure PMDs update it in case of error. */ memset (&error,0x22 ,sizeof (error));@@ -1564,11 +1569,24 @@ port_action_handle_update(portid_t port_id, uint32_t id, {struct rte_flow_error error;struct rte_flow_action_handle *action_handle; +struct port_indirect_action *pia; +const void *update; action_handle =port_action_handle_get_by_id (port_id, id);if (!action_handle)return -EINVAL ; -if (rte_flow_action_handle_update (port_id, action_handle, action, + pia =action_get_by_id (port_id, id); +if (!pia) +return -EINVAL ; +switch (pia->type) { +case RTE_FLOW_ACTION_TYPE_CONNTRACK : + update = action->conf; +break ; +default : + update = action; +break ; + } +if (rte_flow_action_handle_update (port_id, action_handle, update, &error)) {return port_flow_complain (&error);app/test-pmd/config.c +45
-0}@@ -1621,6 +1639,51 @@ port_action_handle_query(portid_t port_id, uint32_t id) } data =NULL ;break ; +case RTE_FLOW_ACTION_TYPE_CONNTRACK : +if (!ret) { +struct rte_flow_action_conntrack *ct = data; + +printf ("Conntrack Context:\n" +" Peer: %u, Flow dir: %s, Enable: %u\n" +" Live: %u, SACK: %u, CACK: %u\n" +" Packet dir: %s, Liberal: %u, State: %u\n" +" Factor: %u, Retrans: %u, TCP flags: %u\n" +" Last Seq: %u, Last ACK: %u\n" +" Last Win: %u, Last End: %u\n" , + ct->peer_port, + ct->is_original_dir ?"Original" :"Reply" , + ct->enable, ct->live_connection, + ct->selective_ack, ct->challenge_ack_passed, + ct->last_direction ?"Original" :"Reply" , + ct->liberal_mode, ct->state, + ct->max_ack_window, ct->retransmission_limit, + ct->last_index, ct->last_seq, ct->last_ack, + ct->last_window, ct->last_end); +printf (" Original Dir:\n" +" scale: %u, fin: %u, ack seen: %u\n" +" unacked data: %u\n Sent end: %u," +" Reply end: %u, Max win: %u, Max ACK: %u\n" , + ct->original_dir.scale, + ct->original_dir.close_initiated, + ct->original_dir.last_ack_seen, + ct->original_dir.data_unacked, + ct->original_dir.sent_end, + ct->original_dir.reply_end, + ct->original_dir.max_win, + ct->original_dir.max_ack); +printf (" Reply Dir:\n" +" scale: %u, fin: %u, ack seen: %u\n" +" unacked data: %u\n Sent end: %u," +" Reply end: %u, Max win: %u, Max ACK: %u\n" , + ct->reply_dir.scale, + ct->reply_dir.close_initiated, + ct->reply_dir.last_ack_seen, + ct->reply_dir.data_unacked, + ct->reply_dir.sent_end, ct->reply_dir.reply_end, + ct->reply_dir.max_win, ct->reply_dir.max_ack); + } + data =NULL ; +break ;default : printf("Indirect action %u (type: %d) on port %u doesn't"app/test-pmd/config.c +0
-0" support query\n", id, pia->type, port_id);app/test-pmd/testpmd.h +2
-0@@ -630,6 +630,8 @@ extern struct mplsoudp_decap_conf mplsoudp_decap_conf;extern enum rte_eth_rx_mq_mode rx_mq_mode; +extern struct rte_flow_action_conntrack conntrack_context; +static inline unsigned int lcore_num (void ){
--
2.19.0.windows.1
Re: [dpdk-dev] [PATCH v2 2/2] app/testpmd: add CLI for conntrack
Hi Ori,
Quoted 9 lines
-----Original Message-----
From: Ori Kam <[email protected]>
Sent: Friday, April 16, 2021 4:47 PM
To: Bing Zhao <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: RE: [PATCH v2 2/2] app/testpmd: add CLI for conntrack
Quoted 5 lines
Hi Bing,
1. you are missing the documentation patch.doc/guides/testpmd_app_ug/testpmd_funcs.rstplease make sure that you add examples at the and of fil. you can see example in the integrity patch.
Simple example is added for doc in the new patch set.
Quoted 21 lines
Quoted 7 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Thursday, April 15, 2021 7:41 PM
Subject: [PATCH v2 2/2] app/testpmd: add CLI for conntrackThe command line for testing connection tracking is added. To
create a
Quoted 5 lines
conntrack object, 3 parts are needed.
set conntrack com peer ...
set conntrack orig scale ...
set conntrack rply scale ...
This will create a full conntrack action structure for theindirect
Quoted 1 line
action. After the indirect action handle of "conntrack" created,
it
Quoted 5 lines
could be used in the flow creation. Before updating, the same structure is also needed together with the update command "
conntrack_update" to update the "dir" or "ctx".After the flow with conntrack action created, the packet should
Quoted 9 lines
jump
Quoted 2 lines
to the next flow for the result checking with conntrack item. The state is defined with bits and a valid combination could be
supported.
Quoted 1 line
Can you please add more detail examples?
Also what is the command to update and use the connection tracking action and item.
Not sure if all the details should be listed here, maybe the doc is enough?
Quoted 723 lines
Quoted 4 lines
Signed-off-by Bing Zhao <[email protected]>--- app/test-pmd/cmdline.c | 354++++++++++++++++++++++++++++++++++++
Quoted 41 lines
app/test-pmd/cmdline_flow.c | 92 ++++++++++ app/test-pmd/config.c | 65 ++++++- app/test-pmd/testpmd.h | 2 + 4 files changed, 512 insertions(+), 1 deletion(-)app/test-pmd/cmdline.c index renamed from app/test-pmd/cmdline.c +0
-0
c28a3d2e5d..58ab7191d6100644app/test-pmd/cmdline.c +27
-0@@ -13618,6 +13618,358 @@ cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { }, }; +/** Set connection tracking object common details */ struct +cmd_set_conntrack_common_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t conntrack; +cmdline_fixed_string_t common; +cmdline_fixed_string_t peer; +cmdline_fixed_string_t is_orig; +cmdline_fixed_string_t enable; +cmdline_fixed_string_t live; +cmdline_fixed_string_t sack; +cmdline_fixed_string_t cack; +cmdline_fixed_string_t last_dir; +cmdline_fixed_string_t liberal; +cmdline_fixed_string_t state; +cmdline_fixed_string_t max_ack_win; +cmdline_fixed_string_t retrans; +cmdline_fixed_string_t last_win; +cmdline_fixed_string_t last_seq; +cmdline_fixed_string_t last_ack; +cmdline_fixed_string_t last_end; +cmdline_fixed_string_t last_index; +uint8_t stat; +uint8_t factor; +uint16_t peer_port; +uint32_t is_original; +uint32_t en; +uint32_t is_live;app/test-pmd/cmdline.c cmdline_parse_inst_t · line 13658
Quoted 10 lines
app/test-pmd/cmdline.c +10
-0+uint32_t s_ack; +uint32_t c_ack; +uint32_t ld; +uint32_t lb; +uint8_t re_num; +uint8_t li; +uint16_t lw; +uint32_t ls; +uint32_t la; +uint32_t le;Why not use full names?
Quoted 24 lines
app/test-pmd/cmdline.c +10
-0+}; + +cmdline_parse_token_string_t cmd_set_conntrack_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + set,"set" ); +cmdline_parse_token_string_t cmd_set_conntrack_conntrack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + conntrack,"conntrack" ); +cmdline_parse_token_string_t cmd_set_conntrack_conntrack = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +3
-0+ common, "com"); +cmdline_parse_token_string_t cmd_set_conntrack_common_peer = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ peer, "peer"); +cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + peer_port,RTE_UINT16 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c
Quoted 2 lines
app/test-pmd/cmdline.c +2
-0+ is_orig, "is_orig"); +cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value=
Quoted 33 lines
app/test-pmd/cmdline.c +4
-0+ TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + is_original, RTE_UINT32); +cmdline_parse_token_string_t cmd_set_conntrack_common_enable = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ enable, "enable"); +cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + en,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_live = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ live, "live"); +cmdline_parse_token_num_t cmd_set_conntrack_common_live_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + is_live,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_sack = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ sack, "sack"); +cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + s_ack,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_cack = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +6
-0+ cack, "cack"); +cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + c_ack,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c
Quoted 2 lines
app/test-pmd/cmdline.c +2
-0+ last_dir, "last_dir"); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value=
app/test-pmd/cmdline.c
Quoted 7 lines
app/test-pmd/cmdline.c +4
-0+ TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + ld, RTE_UINT32); +cmdline_parse_token_string_t cmd_set_conntrack_common_liberal = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +2
-0+ liberal, "liberal"); +cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value=
app/test-pmd/cmdline.c cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
Quoted 10 lines
app/test-pmd/cmdline.c +4
-0+ TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + lb, RTE_UINT32); +cmdline_parse_token_string_t cmd_set_conntrack_common_state = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +5
-0+ state, "state"); +cmdline_parse_token_num_t cmd_set_conntrack_common_state_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + stat,RTE_UINT8 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin=
app/test-pmd/cmdline.c
Quoted 12 lines
app/test-pmd/cmdline.c +1
-0+ TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +2
-0+ max_ack_win, "max_ack_win"); +cmdline_parse_token_num_t
cmd_set_conntrack_common_max_ackwin_value=app/test-pmd/cmdline.c +4
-0+ TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + factor, RTE_UINT8); +cmdline_parse_token_string_t cmd_set_conntrack_common_retrans = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +2
-0+ retrans, "r_lim"); +cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value=
app/test-pmd/cmdline.c
Quoted 7 lines
app/test-pmd/cmdline.c +4
-0+ TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + re_num, RTE_UINT8); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_win = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +2
-0+ last_win, "last_win"); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value=
app/test-pmd/cmdline.c
Quoted 7 lines
app/test-pmd/cmdline.c +4
-0+ TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + lw, RTE_UINT16); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +2
-0+ last_seq, "last_seq"); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value=
app/test-pmd/cmdline.c
Quoted 7 lines
app/test-pmd/cmdline.c +4
-0+ TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + ls, RTE_UINT32); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +2
-0+ last_ack, "last_ack"); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value=
app/test-pmd/cmdline.c
Quoted 7 lines
app/test-pmd/cmdline.c +4
-0+ TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + la, RTE_UINT32); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_end = + TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +2
-0+ last_end, "last_end"); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value=
app/test-pmd/cmdline.c cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
Quoted 3 lines
app/test-pmd/cmdline.c +3
-0+ TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + le, RTE_UINT32); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_index=
app/test-pmd/cmdline.c
Quoted 4 lines
app/test-pmd/cmdline.c +1
-0+ TOKEN_STRING_INITIALIZER(struct
cmd_set_conntrack_common_result,app/test-pmd/cmdline.c +2
-0+ last_index, "last_index"); +cmdline_parse_token_num_t
cmd_set_conntrack_common_last_index_valueQuoted 24 lines
=
app/test-pmd/cmdline.c +19
-0+ TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + li, RTE_UINT8); + +static void cmd_set_conntrack_common_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_conntrack_common_result *res = parsed_result; + +/* No need to swap to big endian. */ + conntrack_context.peer_port = res->peer_port; + conntrack_context.is_original_dir = res->is_original; + conntrack_context.enable = res->en; + conntrack_context.live_connection = res->is_live; + conntrack_context.selective_ack = res->s_ack; + conntrack_context.challenge_ack_passed = res->c_ack; + conntrack_context.last_direction = res->ld; + conntrack_context.liberal_mode = res->lb; + conntrack_context.state = (enum rte_flow_conntrack_state)res-stat;
app/test-pmd/cmdline.c +3
-0+ conntrack_context.max_ack_window = res->factor; + conntrack_context.retransmission_limit = res->re_num; + conntrack_context.last_window = res->lw;app/test-pmd/cmdline.c cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
Quoted 10 lines
app/test-pmd/cmdline.c +10
-0+ conntrack_context.last_index = + (enum rte_flow_conntrack_tcp_last_index )res->li; + conntrack_context.last_seq = res->ls; + conntrack_context.last_ack = res->la; + conntrack_context.last_end = res->le; } + +cmdline_parse_inst_t cmd_set_conntrack_common = { + .f = cmd_set_conntrack_common_parsed, + .data =NULL , + .help_str = "set conntrack com peer <port_id> is_orig <dir>enable
app/test-pmd/cmdline.c
Quoted 2 lines
<en>"
app/test-pmd/cmdline.c +1
-0+ " live <ack_seen> sack <en> cack <passed> last_dir<dir>"
app/test-pmd/cmdline.c
Quoted 1 line
app/test-pmd/cmdline.c +1
-0+ " liberal <en> state <s> max_ack_win <factor> r_lim<num>"
Quoted 33 lines
app/test-pmd/cmdline.c +1
-0+ " last_win <win> last_seq <seq> last_ack <ack> last_end<end>"
app/test-pmd/cmdline.c +31
-0+ " last_index <flag>", + .tokens = { + (void *)&cmd_set_conntrack_set, + (void *)&cmd_set_conntrack_conntrack, + (void *)&cmd_set_conntrack_common_peer, + (void *)&cmd_set_conntrack_common_peer_value, + (void *)&cmd_set_conntrack_common_is_orig, + (void *)&cmd_set_conntrack_common_is_orig_value, + (void *)&cmd_set_conntrack_common_enable, + (void *)&cmd_set_conntrack_common_enable_value, + (void *)&cmd_set_conntrack_common_live, + (void *)&cmd_set_conntrack_common_live_value, + (void *)&cmd_set_conntrack_common_sack, + (void *)&cmd_set_conntrack_common_sack_value, + (void *)&cmd_set_conntrack_common_cack, + (void *)&cmd_set_conntrack_common_cack_value, + (void *)&cmd_set_conntrack_common_last_dir, + (void *)&cmd_set_conntrack_common_last_dir_value, + (void *)&cmd_set_conntrack_common_liberal, + (void *)&cmd_set_conntrack_common_liberal_value, + (void *)&cmd_set_conntrack_common_state, + (void *)&cmd_set_conntrack_common_state_value, + (void *)&cmd_set_conntrack_common_max_ackwin, + (void *)&cmd_set_conntrack_common_max_ackwin_value, + (void *)&cmd_set_conntrack_common_retrans, + (void *)&cmd_set_conntrack_common_retrans_value, + (void *)&cmd_set_conntrack_common_last_win, + (void *)&cmd_set_conntrack_common_last_win_value, + (void *)&cmd_set_conntrack_common_last_seq, + (void *)&cmd_set_conntrack_common_last_seq_value, + (void *)&cmd_set_conntrack_common_last_ack,app/test-pmd/cmdline.c cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { · line 13839
Quoted 10 lines
app/test-pmd/cmdline.c +10
-0+ (void *)&cmd_set_conntrack_common_last_ack_value, + (void *)&cmd_set_conntrack_common_last_end, + (void *)&cmd_set_conntrack_common_last_end_value, + (void *)&cmd_set_conntrack_common_last_index, + (void *)&cmd_set_conntrack_common_last_index_value, + NULL, + }, +}; + +/** Set connection tracking object both directions' details */ struct
Quoted 43 lines
app/test-pmd/cmdline.c +43
-0+cmd_set_conntrack_dir_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t conntrack; +cmdline_fixed_string_t dir; +cmdline_fixed_string_t scale; +cmdline_fixed_string_t fin; +cmdline_fixed_string_t ack_seen; +cmdline_fixed_string_t unack; +cmdline_fixed_string_t sent_end; +cmdline_fixed_string_t reply_end; +cmdline_fixed_string_t max_win; +cmdline_fixed_string_t max_ack; +uint32_t factor; +uint32_t f; +uint32_t as; +uint32_t un; +uint32_t se; +uint32_t re; +uint32_t mw; +uint32_t ma; +}; + +cmdline_parse_token_string_t cmd_set_conntrack_dir_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + set,"set" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + conntrack,"conntrack" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_dir = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + dir,"orig#rply" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_scale = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + scale,"scale" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + factor,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_fin = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + fin,"fin" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + f,RTE_UINT32 );app/test-pmd/cmdline.c cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
Quoted 10 lines
app/test-pmd/cmdline.c +10
-0+cmdline_parse_token_string_t cmd_set_conntrack_dir_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + ack_seen,"acked" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + as,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + unack,"unack_data" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value=
Quoted 44 lines
app/test-pmd/cmdline.c +44
-0+ TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + un, RTE_UINT32); +cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + sent_end,"sent_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + se,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + reply_end,"reply_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + re,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + max_win,"max_win" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + mw,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + max_ack,"max_ack" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + ma,RTE_UINT32 ); + +static void cmd_set_conntrack_dir_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_conntrack_dir_result *res = parsed_result; +struct rte_flow_tcp_dir_param *dir =NULL ; + +if (strcmp (res->dir,"orig" ) ==0 ) + dir = &conntrack_context.original_dir; +else if (strcmp (res->dir,"rply" ) ==0 ) + dir = &conntrack_context.reply_dir; +else +return ; + dir->scale = res->factor; + dir->close_initiated = res->f; + dir->last_ack_seen = res->as; + dir->data_unacked = res->un;app/test-pmd/cmdline.c cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = {
Quoted 10 lines
app/test-pmd/cmdline.c +10
-0+ dir->sent_end = res->se; + dir->reply_end = res->re; + dir->max_ack = res->ma; + dir->max_win = res->mw; +} + +cmdline_parse_inst_t cmd_set_conntrack_dir = { + .f = cmd_set_conntrack_dir_parsed, + .data =NULL , + .help_str = "set conntrack orig|rply scale <factor> fin<sent>"
Quoted 69 lines
app/test-pmd/cmdline.c +26
-0+" acked <seen> unack_data <unack> sent_end <sent>" + " reply_end <reply> max_win <win> max_ack <ack>", + .tokens = { + (void *)&cmd_set_conntrack_set, + (void *)&cmd_set_conntrack_conntrack, + (void *)&cmd_set_conntrack_dir_dir, + (void *)&cmd_set_conntrack_dir_scale, + (void *)&cmd_set_conntrack_dir_scale_value, + (void *)&cmd_set_conntrack_dir_fin, + (void *)&cmd_set_conntrack_dir_fin_value, + (void *)&cmd_set_conntrack_dir_ack, + (void *)&cmd_set_conntrack_dir_ack_value, + (void *)&cmd_set_conntrack_dir_unack_data, + (void *)&cmd_set_conntrack_dir_unack_data_value, + (void *)&cmd_set_conntrack_dir_sent_end, + (void *)&cmd_set_conntrack_dir_sent_end_value, + (void *)&cmd_set_conntrack_dir_reply_end, + (void *)&cmd_set_conntrack_dir_reply_end_value, + (void *)&cmd_set_conntrack_dir_max_win, + (void *)&cmd_set_conntrack_dir_max_win_value, + (void *)&cmd_set_conntrack_dir_max_ack, + (void *)&cmd_set_conntrack_dir_max_ack_value, + NULL, + }, +}; + /* Strict link priority scheduling mode setting */ static voidcmd_strict_link_prio_parsed( @@ -17117,6 +17469,8 @@
cmdline_parse_ctx_tmain_ctx[] = {app/test-pmd/cmdline.c +2
-0(cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, + (cmdline_parse_inst_t *)&cmd_set_conntrack_common, + (cmdline_parse_inst_t *)&cmd_set_conntrack_dir, (cmdline_parse_inst_t *)&cmd_ddp_add, (cmdline_parse_inst_t *)&cmd_ddp_del, (cmdline_parse_inst_t *)&cmd_ddp_get_list, diff --git
a/app/test-pmd/cmdline_flow.cb/app/test-pmd/cmdline_flow.cindexd83dec942a..fc5e31be5e100644app/test-pmd/cmdline_flow.c +7
-1@@ -289,6 +289,7 @@ enum index {ITEM_GENEVE_OPT_TYPE ,ITEM_GENEVE_OPT_LENGTH ,ITEM_GENEVE_OPT_DATA , +ITEM_CONNTRACK ,/* Validate/create actions. */ ACTIONS,@@ -427,6 +428,10 @@ enum index {ACTION_MODIFY_FIELD_SRC_OFFSET ,ACTION_MODIFY_FIELD_SRC_VALUE ,ACTION_MODIFY_FIELD_WIDTH , +ACTION_CONNTRACK , +ACTION_CONNTRACK_UPDATE , +ACTION_CONNTRACK_UPDATE_DIR , +ACTION_CONNTRACK_UPDATE_CTX , }; /** Maximum size for pattern in struct rte_flow_item_raw. */ @@ -565,6 +570,8 @@ struct mplsoudp_encap_conf mplsoudp_encap_conf; struct mplsoudp_decap_conf mplsoudp_decap_conf; +struct rte_flow_action_conntrack conntrack_context; +#define ACTION_SAMPLE_ACTIONS_NUM 10#define RAW_SAMPLE_CONFS_MAX_NUM 8/** Storage for struct rte_flow_action_sample including external Quoted 1 line
data. */ @@ -956,6 +963,7 @@ static const enum index next_item[] =
{
Quoted 19 lines
app/test-pmd/cmdline_flow.c +3
-0ITEM_PFCP ,ITEM_ECPRI ,ITEM_GENEVE_OPT , +ITEM_CONNTRACK ,END_SET , ZERO, };@@ -1370,6 +1378,8 @@ static const enum index next_action[] = {ACTION_SAMPLE ,ACTION_INDIRECT ,ACTION_MODIFY_FIELD , +ACTION_CONNTRACK , +ACTION_CONNTRACK_UPDATE , ZERO, };@@ -1638,6 +1648,13 @@ static const enum index action_modify_field_src[] = { ZERO,app/test-pmd/cmdline_flow.c static const enum index · line 1659
Quoted 10 lines
app/test-pmd/cmdline_flow.c +7
-0}; +static const enum index action_update_conntrack[] = { +ACTION_CONNTRACK_UPDATE_DIR , +ACTION_CONNTRACK_UPDATE_CTX , +ACTION_NEXT , +ZERO , +}; + static int parse_set_raw_encap_decap(struct context *, conststruct token *,
app/test-pmd/cmdline_flow.c static int · line 1745
Quoted 4 lines
app/test-pmd/cmdline_flow.c +0
-0const char *, unsigned int,app/test-pmd/cmdline_flow.c +0
-0void *, unsigned int);@@ -1728,6 +1745,10 @@ static int parse_vc_modify_field_id(struct context *ctx, const struct token*token,
app/test-pmd/cmdline_flow.c static int
Quoted 4 lines
app/test-pmd/cmdline_flow.c +2
-0const char *str, unsigned int len, void *buf, unsigned int size); +static int +parse_vc_action_conntrack_update(struct context *ctx, conststruct
Quoted 24 lines
app/test-pmd/cmdline_flow.c +10
-0+token *token, + const char *str, unsigned int len, void *buf, + unsigned int size);static int parse_destroy (struct context *,const struct token *,const char *,unsigned int ,void *,unsigned int );@@ -3373,6 +3394,13 @@ static const struct token token_list[] = { (sizeof (struct rte_flow_item_geneve_opt ), ITEM_GENEVE_OPT_DATA_SIZE)), }, + [ITEM_CONNTRACK] = { + .name = "conntrack", + .help = "conntrack state", + .next =NEXT (NEXT_ENTRY (ITEM_NEXT ),NEXT_ENTRY (UNSIGNED ), + item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_conntrack, flags)), + },/* Validate/create actions. */ app/test-pmd/cmdline_flow.c +0
-0[ACTIONS] = { .name = "actions",app/test-pmd/cmdline_flow.c static const struct token token_list[] = { · line 4507
Quoted 9 lines
app/test-pmd/cmdline_flow.c +6
-0@@ -4471,6 +4499,34 @@ static const struct token token_list[] = { .call = parse_vc_action_sample_index, .comp = comp_set_sample_index, }, + [ACTION_CONNTRACK] = { + .name = "conntrack", + .help = "create a conntrack object", + .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), + .priv = PRIV_ACTION(CONNTRACK, + sizeof(struct
rte_flow_action_conntrack)),app/test-pmd/cmdline_flow.c static const struct token token_list[] = {
Quoted 8 lines
app/test-pmd/cmdline_flow.c +8
-0+ .call = parse_vc, + }, + [ACTION_CONNTRACK_UPDATE] = { + .name = "conntrack_update", + .help = "update a conntrack object", + .next = NEXT(action_update_conntrack), + .priv = PRIV_ACTION(CONNTRACK, + sizeof(struct
rte_flow_modify_conntrack)),app/test-pmd/cmdline_flow.c parse_vc_modify_field_id(struct context
Quoted 18 lines
app/test-pmd/cmdline_flow.c +14
-0+ .call = parse_vc, + }, + [ACTION_CONNTRACK_UPDATE_DIR] = { + .name = "dir", + .help = "update a conntrack object direction", + .next = NEXT(action_update_conntrack), + .call = parse_vc_action_conntrack_update, + }, + [ACTION_CONNTRACK_UPDATE_CTX] = { + .name = "ctx", + .help = "update a conntrack object context", + .next = NEXT(action_update_conntrack), + .call = parse_vc_action_conntrack_update, + },/* Indirect action destroy arguments. */ [INDIRECT_ACTION_DESTROY_ID] = { .name = "action_id",@@ -6277,6 +6333,42 @@ parse_vc_modify_field_id(struct context*ctx,
app/test-pmd/cmdline_flow.c parse_vc_modify_field_id(struct context *ctx, const struct token *token,
Quoted 5 lines
app/test-pmd/cmdline_flow.c +1
-0const struct token *token, return len; } +/** Parse the conntrack update, not a rte_flow_action. */ staticint
app/test-pmd/cmdline_flow.c parse_vc_modify_field_id(struct context · line 6338
Quoted 1 line
app/test-pmd/cmdline_flow.c +1
-0+parse_vc_action_conntrack_update(struct context *ctx, conststruct
Quoted 58 lines
app/test-pmd/cmdline_flow.c +34
-0+token *token, + const char *str, unsigned int len, void *buf, + unsigned int size) +{ + struct buffer *out = buf; +struct rte_flow_modify_conntrack *ct_modify =NULL ; + + (void )size; +if (ctx->curr !=ACTION_CONNTRACK_UPDATE_CTX && + ctx->curr !=ACTION_CONNTRACK_UPDATE_DIR ) +return -1 ; +/* Token name must match. */ +if (parse_default (ctx, token, str, len,NULL ,0 ) <0 ) +return -1 ; + ct_modify = (struct rte_flow_modify_conntrack *)out- args.vc.data; +/* Nothing else to do if there is no buffer. */ +if (!out) +return len; +if (ctx->curr ==ACTION_CONNTRACK_UPDATE_DIR ) { + ct_modify->new_ct.is_original_dir = + conntrack_context.is_original_dir; + ct_modify->direction =1 ; + }else { +uint32_t old_dir; + + old_dir = ct_modify->new_ct.is_original_dir; +memcpy (&ct_modify->new_ct, &conntrack_context, +sizeof (conntrack_context)); + ct_modify->new_ct.is_original_dir = old_dir; + ct_modify->state =1 ; + } +return len; +} +/** Parse tokens for destroy command. */ static int
parse_destroy(struct context *ctx, const struct token *token, diff --gita/app/test-pmd/config.cb/app/test-pmd/config.cindex1eec0612a4..06143a7501100644app/test-pmd/config.c +5
-0@@ -1483,6 +1483,11 @@ port_action_handle_create(portid_t port_id,uint32_t id, pia->age_type =ACTION_AGE_CONTEXT_TYPE_INDIRECT_ACTION ; age->context = &pia->age_type; + }else if (action->type ==RTE_FLOW_ACTION_TYPE_CONNTRACK ) { +struct rte_flow_action_conntrack *ct = + (struct rte_flow_action_conntrack *)(uintptr_t )(action- conf); + +memcpy (ct, &conntrack_context,sizeof (*ct));app/test-pmd/config.c +0
-0}/* Poisoning to make sure PMDs update it in case of error. */ memset(&error, 0x22, sizeof(error)); @@ -1564,11 +1569,24 @@port_action_handle_update(portid_t
port_id,uint32_tid, {app/test-pmd/config.c port_action_handle_update(portid_t port_id, uint32_t id,
Quoted 9 lines
app/test-pmd/config.c +2
-1struct rte_flow_error error;struct rte_flow_action_handle *action_handle; +struct port_indirect_action *pia; +const void *update; action_handle =port_action_handle_get_by_id (port_id, id);if (!action_handle)return -EINVAL ; - if (rte_flow_action_handle_update(port_id, action_handle,action,
app/test-pmd/config.c port_action_handle_update(portid_t port_id, uint32_t id,
Quoted 12 lines
app/test-pmd/config.c +12
-0+ pia =action_get_by_id (port_id, id); +if (!pia) +return -EINVAL ; +switch (pia->type) { +case RTE_FLOW_ACTION_TYPE_CONNTRACK : + update = action->conf; +break ; +default : + update = action; +break ; + } + if (rte_flow_action_handle_update(port_id, action_handle,update,
Quoted 6 lines
app/test-pmd/config.c +0
-0&error)) {return port_flow_complain (&error); }@@ -1621,6 +1639,51 @@ port_action_handle_query(portid_t port_id, uint32_t id) }app/test-pmd/config.c port_action_handle_query(portid_t port_id, · line 1650
Quoted 10 lines
app/test-pmd/config.c +8
-0data =NULL ;break ; +case RTE_FLOW_ACTION_TYPE_CONNTRACK : + if (!ret) { + struct rte_flow_action_conntrack *ct = data; + + printf("Conntrack Context:\n" + " Peer: %u, Flow dir: %s, Enable: %u\n" + " Live: %u, SACK: %u, CACK: %u\n" + " Packet dir: %s, Liberal: %u,State: %u\n"
app/test-pmd/config.c port_action_handle_query(portid_t port_id, · line 1651
Quoted 1 line
app/test-pmd/config.c +1
-0+ " Factor: %u, Retrans: %u, TCPflags: %u\n"
Quoted 6 lines
app/test-pmd/config.c +6
-0+" Last Seq: %u, Last ACK: %u\n" +" Last Win: %u, Last End: %u\n" , + ct->peer_port, + ct->is_original_dir ?"Original" :"Reply" , + ct->enable, ct->live_connection, + ct->selective_ack, ct->challenge_ack_passed,app/test-pmd/config.c port_action_handle_query(portid_t port_id, uint32_t id)
Quoted 10 lines
app/test-pmd/config.c +9
-0+ ct->last_direction ? "Original" : "Reply", + ct->liberal_mode, ct->state, + ct->max_ack_window, ct- retransmission_limit, + ct->last_index, ct->last_seq, ct->last_ack, + ct->last_window, ct->last_end); +printf (" Original Dir:\n" +" scale: %u, fin: %u, ack seen: %u\n" +" unacked data: %u\n Sent end: %u," + " Reply end: %u, Max win: %u, MaxACK: %u\n",
app/test-pmd/config.c port_action_handle_query(portid_t port_id, uint32_t id)
Quoted 12 lines
app/test-pmd/config.c +12
-0+ ct->original_dir.scale, + ct->original_dir.close_initiated, + ct->original_dir.last_ack_seen, + ct->original_dir.data_unacked, + ct->original_dir.sent_end, + ct->original_dir.reply_end, + ct->original_dir.max_win, + ct->original_dir.max_ack); +printf (" Reply Dir:\n" +" scale: %u, fin: %u, ack seen: %u\n" +" unacked data: %u\n Sent end: %u," + " Reply end: %u, Max win: %u, MaxACK: %u\n",
app/test-pmd/config.c port_action_handle_query(portid_t port_id, uint32_t id)
Quoted 13 lines
app/test-pmd/config.c +6
-0+ ct->reply_dir.scale, + ct->reply_dir.close_initiated, + ct->reply_dir.last_ack_seen, + ct->reply_dir.data_unacked, + ct->reply_dir.sent_end, ct- reply_dir.reply_end, + ct->reply_dir.max_win, ct-reply_dir.max_ack);
app/test-pmd/config.c +3
-0+ } + data =NULL ; +break ;default : printf("Indirect action %u (type: %d) on port %udoesn't"
Quoted 1 line
" support query\n", id,
pia->type,port_id); diff--git
Quoted 9 lines
a/app/test-pmd/testpmd.hb/app/test-pmd/testpmd.hindexd1eaaadb17..d7528f9cb5100644app/test-pmd/testpmd.h +0
-0@@ -630,6 +630,8 @@ extern struct mplsoudp_decap_conf mplsoudp_decap_conf;extern enum rte_eth_rx_mq_mode rx_mq_mode;
Quoted 7 lines
Quoted 7 lines
app/test-pmd/testpmd.h +2
-0+extern struct rte_flow_action_conntrack conntrack_context; +static inline unsigned int lcore_num (void ){
--
2.19.0.windows.1
BR. Bing
v3 cover ethdev: introduce conntrack flow action and item
In reply to Bing ZhaoDepends-on: series-16451 ("Change shared action API to action handle API")
This patch set includes the conntrack action and item definitions as well as the testpmd CLI proposal.
Documents of release notes and guides are also updated.
---
v2: add testpmd CLI proposal
v3: add doc update
---
Bing Zhao (3):
ethdev: introduce conntrack flow action and item app/testpmd: add CLI for conntrack
doc: update for conntrack
app/test-pmd/cmdline.c | 354 ++++++++++++++++++++ app/test-pmd/cmdline_flow.c | 92 +++++ app/test-pmd/config.c | 65 +++- app/test-pmd/testpmd.h | 2 + doc/guides/prog_guide/rte_flow.rst | 113 +++++++ doc/guides/rel_notes/release_21_05.rst | 4 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 35 ++ lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 207 ++++++++++++ 9 files changed, 873 insertions(+), 1 deletion(-)
Signature · 1 line
2.19.0.windows.1
PATCH v3 1/3 ethdev: introduce conntrack flow action and item
This commit introduces the conntrack action and item.
Usually the HW offloading is stateless. For some stateful offloading like a TCP connection, HW module will help provide the ability of a full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow rule the application should add the conntrack action and jump to the next flow table. In the following flow rule(s) of the next table, the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack action context correctly, the information of packets from both directions are required.
The conntrack action should be created on one ethdev port and supply the peer ethdev port as a parameter to the action. After context created, it could only be used between these two ethdev ports (dual-port mode) or a single port. The application should modify the action via the API "rte_action_handle_update" only when before using it to create a flow rule with conntrack conntrack for the opposite direction. This will help the driver to recognize the direction of the flow to be created, especially in the single-port mode, in which case the traffic from both directions will go through the same ethdev port if the application works as an "forwarding engine" but not an end point. There is no need to call the update interface if the subsequent flow rules have nothing to be changed.
Query will be supported via "rte_action_handle_query" interface, about the current packets information and connection status. The fields query capabilities depends on the HW.
For the packets received during the conntrack setup, it is suggested to re-inject the packets in order to make sure the conntrack module works correctly without missing any packet. Only the valid packets should pass the conntrack, packets with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Naming and definition:
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/netfilter/nf_conntrack_tcp.h
https://elixir.bootlin.com/linux/latest/source/net/netfilter/nf_conntrack_proto_tcp.c
Other reference:
https://www.usenix.org/legacy/events/sec01/invitedtalks/rooij.pdf
--- lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 207 +++++++++++++++++++++++++++++++++++ 2 files changed, 209 insertions(+)
lib/librte_ethdev/rte_flow.c +2 -0
@@ -98,6 +98,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {MK_FLOW_ITEM (PFCP ,sizeof (struct rte_flow_item_pfcp )),MK_FLOW_ITEM (ECPRI ,sizeof (struct rte_flow_item_ecpri )),MK_FLOW_ITEM (GENEVE_OPT ,sizeof (struct rte_flow_item_geneve_opt )), + MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)), };/** Generate flow_action[] entry. */
@@ -186,6 +187,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {* indirect action handle. */ MK_FLOW_ACTION (INDIRECT ,0 ), + MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)), };int
lib/librte_ethdev/rte_flow.h +207 -0
231 lines not on this page · raw message
Signature · 1 line
2.19.0.windows.1
Quoted 8 lines · Bing Zhao
This commit introduces the conntrack action and item.
Usually the HW offloading is stateless. For some stateful offloading like a TCP connection, HW module will help provide the ability of a full offloading w/o SW participation after the connection was established.
Quoted 6 lines
The basic usage is that in the first flow rule the application should add the conntrack action and jump to the next flow table. In the following flow rule(s) of the next table, the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack
s/has two directions traffic/can have traffic in two directions.
Quoted 16 lines
action context correctly, the information of packets from both directions are required.
The conntrack action should be created on one ethdev port and supply the peer ethdev port as a parameter to the action. After context created, it could only be used between these two ethdev ports (dual-port mode) or a single port. The application should modify the action via the API "
rte_action_handle_update" only when before using it to create a flow rule with conntrack conntrack for the opposite direction. This will help the driver to recognize the direction of the flow to be created, especially in the single-port mode, in which case the traffic from both directions will go through the same ethdev port if the application works as an "forwarding engine" but not an end point. There is no need to call the update interface if the subsequent flow rules have nothing to be changed.
Quoted 3 lines
Query will be supported via "
rte_action_handle_query" interface, about the current packets information and connection status. The fields query capabilities depends on the HW.
How about this:
The fields which can be queried will depend on the HW capabilities.
Quoted 202 lines
For the packets received during the conntrack setup, it is suggested to re-inject the packets in order to make sure the conntrack module works correctly without missing any packet. Only the valid packets should pass the conntrack, packets with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Naming and definition:
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/netfilter/nf_conntrack_tcp.h
https://elixir.bootlin.com/linux/latest/source/net/netfilter/nf_conntrack_proto_tcp.cOther reference:
https://www.usenix.org/legacy/events/sec01/invitedtalks/rooij.pdfSigned-off-by Bing Zhao <[email protected]>--- lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 207 +++++++++++++++++++++++++++++++++++ 2 files changed, 209 insertions(+)lib/librte_ethdev/rte_flow.c +2
-0@@ -98,6 +98,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {MK_FLOW_ITEM (PFCP ,sizeof (struct rte_flow_item_pfcp )),MK_FLOW_ITEM (ECPRI ,sizeof (struct rte_flow_item_ecpri )),MK_FLOW_ITEM (GENEVE_OPT ,sizeof (struct rte_flow_item_geneve_opt )), + MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)), };/** Generate flow_action[] entry. */ @@ -186,6 +187,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {* indirect action handle. */ MK_FLOW_ACTION (INDIRECT ,0 ), + MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)), };int lib/librte_ethdev/rte_flow.h +132
-0@@ -551,6 +551,15 @@ enum rte_flow_item_type {* See struct rte_flow_item_geneve_opt */ RTE_FLOW_ITEM_TYPE_GENEVE_OPT , + +/** +* [META] +* +* Matches conntrack state. +* +* @see struct rte_flow_item_conntrack. +*/ + RTE_FLOW_ITEM_TYPE_CONNTRACK, };/** @@ -1685,6 +1694,51 @@ rte_flow_item_geneve_opt_mask = { };#endif +/** +* The packet is valid after conntrack checking. +*/ +#define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0) +/** +* The state of the connection is changed. +*/ +#define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1) +/** +* Error is detected on this packet for this connection and +* an invalid state is set. +*/ +#define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2) +/** +* The HW connection tracking module is disabled. +* It can be due to application command or an invalid state. +*/ +#define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3) +/** +* The packet contains some bad field(s) and cannot continue +* with the conntrack module checking. +*/ +#define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4) + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ITEM_TYPE_CONNTRACK +* +* Matches the state of a packet after it passed the connection tracking +* examination. The state is a bitmap of one RTE_FLOW_CONNTRACK_PKT_STATE* +* or a reasonable combination of these bits. +*/ +struct rte_flow_item_conntrack { +uint32_t flags; +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_CONNTRACK. */ +#ifndef __cplusplus +static const struct rte_flow_item_conntrack rte_flow_item_conntrack_mask = { + .flags =0xffffffff , +}; +#endif +/** * Matching pattern item definition. * @@ -2277,6 +2331,15 @@ enum rte_flow_action_type {* same port or across different ports. */ RTE_FLOW_ACTION_TYPE_INDIRECT , + +/** +* [META] +* +* Enable tracking a TCP connection state. +* +* @see struct rte_flow_action_conntrack. +*/ + RTE_FLOW_ACTION_TYPE_CONNTRACK, };/** @@ -2875,6 +2938,150 @@ struct rte_flow_action_set_dscp {*/ struct rte_flow_action_handle ; +/** +* The state of a TCP connection. +*/ +enum rte_flow_conntrack_state { +/**< SYN-ACK packet was seen. */ +RTE_FLOW_CONNTRACK_STATE_SYN_RECV , +/**< 3-way handshake was done. */ +RTE_FLOW_CONNTRACK_STATE_ESTABLISHED , +/**< First FIN packet was received to close the connection. */ +RTE_FLOW_CONNTRACK_STATE_FIN_WAIT , +/**< First FIN was ACKed. */ +RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT , +/**< Second FIN was received, waiting for the last ACK. */ +RTE_FLOW_CONNTRACK_STATE_LAST_ACK , +/**< Second FIN was ACKed, connection was closed. */ +RTE_FLOW_CONNTRACK_STATE_TIME_WAIT , +}; + +/** +* The last passed TCP packet flags of a connection. +*/ +enum rte_flow_conntrack_tcp_last_index { +RTE_FLOW_CONNTRACK_FLAG_NONE =0 ,/**< No Flag. */ +RTE_FLOW_CONNTRACK_FLAG_SYN =RTE_BIT32 (0 ),/**< With SYN flag. */ +RTE_FLOW_CONNTRACK_FLAG_SYNACK =RTE_BIT32 (1 ),/**< With SYNACK flag. */ +RTE_FLOW_CONNTRACK_FLAG_FIN =RTE_BIT32 (2 ),/**< With FIN flag. */ +RTE_FLOW_CONNTRACK_FLAG_ACK =RTE_BIT32 (3 ),/**< With ACK flag. */ +RTE_FLOW_CONNTRACK_FLAG_RST =RTE_BIT32 (4 ),/**< With RST flag. */ +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* Configuration parameters for each direction of a TCP connection. +*/ +struct rte_flow_tcp_dir_param { +/** TCP window scaling factor, 0xF to disable. */ +uint32_t scale:4 ; +/** The FIN was sent by this direction. */ +uint32_t close_initiated:1 ; +/** An ACK packet has been received by this side. */ +uint32_t last_ack_seen:1 ; +/** +* If set, it indicates that there is unacknowledged data for the +* packets sent from this direction. +*/ +uint32_t data_unacked:1 ; +/** +* Maximal value of sequence + payload length in sent +* packets (next ACK from the opposite direction). +*/ +uint32_t sent_end; +/** +* Maximal value of (ACK + window size) in received packet + length +* over sent packet (maximal sequence could be sent). +*/ +uint32_t reply_end; +/** Maximal value of actual window size in sent packets. */ +uint32_t max_win; +/** Maximal value of ACK in sent packets. */ +uint32_t max_ack; +}; + +/** +* @warning +* @b EXPERIMENTAL: this structure may change without prior notice +* +* RTE_FLOW_ACTION_TYPE_CONNTRACK
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3019
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* +* Configuration and initial state for the connection tracking module. +* This structure could be used for both setting and query. +*/ +struct rte_flow_action_conntrack { +/** The peer port number, can be the same port. */ +uint16_t peer_port; +/** +* Direction of this connection when creating a flow, the value +* only affects the subsequent flows creation.
s/flows/flow
or
s/the subsequent flows creation/the creation of subsequent flows
Quoted 18 lines
lib/librte_ethdev/rte_flow.h +18
-0+*/ + uint32_t is_original_dir:1; +/** +* Enable / disable the conntrack HW module. When disabled, the +* result will always be RTE_FLOW_CONNTRACK_FLAG_DISABLED. +* In this state the HW will act as passthrough. +* It only affects this conntrack object in the HW without any effect +* to the other objects. +*/ + uint32_t enable:1; +/** At least one ack was seen after the connection was established. */ + uint32_t live_connection:1; +/** Enable selective ACK on this connection. */ + uint32_t selective_ack:1; +/** A challenge ack has passed. */ + uint32_t challenge_ack_passed:1; +/** +* 1: The last packet is seen from the original direction.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3047
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+* 0: The last packet is seen from the reply direction. +*/ + uint32_t last_direction:1; +/** No TCP check will be done except the state change. */ + uint32_t liberal_mode:1; +/**<The current state of this connection. */ +enum rte_flow_conntrack_state state; +/** Scaling factor for maximal allowed ACK window. */ +uint8_t max_ack_window; +/** Maximal allowed number of retransmission times. */
s/times/limit
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3053
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+uint8_t retransmission_limit; +/** TCP parameters of the original direction. */ +struct rte_flow_tcp_dir_param original_dir; +/** TCP parameters of the reply direction. */ +struct rte_flow_tcp_dir_param reply_dir; +/** The window value of the last packet passed this conntrack. */
s/value/size
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3056
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+uint16_t last_window; +enum rte_flow_conntrack_tcp_last_index last_index; +/** The sequence of the last packet passed this conntrack. */
sequence number of the ...
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3058
Quoted 2 lines
lib/librte_ethdev/rte_flow.h +2
-0+uint32_t last_seq; +/** The acknowledgement of the last packet passed this conntrack. */
ACK number of the..
s/passed this/passed by this
or
passing this
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3062
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+uint32_t last_ack; +/** +* The total value ACK + payload length of the last packet +* passed this conntrack.
s/passed this/passed by this
or passing this
Quoted 28 lines
lib/librte_ethdev/rte_flow.h +22
-1+*/ +uint32_t last_end; +}; + +/** +* RTE_FLOW_ACTION_TYPE_CONNTRACK +* +* Wrapper structure for the context update interface. +* Ports cannot support updating, and the only valid solution is to +* destroy the old context and create a new one instead. +*/ +struct rte_flow_modify_conntrack { +/** New connection tracking parameters to be updated. */ +struct rte_flow_action_conntrack new_ct; +/** The direction field will be updated. */ +uint32_t direction:1 ; +/** All the other fields except direction will be updated. */ +uint32_t state:1 ; +/** Reserved bits for the future usage. */ +uint32_t reserved:30 ; +}; +/** * Field IDs for MODIFY_FIELD action. */ --2.19.0.windows.1
16/04/2021 20:30, Ajit Khaparde:
Quoted 11 lines · Bing Zhao
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3019
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+struct rte_flow_action_conntrack { +/** The peer port number, can be the same port. */ +uint16_t peer_port; +/** +* Direction of this connection when creating a flow, the value +* only affects the subsequent flows creation. s/flows/flow
or
s/the subsequent flows creation/the creation of subsequent flows
s/flows/flow rules/
Hi,
Quoted 23 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, April 19, 2021 10:08 PM
To: Bing Zhao <[email protected]>; Ajit Khaparde <[email protected]>
Cc: [email protected]; Ori Kam <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>; dpdk-dev <[email protected]>; Xiaoyun Li <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v3 1/3] ethdev: introduce conntrack flow action and itemExternal email: Use caution opening links or attachments
16/04/2021 20:30, Ajit Khaparde:
Quoted 1 line
On Fri, Apr 16, 2021 at 10:54 AM Bing Zhao <[email protected]>
Quoted 5 lines · wrote:
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 5 lines
lib/librte_ethdev/rte_flow.h +5
-0+struct rte_flow_action_conntrack { +/** The peer port number, can be the same port. */ +uint16_t peer_port; +/** +* Direction of this connection when creating a flow,
Quoted 8 lines
the value
Quoted 5 lines
Quoted 1 line
+ * only affects the subsequent flows creation.
s/flows/flow
or
s/the subsequent flows creation/the creation of subsequent flowss/flows/flow rules/
Done
Quoted 3 lines
BR. Bing
16/04/2021 19:54, Bing Zhao:
Quoted 13 lines
lib/librte_ethdev/rte_flow.h +13
-0+/** +* The packet is valid after conntrack checking. +*/ +#define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0) +/** +* The state of the connection is changed. +*/ +#define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1) +/** +* Error is detected on this packet for this connection and +* an invalid state is set. +*/ +#define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)
lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = { · line 1719
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+/** +* The HW connection tracking module is disabled. +* It can be due to application command or an invalid state. +*/ +#define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3) +/** +* The packet contains some bad field(s) and cannot continue +* with the conntrack module checking. +*/ +#define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)
I like it better now that all bits have the same prefix, thanks.
Quoted 4 lines
lib/librte_ethdev/rte_flow.h +4
-0+enum rte_flow_conntrack_state { +/**< SYN-ACK packet was seen. */ +RTE_FLOW_CONNTRACK_STATE_SYN_RECV , +/**< 3-way handshake was done. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2957
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+RTE_FLOW_CONNTRACK_STATE_ESTABLISHED , +/**< First FIN packet was received to close the connection. */ +RTE_FLOW_CONNTRACK_STATE_FIN_WAIT , +/**< First FIN was ACKed. */ +RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT , +/**< Second FIN was received, waiting for the last ACK. */ +RTE_FLOW_CONNTRACK_STATE_LAST_ACK , +/**< Second FIN was ACKed, connection was closed. */ + RTE_FLOW_CONNTRACK_STATE_TIME_WAIT, +};
These doxygen comments should not have "<" in them, because they are "before".
[...]
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3043
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+/** No TCP check will be done except the state change. */ + uint32_t liberal_mode:1; +/**<The current state of this connection. */
s,/**<,/** ,
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3044
Quoted 1 line
lib/librte_ethdev/rte_flow.h +1
-0+enum rte_flow_conntrack_state state;
Looks good overrall, thanks.
Hi Thomas,
Quoted 56 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, April 19, 2021 10:06 PM
To: Bing Zhao <[email protected]>
Cc: Ori Kam <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [dpdk-dev] [PATCH v3 1/3] ethdev: introduce conntrack flow action and itemExternal email: Use caution opening links or attachments
16/04/2021 19:54, Bing Zhao:
Quoted 13 lines
lib/librte_ethdev/rte_flow.h +13
-0+/** +* The packet is valid after conntrack checking. +*/ +#define RTE_FLOW_CONNTRACK_PKT_STATE_VALID RTE_BIT32(0) +/** +* The state of the connection is changed. +*/ +#define RTE_FLOW_CONNTRACK_PKT_STATE_CHANGED RTE_BIT32(1) +/** +* Error is detected on this packet for this connection and +* an invalid state is set. +*/ +#define RTE_FLOW_CONNTRACK_PKT_STATE_INVALID RTE_BIT32(2)lib/librte_ethdev/rte_flow.h rte_flow_item_geneve_opt_mask = { · line 1719
Quoted 10 lines
lib/librte_ethdev/rte_flow.h +10
-0+/** +* The HW connection tracking module is disabled. +* It can be due to application command or an invalid state. +*/ +#define RTE_FLOW_CONNTRACK_PKT_STATE_DISABLED RTE_BIT32(3) +/** +* The packet contains some bad field(s) and cannot continue +* with the conntrack module checking. +*/ +#define RTE_FLOW_CONNTRACK_PKT_STATE_BAD RTE_BIT32(4)I like it better now that all bits have the same prefix, thanks.
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp {
Quoted 6 lines
lib/librte_ethdev/rte_flow.h +6
-0+enum rte_flow_conntrack_state { +/**< SYN-ACK packet was seen. */ +RTE_FLOW_CONNTRACK_STATE_SYN_RECV , +/**< 3-way handshake was done. */ +RTE_FLOW_CONNTRACK_STATE_ESTABLISHED , +/**< First FIN packet was received to close the connection. */
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 2957
Quoted 8 lines
lib/librte_ethdev/rte_flow.h +8
-0+RTE_FLOW_CONNTRACK_STATE_FIN_WAIT , +/**< First FIN was ACKed. */ +RTE_FLOW_CONNTRACK_STATE_CLOSE_WAIT , +/**< Second FIN was received, waiting for the last ACK. */ +RTE_FLOW_CONNTRACK_STATE_LAST_ACK , +/**< Second FIN was ACKed, connection was closed. */ + RTE_FLOW_CONNTRACK_STATE_TIME_WAIT, +};
Quoted 2 lines
These doxygen comments should not have "<" in them, because they are "before".
All "<" are removed, thanks.
Quoted 6 lines
[...]
lib/librte_ethdev/rte_flow.h struct rte_flow_action_set_dscp { · line 3043
Quoted 3 lines
lib/librte_ethdev/rte_flow.h +3
-0+/** No TCP check will be done except the state change. */ + uint32_t liberal_mode:1; +/**<The current state of this connection. */
Quoted 6 lines
s,/**<,/** ,
Quoted 1 line
+ enum
rte_flow_conntrack_statestate;Looks good overrall, thanks.
BR. Bing
PATCH v3 2/3 app/testpmd: add CLI for conntrack
In reply to Bing ZhaoThe command line for testing connection tracking is added. To create a conntrack object, 3 parts are needed.
set conntrack com peer ...
set conntrack orig scale ...
set conntrack rply scale ...
This will create a full conntrack action structure for the indirect action. After the indirect action handle of "conntrack" created, it could be used in the flow creation. Before updating, the same structure is also needed together with the update command "conntrack_update" to update the "dir" or "ctx".
After the flow with conntrack action created, the packet should jump to the next flow for the result checking with conntrack item. The state is defined with bits and a valid combination could be supported.
--- app/test-pmd/cmdline.c | 354 ++++++++++++++++++++++++++++++++++++ app/test-pmd/cmdline_flow.c | 92 ++++++++++ app/test-pmd/config.c | 65 ++++++- app/test-pmd/testpmd.h | 2 + 4 files changed, 512 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +354 -0
@@ -13621,6 +13621,358 @@ cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { }, }; +/** Set connection tracking object common details */ +struct cmd_set_conntrack_common_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t conntrack; +cmdline_fixed_string_t common; +cmdline_fixed_string_t peer; +cmdline_fixed_string_t is_orig; +cmdline_fixed_string_t enable; +cmdline_fixed_string_t live; +cmdline_fixed_string_t sack; +cmdline_fixed_string_t cack; +cmdline_fixed_string_t last_dir; +cmdline_fixed_string_t liberal; +cmdline_fixed_string_t state; +cmdline_fixed_string_t max_ack_win; +cmdline_fixed_string_t retrans; +cmdline_fixed_string_t last_win; +cmdline_fixed_string_t last_seq; +cmdline_fixed_string_t last_ack; +cmdline_fixed_string_t last_end; +cmdline_fixed_string_t last_index; +uint8_t stat; +uint8_t factor; +uint16_t peer_port; +uint32_t is_original; +uint32_t en; +uint32_t is_live; +uint32_t s_ack; +uint32_t c_ack; +uint32_t ld; +uint32_t lb; +uint8_t re_num; +uint8_t li; +uint16_t lw; +uint32_t ls; +uint32_t la; +uint32_t le; +}; + +cmdline_parse_token_string_t cmd_set_conntrack_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + set,"set" ); +cmdline_parse_token_string_t cmd_set_conntrack_conntrack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + conntrack,"conntrack" ); +cmdline_parse_token_string_t cmd_set_conntrack_conntrack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + common,"com" ); +cmdline_parse_token_string_t cmd_set_conntrack_common_peer = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + peer,"peer" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + peer_port,RTE_UINT16 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + is_orig,"is_orig" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + is_original,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_enable = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + enable,"enable" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + en,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_live = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + live,"live" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_live_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + is_live,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_sack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + sack,"sack" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + s_ack,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_cack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + cack,"cack" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + c_ack,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_dir,"last_dir" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + ld,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_liberal = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + liberal,"liberal" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + lb,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_state = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + state,"state" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_state_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + stat,RTE_UINT8 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + max_ack_win,"max_ack_win" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + factor,RTE_UINT8 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_retrans = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + retrans,"r_lim" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + re_num,RTE_UINT8 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_win = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_win,"last_win" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + lw,RTE_UINT16 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_seq,"last_seq" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + ls,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_ack,"last_ack" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + la,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_end,"last_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + le,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_index = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_index,"last_index" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + li,RTE_UINT8 ); + +static void cmd_set_conntrack_common_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_conntrack_common_result *res = parsed_result; + +/* No need to swap to big endian. */ + conntrack_context.peer_port = res->peer_port; + conntrack_context.is_original_dir = res->is_original; + conntrack_context.enable = res->en; + conntrack_context.live_connection = res->is_live; + conntrack_context.selective_ack = res->s_ack; + conntrack_context.challenge_ack_passed = res->c_ack; + conntrack_context.last_direction = res->ld; + conntrack_context.liberal_mode = res->lb; + conntrack_context.state = (enum rte_flow_conntrack_state )res->stat; + conntrack_context.max_ack_window = res->factor; + conntrack_context.retransmission_limit = res->re_num; + conntrack_context.last_window = res->lw; + conntrack_context.last_index = + (enum rte_flow_conntrack_tcp_last_index )res->li; + conntrack_context.last_seq = res->ls; + conntrack_context.last_ack = res->la; + conntrack_context.last_end = res->le; +} + +cmdline_parse_inst_t cmd_set_conntrack_common = { + .f = cmd_set_conntrack_common_parsed, + .data =NULL , + .help_str ="set conntrack com peer <port_id> is_orig <dir> enable <en>" +" live <ack_seen> sack <en> cack <passed> last_dir <dir>" +" liberal <en> state <s> max_ack_win <factor> r_lim <num>" +" last_win <win> last_seq <seq> last_ack <ack> last_end <end>" +" last_index <flag>" , + .tokens = { + (void *)&cmd_set_conntrack_set, + (void *)&cmd_set_conntrack_conntrack, + (void *)&cmd_set_conntrack_common_peer, + (void *)&cmd_set_conntrack_common_peer_value, + (void *)&cmd_set_conntrack_common_is_orig, + (void *)&cmd_set_conntrack_common_is_orig_value, + (void *)&cmd_set_conntrack_common_enable, + (void *)&cmd_set_conntrack_common_enable_value, + (void *)&cmd_set_conntrack_common_live, + (void *)&cmd_set_conntrack_common_live_value, + (void *)&cmd_set_conntrack_common_sack, + (void *)&cmd_set_conntrack_common_sack_value, + (void *)&cmd_set_conntrack_common_cack, + (void *)&cmd_set_conntrack_common_cack_value, + (void *)&cmd_set_conntrack_common_last_dir, + (void *)&cmd_set_conntrack_common_last_dir_value, + (void *)&cmd_set_conntrack_common_liberal, + (void *)&cmd_set_conntrack_common_liberal_value, + (void *)&cmd_set_conntrack_common_state, + (void *)&cmd_set_conntrack_common_state_value, + (void *)&cmd_set_conntrack_common_max_ackwin, + (void *)&cmd_set_conntrack_common_max_ackwin_value, + (void *)&cmd_set_conntrack_common_retrans, + (void *)&cmd_set_conntrack_common_retrans_value, + (void *)&cmd_set_conntrack_common_last_win, + (void *)&cmd_set_conntrack_common_last_win_value, + (void *)&cmd_set_conntrack_common_last_seq, + (void *)&cmd_set_conntrack_common_last_seq_value, + (void *)&cmd_set_conntrack_common_last_ack, + (void *)&cmd_set_conntrack_common_last_ack_value, + (void *)&cmd_set_conntrack_common_last_end, + (void *)&cmd_set_conntrack_common_last_end_value, + (void *)&cmd_set_conntrack_common_last_index, + (void *)&cmd_set_conntrack_common_last_index_value, +NULL , + }, +}; + +/** Set connection tracking object both directions' details */ +struct cmd_set_conntrack_dir_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t conntrack; +cmdline_fixed_string_t dir; +cmdline_fixed_string_t scale; +cmdline_fixed_string_t fin; +cmdline_fixed_string_t ack_seen; +cmdline_fixed_string_t unack; +cmdline_fixed_string_t sent_end; +cmdline_fixed_string_t reply_end; +cmdline_fixed_string_t max_win; +cmdline_fixed_string_t max_ack; +uint32_t factor; +uint32_t f; +uint32_t as; +uint32_t un; +uint32_t se; +uint32_t re; +uint32_t mw; +uint32_t ma; +}; + +cmdline_parse_token_string_t cmd_set_conntrack_dir_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + set,"set" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + conntrack,"conntrack" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_dir = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + dir,"orig#rply" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_scale = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + scale,"scale" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + factor,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_fin = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + fin,"fin" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + f,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + ack_seen,"acked" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + as,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + unack,"unack_data" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + un,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + sent_end,"sent_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + se,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + reply_end,"reply_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + re,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + max_win,"max_win" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + mw,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + max_ack,"max_ack" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + ma,RTE_UINT32 ); + +static void cmd_set_conntrack_dir_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_conntrack_dir_result *res = parsed_result; +struct rte_flow_tcp_dir_param *dir =NULL ; + +if (strcmp (res->dir,"orig" ) ==0 ) + dir = &conntrack_context.original_dir; +else if (strcmp (res->dir,"rply" ) ==0 ) + dir = &conntrack_context.reply_dir; +else +return ; + dir->scale = res->factor; + dir->close_initiated = res->f; + dir->last_ack_seen = res->as; + dir->data_unacked = res->un; + dir->sent_end = res->se; + dir->reply_end = res->re; + dir->max_ack = res->ma; + dir->max_win = res->mw; +} + +cmdline_parse_inst_t cmd_set_conntrack_dir = { + .f = cmd_set_conntrack_dir_parsed, + .data =NULL , + .help_str ="set conntrack orig|rply scale <factor> fin <sent>" +" acked <seen> unack_data <unack> sent_end <sent>" +" reply_end <reply> max_win <win> max_ack <ack>" , + .tokens = { + (void *)&cmd_set_conntrack_set, + (void *)&cmd_set_conntrack_conntrack, + (void *)&cmd_set_conntrack_dir_dir, + (void *)&cmd_set_conntrack_dir_scale, + (void *)&cmd_set_conntrack_dir_scale_value, + (void *)&cmd_set_conntrack_dir_fin, + (void *)&cmd_set_conntrack_dir_fin_value, + (void *)&cmd_set_conntrack_dir_ack, + (void *)&cmd_set_conntrack_dir_ack_value, + (void *)&cmd_set_conntrack_dir_unack_data, + (void *)&cmd_set_conntrack_dir_unack_data_value, + (void *)&cmd_set_conntrack_dir_sent_end, + (void *)&cmd_set_conntrack_dir_sent_end_value, + (void *)&cmd_set_conntrack_dir_reply_end, + (void *)&cmd_set_conntrack_dir_reply_end_value, + (void *)&cmd_set_conntrack_dir_max_win, + (void *)&cmd_set_conntrack_dir_max_win_value, + (void *)&cmd_set_conntrack_dir_max_ack, + (void *)&cmd_set_conntrack_dir_max_ack_value, +NULL , + }, +}; +/* Strict link priority scheduling mode setting */ static void cmd_strict_link_prio_parsed(
@@ -17120,6 +17472,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, + (cmdline_parse_inst_t *)&cmd_set_conntrack_common, + (cmdline_parse_inst_t *)&cmd_set_conntrack_dir, (cmdline_parse_inst_t *)&cmd_ddp_add, (cmdline_parse_inst_t *)&cmd_ddp_del, (cmdline_parse_inst_t *)&cmd_ddp_get_list,
app/test-pmd/cmdline_flow.c +92 -0
152 lines not on this page · raw message
app/test-pmd/config.c +64 -1
87 lines not on this page · raw message
app/test-pmd/testpmd.h +2 -0
@@ -630,6 +630,8 @@ extern struct mplsoudp_decap_conf mplsoudp_decap_conf;extern enum rte_eth_rx_mq_mode rx_mq_mode; +extern struct rte_flow_action_conntrack conntrack_context; +static inline unsigned int lcore_num (void ) {
Signature · 1 line
2.19.0.windows.1
PATCH v3 3/3 doc: update for conntrack
In reply to Bing ZhaoThe updated documentations include:
1. Release notes
2. rte_flow.rst
3. testpmd user guide
--- doc/guides/prog_guide/rte_flow.rst | 113 ++++++++++++++++++++ doc/guides/rel_notes/release_21_05.rst | 4 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 35 ++++++ 3 files changed, 152 insertions(+)
doc/guides/prog_guide/rte_flow.rst +113 -0
@@ -1398,6 +1398,14 @@ Matches a eCPRI header. - ``hdr``: eCPRI header definition (``rte_ecpri.h``). - Default ``mask`` matches nothing, for all eCPRI messages. +Item: ``CONNTRACK`` +^^^^^^^^^^^^^^^^^^^ + +Matches a conntrack state after conntrack action. + +- ``flags``: conntrack packet state flags. +- Default ``mask`` matches all state bits. + Actions ~~~~~~~
@@ -2842,6 +2850,111 @@ for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. | ``value`` | immediate value or a pointer to this value | +---------------+----------------------------------------------------------+ +Action: ``CONNTRACK`` +^^^^^^^^^^^^^^^^^^^^^ + +Create a conntrack (connection tracking) context with the provided information. + +In stateful session like TCP, the conntrack action provides the ability to +examine every packet of this connection and associate the state to every +packet. It will help to realize the stateful offloading with little software +participation. For example, only the control packets like SYN / FIN or packets +with invalid state should be handled by the software. + +A conntrack context should be created via ``rte_flow_action_handle_create()`` +before using. Then the handle with ``INDIRECT`` type is used for a flow rule +creation. If a flow rule with an opposite direction needs to be created, the +``rte_flow_action_handle_update()`` should be used to modify the direction. + +Not all the fields of the ``struct rte_flow_action_conntrack`` will be used +for a conntrack context creating, depending on the HW. +The ``struct rte_flow_modify_conntrack`` should be used for an updating. + +The current conntrack context information could be queried via the +``rte_flow_action_handle_query()`` interface. + +.. _table_rte_flow_action_conntrack: + +.. table:: CONNTRACK + + +--------------------------+-------------------------------------------------------------+ + | Field | Value | + +==========================+=============================================================+ + | ``peer_port`` | peer port number | + +--------------------------+-------------------------------------------------------------+ + | ``is_original_dir`` | direction of this connection for flow rule creating | + +--------------------------+-------------------------------------------------------------+ + | ``enable`` | enable the conntrack context | + +--------------------------+-------------------------------------------------------------+ + | ``live_connection`` | one ack was seen for this connection | + +--------------------------+-------------------------------------------------------------+ + | ``selective_ack`` | SACK enabled | + +--------------------------+-------------------------------------------------------------+ + | ``challenge_ack_passed`` | a challenge ack has passed | + +--------------------------+-------------------------------------------------------------+ + | ``last_direction`` | direction of the last passed packet | + +--------------------------+-------------------------------------------------------------+ + | ``liberal_mode`` | only report state change | + +--------------------------+-------------------------------------------------------------+ + | ``state`` | current state | + +--------------------------+-------------------------------------------------------------+ + | ``max_ack_window`` | maximal window scaling factor | + +--------------------------+-------------------------------------------------------------+ + | ``retransmission_limit`` | maximal retransmission times | + +--------------------------+-------------------------------------------------------------+ + | ``original_dir`` | TCP parameters of the original direction | + +--------------------------+-------------------------------------------------------------+ + | ``reply_dir`` | TCP parameters of the reply direction | + +--------------------------+-------------------------------------------------------------+ + | ``last_window`` | window value of the last passed packet | + +--------------------------+-------------------------------------------------------------+ + | ``last_seq`` | sequence value of the last passed packet | + +--------------------------+-------------------------------------------------------------+ + | ``last_ack`` | acknowledgement value the last passed packet | + +--------------------------+-------------------------------------------------------------+ + | ``last_end`` | sum acknowledgement and length value the last passed packet | + +--------------------------+-------------------------------------------------------------+ + +.. _table_rte_flow_tcp_dir_param: + +.. table:: configuration parameters for each direction + + +---------------------+---------------------------------------------------------+ + | Field | Value | + +=====================+=========================================================+ + | ``scale`` | TCP window scaling factor | + +---------------------+---------------------------------------------------------+ + | ``close_initiated`` | FIN sent from this direction | + +---------------------+---------------------------------------------------------+ + | ``last_ack_seen`` | an ACK packet received | + +---------------------+---------------------------------------------------------+ + | ``data_unacked`` | unacknowledged data for packets from this direction | + +---------------------+---------------------------------------------------------+ + | ``sent_end`` | max{seq + len} seen in sent packets | + +---------------------+---------------------------------------------------------+ + | ``reply_end`` | max{sack + max{win, 1}} seen in reply packets | + +---------------------+---------------------------------------------------------+ + | ``max_win`` | max{max{win, 1}} + {sack - ack} seen in sent packets | + +---------------------+---------------------------------------------------------+ + | ``max_ack`` | max{ack} + seen in sent packets | + +---------------------+---------------------------------------------------------+ + +.. _table_rte_flow_modify_conntrack: + +.. table:: update a conntrack context + + +----------------+---------------------------------------+ + | Field | Value | + +================+=======================================+ + | ``new_ct`` | new conntrack information | + +----------------+---------------------------------------+ + | ``direction`` | direction will be updated | + +----------------+---------------------------------------+ + | ``state`` | other fields except will be updated | + +----------------+---------------------------------------+ + | ``reserved`` | reserved bits | + +----------------+---------------------------------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/rel_notes/release_21_05.rst +4 -0
@@ -183,6 +183,10 @@ New Features the events across multiple stages. * This also reduced the scheduling overhead on a event device. +* **Added conntrack support for rte_flow.** + + * Added conntrack action and item for stateful offloading. + * **Updated testpmd.** * Added a command line option to configure forced speed for Ethernet port.
doc/guides/testpmd_app_ug/testpmd_funcs.rst +35 -0
@@ -3791,6 +3791,8 @@ This section lists supported pattern items and their attributes, if any. - ``s_field {unsigned}``: S field. - ``seid {unsigned}``: session endpoint identifier. +- ``conntrack``: match conntrack state. + Actions list ^^^^^^^^^^^^
@@ -4925,6 +4927,39 @@ NVGRE encapsulation header and sent to port id 0. testpmd> flow create 0 ingress transfer pattern eth / end actions sample ratio 1 index 0 / port_id id 2 / end +Sample conntrack rules +~~~~~~~~~~~~~~~~~~~~~~ + +Conntrack rules can be set by the following commands + +Need to construct the connection context with provided information. +In the first table, create a flow rule by using conntrack action and jump to +the next table. In the next table, create a rule to check the state. + +:: + + testpmd> set conntrack com peer 1 is_orig 1 enable 1 live 1 sack 1 cack 0 + last_dir 0 liberal 0 state 1 max_ack_win 7 r_lim 5 last_win 510 + last_seq 2632987379 last_ack 2532480967 last_end 2632987379 + last_index 0x8 + testpmd> set conntrack orig scale 7 fin 0 acked 1 unack_data 0 + sent_end 2632987379 reply_end 2633016339 max_win 28960 + max_ack 2632987379 + testpmd> set conntrack rply scale 7 fin 0 acked 1 unack_data 0 + sent_end 2532480967 reply_end 2532546247 max_win 65280 + max_ack 2532480967 + testpmd> flow indirect_action 0 create ingress action conntrack / end + testpmd> flow create 0 group 3 ingress pattern eth / ipv4 / tcp / end actions indirect 0 / jump group 5 / end + testpmd> flow create 0 group 5 ingress pattern eth / ipv4 / tcp / conntrack is 1 / end actions queue index 5 / end + +Construct the conntrack again with only "is_orig" set to 0 (other fields are +ignored), then use "update" interface to update the direction. Create flow +rules like above for the peer port. + +:: + + testpmd> flow indirect_action 0 update 0 action conntrack_update dir / end + BPF Functions --------------
Signature · 1 line
2.19.0.windows.1
Re: [dpdk-dev] [PATCH v3 3/3] doc: update for conntrack
Doc should be added with the code.
16/04/2021 19:54, Bing Zhao:
Quoted 3 lines
The updated documentations include:
1. Release notes
2.rte_flow.rst
1 & 2 can go in ethdev patch
Quoted 1 line
3. testpmd user guide
3 can go in testpmd patch.
Re: [dpdk-dev] [PATCH v3 3/3] doc: update for conntrack
In reply to Bing ZhaoQuoted 34 lines · Bing Zhao
The updated documentations include:
1. Release notes
2.rte_flow.rst
3. testpmd user guideSigned-off-by Bing Zhao <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 113 ++++++++++++++++++++ doc/guides/rel_notes/release_21_05.rst | 4 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 35 ++++++ 3 files changed, 152 insertions(+)doc/guides/prog_guide/rte_flow.rst +8
-0@@ -1398,6 +1398,14 @@ Matches a eCPRI header. - ``hdr``: eCPRI header definition (``rte_ecpri.h``). - Default ``mask`` matches nothing, for all eCPRI messages. +Item: ``CONNTRACK`` +^^^^^^^^^^^^^^^^^^^ + +Matches a conntrack state after conntrack action. + +- ``flags``: conntrack packet state flags. +- Default ``mask`` matches all state bits. + Actions ~~~~~~~@@ -2842,6 +2850,111 @@ for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. | ``value`` | immediate value or a pointer to this value |
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. · line 2860
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+---------------+----------------------------------------------------------+ +Action: ``CONNTRACK`` +^^^^^^^^^^^^^^^^^^^^^ + +Create a conntrack (connection tracking) context with the provided information. + +In stateful session like TCP, the conntrack action provides the ability to +examine every packet of this connection and associate the state to every +packet. It will help to realize the stateful offloading with little software
s/stateful offloading/stateful offload of connections
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. · line 2862
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+participation. For example, only the control packets like SYN / FIN or packets +with invalid state should be handled by the software.
s/invalid state should be handled by the software/invalid state may be handled by the software while the rest of the control frames may be handled in hardware.
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. · line 2870
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+ +A conntrack context should be created via ``rte_flow_action_handle_create()`` +before using. Then the handle with ``INDIRECT`` type is used for a flow rule +creation. If a flow rule with an opposite direction needs to be created, the +``rte_flow_action_handle_update()`` should be used to modify the direction. + +Not all the fields of the ``struct rte_flow_action_conntrack`` will be used +for a conntrack context creating, depending on the HW.
s/context creating/context creation.
s/depending on the HW./This capability will depend on the underlying hardware
Quoted 5 lines
doc/guides/prog_guide/rte_flow.rst +5
-0+The ``struct rte_flow_modify_conntrack`` should be used for an updating. + +The current conntrack context information could be queried via the +``rte_flow_action_handle_query()`` interface. +
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. · line 2885
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+.. _table_rte_flow_action_conntrack: + +.. table:: CONNTRACK + + +--------------------------+-------------------------------------------------------------+ + | Field | Value | + +==========================+=============================================================+ + | ``peer_port`` | peer port number | + +--------------------------+-------------------------------------------------------------+ + | ``is_original_dir`` | direction of this connection for flow rule creating |
s/for flow rule creating/for creating flow rule
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst +8
-0+ +--------------------------+-------------------------------------------------------------+ + | ``enable`` | enable the conntrack context | + +--------------------------+-------------------------------------------------------------+ + | ``live_connection`` | one ack was seen for this connection | + +--------------------------+-------------------------------------------------------------+ + | ``selective_ack`` | SACK enabled | + +--------------------------+-------------------------------------------------------------+ + | ``challenge_ack_passed`` | a challenge ack has passed |
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. · line 2903
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+ +--------------------------+-------------------------------------------------------------+ + | ``last_direction`` | direction of the last passed packet | + +--------------------------+-------------------------------------------------------------+ + | ``liberal_mode`` | only report state change | + +--------------------------+-------------------------------------------------------------+ + | ``state`` | current state | + +--------------------------+-------------------------------------------------------------+ + | ``max_ack_window`` | maximal window scaling factor | + +--------------------------+-------------------------------------------------------------+ + | ``retransmission_limit`` | maximal retransmission times |
s/times/limit
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. · line 2909
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst +6
-0+ +--------------------------+-------------------------------------------------------------+ + | ``original_dir`` | TCP parameters of the original direction | + +--------------------------+-------------------------------------------------------------+ + | ``reply_dir`` | TCP parameters of the reply direction | + +--------------------------+-------------------------------------------------------------+ + | ``last_window`` | window value of the last passed packet |
s/value/size
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. · line 2911
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+ +--------------------------+-------------------------------------------------------------+ + | ``last_seq`` | sequence value of the last passed packet |
s/value/number
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. · line 2913
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+ +--------------------------+-------------------------------------------------------------+ + | ``last_ack`` | acknowledgement value the last passed packet |
s/value/number
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. · line 2915
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+ +--------------------------+-------------------------------------------------------------+ + | ``last_end`` | sum acknowledgement and length value the last passed packet |
sum of ack number and length of the last passed packet or
sum of acknowledgement number and length of the last passed packet
Quoted 28 lines
doc/guides/prog_guide/rte_flow.rst +28
-0+ +--------------------------+-------------------------------------------------------------+ + +.. _table_rte_flow_tcp_dir_param: + +.. table:: configuration parameters for each direction + + +---------------------+---------------------------------------------------------+ + | Field | Value | + +=====================+=========================================================+ + | ``scale`` | TCP window scaling factor | + +---------------------+---------------------------------------------------------+ + | ``close_initiated`` | FIN sent from this direction | + +---------------------+---------------------------------------------------------+ + | ``last_ack_seen`` | an ACK packet received | + +---------------------+---------------------------------------------------------+ + | ``data_unacked`` | unacknowledged data for packets from this direction | + +---------------------+---------------------------------------------------------+ + | ``sent_end`` | max{seq + len} seen in sent packets | + +---------------------+---------------------------------------------------------+ + | ``reply_end`` | max{sack + max{win, 1}} seen in reply packets | + +---------------------+---------------------------------------------------------+ + | ``max_win`` | max{max{win, 1}} + {sack - ack} seen in sent packets | + +---------------------+---------------------------------------------------------+ + | ``max_ack`` | max{ack} + seen in sent packets | + +---------------------+---------------------------------------------------------+ + +.. _table_rte_flow_modify_conntrack: +
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. · line 2953
Quoted 10 lines
doc/guides/prog_guide/rte_flow.rst +10
-0+.. table:: update a conntrack context + + +----------------+---------------------------------------+ + | Field | Value | + +================+=======================================+ + | ``new_ct`` | new conntrack information | + +----------------+---------------------------------------+ + | ``direction`` | direction will be updated | + +----------------+---------------------------------------+ + | ``state`` | other fields except will be updated |
except what?
direction??
Quoted 56 lines
doc/guides/prog_guide/rte_flow.rst +4
-0+ +----------------+---------------------------------------+ + | ``reserved`` | reserved bits | + +----------------+---------------------------------------+ + Negative types ~~~~~~~~~~~~~~doc/guides/rel_notes/release_21_05.rst +4
-0@@ -183,6 +183,10 @@ New Features the events across multiple stages. * This also reduced the scheduling overhead on a event device. +* **Added conntrack support for rte_flow.** + + * Added conntrack action and item for stateful offloading. + * **Updated testpmd.** * Added a command line option to configure forced speed for Ethernet port.doc/guides/testpmd_app_ug/testpmd_funcs.rst +19
-0@@ -3791,6 +3791,8 @@ This section lists supported pattern items and their attributes, if any. - ``s_field {unsigned}``: S field. - ``seid {unsigned}``: session endpoint identifier. +- ``conntrack``: match conntrack state. + Actions list ^^^^^^^^^^^^@@ -4925,6 +4927,39 @@ NVGRE encapsulation header and sent to port id 0. testpmd> flow create 0 ingress transfer pattern eth / end actions sample ratio 1 index 0 / port_id id 2 / end +Sample conntrack rules +~~~~~~~~~~~~~~~~~~~~~~ + +Conntrack rules can be set by the following commands + +Need to construct the connection context with provided information. +In the first table, create a flow rule by using conntrack action and jump to +the next table. In the next table, create a rule to check the state. + +:: + + testpmd> set conntrack com peer 1 is_orig 1 enable 1 live 1 sack 1 cack 0 + last_dir 0 liberal 0 state 1 max_ack_win 7 r_lim 5 last_win 510 + last_seq 2632987379 last_ack 2532480967 last_end 2632987379 + last_index 0x8 + testpmd> set conntrack orig scale 7 fin 0 acked 1 unack_data 0 + sent_end 2632987379 reply_end 2633016339 max_win 28960
doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port id 0. · line 4956
Quoted 10 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +10
-0+ max_ack 2632987379 + testpmd> set conntrack rply scale 7 fin 0 acked 1 unack_data 0 + sent_end 2532480967 reply_end 2532546247 max_win 65280 + max_ack 2532480967 + testpmd> flow indirect_action 0 create ingress action conntrack / end + testpmd> flow create 0 group 3 ingress pattern eth / ipv4 / tcp / end actions indirect 0 / jump group 5 / end + testpmd> flow create 0 group 5 ingress pattern eth / ipv4 / tcp / conntrack is 1 / end actions queue index 5 / end + +Construct the conntrack again with only "is_orig" set to 0 (other fields are +ignored), then use "update" interface to update the direction. Create flow
s/use/use the
doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port id 0. · line 4957
Quoted 1 line
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1
-0+rules like above for the peer port.
By peer, do you mean peer system? Or remote/dst port of the TCP connection?
Quoted 11 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +5
-1+ +:: + + testpmd> flow indirect_action 0 update 0 action conntrack_update dir / end + BPF Functions -------------- --2.19.0.windows.1
Re: [dpdk-dev] [PATCH v3 3/3] doc: update for conntrack
Hi Ajit,
Quoted 66 lines
-----Original Message-----
From: Ajit Khaparde <[email protected]>
Sent: Saturday, April 17, 2021 2:30 AM
To: Bing Zhao <[email protected]>
Cc: Ori Kam <[email protected]>; NBU-Contact-Thomas Monjalon <[email protected]>; Ferruh Yigit <[email protected]>; Andrew Rybchenko <[email protected]>; dpdk-dev <[email protected]>; Xiaoyun Li <[email protected]>
Subject: Re: [PATCH v3 3/3] doc: update for conntrackQuoted 9 lines · Bing Zhao
The updated documentations include:
1. Release notes
2.rte_flow.rst
3. testpmd user guideSigned-off-by Bing Zhao <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 113++++++++++++++++++++
Review
Quoted 5 lines
doc/guides/rel_notes/release_21_05.rst | 4 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 35 ++++++ 3 files changed, 152 insertions(+)(quoted diff) +0
-0
b/doc/guides/prog_guide/rte_flow.rstdoc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and
Quoted 19 lines
index
2ecc48cfff..a1333819fc100644doc/guides/prog_guide/rte_flow.rst +8
-0@@ -1398,6 +1398,14 @@ Matches a eCPRI header. - ``hdr``: eCPRI header definition (``rte_ecpri.h``). - Default ``mask`` matches nothing, for all eCPRI messages. +Item: ``CONNTRACK`` +^^^^^^^^^^^^^^^^^^^ + +Matches a conntrack state after conntrack action. + +- ``flags``: conntrack packet state flags. +- Default ``mask`` matches all state bits. + Actions ~~~~~~~@@ -2842,6 +2850,111 @@ for ``RTE_FLOW_FIELD_VALUE`` and``RTE_FLOW_FIELD_POINTER`` respectively.
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2850
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +0
-0| ``value`` | immediate value or a pointer to this value|
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2851
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +0
-0+---------------+----------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively.
Quoted 5 lines
doc/guides/prog_guide/rte_flow.rst +4
-0+Action: ``CONNTRACK`` +^^^^^^^^^^^^^^^^^^^^^ + +Create a conntrack (connection tracking) context with theprovided information.
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2857
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+ +In stateful session like TCP, the conntrack action provides theability to
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2858
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+examine every packet of this connection and associate the stateto every
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2859
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+packet. It will help to realize the stateful offloading withlittle software
s/stateful offloading/stateful offload of connections
Quoted 8 lines
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2860
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+participation. For example, only the control packets like SYN /FIN or packets
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. · line 2862
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+with invalid state should be handled by the software.s/invalid state should be handled by the software/invalid state may be
handled by the software while the rest of the control frames may be handled in hardware.
I updated this part, please take a review.
In general, the control packets could be handled by HW and SW could get a state change state of the packet. The SW could also handle the control packet if there is a flow rule for the state change.
Quoted 87 lines
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2863
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+ +A conntrack context should be created via``rte_flow_action_handle_create()``
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2864
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+before using. Then the handle with ``INDIRECT`` type is used fora flow rule
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2865
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+creation. If a flow rule with an opposite direction needs to becreated, the
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2866
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+``rte_flow_action_handle_update()`` should be used to modify thedirection.
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2868
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+ +Not all the fields of the ``struct rte_flow_action_conntrack``will be used
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. · line 2870
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+for a conntrack context creating, depending on the HW.s/context creating/context creation.
s/depending on the HW./This capability will depend on the underlying hardwaredoc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2870
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+The ``struct rte_flow_modify_conntrack`` should be used for anupdating.
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2872
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +2
-0+ +The current conntrack context information could be queried viathe
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively.
Quoted 7 lines
doc/guides/prog_guide/rte_flow.rst +7
-0+``rte_flow_action_handle_query()`` interface. + +.. _table_rte_flow_action_conntrack: + +.. table:: CONNTRACK + + +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2880
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | Field | Value|
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2881
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0++==========================+========================================
=====================+doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2882
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``peer_port`` | peer port number|
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2883
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2884
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``is_original_dir`` | direction of this connection forflow rule creating |
s/for flow rule creating/for creating flow ruledoc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2885
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2886
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``enable`` | enable the conntrack context|
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2887
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2888
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``live_connection`` | one ack was seen for thisconnection |
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2889
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2890
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``selective_ack`` | SACK enabled|
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2891
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2892
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``challenge_ack_passed`` | a challenge ack has passed|
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2893
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2894
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``last_direction`` | direction of the last passedpacket |
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2895
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2896
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``liberal_mode`` | only report state change|
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2897
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2898
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``state`` | current state|
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2899
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2900
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``max_ack_window`` | maximal window scaling factor|
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2901
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2902
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``retransmission_limit`` | maximal retransmission times|
s/times/limitdoc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2903
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2904
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``original_dir`` | TCP parameters of the originaldirection |
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2905
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+----------------------------------
Quoted 8 lines
---------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2906
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``reply_dir`` | TCP parameters of the replydirection |
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2907
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2908
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``last_window`` | window value of the last passedpacket |
s/value/size
Done
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2909
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2910
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``last_seq`` | sequence value of the last passedpacket |
s/value/number
Agree, thanks
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2911
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2912
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``last_ack`` | acknowledgement value the lastpassed packet |
s/value/number
Thanks
Quoted 9 lines
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2913
Quoted 2 lines
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2914
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``last_end`` | sum acknowledgement and lengthvalue the last passed packet |
sum of ack number and length of the last passed packet or
sum of acknowledgement number and length of the last passed packet
Updated, thanks. Also update the typo
Quoted 46 lines
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2915
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +--------------------------+-------------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively.
Quoted 6 lines
doc/guides/prog_guide/rte_flow.rst +6
-0+ +.. _table_rte_flow_tcp_dir_param: + +.. table:: configuration parameters for each direction + + +---------------------+---------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2922
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | Field | Value|
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2923
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0++=====================+=============================================
============+doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2924
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``scale`` | TCP window scaling factor|
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2925
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +---------------------+---------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2926
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``close_initiated`` | FIN sent from this direction|
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2927
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +---------------------+---------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2928
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``last_ack_seen`` | an ACK packet received|
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2929
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +---------------------+---------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2930
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``data_unacked`` | unacknowledged data for packets fromthis direction |
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2931
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +---------------------+---------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2932
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``sent_end`` | max{seq + len} seen in sent packets|
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2933
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +---------------------+---------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2934
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``reply_end`` | max{sack + max{win, 1}} seen in replypackets |
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2935
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +---------------------+---------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2936
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``max_win`` | max{max{win, 1}} + {sack - ack} seenin sent packets |
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2937
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +---------------------+---------------------------------------------------------+
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2938
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ | ``max_ack`` | max{ack} + seen in sent packets|
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and · line 2939
Quoted 1 line
doc/guides/prog_guide/rte_flow.rst +1
-0+ +---------------------+---------------------------------------------------------+
Quoted 15 lines
doc/guides/prog_guide/rte_flow.rst for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. · line 2953
Quoted 13 lines
doc/guides/prog_guide/rte_flow.rst +13
-0+ +.. _table_rte_flow_modify_conntrack: + +.. table:: update a conntrack context + + +----------------+---------------------------------------+ + | Field | Value | + +================+=======================================+ + | ``new_ct`` | new conntrack information | + +----------------+---------------------------------------+ + | ``direction`` | direction will be updated | + +----------------+---------------------------------------+ + | ``state`` | other fields except will be updated |except what?
direction??
Yes, missed this word, updated.
Quoted 82 lines
Review
Quoted 9 lines
doc/guides/prog_guide/rte_flow.rst +4
-0+ +----------------+---------------------------------------+ + | ``reserved`` | reserved bits | + +----------------+---------------------------------------+ + Negative types ~~~~~~~~~~~~~~(quoted diff) +0
-0
b/doc/guides/rel_notes/release_21_05.rstQuoted 4 lines
index
e6f99350af..824eb72981100644doc/guides/rel_notes/release_21_05.rst New Features · line 192
Quoted 10 lines
doc/guides/rel_notes/release_21_05.rst +4
-0@@ -183,6 +183,10 @@ New Features the events across multiple stages. * This also reduced the scheduling overhead on a event device. +* **Added conntrack support for rte_flow.** + + * Added conntrack action and item for stateful offloading. + * **Updated testpmd.** * Added a command line option to configure forced speed forEthernet port.
Review
Quoted 1 line
(quoted diff) +0
-0
b/doc/guides/testpmd_app_ug/testpmd_funcs.rstdoc/guides/testpmd_app_ug/testpmd_funcs.rst This section lists supported pattern items
Quoted 4 lines
index
1fa6e2000e..4c029776aa100644doc/guides/testpmd_app_ug/testpmd_funcs.rst +0
-0@@ -3791,6 +3791,8 @@ This section lists supported pattern itemsand their attributes, if any.
doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port
Quoted 9 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2
-0- ``s_field {unsigned}``: S field. - ``seid {unsigned}``: session endpoint identifier. +- ``conntrack``: match conntrack state. + Actions list ^^^^^^^^^^^^@@ -4925,6 +4927,39 @@ NVGRE encapsulation header and sent to portid 0.
doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port · line 4927
Quoted 1 line
doc/guides/testpmd_app_ug/testpmd_funcs.rst +0
-0testpmd> flow create 0 ingress transfer pattern eth / endactions
doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port id 0.
Quoted 8 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +6
-0sample ratio 1 index 0 / port_id id 2 / end +Sample conntrack rules +~~~~~~~~~~~~~~~~~~~~~~ + +Conntrack rules can be set by the following commands + +Need to construct the connection context with providedinformation.
doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port · line 4936
Quoted 1 line
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1
-0+In the first table, create a flow rule by using conntrack actionand jump to
doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port · line 4937
Quoted 1 line
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1
-0+the next table. In the next table, create a rule to check thestate.
doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port id 0.
Quoted 4 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4
-0+ +:: + + testpmd> set conntrack com peer 1 is_orig 1 enable 1 live 1 sack1 cack 0
doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port · line 4942
Quoted 1 line
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1
-0+ last_dir 0 liberal 0 state 1 max_ack_win 7 r_lim 5
last_win510doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port · line 4943
Quoted 1 line
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1
-0+ last_seq 2632987379 last_ack 2532480967 last_end2632987379
doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port id 0.
Quoted 8 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +8
-0+ last_index 0x8 + testpmd> set conntrack orig scale 7 fin 0 acked 1 unack_data 0 + sent_end 2632987379 reply_end 2633016339 max_win 28960 + max_ack 2632987379 + testpmd> set conntrack rply scale 7 fin 0 acked 1 unack_data 0 + sent_end 2532480967 reply_end 2532546247 max_win 65280 + max_ack 2532480967 + testpmd> flow indirect_action 0 create ingress action conntrack/ end
doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port · line 4952
Quoted 1 line
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1
-0+ testpmd> flow create 0 group 3 ingress pattern eth / ipv4 / tcp/ end actions indirect 0 / jump group 5 / end
doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port · line 4953
Quoted 1 line
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1
-0+ testpmd> flow create 0 group 5 ingress pattern eth / ipv4 / tcp/ conntrack is 1 / end actions queue index 5 / end
doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port · line 4955
Quoted 2 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +2
-0+ +Construct the conntrack again with only "is_orig" set to 0 (otherfields are
Quoted 7 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port · line 4956
Quoted 1 line
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1
-0+ignored), then use "update" interface to update the direction.Create flow
s/use/use thedoc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port id 0. · line 4957
Quoted 1 line
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1
-0+rules like above for the peer port.By peer, do you mean peer system? Or remote/dst port of the TCP connection?
The peer port of the conntrack. One conntrack context should only be used for a bi-dir traffic from to same ethdev port or between a pair of ethdev ports.
Quoted 13 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst NVGRE encapsulation header and sent to port id 0.
Quoted 5 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +4
-0+ +:: + + testpmd> flow indirect_action 0 update 0 action conntrack_updatedir / end
Quoted 7 lines
doc/guides/testpmd_app_ug/testpmd_funcs.rst +1
-1+ BPF Functions -------------- --2.19.0.windows.1
v4 cover ethdev: introduce conntrack flow action and item
In reply to Bing ZhaoThis patch set includes the conntrack action and item definitions as well as the testpmd CLI proposal.
Documents of release notes and guides are also updated.
---
v2: add testpmd CLI proposal
v3: add doc update
v4: fix building and address comments for doc and header file
---
Bing Zhao (3):
ethdev: introduce conntrack flow action and item app/testpmd: add CLI for conntrack
doc: update for conntrack
app/test-pmd/cmdline.c | 355 ++++++++++++++++++++ app/test-pmd/cmdline_flow.c | 92 +++++ app/test-pmd/config.c | 65 +++- app/test-pmd/testpmd.h | 2 + doc/guides/prog_guide/rte_flow.rst | 118 +++++++ doc/guides/rel_notes/release_21_05.rst | 4 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 35 ++ lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 212 ++++++++++++ 9 files changed, 884 insertions(+), 1 deletion(-)
Signature · 1 line
2.19.0.windows.1
PATCH v4 1/3 ethdev: introduce conntrack flow action and item
This commit introduces the conntrack action and item.
Usually the HW offloading is stateless. For some stateful offloading like a TCP connection, HW module will help provide the ability of a full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow rule the application should add the conntrack action and jump to the next flow table. In the following flow rule(s) of the next table, the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack action context correctly, the information of packets from both directions are required.
The conntrack action should be created on one ethdev port and supply the peer ethdev port as a parameter to the action. After context created, it could only be used between these two ethdev ports (dual-port mode) or a single port. The application should modify the action via the API "rte_action_handle_update" only when before using it to create a flow rule with conntrack for the opposite direction. This will help the driver to recognize the direction of the flow to be created, especially in the single-port mode, in which case the traffic from both directions will go through the same ethdev port if the application works as an "forwarding engine" but not an end point. There is no need to call the update interface if the subsequent flow rules have nothing to be changed.
Query will be supported via "rte_action_handle_query" interface, about the current packets information and connection status. The fields query capabilities depends on the HW.
For the packets received during the conntrack setup, it is suggested to re-inject the packets in order to make sure the conntrack module works correctly without missing any packet. Only the valid packets should pass the conntrack, packets with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Naming and definition:
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/
netfilter/nf_conntrack_tcp.h
https://elixir.bootlin.com/linux/latest/source/net/netfilter/
nf_conntrack_proto_tcp.c
Other reference:
https://www.usenix.org/legacy/events/sec01/invitedtalks/rooij.pdf
--- lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 212 +++++++++++++++++++++++++++++++++++ 2 files changed, 214 insertions(+)
lib/librte_ethdev/rte_flow.c +2 -0
@@ -98,6 +98,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {MK_FLOW_ITEM (PFCP ,sizeof (struct rte_flow_item_pfcp )),MK_FLOW_ITEM (ECPRI ,sizeof (struct rte_flow_item_ecpri )),MK_FLOW_ITEM (GENEVE_OPT ,sizeof (struct rte_flow_item_geneve_opt )), + MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)), };/** Generate flow_action[] entry. */
@@ -186,6 +187,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {* indirect action handle. */ MK_FLOW_ACTION (INDIRECT ,0 ), + MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)), };int
lib/librte_ethdev/rte_flow.h +212 -0
242 lines not on this page · raw message
Signature · 1 line
2.19.0.windows.1
Quoted 53 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Monday, April 19, 2021 8:17 PM
Subject: [PATCH v4 1/3] ethdev: introduce conntrack flow action and itemThis commit introduces the conntrack action and item.
Usually the HW offloading is stateless. For some stateful offloading like a TCP connection, HW module will help provide the ability of a full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow rule the application should add the conntrack action and jump to the next flow table. In the following flow rule(s) of the next table, the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack action context correctly, the information of packets from both directions are required.
The conntrack action should be created on one ethdev port and supply the peer ethdev port as a parameter to the action. After context created, it could only be used between these two ethdev ports (dual-port mode) or a single port. The application should modify the action via the API "
rte_action_handle_update" only when before using it to create a flow rule with conntrack for the opposite direction. This will help the driver to recognize the direction of the flow to be created, especially in the single-port mode, in which case the traffic from both directions will go through the same ethdev port if the application works as an "forwarding engine" but not an end point. There is no need to call the update interface if the subsequent flow rules have nothing to be changed.Query will be supported via "
rte_action_handle_query" interface, about the current packets information and connection status. The fields query capabilities depends on the HW.For the packets received during the conntrack setup, it is suggested to re-inject the packets in order to make sure the conntrack module works correctly without missing any packet. Only the valid packets should pass the conntrack, packets with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Naming and definition:
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/
netfilter/nf_conntrack_tcp.h
https://elixir.bootlin.com/linux/latest/source/net/netfilter/
nf_conntrack_proto_tcp.c
Quoted 5 lines
Other reference:
https://www.usenix.org/legacy/events/sec01/invitedtalks/rooij.pdfSigned-off-by Bing Zhao <[email protected]>---
Thanks,
Ori
PATCH v4 2/3 app/testpmd: add CLI for conntrack
In reply to Bing ZhaoThe command line for testing connection tracking is added. To create a conntrack object, 3 parts are needed.
set conntrack com peer ...
set conntrack orig scale ...
set conntrack rply scale ...
This will create a full conntrack action structure for the indirect action. After the indirect action handle of "conntrack" created, it could be used in the flow creation. Before updating, the same structure is also needed together with the update command "conntrack_update" to update the "dir" or "ctx".
After the flow with conntrack action created, the packet should jump to the next flow for the result checking with conntrack item. The state is defined with bits and a valid combination could be supported.
--- app/test-pmd/cmdline.c | 355 ++++++++++++++++++++++++++++++++++++ app/test-pmd/cmdline_flow.c | 92 ++++++++++ app/test-pmd/config.c | 65 ++++++- app/test-pmd/testpmd.h | 2 + 4 files changed, 513 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +355 -0
@@ -13621,6 +13621,359 @@ cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { }, }; +/** Set connection tracking object common details */ +struct cmd_set_conntrack_common_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t conntrack; +cmdline_fixed_string_t common; +cmdline_fixed_string_t peer; +cmdline_fixed_string_t is_orig; +cmdline_fixed_string_t enable; +cmdline_fixed_string_t live; +cmdline_fixed_string_t sack; +cmdline_fixed_string_t cack; +cmdline_fixed_string_t last_dir; +cmdline_fixed_string_t liberal; +cmdline_fixed_string_t state; +cmdline_fixed_string_t max_ack_win; +cmdline_fixed_string_t retrans; +cmdline_fixed_string_t last_win; +cmdline_fixed_string_t last_seq; +cmdline_fixed_string_t last_ack; +cmdline_fixed_string_t last_end; +cmdline_fixed_string_t last_index; +uint8_t stat; +uint8_t factor; +uint16_t peer_port; +uint32_t is_original; +uint32_t en; +uint32_t is_live; +uint32_t s_ack; +uint32_t c_ack; +uint32_t ld; +uint32_t lb; +uint8_t re_num; +uint8_t li; +uint16_t lw; +uint32_t ls; +uint32_t la; +uint32_t le; +}; + +cmdline_parse_token_string_t cmd_set_conntrack_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + set,"set" ); +cmdline_parse_token_string_t cmd_set_conntrack_conntrack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + conntrack,"conntrack" ); +cmdline_parse_token_string_t cmd_set_conntrack_common_com = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + common,"com" ); +cmdline_parse_token_string_t cmd_set_conntrack_common_peer = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + peer,"peer" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + peer_port,RTE_UINT16 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + is_orig,"is_orig" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + is_original,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_enable = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + enable,"enable" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + en,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_live = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + live,"live" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_live_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + is_live,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_sack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + sack,"sack" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + s_ack,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_cack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + cack,"cack" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + c_ack,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_dir,"last_dir" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + ld,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_liberal = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + liberal,"liberal" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + lb,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_state = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + state,"state" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_state_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + stat,RTE_UINT8 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + max_ack_win,"max_ack_win" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + factor,RTE_UINT8 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_retrans = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + retrans,"r_lim" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + re_num,RTE_UINT8 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_win = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_win,"last_win" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + lw,RTE_UINT16 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_seq,"last_seq" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + ls,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_ack,"last_ack" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + la,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_end,"last_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + le,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_index = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_index,"last_index" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + li,RTE_UINT8 ); + +static void cmd_set_conntrack_common_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_conntrack_common_result *res = parsed_result; + +/* No need to swap to big endian. */ + conntrack_context.peer_port = res->peer_port; + conntrack_context.is_original_dir = res->is_original; + conntrack_context.enable = res->en; + conntrack_context.live_connection = res->is_live; + conntrack_context.selective_ack = res->s_ack; + conntrack_context.challenge_ack_passed = res->c_ack; + conntrack_context.last_direction = res->ld; + conntrack_context.liberal_mode = res->lb; + conntrack_context.state = (enum rte_flow_conntrack_state )res->stat; + conntrack_context.max_ack_window = res->factor; + conntrack_context.retransmission_limit = res->re_num; + conntrack_context.last_window = res->lw; + conntrack_context.last_index = + (enum rte_flow_conntrack_tcp_last_index )res->li; + conntrack_context.last_seq = res->ls; + conntrack_context.last_ack = res->la; + conntrack_context.last_end = res->le; +} + +cmdline_parse_inst_t cmd_set_conntrack_common = { + .f = cmd_set_conntrack_common_parsed, + .data =NULL , + .help_str ="set conntrack com peer <port_id> is_orig <dir> enable <en>" +" live <ack_seen> sack <en> cack <passed> last_dir <dir>" +" liberal <en> state <s> max_ack_win <factor> r_lim <num>" +" last_win <win> last_seq <seq> last_ack <ack> last_end <end>" +" last_index <flag>" , + .tokens = { + (void *)&cmd_set_conntrack_set, + (void *)&cmd_set_conntrack_conntrack, + (void *)&cmd_set_conntrack_common_com, + (void *)&cmd_set_conntrack_common_peer, + (void *)&cmd_set_conntrack_common_peer_value, + (void *)&cmd_set_conntrack_common_is_orig, + (void *)&cmd_set_conntrack_common_is_orig_value, + (void *)&cmd_set_conntrack_common_enable, + (void *)&cmd_set_conntrack_common_enable_value, + (void *)&cmd_set_conntrack_common_live, + (void *)&cmd_set_conntrack_common_live_value, + (void *)&cmd_set_conntrack_common_sack, + (void *)&cmd_set_conntrack_common_sack_value, + (void *)&cmd_set_conntrack_common_cack, + (void *)&cmd_set_conntrack_common_cack_value, + (void *)&cmd_set_conntrack_common_last_dir, + (void *)&cmd_set_conntrack_common_last_dir_value, + (void *)&cmd_set_conntrack_common_liberal, + (void *)&cmd_set_conntrack_common_liberal_value, + (void *)&cmd_set_conntrack_common_state, + (void *)&cmd_set_conntrack_common_state_value, + (void *)&cmd_set_conntrack_common_max_ackwin, + (void *)&cmd_set_conntrack_common_max_ackwin_value, + (void *)&cmd_set_conntrack_common_retrans, + (void *)&cmd_set_conntrack_common_retrans_value, + (void *)&cmd_set_conntrack_common_last_win, + (void *)&cmd_set_conntrack_common_last_win_value, + (void *)&cmd_set_conntrack_common_last_seq, + (void *)&cmd_set_conntrack_common_last_seq_value, + (void *)&cmd_set_conntrack_common_last_ack, + (void *)&cmd_set_conntrack_common_last_ack_value, + (void *)&cmd_set_conntrack_common_last_end, + (void *)&cmd_set_conntrack_common_last_end_value, + (void *)&cmd_set_conntrack_common_last_index, + (void *)&cmd_set_conntrack_common_last_index_value, +NULL , + }, +}; + +/** Set connection tracking object both directions' details */ +struct cmd_set_conntrack_dir_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t conntrack; +cmdline_fixed_string_t dir; +cmdline_fixed_string_t scale; +cmdline_fixed_string_t fin; +cmdline_fixed_string_t ack_seen; +cmdline_fixed_string_t unack; +cmdline_fixed_string_t sent_end; +cmdline_fixed_string_t reply_end; +cmdline_fixed_string_t max_win; +cmdline_fixed_string_t max_ack; +uint32_t factor; +uint32_t f; +uint32_t as; +uint32_t un; +uint32_t se; +uint32_t re; +uint32_t mw; +uint32_t ma; +}; + +cmdline_parse_token_string_t cmd_set_conntrack_dir_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + set,"set" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + conntrack,"conntrack" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_dir = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + dir,"orig#rply" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_scale = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + scale,"scale" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + factor,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_fin = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + fin,"fin" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + f,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + ack_seen,"acked" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + as,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + unack,"unack_data" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + un,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + sent_end,"sent_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + se,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + reply_end,"reply_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + re,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + max_win,"max_win" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + mw,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + max_ack,"max_ack" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + ma,RTE_UINT32 ); + +static void cmd_set_conntrack_dir_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_conntrack_dir_result *res = parsed_result; +struct rte_flow_tcp_dir_param *dir =NULL ; + +if (strcmp (res->dir,"orig" ) ==0 ) + dir = &conntrack_context.original_dir; +else if (strcmp (res->dir,"rply" ) ==0 ) + dir = &conntrack_context.reply_dir; +else +return ; + dir->scale = res->factor; + dir->close_initiated = res->f; + dir->last_ack_seen = res->as; + dir->data_unacked = res->un; + dir->sent_end = res->se; + dir->reply_end = res->re; + dir->max_ack = res->ma; + dir->max_win = res->mw; +} + +cmdline_parse_inst_t cmd_set_conntrack_dir = { + .f = cmd_set_conntrack_dir_parsed, + .data =NULL , + .help_str ="set conntrack orig|rply scale <factor> fin <sent>" +" acked <seen> unack_data <unack> sent_end <sent>" +" reply_end <reply> max_win <win> max_ack <ack>" , + .tokens = { + (void *)&cmd_set_conntrack_set, + (void *)&cmd_set_conntrack_conntrack, + (void *)&cmd_set_conntrack_dir_dir, + (void *)&cmd_set_conntrack_dir_scale, + (void *)&cmd_set_conntrack_dir_scale_value, + (void *)&cmd_set_conntrack_dir_fin, + (void *)&cmd_set_conntrack_dir_fin_value, + (void *)&cmd_set_conntrack_dir_ack, + (void *)&cmd_set_conntrack_dir_ack_value, + (void *)&cmd_set_conntrack_dir_unack_data, + (void *)&cmd_set_conntrack_dir_unack_data_value, + (void *)&cmd_set_conntrack_dir_sent_end, + (void *)&cmd_set_conntrack_dir_sent_end_value, + (void *)&cmd_set_conntrack_dir_reply_end, + (void *)&cmd_set_conntrack_dir_reply_end_value, + (void *)&cmd_set_conntrack_dir_max_win, + (void *)&cmd_set_conntrack_dir_max_win_value, + (void *)&cmd_set_conntrack_dir_max_ack, + (void *)&cmd_set_conntrack_dir_max_ack_value, +NULL , + }, +}; +/* Strict link priority scheduling mode setting */ static void cmd_strict_link_prio_parsed(
@@ -17120,6 +17473,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, + (cmdline_parse_inst_t *)&cmd_set_conntrack_common, + (cmdline_parse_inst_t *)&cmd_set_conntrack_dir, (cmdline_parse_inst_t *)&cmd_ddp_add, (cmdline_parse_inst_t *)&cmd_ddp_del, (cmdline_parse_inst_t *)&cmd_ddp_get_list,
app/test-pmd/cmdline_flow.c +92 -0
152 lines not on this page · raw message
app/test-pmd/config.c +64 -1
87 lines not on this page · raw message
app/test-pmd/testpmd.h +2 -0
@@ -630,6 +630,8 @@ extern struct mplsoudp_decap_conf mplsoudp_decap_conf;extern enum rte_eth_rx_mq_mode rx_mq_mode; +extern struct rte_flow_action_conntrack conntrack_context; +static inline unsigned int lcore_num (void ) {
Signature · 1 line
2.19.0.windows.1
Re: [dpdk-dev] [PATCH v4 2/3] app/testpmd: add CLI for conntrack
Hi Bing,
Quoted 16 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Monday, April 19, 2021 8:17 PM
Subject: [PATCH v4 2/3] app/testpmd: add CLI for conntrackThe command line for testing connection tracking is added. To create a conntrack object, 3 parts are needed.
set conntrack com peer ...
set conntrack orig scale ...
set conntrack rply scale ...
This will create a full conntrack action structure for the indirect action. After the indirect action handle of "conntrack" created, it could be used in the flow creation. Before updating, the same structure is also needed together with the update command "conntrack_update" to update the "dir" or "ctx".
Quoted 7 lines
After the flow with conntrack action created, the packet should jump to the next flow for the result checking with conntrack item. The state is defined with bits and a valid combination could be supported.
Signed-off-by Bing Zhao <[email protected]>---
Thanks,
Ori
PATCH v4 3/3 doc: update for conntrack
In reply to Bing ZhaoThe updated documentations include:
1. Release notes
2. rte_flow.rst
3. testpmd user guide
--- doc/guides/prog_guide/rte_flow.rst | 118 ++++++++++++++++++++ doc/guides/rel_notes/release_21_05.rst | 4 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 35 ++++++ 3 files changed, 157 insertions(+)
doc/guides/prog_guide/rte_flow.rst +118 -0
@@ -1398,6 +1398,14 @@ Matches a eCPRI header. - ``hdr``: eCPRI header definition (``rte_ecpri.h``). - Default ``mask`` matches nothing, for all eCPRI messages. +Item: ``CONNTRACK`` +^^^^^^^^^^^^^^^^^^^ + +Matches a conntrack state after conntrack action. + +- ``flags``: conntrack packet state flags. +- Default ``mask`` matches all state bits. + Actions ~~~~~~~
@@ -2842,6 +2850,116 @@ for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. | ``value`` | immediate value or a pointer to this value | +---------------+----------------------------------------------------------+ +Action: ``CONNTRACK`` +^^^^^^^^^^^^^^^^^^^^^ + +Create a conntrack (connection tracking) context with the provided information. + +In stateful session like TCP, the conntrack action provides the ability to +examine every packet of this connection and associate the state to every +packet. It will help to realize the stateful offload of connections with little +software participation. For example, the packets with invalid state may be +handled by the software. The control packets could be handled in the hardware. +The software just need to query the state of a connection when needed, and then +decide how to handle the flow rules and conntrack context. + +A conntrack context should be created via ``rte_flow_action_handle_create()`` +before using. Then the handle with ``INDIRECT`` type is used for a flow rule +creation. If a flow rule with an opposite direction needs to be created, the +``rte_flow_action_handle_update()`` should be used to modify the direction. + +Not all the fields of the ``struct rte_flow_action_conntrack`` will be used +for a conntrack context creating, depending on the HW, and they should be +in host byte order. PMD should convert them into network byte order when +needed by the HW. + +The ``struct rte_flow_modify_conntrack`` should be used for an updating. + +The current conntrack context information could be queried via the +``rte_flow_action_handle_query()`` interface. + +.. _table_rte_flow_action_conntrack: + +.. table:: CONNTRACK + + +--------------------------+-------------------------------------------------------------+ + | Field | Value | + +==========================+=============================================================+ + | ``peer_port`` | peer port number | + +--------------------------+-------------------------------------------------------------+ + | ``is_original_dir`` | direction of this connection for creating flow rule | + +--------------------------+-------------------------------------------------------------+ + | ``enable`` | enable the conntrack context | + +--------------------------+-------------------------------------------------------------+ + | ``live_connection`` | one ack was seen for this connection | + +--------------------------+-------------------------------------------------------------+ + | ``selective_ack`` | SACK enabled | + +--------------------------+-------------------------------------------------------------+ + | ``challenge_ack_passed`` | a challenge ack has passed | + +--------------------------+-------------------------------------------------------------+ + | ``last_direction`` | direction of the last passed packet | + +--------------------------+-------------------------------------------------------------+ + | ``liberal_mode`` | only report state change | + +--------------------------+-------------------------------------------------------------+ + | ``state`` | current state | + +--------------------------+-------------------------------------------------------------+ + | ``max_ack_window`` | maximal window scaling factor | + +--------------------------+-------------------------------------------------------------+ + | ``retransmission_limit`` | maximal retransmission times | + +--------------------------+-------------------------------------------------------------+ + | ``original_dir`` | TCP parameters of the original direction | + +--------------------------+-------------------------------------------------------------+ + | ``reply_dir`` | TCP parameters of the reply direction | + +--------------------------+-------------------------------------------------------------+ + | ``last_window`` | window value of the last passed packet | + +--------------------------+-------------------------------------------------------------+ + | ``last_seq`` | sequence value of the last passed packet | + +--------------------------+-------------------------------------------------------------+ + | ``last_ack`` | acknowledgment value the last passed packet | + +--------------------------+-------------------------------------------------------------+ + | ``last_end`` | sum of ack number and length of the last passed packet | + +--------------------------+-------------------------------------------------------------+ + +.. _table_rte_flow_tcp_dir_param: + +.. table:: configuration parameters for each direction + + +---------------------+---------------------------------------------------------+ + | Field | Value | + +=====================+=========================================================+ + | ``scale`` | TCP window scaling factor | + +---------------------+---------------------------------------------------------+ + | ``close_initiated`` | FIN sent from this direction | + +---------------------+---------------------------------------------------------+ + | ``last_ack_seen`` | an ACK packet received | + +---------------------+---------------------------------------------------------+ + | ``data_unacked`` | unacknowledged data for packets from this direction | + +---------------------+---------------------------------------------------------+ + | ``sent_end`` | max{seq + len} seen in sent packets | + +---------------------+---------------------------------------------------------+ + | ``reply_end`` | max{sack + max{win, 1}} seen in reply packets | + +---------------------+---------------------------------------------------------+ + | ``max_win`` | max{max{win, 1}} + {sack - ack} seen in sent packets | + +---------------------+---------------------------------------------------------+ + | ``max_ack`` | max{ack} + seen in sent packets | + +---------------------+---------------------------------------------------------+ + +.. _table_rte_flow_modify_conntrack: + +.. table:: update a conntrack context + + +----------------+-------------------------------------------------+ + | Field | Value | + +================+=================================================+ + | ``new_ct`` | new conntrack information | + +----------------+-------------------------------------------------+ + | ``direction`` | direction will be updated | + +----------------+-------------------------------------------------+ + | ``state`` | other fields except direction will be updated | + +----------------+-------------------------------------------------+ + | ``reserved`` | reserved bits | + +----------------+-------------------------------------------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/rel_notes/release_21_05.rst +4 -0
@@ -203,6 +203,10 @@ New Features the events across multiple stages. * This also reduced the scheduling overhead on a event device. +* **Added conntrack support for rte_flow.** + + * Added conntrack action and item for stateful offloading. + * **Updated testpmd.** * Added a command line option to configure forced speed for Ethernet port.
doc/guides/testpmd_app_ug/testpmd_funcs.rst +35 -0
@@ -3789,6 +3789,8 @@ This section lists supported pattern items and their attributes, if any. - ``s_field {unsigned}``: S field. - ``seid {unsigned}``: session endpoint identifier. +- ``conntrack``: match conntrack state. + Actions list ^^^^^^^^^^^^
@@ -4927,6 +4929,39 @@ NVGRE encapsulation header and sent to port id 0. testpmd> flow create 0 ingress transfer pattern eth / end actions sample ratio 1 index 0 / port_id id 2 / end +Sample conntrack rules +~~~~~~~~~~~~~~~~~~~~~~ + +Conntrack rules can be set by the following commands + +Need to construct the connection context with provided information. +In the first table, create a flow rule by using conntrack action and jump to +the next table. In the next table, create a rule to check the state. + +:: + + testpmd> set conntrack com peer 1 is_orig 1 enable 1 live 1 sack 1 cack 0 + last_dir 0 liberal 0 state 1 max_ack_win 7 r_lim 5 last_win 510 + last_seq 2632987379 last_ack 2532480967 last_end 2632987379 + last_index 0x8 + testpmd> set conntrack orig scale 7 fin 0 acked 1 unack_data 0 + sent_end 2632987379 reply_end 2633016339 max_win 28960 + max_ack 2632987379 + testpmd> set conntrack rply scale 7 fin 0 acked 1 unack_data 0 + sent_end 2532480967 reply_end 2532546247 max_win 65280 + max_ack 2532480967 + testpmd> flow indirect_action 0 create ingress action conntrack / end + testpmd> flow create 0 group 3 ingress pattern eth / ipv4 / tcp / end actions indirect 0 / jump group 5 / end + testpmd> flow create 0 group 5 ingress pattern eth / ipv4 / tcp / conntrack is 1 / end actions queue index 5 / end + +Construct the conntrack again with only "is_orig" set to 0 (other fields are +ignored), then use "update" interface to update the direction. Create flow +rules like above for the peer port. + +:: + + testpmd> flow indirect_action 0 update 0 action conntrack_update dir / end + BPF Functions --------------
Signature · 1 line
2.19.0.windows.1
Re: [dpdk-dev] [PATCH v4 3/3] doc: update for conntrack
19/04/2021 19:16, Bing Zhao:
Quoted 4 lines
The updated documentations include:
1. Release notes
2.rte_flow.rst
3. testpmd user guide
We need a v5 with doc squashed in previous patches. Release notes should go with ethdev patch.
doc/guides/rel_notes/release_21_05.rst New Features · line 206
Quoted 7 lines
doc/guides/rel_notes/release_21_05.rst +1
-0@@ -203,6 +203,10 @@ New Features the events across multiple stages. * This also reduced the scheduling overhead on a event device. +* **Added conntrack support for rte_flow.**
Suggested headline:
Added TCP connection tracking offload in flow API.
doc/guides/rel_notes/release_21_05.rst New Features · line 208
Quoted 2 lines
doc/guides/rel_notes/release_21_05.rst +2
-0+ + * Added conntrack action and item for stateful offloading.
It should be moved above with other ethdev features.
Re: [dpdk-dev] [PATCH v4 3/3] doc: update for conntrack
In reply to Bing ZhaoHi Bing
I think that this patch should be merged to the two previous patches.
Except this,
Thanks,
Ori
Quoted 249 lines
-----Original Message-----
From: Bing Zhao <[email protected]>
Sent: Monday, April 19, 2021 8:17 PM
Subject: [PATCH v4 3/3] doc: update for conntrackThe updated documentations include:
1. Release notes
2.rte_flow.rst
3. testpmd user guideSigned-off-by Bing Zhao <[email protected]>--- doc/guides/prog_guide/rte_flow.rst | 118 ++++++++++++++++++++ doc/guides/rel_notes/release_21_05.rst | 4 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 35 ++++++ 3 files changed, 157 insertions(+)doc/guides/prog_guide/rte_flow.rst +8
-0@@ -1398,6 +1398,14 @@ Matches a eCPRI header. - ``hdr``: eCPRI header definition (``rte_ecpri.h``). - Default ``mask`` matches nothing, for all eCPRI messages. +Item: ``CONNTRACK`` +^^^^^^^^^^^^^^^^^^^ + +Matches a conntrack state after conntrack action. + +- ``flags``: conntrack packet state flags. +- Default ``mask`` matches all state bits. + Actions ~~~~~~~@@ -2842,6 +2850,116 @@ for ``RTE_FLOW_FIELD_VALUE`` and``RTE_FLOW_FIELD_POINTER`` respectively.
| ``value`` | immediate value or a pointer to this value | +---------------+----------------------------------------------------------+doc/guides/prog_guide/rte_flow.rst +4
-0+Action: ``CONNTRACK`` +^^^^^^^^^^^^^^^^^^^^^ + +Create a conntrack (connection tracking) context with the providedinformation.
doc/guides/prog_guide/rte_flow.rst +6
-0+ +In stateful session like TCP, the conntrack action provides the ability to +examine every packet of this connection and associate the state to every +packet. It will help to realize the stateful offload of connections with little +software participation. For example, the packets with invalid state may be +handled by the software. The control packets could be handled in thehardware.
+The software just need to query the state of a connection when needed, and thendoc/guides/prog_guide/rte_flow.rst +25
-0+decide how to handle the flow rules and conntrack context. + +A conntrack context should be created via ``rte_flow_action_handle_create()`` +before using. Then the handle with ``INDIRECT`` type is used for a flow rule +creation. If a flow rule with an opposite direction needs to be created, the +``rte_flow_action_handle_update()`` should be used to modify the direction. + +Not all the fields of the ``struct rte_flow_action_conntrack`` will be used +for a conntrack context creating, depending on the HW, and they should be +in host byte order. PMD should convert them into network byte order when +needed by the HW. + +The ``struct rte_flow_modify_conntrack`` should be used for an updating. + +The current conntrack context information could be queried via the +``rte_flow_action_handle_query()`` interface. + +.. _table_rte_flow_action_conntrack: + +.. table:: CONNTRACK + + +--------------------------+-------------------------------------------------------------+ + | Field | Value | + +==========================+=============================================================+
doc/guides/prog_guide/rte_flow.rst +3
-0+ | ``peer_port`` | peer port number | + +--------------------------+-------------------------------------------------------------+ + | ``is_original_dir`` | direction of this connection for creating flow rule|
doc/guides/prog_guide/rte_flow.rst +4
-0+ +--------------------------+-------------------------------------------------------------+ + | ``enable`` | enable the conntrack context | + +--------------------------+-------------------------------------------------------------+ + | ``live_connection`` | one ack was seen for this connection|
doc/guides/prog_guide/rte_flow.rst +4
-0+ +--------------------------+-------------------------------------------------------------+ + | ``selective_ack`` | SACK enabled | + +--------------------------+-------------------------------------------------------------+ + | ``challenge_ack_passed`` | a challenge ack has passed|
doc/guides/prog_guide/rte_flow.rst +8
-0+ +--------------------------+-------------------------------------------------------------+ + | ``last_direction`` | direction of the last passed packet | + +--------------------------+-------------------------------------------------------------+ + | ``liberal_mode`` | only report state change | + +--------------------------+-------------------------------------------------------------+ + | ``state`` | current state | + +--------------------------+-------------------------------------------------------------+ + | ``max_ack_window`` | maximal window scaling factor|
doc/guides/prog_guide/rte_flow.rst +2
-0+ +--------------------------+-------------------------------------------------------------+ + | ``retransmission_limit`` | maximal retransmission times|
doc/guides/prog_guide/rte_flow.rst +2
-0+ +--------------------------+-------------------------------------------------------------+ + | ``original_dir`` | TCP parameters of the original direction|
doc/guides/prog_guide/rte_flow.rst +4
-0+ +--------------------------+-------------------------------------------------------------+ + | ``reply_dir`` | TCP parameters of the reply direction | + +--------------------------+-------------------------------------------------------------+ + | ``last_window`` | window value of the last passed packet|
doc/guides/prog_guide/rte_flow.rst +4
-0+ +--------------------------+-------------------------------------------------------------+ + | ``last_seq`` | sequence value of the last passed packet | + +--------------------------+-------------------------------------------------------------+ + | ``last_ack`` | acknowledgment value the last passed packet|
doc/guides/prog_guide/rte_flow.rst +2
-0+ +--------------------------+-------------------------------------------------------------+ + | ``last_end`` | sum of ack number and length of the last passedpacket |
doc/guides/prog_guide/rte_flow.rst +10
-0+ +--------------------------+-------------------------------------------------------------+ + +.. _table_rte_flow_tcp_dir_param: + +.. table:: configuration parameters for each direction + + +---------------------+---------------------------------------------------------+ + | Field | Value | + +=====================+=========================================================+
doc/guides/prog_guide/rte_flow.rst +7
-0+ | ``scale`` | TCP window scaling factor | + +---------------------+---------------------------------------------------------+ + | ``close_initiated`` | FIN sent from this direction | + +---------------------+---------------------------------------------------------+ + | ``last_ack_seen`` | an ACK packet received | + +---------------------+---------------------------------------------------------+ + | ``data_unacked`` | unacknowledged data for packets from this direction|
doc/guides/prog_guide/rte_flow.rst +18
-0+ +---------------------+---------------------------------------------------------+ + | ``sent_end`` | max{seq + len} seen in sent packets | + +---------------------+---------------------------------------------------------+ + | ``reply_end`` | max{sack + max{win, 1}} seen in reply packets | + +---------------------+---------------------------------------------------------+ + | ``max_win`` | max{max{win, 1}} + {sack - ack} seen in sent packets | + +---------------------+---------------------------------------------------------+ + | ``max_ack`` | max{ack} + seen in sent packets | + +---------------------+---------------------------------------------------------+ + +.. _table_rte_flow_modify_conntrack: + +.. table:: update a conntrack context + + +----------------+-------------------------------------------------+ + | Field | Value | + +================+=================================================+
doc/guides/prog_guide/rte_flow.rst +9
-0+ | ``new_ct`` | new conntrack information | + +----------------+-------------------------------------------------+ + | ``direction`` | direction will be updated | + +----------------+-------------------------------------------------+ + | ``state`` | other fields except direction will be updated | + +----------------+-------------------------------------------------+ + | ``reserved`` | reserved bits | + +----------------+-------------------------------------------------+ + Negative types ~~~~~~~~~~~~~~doc/guides/rel_notes/release_21_05.rst +4
-0@@ -203,6 +203,10 @@ New Features the events across multiple stages. * This also reduced the scheduling overhead on a event device. +* **Added conntrack support for rte_flow.** + + * Added conntrack action and item for stateful offloading. + * **Updated testpmd.** * Added a command line option to configure forced speed for Ethernet port.doc/guides/testpmd_app_ug/testpmd_funcs.rst +0
-0@@ -3789,6 +3789,8 @@ This section lists supported pattern items and theirattributes, if any.
- ``s_field {unsigned}``: S field.
- ``seid {unsigned}``: session endpoint identifier.+- ``conntrack``: match conntrack state.
doc/guides/testpmd_app_ug/testpmd_funcs.rst +24
-0+ Actions list ^^^^^^^^^^^^@@ -4927,6 +4929,39 @@ NVGRE encapsulation header and sent to port id 0. testpmd> flow create 0 ingress transfer pattern eth / end actions sample ratio 1 index 0 / port_id id 2 / end +Sample conntrack rules +~~~~~~~~~~~~~~~~~~~~~~ + +Conntrack rules can be set by the following commands + +Need to construct the connection context with provided information. +In the first table, create a flow rule by using conntrack action and jump to +the next table. In the next table, create a rule to check the state. + +:: + + testpmd> set conntrack com peer 1 is_orig 1 enable 1 live 1 sack 1 cack 0 + last_dir 0 liberal 0 state 1 max_ack_win 7 r_lim 5 last_win 510 + last_seq 2632987379 last_ack 2532480967 last_end 2632987379 + last_index 0x8 + testpmd> set conntrack orig scale 7 fin 0 acked 1 unack_data 0 + sent_end 2632987379 reply_end 2633016339 max_win 28960 + max_ack 2632987379 + testpmd> set conntrack rply scale 7 fin 0 acked 1 unack_data 0 + sent_end 2532480967 reply_end 2532546247 max_win 65280 + max_ack 2532480967 + testpmd> flow indirect_action 0 create ingress action conntrack / end + testpmd> flow create 0 group 3 ingress pattern eth / ipv4 / tcp / end actionsindirect 0 / jump group 5 / end
+ testpmd> flow create 0 group 5 ingress pattern eth / ipv4 / tcp / conntrack is 1 / end actions queue index 5 / enddoc/guides/testpmd_app_ug/testpmd_funcs.rst +9
-1+ +Construct the conntrack again with only "is_orig" set to 0 (other fields are +ignored), then use "update" interface to update the direction. Create flow +rules like above for the peer port. + +:: + + testpmd> flow indirect_action 0 update 0 action conntrack_update dir / end + BPF Functions -------------- --2.19.0.windows.1
v5 cover ethdev: introduce conntrack flow action and item
In reply to Bing ZhaoThis patch set includes the conntrack action and item definitions as well as the testpmd CLI proposal.
Documents of release notes and guides are also updated.
---
v2: add testpmd CLI proposal
v3: add doc update
v4: fix building and address comments for doc and header file
v5: squash doc update into ethdev and testpmd separately
---
Bing Zhao (2):
ethdev: introduce conntrack flow action and item app/testpmd: add CLI for conntrack
app/test-pmd/cmdline.c | 355 ++++++++++++++++++++ app/test-pmd/cmdline_flow.c | 92 +++++ app/test-pmd/config.c | 65 +++- app/test-pmd/testpmd.h | 2 + doc/guides/prog_guide/rte_flow.rst | 118 +++++++ doc/guides/rel_notes/release_21_05.rst | 7 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 35 ++ lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 212 ++++++++++++ 9 files changed, 887 insertions(+), 1 deletion(-)
Signature · 1 line
2.19.0.windows.1
PATCH v5 1/2 ethdev: introduce conntrack flow action and item
This commit introduces the conntrack action and item.
Usually the HW offloading is stateless. For some stateful offloading like a TCP connection, HW module will help provide the ability of a full offloading w/o SW participation after the connection was established.
The basic usage is that in the first flow rule the application should add the conntrack action and jump to the next flow table. In the following flow rule(s) of the next table, the application should use the conntrack item to match on the result.
A TCP connection has two directions traffic. To set a conntrack action context correctly, the information of packets from both directions are required.
The conntrack action should be created on one ethdev port and supply the peer ethdev port as a parameter to the action. After context created, it could only be used between these two ethdev ports (dual-port mode) or a single port. The application should modify the action via the API "rte_action_handle_update" only when before using it to create a flow rule with conntrack for the opposite direction. This will help the driver to recognize the direction of the flow to be created, especially in the single-port mode, in which case the traffic from both directions will go through the same ethdev port if the application works as an "forwarding engine" but not an end point. There is no need to call the update interface if the subsequent flow rules have nothing to be changed.
Query will be supported via "rte_action_handle_query" interface, about the current packets information and connection status. The fields query capabilities depends on the HW.
For the packets received during the conntrack setup, it is suggested to re-inject the packets in order to make sure the conntrack module works correctly without missing any packet. Only the valid packets should pass the conntrack, packets with invalid TCP information, like out of window, or with invalid header, like malformed, should not pass.
Naming and definition:
https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/
netfilter/nf_conntrack_tcp.h
https://elixir.bootlin.com/linux/latest/source/net/netfilter/
nf_conntrack_proto_tcp.c
Other reference:
https://www.usenix.org/legacy/events/sec01/invitedtalks/rooij.pdf
--- doc/guides/prog_guide/rte_flow.rst | 118 ++++++++++++++ doc/guides/rel_notes/release_21_05.rst | 4 + lib/librte_ethdev/rte_flow.c | 2 + lib/librte_ethdev/rte_flow.h | 212 +++++++++++++++++++++++++ 4 files changed, 336 insertions(+)
doc/guides/prog_guide/rte_flow.rst +118 -0
@@ -1398,6 +1398,14 @@ Matches a eCPRI header. - ``hdr``: eCPRI header definition (``rte_ecpri.h``). - Default ``mask`` matches nothing, for all eCPRI messages. +Item: ``CONNTRACK`` +^^^^^^^^^^^^^^^^^^^ + +Matches a conntrack state after conntrack action. + +- ``flags``: conntrack packet state flags. +- Default ``mask`` matches all state bits. + Actions ~~~~~~~
@@ -2842,6 +2850,116 @@ for ``RTE_FLOW_FIELD_VALUE`` and ``RTE_FLOW_FIELD_POINTER`` respectively. | ``value`` | immediate value or a pointer to this value | +---------------+----------------------------------------------------------+ +Action: ``CONNTRACK`` +^^^^^^^^^^^^^^^^^^^^^ + +Create a conntrack (connection tracking) context with the provided information. + +In stateful session like TCP, the conntrack action provides the ability to +examine every packet of this connection and associate the state to every +packet. It will help to realize the stateful offload of connections with little +software participation. For example, the packets with invalid state may be +handled by the software. The control packets could be handled in the hardware. +The software just need to query the state of a connection when needed, and then +decide how to handle the flow rules and conntrack context. + +A conntrack context should be created via ``rte_flow_action_handle_create()`` +before using. Then the handle with ``INDIRECT`` type is used for a flow rule +creation. If a flow rule with an opposite direction needs to be created, the +``rte_flow_action_handle_update()`` should be used to modify the direction. + +Not all the fields of the ``struct rte_flow_action_conntrack`` will be used +for a conntrack context creating, depending on the HW, and they should be +in host byte order. PMD should convert them into network byte order when +needed by the HW. + +The ``struct rte_flow_modify_conntrack`` should be used for an updating. + +The current conntrack context information could be queried via the +``rte_flow_action_handle_query()`` interface. + +.. _table_rte_flow_action_conntrack: + +.. table:: CONNTRACK + + +--------------------------+-------------------------------------------------------------+ + | Field | Value | + +==========================+=============================================================+ + | ``peer_port`` | peer port number | + +--------------------------+-------------------------------------------------------------+ + | ``is_original_dir`` | direction of this connection for creating flow rule | + +--------------------------+-------------------------------------------------------------+ + | ``enable`` | enable the conntrack context | + +--------------------------+-------------------------------------------------------------+ + | ``live_connection`` | one ack was seen for this connection | + +--------------------------+-------------------------------------------------------------+ + | ``selective_ack`` | SACK enabled | + +--------------------------+-------------------------------------------------------------+ + | ``challenge_ack_passed`` | a challenge ack has passed | + +--------------------------+-------------------------------------------------------------+ + | ``last_direction`` | direction of the last passed packet | + +--------------------------+-------------------------------------------------------------+ + | ``liberal_mode`` | only report state change | + +--------------------------+-------------------------------------------------------------+ + | ``state`` | current state | + +--------------------------+-------------------------------------------------------------+ + | ``max_ack_window`` | maximal window scaling factor | + +--------------------------+-------------------------------------------------------------+ + | ``retransmission_limit`` | maximal retransmission times | + +--------------------------+-------------------------------------------------------------+ + | ``original_dir`` | TCP parameters of the original direction | + +--------------------------+-------------------------------------------------------------+ + | ``reply_dir`` | TCP parameters of the reply direction | + +--------------------------+-------------------------------------------------------------+ + | ``last_window`` | window size of the last passed packet | + +--------------------------+-------------------------------------------------------------+ + | ``last_seq`` | sequence number of the last passed packet | + +--------------------------+-------------------------------------------------------------+ + | ``last_ack`` | acknowledgment number the last passed packet | + +--------------------------+-------------------------------------------------------------+ + | ``last_end`` | sum of ack number and length of the last passed packet | + +--------------------------+-------------------------------------------------------------+ + +.. _table_rte_flow_tcp_dir_param: + +.. table:: configuration parameters for each direction + + +---------------------+---------------------------------------------------------+ + | Field | Value | + +=====================+=========================================================+ + | ``scale`` | TCP window scaling factor | + +---------------------+---------------------------------------------------------+ + | ``close_initiated`` | FIN sent from this direction | + +---------------------+---------------------------------------------------------+ + | ``last_ack_seen`` | an ACK packet received | + +---------------------+---------------------------------------------------------+ + | ``data_unacked`` | unacknowledged data for packets from this direction | + +---------------------+---------------------------------------------------------+ + | ``sent_end`` | max{seq + len} seen in sent packets | + +---------------------+---------------------------------------------------------+ + | ``reply_end`` | max{sack + max{win, 1}} seen in reply packets | + +---------------------+---------------------------------------------------------+ + | ``max_win`` | max{max{win, 1}} + {sack - ack} seen in sent packets | + +---------------------+---------------------------------------------------------+ + | ``max_ack`` | max{ack} + seen in sent packets | + +---------------------+---------------------------------------------------------+ + +.. _table_rte_flow_modify_conntrack: + +.. table:: update a conntrack context + + +----------------+-------------------------------------------------+ + | Field | Value | + +================+=================================================+ + | ``new_ct`` | new conntrack information | + +----------------+-------------------------------------------------+ + | ``direction`` | direction will be updated | + +----------------+-------------------------------------------------+ + | ``state`` | other fields except direction will be updated | + +----------------+-------------------------------------------------+ + | ``reserved`` | reserved bits | + +----------------+-------------------------------------------------+ + Negative types ~~~~~~~~~~~~~~
doc/guides/rel_notes/release_21_05.rst +4 -0
@@ -87,6 +87,10 @@ New Features to support metering traffic by packet per second (PPS), in addition to the initial bytes per second (BPS) mode (value 0). +* **Added TCP connection tracking offload in flow API.** + + * Added conntrack item and action for stateful connection offload. + * **Updated Arkville PMD driver.** Updated Arkville net driver with new features and improvements, including:
lib/librte_ethdev/rte_flow.c +2 -0
@@ -98,6 +98,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = {MK_FLOW_ITEM (PFCP ,sizeof (struct rte_flow_item_pfcp )),MK_FLOW_ITEM (ECPRI ,sizeof (struct rte_flow_item_ecpri )),MK_FLOW_ITEM (GENEVE_OPT ,sizeof (struct rte_flow_item_geneve_opt )), + MK_FLOW_ITEM(CONNTRACK, sizeof(uint32_t)), };/** Generate flow_action[] entry. */
@@ -186,6 +187,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = {* indirect action handle. */ MK_FLOW_ACTION (INDIRECT ,0 ), + MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)), };int
lib/librte_ethdev/rte_flow.h +212 -0
242 lines not on this page · raw message
Signature · 1 line
2.19.0.windows.1
19/04/2021 19:51, Bing Zhao:
Quoted 1 line
This commit introduces the conntrack action and item.
[...]
Quoted 2 lines
Signed-off-by Bing Zhao <[email protected]>Acked-by Ori Kam <[email protected]>
It makes me think we should work together to simplify the whole rte_flow guide and makes it clearer.
Quoted 8 lines · Thomas Monjalon
19/04/2021 19:51, Bing Zhao:
Quoted 1 line
This commit introduces the conntrack action and item.
[...]
Quoted 2 lines
Signed-off-by Bing Zhao <[email protected]>Acked-by Ori Kam <[email protected]>Acked-by Thomas Monjalon <[email protected]>
Series applied to dpdk-next-net/main, thanks.
PATCH v5 2/2 app/testpmd: add CLI for conntrack
In reply to Bing ZhaoThe command line for testing connection tracking is added. To create a conntrack object, 3 parts are needed.
set conntrack com peer ...
set conntrack orig scale ...
set conntrack rply scale ...
This will create a full conntrack action structure for the indirect action. After the indirect action handle of "conntrack" created, it could be used in the flow creation. Before updating, the same structure is also needed together with the update command "conntrack_update" to update the "dir" or "ctx".
After the flow with conntrack action created, the packet should jump to the next flow for the result checking with conntrack item. The state is defined with bits and a valid combination could be supported.
--- app/test-pmd/cmdline.c | 355 ++++++++++++++++++++ app/test-pmd/cmdline_flow.c | 92 +++++ app/test-pmd/config.c | 65 +++- app/test-pmd/testpmd.h | 2 + doc/guides/rel_notes/release_21_05.rst | 3 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 35 ++ 6 files changed, 551 insertions(+), 1 deletion(-)
app/test-pmd/cmdline.c +355 -0
@@ -13621,6 +13621,359 @@ cmdline_parse_inst_t cmd_set_mplsoudp_decap_with_vlan = { }, }; +/** Set connection tracking object common details */ +struct cmd_set_conntrack_common_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t conntrack; +cmdline_fixed_string_t common; +cmdline_fixed_string_t peer; +cmdline_fixed_string_t is_orig; +cmdline_fixed_string_t enable; +cmdline_fixed_string_t live; +cmdline_fixed_string_t sack; +cmdline_fixed_string_t cack; +cmdline_fixed_string_t last_dir; +cmdline_fixed_string_t liberal; +cmdline_fixed_string_t state; +cmdline_fixed_string_t max_ack_win; +cmdline_fixed_string_t retrans; +cmdline_fixed_string_t last_win; +cmdline_fixed_string_t last_seq; +cmdline_fixed_string_t last_ack; +cmdline_fixed_string_t last_end; +cmdline_fixed_string_t last_index; +uint8_t stat; +uint8_t factor; +uint16_t peer_port; +uint32_t is_original; +uint32_t en; +uint32_t is_live; +uint32_t s_ack; +uint32_t c_ack; +uint32_t ld; +uint32_t lb; +uint8_t re_num; +uint8_t li; +uint16_t lw; +uint32_t ls; +uint32_t la; +uint32_t le; +}; + +cmdline_parse_token_string_t cmd_set_conntrack_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + set,"set" ); +cmdline_parse_token_string_t cmd_set_conntrack_conntrack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + conntrack,"conntrack" ); +cmdline_parse_token_string_t cmd_set_conntrack_common_com = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + common,"com" ); +cmdline_parse_token_string_t cmd_set_conntrack_common_peer = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + peer,"peer" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_peer_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + peer_port,RTE_UINT16 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_is_orig = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + is_orig,"is_orig" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_is_orig_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + is_original,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_enable = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + enable,"enable" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_enable_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + en,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_live = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + live,"live" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_live_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + is_live,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_sack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + sack,"sack" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_sack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + s_ack,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_cack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + cack,"cack" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_cack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + c_ack,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_dir = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_dir,"last_dir" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_dir_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + ld,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_liberal = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + liberal,"liberal" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_liberal_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + lb,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_state = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + state,"state" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_state_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + stat,RTE_UINT8 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_max_ackwin = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + max_ack_win,"max_ack_win" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_max_ackwin_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + factor,RTE_UINT8 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_retrans = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + retrans,"r_lim" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_retrans_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + re_num,RTE_UINT8 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_win = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_win,"last_win" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_win_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + lw,RTE_UINT16 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_seq = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_seq,"last_seq" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_seq_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + ls,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_ack,"last_ack" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + la,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_end,"last_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + le,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_common_last_index = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_common_result, + last_index,"last_index" ); +cmdline_parse_token_num_t cmd_set_conntrack_common_last_index_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_common_result, + li,RTE_UINT8 ); + +static void cmd_set_conntrack_common_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_conntrack_common_result *res = parsed_result; + +/* No need to swap to big endian. */ + conntrack_context.peer_port = res->peer_port; + conntrack_context.is_original_dir = res->is_original; + conntrack_context.enable = res->en; + conntrack_context.live_connection = res->is_live; + conntrack_context.selective_ack = res->s_ack; + conntrack_context.challenge_ack_passed = res->c_ack; + conntrack_context.last_direction = res->ld; + conntrack_context.liberal_mode = res->lb; + conntrack_context.state = (enum rte_flow_conntrack_state )res->stat; + conntrack_context.max_ack_window = res->factor; + conntrack_context.retransmission_limit = res->re_num; + conntrack_context.last_window = res->lw; + conntrack_context.last_index = + (enum rte_flow_conntrack_tcp_last_index )res->li; + conntrack_context.last_seq = res->ls; + conntrack_context.last_ack = res->la; + conntrack_context.last_end = res->le; +} + +cmdline_parse_inst_t cmd_set_conntrack_common = { + .f = cmd_set_conntrack_common_parsed, + .data =NULL , + .help_str ="set conntrack com peer <port_id> is_orig <dir> enable <en>" +" live <ack_seen> sack <en> cack <passed> last_dir <dir>" +" liberal <en> state <s> max_ack_win <factor> r_lim <num>" +" last_win <win> last_seq <seq> last_ack <ack> last_end <end>" +" last_index <flag>" , + .tokens = { + (void *)&cmd_set_conntrack_set, + (void *)&cmd_set_conntrack_conntrack, + (void *)&cmd_set_conntrack_common_com, + (void *)&cmd_set_conntrack_common_peer, + (void *)&cmd_set_conntrack_common_peer_value, + (void *)&cmd_set_conntrack_common_is_orig, + (void *)&cmd_set_conntrack_common_is_orig_value, + (void *)&cmd_set_conntrack_common_enable, + (void *)&cmd_set_conntrack_common_enable_value, + (void *)&cmd_set_conntrack_common_live, + (void *)&cmd_set_conntrack_common_live_value, + (void *)&cmd_set_conntrack_common_sack, + (void *)&cmd_set_conntrack_common_sack_value, + (void *)&cmd_set_conntrack_common_cack, + (void *)&cmd_set_conntrack_common_cack_value, + (void *)&cmd_set_conntrack_common_last_dir, + (void *)&cmd_set_conntrack_common_last_dir_value, + (void *)&cmd_set_conntrack_common_liberal, + (void *)&cmd_set_conntrack_common_liberal_value, + (void *)&cmd_set_conntrack_common_state, + (void *)&cmd_set_conntrack_common_state_value, + (void *)&cmd_set_conntrack_common_max_ackwin, + (void *)&cmd_set_conntrack_common_max_ackwin_value, + (void *)&cmd_set_conntrack_common_retrans, + (void *)&cmd_set_conntrack_common_retrans_value, + (void *)&cmd_set_conntrack_common_last_win, + (void *)&cmd_set_conntrack_common_last_win_value, + (void *)&cmd_set_conntrack_common_last_seq, + (void *)&cmd_set_conntrack_common_last_seq_value, + (void *)&cmd_set_conntrack_common_last_ack, + (void *)&cmd_set_conntrack_common_last_ack_value, + (void *)&cmd_set_conntrack_common_last_end, + (void *)&cmd_set_conntrack_common_last_end_value, + (void *)&cmd_set_conntrack_common_last_index, + (void *)&cmd_set_conntrack_common_last_index_value, +NULL , + }, +}; + +/** Set connection tracking object both directions' details */ +struct cmd_set_conntrack_dir_result { +cmdline_fixed_string_t set; +cmdline_fixed_string_t conntrack; +cmdline_fixed_string_t dir; +cmdline_fixed_string_t scale; +cmdline_fixed_string_t fin; +cmdline_fixed_string_t ack_seen; +cmdline_fixed_string_t unack; +cmdline_fixed_string_t sent_end; +cmdline_fixed_string_t reply_end; +cmdline_fixed_string_t max_win; +cmdline_fixed_string_t max_ack; +uint32_t factor; +uint32_t f; +uint32_t as; +uint32_t un; +uint32_t se; +uint32_t re; +uint32_t mw; +uint32_t ma; +}; + +cmdline_parse_token_string_t cmd_set_conntrack_dir_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + set,"set" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_conntrack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + conntrack,"conntrack" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_dir = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + dir,"orig#rply" ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_scale = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + scale,"scale" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_scale_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + factor,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_fin = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + fin,"fin" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_fin_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + f,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + ack_seen,"acked" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + as,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_unack_data = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + unack,"unack_data" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_unack_data_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + un,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_sent_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + sent_end,"sent_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_sent_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + se,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_reply_end = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + reply_end,"reply_end" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_reply_end_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + re,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_max_win = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + max_win,"max_win" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_max_win_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + mw,RTE_UINT32 ); +cmdline_parse_token_string_t cmd_set_conntrack_dir_max_ack = + TOKEN_STRING_INITIALIZER(struct cmd_set_conntrack_dir_result, + max_ack,"max_ack" ); +cmdline_parse_token_num_t cmd_set_conntrack_dir_max_ack_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_conntrack_dir_result, + ma,RTE_UINT32 ); + +static void cmd_set_conntrack_dir_parsed (void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ +struct cmd_set_conntrack_dir_result *res = parsed_result; +struct rte_flow_tcp_dir_param *dir =NULL ; + +if (strcmp (res->dir,"orig" ) ==0 ) + dir = &conntrack_context.original_dir; +else if (strcmp (res->dir,"rply" ) ==0 ) + dir = &conntrack_context.reply_dir; +else +return ; + dir->scale = res->factor; + dir->close_initiated = res->f; + dir->last_ack_seen = res->as; + dir->data_unacked = res->un; + dir->sent_end = res->se; + dir->reply_end = res->re; + dir->max_ack = res->ma; + dir->max_win = res->mw; +} + +cmdline_parse_inst_t cmd_set_conntrack_dir = { + .f = cmd_set_conntrack_dir_parsed, + .data =NULL , + .help_str ="set conntrack orig|rply scale <factor> fin <sent>" +" acked <seen> unack_data <unack> sent_end <sent>" +" reply_end <reply> max_win <win> max_ack <ack>" , + .tokens = { + (void *)&cmd_set_conntrack_set, + (void *)&cmd_set_conntrack_conntrack, + (void *)&cmd_set_conntrack_dir_dir, + (void *)&cmd_set_conntrack_dir_scale, + (void *)&cmd_set_conntrack_dir_scale_value, + (void *)&cmd_set_conntrack_dir_fin, + (void *)&cmd_set_conntrack_dir_fin_value, + (void *)&cmd_set_conntrack_dir_ack, + (void *)&cmd_set_conntrack_dir_ack_value, + (void *)&cmd_set_conntrack_dir_unack_data, + (void *)&cmd_set_conntrack_dir_unack_data_value, + (void *)&cmd_set_conntrack_dir_sent_end, + (void *)&cmd_set_conntrack_dir_sent_end_value, + (void *)&cmd_set_conntrack_dir_reply_end, + (void *)&cmd_set_conntrack_dir_reply_end_value, + (void *)&cmd_set_conntrack_dir_max_win, + (void *)&cmd_set_conntrack_dir_max_win_value, + (void *)&cmd_set_conntrack_dir_max_ack, + (void *)&cmd_set_conntrack_dir_max_ack_value, +NULL , + }, +}; +/* Strict link priority scheduling mode setting */ static void cmd_strict_link_prio_parsed(
@@ -17120,6 +17473,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_mplsoudp_encap_with_vlan, (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap, (cmdline_parse_inst_t *)&cmd_set_mplsoudp_decap_with_vlan, + (cmdline_parse_inst_t *)&cmd_set_conntrack_common, + (cmdline_parse_inst_t *)&cmd_set_conntrack_dir, (cmdline_parse_inst_t *)&cmd_ddp_add, (cmdline_parse_inst_t *)&cmd_ddp_del, (cmdline_parse_inst_t *)&cmd_ddp_get_list,
app/test-pmd/cmdline_flow.c +92 -0
152 lines not on this page · raw message
app/test-pmd/config.c +64 -1
87 lines not on this page · raw message
app/test-pmd/testpmd.h +2 -0
@@ -630,6 +630,8 @@ extern struct mplsoudp_decap_conf mplsoudp_decap_conf;extern enum rte_eth_rx_mq_mode rx_mq_mode; +extern struct rte_flow_action_conntrack conntrack_context; +static inline unsigned int lcore_num (void ) {
doc/guides/rel_notes/release_21_05.rst +3 -0
@@ -215,6 +215,9 @@ New Features ``show port (port_id) rxq (queue_id) desc used count`` * Added command to dump internal representation information of single flow. ``flow dump (port_id) rule (rule_id)`` + * Added commands to construct conntrack context and relevant indirect + action handle creation, update for conntrack action as well as conntrack + item matching. * **Updated ipsec-secgw sample application.**
doc/guides/testpmd_app_ug/testpmd_funcs.rst +35 -0
@@ -3789,6 +3789,8 @@ This section lists supported pattern items and their attributes, if any. - ``s_field {unsigned}``: S field. - ``seid {unsigned}``: session endpoint identifier. +- ``conntrack``: match conntrack state. + Actions list ^^^^^^^^^^^^
@@ -4927,6 +4929,39 @@ NVGRE encapsulation header and sent to port id 0. testpmd> flow create 0 ingress transfer pattern eth / end actions sample ratio 1 index 0 / port_id id 2 / end +Sample conntrack rules +~~~~~~~~~~~~~~~~~~~~~~ + +Conntrack rules can be set by the following commands + +Need to construct the connection context with provided information. +In the first table, create a flow rule by using conntrack action and jump to +the next table. In the next table, create a rule to check the state. + +:: + + testpmd> set conntrack com peer 1 is_orig 1 enable 1 live 1 sack 1 cack 0 + last_dir 0 liberal 0 state 1 max_ack_win 7 r_lim 5 last_win 510 + last_seq 2632987379 last_ack 2532480967 last_end 2632987379 + last_index 0x8 + testpmd> set conntrack orig scale 7 fin 0 acked 1 unack_data 0 + sent_end 2632987379 reply_end 2633016339 max_win 28960 + max_ack 2632987379 + testpmd> set conntrack rply scale 7 fin 0 acked 1 unack_data 0 + sent_end 2532480967 reply_end 2532546247 max_win 65280 + max_ack 2532480967 + testpmd> flow indirect_action 0 create ingress action conntrack / end + testpmd> flow create 0 group 3 ingress pattern eth / ipv4 / tcp / end actions indirect 0 / jump group 5 / end + testpmd> flow create 0 group 5 ingress pattern eth / ipv4 / tcp / conntrack is 1 / end actions queue index 5 / end + +Construct the conntrack again with only "is_orig" set to 0 (other fields are +ignored), then use "update" interface to update the direction. Create flow +rules like above for the peer port. + +:: + + testpmd> flow indirect_action 0 update 0 action conntrack_update dir / end + BPF Functions --------------
Signature · 1 line
2.19.0.windows.1