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)
#fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
#Copyright 2017 Intel Corporation
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing, software
#distributed under the License is distributed on an "AS IS" BASIS,
#WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#See the License for the specific language governing permissions and
#limitations under the License.

_vppctl()
{
    local cur prev num opts
    COMPREPLY=( $(compgen -f ${cur}) )
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[@]:1}"
    num="$((${#COMP_WORDS[@]}-1))"

    VPP_CMD_LIST="$(cat /usr/share/vpp/vppctl-cmd-list)"

    opts="$(awk -v prev="^$prev" -v num=$num '{if($0 ~ prev) print $num}' <<< "${VPP_CMD_LIST}")"

    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )

}
complete -F _vppctl vppctl