diff --git a/include/dp_cntrack.h b/include/dp_cntrack.h index 9dd6c4123..0e173c336 100644 --- a/include/dp_cntrack.h +++ b/include/dp_cntrack.h @@ -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); diff --git a/src/dp_cntrack.c b/src/dp_cntrack.c index 4bf1b9b96..7680db9e2 100644 --- a/src/dp_cntrack.c +++ b/src/dp_cntrack.c @@ -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) { @@ -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) @@ -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) { @@ -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)) ) diff --git a/src/nodes/conntrack_node.c b/src/nodes/conntrack_node.c index 78f270689..d19d64fec 100644 --- a/src/nodes/conntrack_node.c +++ b/src/nodes/conntrack_node.c @@ -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") \ @@ -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) {