diff options
author | Matus Fabian <matfabia@cisco.com> | 2017-02-05 22:45:57 -0800 |
---|---|---|
committer | Matus Fabian <matfabia@cisco.com> | 2017-02-05 22:45:57 -0800 |
commit | 31c31aa3b68f434e047309224ce0923600a59e16 (patch) | |
tree | b6e5fd44c73bbbc90179cc60524fc0fd0d87e95d /src/plugins | |
parent | 71d73fe818b1cd25ca6b181c450c404d43ad4abe (diff) |
SNAT: initialize outside and inside FIB index in snat_config
Change-Id: If26d758997d71792cedad1afae8d6a38cfd364ac
Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/snat/in2out.c | 14 | ||||
-rw-r--r-- | src/plugins/snat/snat.c | 27 |
2 files changed, 5 insertions, 36 deletions
diff --git a/src/plugins/snat/in2out.c b/src/plugins/snat/in2out.c index e783027f856..b0047737121 100644 --- a/src/plugins/snat/in2out.c +++ b/src/plugins/snat/in2out.c @@ -163,13 +163,6 @@ snat_not_translate (snat_main_t * sm, snat_runtime_t * rt, u32 sw_if_index0, if (PREDICT_FALSE(ip0->dst_address.as_u32 == rt->cached_ip4_address)) return 1; - /* If outside FIB index is not resolved yet */ - if (sm->outside_fib_index == ~0) - { - sm->outside_fib_index = - ip4_fib_table_find_or_create_and_lock (sm->outside_vrf_id); - } - key0.addr = ip0->dst_address; key0.port = udp0->dst_port; key0.protocol = proto0; @@ -535,13 +528,6 @@ snat_hairpinning (snat_main_t *sm, u32 new_dst_addr0 = 0, old_dst_addr0, ti = 0, si; u16 new_dst_port0, old_dst_port0; - /* If outside FIB index is not resolved yet */ - if (sm->outside_fib_index == ~0) - { - sm->outside_fib_index = - ip4_fib_table_find_or_create_and_lock (sm->outside_vrf_id); - } - key0.addr = ip0->dst_address; key0.port = udp0->dst_port; key0.protocol = proto0; diff --git a/src/plugins/snat/snat.c b/src/plugins/snat/snat.c index 750cc925d7f..8ad360209e7 100644 --- a/src/plugins/snat/snat.c +++ b/src/plugins/snat/snat.c @@ -346,15 +346,6 @@ int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, snat_interface_t *interface; int i; - /* If outside FIB index is not resolved yet */ - if (sm->outside_fib_index == ~0) - { - p = hash_get (sm->ip4_main->fib_index_by_table_id, sm->outside_vrf_id); - if (!p) - return VNET_API_ERROR_NO_SUCH_FIB; - sm->outside_fib_index = p[0]; - } - /* If the external address is a specific interface address */ if (sw_if_index != ~0) { @@ -402,17 +393,7 @@ int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, /* If not specified use inside VRF id from SNAT plugin startup config */ else { - if (sm->inside_fib_index == ~0) - { - p = hash_get (sm->ip4_main->fib_index_by_table_id, sm->inside_vrf_id); - if (!p) - return VNET_API_ERROR_NO_SUCH_FIB; - fib_index = p[0]; - sm->inside_fib_index = fib_index; - } - else - fib_index = sm->inside_fib_index; - + fib_index = sm->inside_fib_index; vrf_id = sm->inside_vrf_id; } @@ -2127,9 +2108,11 @@ snat_config (vlib_main_t * vm, unformat_input_t * input) sm->user_memory_size = user_memory_size; sm->max_translations_per_user = max_translations_per_user; sm->outside_vrf_id = outside_vrf_id; - sm->outside_fib_index = ~0; + sm->outside_fib_index = fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP4, + outside_vrf_id); sm->inside_vrf_id = inside_vrf_id; - sm->inside_fib_index = ~0; + sm->inside_fib_index = fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP4, + inside_vrf_id); sm->static_mapping_only = static_mapping_only; sm->static_mapping_connection_tracking = static_mapping_connection_tracking; |