summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2017-01-31 22:20:30 -0800
committerOle Trøan <otroan@employees.org>2017-02-02 08:49:50 +0000
commitdccbee391462c1fb8f550dfbc3aa535109ca428b (patch)
tree1a66eb32c6193265c5b35460b5188c1c6da36725 /src
parent05a057bb3af7d83f62a2919ccab57aa0a41b04a9 (diff)
SNAT: changed source for outbound address FIB entry (VPP-613)
Use FIB_SOURCE_PLUGIN_HI and modify ARP input to use non-source variants for flags and resolving interface get. Change-Id: I3bab76f36e0b1ee86e430a416099f1654e02740a Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/snat/snat.c32
-rw-r--r--src/vnet/ethernet/arp.c7
2 files changed, 13 insertions, 26 deletions
diff --git a/src/plugins/snat/snat.c b/src/plugins/snat/snat.c
index 6149411887a..5ee6647576a 100644
--- a/src/plugins/snat/snat.c
+++ b/src/plugins/snat/snat.c
@@ -220,19 +220,13 @@ bad_tx_sw_if_index: \
* that VPP will reply to ARP for this address and we don't need to enable
* proxy ARP on the outside interface.
*
- * @param sm SNAT main
* @param addr IPv4 address.
* @param sw_if_index Interface.
* @param is_add If 0 delete, otherwise add.
*/
static void
-snat_add_del_addr_to_fib (snat_main_t *sm,
- ip4_address_t * addr,
- u32 sw_if_index,
- int is_add)
+snat_add_del_addr_to_fib (ip4_address_t * addr, u32 sw_if_index, int is_add)
{
- ip4_main_t * ip4_main = sm->ip4_main;
- ip4_address_t * first_int_addr;
fib_prefix_t prefix = {
.fp_len = 32,
.fp_proto = FIB_PROTOCOL_IP4,
@@ -242,17 +236,10 @@ snat_add_del_addr_to_fib (snat_main_t *sm,
};
u32 fib_index = ip4_fib_table_get_index_for_sw_if_index(sw_if_index);
- first_int_addr = ip4_interface_first_address (ip4_main, sw_if_index, 0);
- if (first_int_addr)
- {
- if (first_int_addr->as_u32 == addr->as_u32)
- return;
- }
-
if (is_add)
fib_table_entry_update_one_path(fib_index,
&prefix,
- FIB_SOURCE_INTERFACE,
+ FIB_SOURCE_PLUGIN_HI,
(FIB_ENTRY_FLAG_CONNECTED |
FIB_ENTRY_FLAG_LOCAL |
FIB_ENTRY_FLAG_EXCLUSIVE),
@@ -266,7 +253,7 @@ snat_add_del_addr_to_fib (snat_main_t *sm,
else
fib_table_entry_delete(fib_index,
&prefix,
- FIB_SOURCE_INTERFACE);
+ FIB_SOURCE_PLUGIN_HI);
}
void snat_add_address (snat_main_t *sm, ip4_address_t *addr)
@@ -291,7 +278,8 @@ void snat_add_address (snat_main_t *sm, ip4_address_t *addr)
if (i->is_inside)
continue;
- snat_add_del_addr_to_fib(sm, addr, i->sw_if_index, 1);
+ snat_add_del_addr_to_fib(addr, i->sw_if_index, 1);
+ break;
}));
}
@@ -639,7 +627,8 @@ int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr,
if (interface->is_inside)
continue;
- snat_add_del_addr_to_fib(sm, &e_addr, interface->sw_if_index, is_add);
+ snat_add_del_addr_to_fib(&e_addr, interface->sw_if_index, is_add);
+ break;
}));
return 0;
@@ -737,7 +726,8 @@ int snat_del_address (snat_main_t *sm, ip4_address_t addr, u8 delete_sm)
if (interface->is_inside)
continue;
- snat_add_del_addr_to_fib(sm, &addr, interface->sw_if_index, 0);
+ snat_add_del_addr_to_fib(&addr, interface->sw_if_index, 0);
+ break;
}));
return 0;
@@ -796,14 +786,14 @@ fib:
return 0;
vec_foreach (ap, sm->addresses)
- snat_add_del_addr_to_fib(sm, &ap->addr, sw_if_index, !is_del);
+ snat_add_del_addr_to_fib(&ap->addr, sw_if_index, !is_del);
pool_foreach (m, sm->static_mappings,
({
if (!(m->addr_only))
continue;
- snat_add_del_addr_to_fib(sm, &m->external_addr, sw_if_index, !is_del);
+ snat_add_del_addr_to_fib(&m->external_addr, sw_if_index, !is_del);
}));
return 0;
diff --git a/src/vnet/ethernet/arp.c b/src/vnet/ethernet/arp.c
index 8f07fa55394..8898d33b3cf 100644
--- a/src/vnet/ethernet/arp.c
+++ b/src/vnet/ethernet/arp.c
@@ -1062,12 +1062,9 @@ arp_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
dst_fei = ip4_fib_table_lookup (ip4_fib_get (fib_index0),
&arp0->ip4_over_ethernet[1].ip4,
32);
- dst_flags = fib_entry_get_flags_for_source (dst_fei,
- FIB_SOURCE_INTERFACE);
+ dst_flags = fib_entry_get_flags (dst_fei);
- conn_sw_if_index0 =
- fib_entry_get_resolving_interface_for_source (dst_fei,
- FIB_SOURCE_INTERFACE);
+ conn_sw_if_index0 = fib_entry_get_resolving_interface (dst_fei);
if (!(FIB_ENTRY_FLAG_CONNECTED & dst_flags))
{