summaryrefslogtreecommitdiffstats
path: root/src/plugins/cnat/cnat_node_vip.c
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2021-02-25 11:14:53 +0100
committerFlorin Coras <florin.coras@gmail.com>2021-02-26 01:55:07 +0000
commit4d237874e5c9922330c62ac1b003a9a171c1bc3b (patch)
tree3ce74a3e85659124653e8406635bec29e156b9f2 /src/plugins/cnat/cnat_node_vip.c
parent27647a27c7b1e800547e3a3ea97b099b25618177 (diff)
cnat: Add maglev support
* Backend choice in translations is controlled by lb_type switch allowing to enable Maglev. * Size of pool is set with cnat { maglev-len 1009 } Type: feature Change-Id: I956e19d70bc9f3b997b4f8042831164e4b559d17 Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
Diffstat (limited to 'src/plugins/cnat/cnat_node_vip.c')
-rw-r--r--src/plugins/cnat/cnat_node_vip.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/plugins/cnat/cnat_node_vip.c b/src/plugins/cnat/cnat_node_vip.c
index f653aa1e430..bc7d30369ab 100644
--- a/src/plugins/cnat/cnat_node_vip.c
+++ b/src/plugins/cnat/cnat_node_vip.c
@@ -109,14 +109,12 @@ cnat_vip_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b,
}
/* New flow, create the sessions */
- const load_balance_t *lb0;
cnat_ep_trk_t *trk0;
- u32 hash_c0, bucket0;
u32 rsession_flags = 0;
- const dpo_id_t *dpo0;
+ u32 dpoi_index = -1;
- lb0 = load_balance_get (ct->ct_lb.dpoi_index);
- if (!lb0->lb_n_buckets)
+ trk0 = cnat_load_balance (ct, ctx->af, ip4, ip6, &dpoi_index);
+ if (PREDICT_FALSE (NULL == trk0))
{
/* Dont translate & Follow the fib programming */
vnet_buffer (b)->ip.adj_index[VLIB_TX] = cc->cc_parent.dpoi_index;
@@ -124,16 +122,7 @@ cnat_vip_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b,
goto trace;
}
- /* session table miss */
- hash_c0 = (AF_IP4 == ctx->af ?
- ip4_compute_flow_hash (ip4, lb0->lb_hash_config) :
- ip6_compute_flow_hash (ip6, lb0->lb_hash_config));
- bucket0 = hash_c0 % lb0->lb_n_buckets;
- dpo0 = load_balance_get_fwd_bucket (lb0, bucket0);
-
/* add the session */
- trk0 = &ct->ct_paths[bucket0];
-
ip46_address_copy (&session->value.cs_ip[VLIB_TX],
&trk0->ct_ep[VLIB_TX].ce_ip.ip);
if (ip_address_is_zero (&trk0->ct_ep[VLIB_RX].ce_ip))
@@ -158,7 +147,7 @@ cnat_vip_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_buffer_t *b,
clib_host_to_net_u16 (trk0->ct_ep[VLIB_RX].ce_port);
session->value.dpoi_next_node = ct->ct_lb.dpoi_next_node;
- session->value.cs_lbi = dpo0->dpoi_index;
+ session->value.cs_lbi = dpoi_index;
rv = cspm->vip_policy (vm, b, session, &rsession_flags, ct, ctx);
if (CNAT_SOURCE_ERROR_USE_DEFAULT == rv)