Skip to content

Commit

Permalink
Introduce init() function to refactored conntrack handling
Browse files Browse the repository at this point in the history
Signed-off-by: Guvenc Gulce <[email protected]>
  • Loading branch information
guvenc committed Aug 1, 2023
1 parent 39976c9 commit d261f77
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions include/dp_cntrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
extern "C" {
#endif

void dp_cntrack_init(void);
int dp_cntrack_handle(struct rte_node *node, struct rte_mbuf *m, struct dp_flow *df);


Expand Down
12 changes: 9 additions & 3 deletions src/dp_cntrack.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ static struct flow_key second_key = {0};
static struct flow_key *prev_key = NULL, *curr_key = &first_key;
static struct flow_value *prev_flow_val = NULL;
static int flow_timeout = DP_FLOW_DEFAULT_TIMEOUT;
static bool offload_mode_enabled = 0;

void dp_cntrack_init(void)
{
offload_mode_enabled = dp_conf_is_offload_enabled();
}

static __rte_always_inline void dp_cntrack_tcp_state(struct flow_value *flow_val, struct rte_tcp_hdr *tcp_hdr)
{
Expand Down Expand Up @@ -52,7 +58,7 @@ static __rte_always_inline void dp_cntrack_tcp_state(struct flow_value *flow_val

static __rte_always_inline void dp_cntrack_init_flow_offload_flags(struct flow_value *flow_val, struct dp_flow *df)
{
if (!dp_conf_is_offload_enabled())
if (!offload_mode_enabled)
return;

if (df->l4_type != IPPROTO_TCP)
Expand All @@ -66,7 +72,7 @@ static __rte_always_inline void dp_cntrack_init_flow_offload_flags(struct flow_v

static __rte_always_inline void dp_cntrack_change_flow_offload_flags(struct flow_value *flow_val, struct dp_flow *df)
{
if (!dp_conf_is_offload_enabled())
if (!offload_mode_enabled)
return;

if (df->flags.dir == DP_FLOW_DIR_ORG) {
Expand Down Expand Up @@ -124,7 +130,7 @@ static __rte_always_inline struct flow_value *flow_table_insert_entry(struct flo
flow_val->flow_status = DP_FLOW_STATUS_FLAG_NONE;
/* Target ip of the traffic is an alias prefix of a VM in the same VNI on this dp-service */
/* This will be an uni-directional traffic. So prepare the flag to offload immediately */
if (dp_conf_is_offload_enabled()
if (offload_mode_enabled
&& (df->flags.flow_type != DP_FLOW_TYPE_INCOMING)
&& !DP_FAILED(dp_get_vnf_entry(&vnf_val, DP_VNF_TYPE_LB_ALIAS_PFX, m->port, DP_VNF_MATCH_ALL_PORT_ID))
)
Expand Down
7 changes: 1 addition & 6 deletions src/nodes/conntrack_node.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include "nodes/dhcp_node.h"
#include "rte_flow/dp_rte_flow.h"

static bool offload_mode_enabled = 0;

#define NEXT_NODES(NEXT) \
NEXT(CONNTRACK_NEXT_LB, "lb") \
NEXT(CONNTRACK_NEXT_DNAT, "dnat") \
Expand All @@ -23,13 +21,10 @@ DP_NODE_REGISTER(CONNTRACK, conntrack, NEXT_NODES);

static int conntrack_node_init(__rte_unused const struct rte_graph *graph, __rte_unused struct rte_node *node)
{

offload_mode_enabled = dp_conf_is_offload_enabled();

dp_cntrack_init();
return DP_OK;
}


static __rte_always_inline rte_edge_t dp_find_nxt_graph_node(struct dp_flow *df)
{
if (df->flags.flow_type == DP_FLOW_TYPE_INCOMING) {
Expand Down

0 comments on commit d261f77

Please sign in to comment.