vl_api_ip_proto_t ip_proto;
u8 is_real_ip;
u8 flags;
- u8 n_paths;
+ u32 n_paths;
vl_api_cnat_endpoint_tuple_t paths[n_paths];
};
u32 id = ~0;
u8 flags;
int rv = 0;
- u8 pi;
+ u32 pi, n_paths;
rv = ip_proto_decode (mp->translation.ip_proto, &ip_proto);
if (rv)
goto done;
- vec_validate (paths, mp->translation.n_paths - 1);
+ n_paths = clib_net_to_host_u32 (mp->translation.n_paths);
+ vec_validate (paths, n_paths - 1);
- for (pi = 0; pi < mp->translation.n_paths; pi++)
+ for (pi = 0; pi < n_paths; pi++)
{
path = &paths[pi];
cnat_endpoint_tuple_decode (&mp->translation.paths[pi], path);
vl_api_cnat_endpoint_tuple_t *path;
size_t msg_size;
cnat_translation_t *ct;
- u8 n_paths;
+ u32 n_paths;
ctx = args;
ct = cnat_translation_get (cti);
/* fill in the message */
mp->context = ctx->context;
- mp->translation.n_paths = n_paths;
- mp->translation.id = htonl (cti);
+ mp->translation.n_paths = clib_host_to_net_u32 (n_paths);
+ mp->translation.id = clib_host_to_net_u32 (cti);
cnat_endpoint_encode (&ct->ct_vip, &mp->translation.vip);
mp->translation.ip_proto = ip_proto_encode (ct->ct_proto);
fib_protocol_t fproto;
cnat_ep_trk_t *trk;
dpo_proto_t dproto;
- u8 ep_idx = 0;
+ u32 ep_idx = 0;
index_t lbi;
fproto = ip_address_family_to_fib_proto (ct->ct_vip.ce_ip.version);
dpo_set (&ct->ct_lb, DPO_LOAD_BALANCE, dproto, lbi);
dpo_stack (cnat_client_dpo, dproto, &ct->ct_lb, &ct->ct_lb);
+ ct->flags |= CNAT_TRANSLATION_STACKED;
}
int
}
vec_reset_length (ct->ct_paths);
+ ct->flags &= ~CNAT_TRANSLATION_STACKED;
u64 path_idx = 0;
vec_foreach (path, paths)
*/
cnat_translation_t *ct = cnat_translation_get_from_node (node);
+ /* If we have more than FIB_PATH_LIST_POPULAR paths
+ * we might get called during path tracking
+ * (cnat_tracker_track) */
+ if (!(ct->flags & CNAT_TRANSLATION_STACKED))
+ return (FIB_NODE_BACK_WALK_CONTINUE);
+
cnat_translation_stack (ct);
return (FIB_NODE_BACK_WALK_CONTINUE);
ip_address_copy (&ep->ce_ip, address);
ep->ce_flags |= CNAT_EP_FLAG_RESOLVED;
}
+
+ ct->flags &= ~CNAT_TRANSLATION_STACKED;
cnat_tracker_track (ar->cti, trk);
cnat_translation_stack (ct);
+ ct->flags |= CNAT_TRANSLATION_STACKED;
}
static void
typedef enum cnat_translation_flag_t_
{
+ /* Do allocate a source port */
CNAT_TRANSLATION_FLAG_ALLOCATE_PORT = (1 << 0),
+ /* Has this translation been satcked ?
+ * this allow not being called twice when
+ * with more then FIB_PATH_LIST_POPULAR backends */
+ CNAT_TRANSLATION_STACKED = (1 << 1),
} cnat_translation_flag_t;
typedef enum