clib_host_to_net_u16 (trk0->ct_ep[VLIB_TX].ce_port);
session->value.cs_port[VLIB_RX] = udp0->src_port;
- const dpo_id_t *dpo0;
- const load_balance_t *lb1;
- fib_entry_t *fib_entry;
- fib_entry = fib_entry_get (trk0->ct_fei);
-
- lb1 = load_balance_get (fib_entry->fe_lb /*[fct] */.dpoi_index);
- dpo0 = load_balance_get_bucket_i (lb1, 0);
+ if (trk0->ct_flags & CNAT_TRK_FLAG_NO_NAT)
+ {
+ const dpo_id_t *dpo0;
+ const load_balance_t *lb1;
- session->value.dpoi_next_node = dpo0->dpoi_next_node;
- session->value.cs_lbi = dpo0->dpoi_index;
+ lb1 = load_balance_get (trk0->ct_dpo.dpoi_index);
+ /* Assume backend has exactly one item in LB */
+ dpo0 = load_balance_get_bucket_i (lb1, 0);
- if (trk0->ct_flags & CNAT_TRK_FLAG_NO_NAT)
- session->value.flags |= CNAT_SESSION_FLAG_NO_NAT;
+ session->value.dpoi_next_node = dpo0->dpoi_next_node;
+ session->value.cs_lbi = dpo0->dpoi_index;
+ session->value.flags = CNAT_SESSION_FLAG_NO_NAT;
+ }
/* refcnt session in current client */
cnat_client_cnt_session (cc);
trace_flags |= CNAT_TRACE_SESSION_CREATED;
}
- next0 = session->value.dpoi_next_node;
- vnet_buffer (b)->ip.adj_index[VLIB_TX] = session->value.cs_lbi;
-
if (session->value.flags & CNAT_SESSION_FLAG_NO_NAT)
- goto trace;
+ {
+ /* If we don't translate, directly do the lookup & bypass arc */
+ next0 = session->value.dpoi_next_node;
+ vnet_buffer (b)->ip.adj_index[VLIB_TX] = session->value.cs_lbi;
+ goto trace;
+ }
if (AF_IP4 == ctx->af)
cnat_translation_ip4 (session, ip4, udp0);
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = CNAT_N_ERROR,
.error_strings = cnat_error_strings,
- .n_next_nodes = IP_LOOKUP_N_NEXT,
- .next_nodes = IP4_LOOKUP_NEXT_NODES,
+ .sibling_of = "ip4-lookup",
};
VNET_FEATURE_INIT (cnat_in_ip4_feature, static) = {
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = CNAT_N_ERROR,
.error_strings = cnat_error_strings,
- .n_next_nodes = IP6_LOOKUP_N_NEXT,
- .next_nodes = IP6_LOOKUP_NEXT_NODES,
+ .sibling_of = "ip6-lookup",
};
VNET_FEATURE_INIT (cnat_in_ip6_feature, static) = {
return 1;
}
+uword
+unformat_cnat_ep_flags (unformat_input_t *input, va_list *args)
+{
+ int *a = va_arg (*args, int *);
+ if (unformat (input, ":nonat"))
+ *a = CNAT_TRK_FLAG_NO_NAT;
+ return 1;
+}
+
uword
unformat_cnat_ep_tuple (unformat_input_t * input, va_list * args)
{
cnat_endpoint_tuple_t *a = va_arg (*args, cnat_endpoint_tuple_t *);
- if (unformat (input, "%U->%U", unformat_cnat_ep, &a->src_ep,
- unformat_cnat_ep, &a->dst_ep))
- ;
- else if (unformat (input, "->%U", unformat_cnat_ep, &a->dst_ep))
- ;
- else if (unformat (input, "%U->", unformat_cnat_ep, &a->src_ep))
- ;
+ int flgs = 0;
+ if (unformat (input, "%U->%U%U", unformat_cnat_ep, &a->src_ep,
+ unformat_cnat_ep, &a->dst_ep, unformat_cnat_ep_flags, &flgs))
+ a->ep_flags = flgs;
+ else if (unformat (input, "->%U%U", unformat_cnat_ep, &a->dst_ep,
+ unformat_cnat_ep_flags, &flgs))
+ a->ep_flags = flgs;
+ else if (unformat (input, "%U->%U", unformat_cnat_ep, &a->src_ep,
+ unformat_cnat_ep_flags, &flgs))
+ a->ep_flags = flgs;
else
return 0;
return 1;