goto trace;
}
- ct = cnat_find_translation (cc->parent_cci,
- clib_host_to_net_u16 (udp0->dst_port), iproto);
-
if (!rv)
{
/* session table hit */
cnat_timestamp_update (session->value.cs_ts_index, ctx->now);
- if (NULL != ct)
+ if (INDEX_INVALID != session->value.cs_lbi)
{
/* Translate & follow the translation given LB */
+ ct = cnat_translation_get (session->value.ct_index);
next0 = ct->ct_lb.dpoi_next_node;
vnet_buffer (b)->ip.adj_index[VLIB_TX] = session->value.cs_lbi;
}
}
else
{
+ ct =
+ cnat_find_translation (cc->parent_cci,
+ clib_host_to_net_u16 (udp0->dst_port), iproto);
if (NULL == ct)
{
/* Dont translate & Follow the fib programming */
session->value.cs_port[VLIB_RX] =
clib_host_to_net_u16 (trk0->ct_ep[VLIB_RX].ce_port);
- session->value.flags = 0;
+ session->value.ct_index = ct - cnat_translation_pool;
session->value.cs_lbi = dpo0->dpoi_index;
rv = cspm->vip_policy (vm, b, session, &rsession_flags, ct, ctx);
* Timestamp index this session was last used
*/
u32 cs_ts_index;
- /**
- * Indicates a return path session that was source NATed
- * on the way in.
- */
- u32 flags;
+
+ union
+ {
+ /**
+ * session flags if cs_lbi == INDEX_INVALID
+ */
+ u32 flags;
+ /**
+ * Persist translation->ct_lb.dpoi_next_node
+ * when cs_lbi != INDEX_INVALID
+ */
+ u32 ct_index;
+ };
} value;
} cnat_session_t;
typedef enum cnat_session_flag_t_
{
+ /**
+ * Indicates a return path session that was source NATed
+ * on the way in.
+ */
CNAT_SESSION_FLAG_HAS_SNAT = (1 << 0),
+ /**
+ * This session source port was allocated, free it on cleanup
+ */
CNAT_SESSION_FLAG_ALLOC_PORT = (1 << 1),
+ /**
+ * This session doesn't have a client, do not attempt to free it
+ */
CNAT_SESSION_FLAG_NO_CLIENT = (1 << 2),
} cnat_session_flag_t;