aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ip
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/ip')
-rw-r--r--src/vnet/ip/ip4.h20
-rw-r--r--src/vnet/ip/ip4_forward.c138
-rw-r--r--src/vnet/ip/ip6_link.c35
-rw-r--r--src/vnet/ip/ip6_link.h4
4 files changed, 49 insertions, 148 deletions
diff --git a/src/vnet/ip/ip4.h b/src/vnet/ip/ip4.h
index 22de22f227a..3be2f7f1a7e 100644
--- a/src/vnet/ip/ip4.h
+++ b/src/vnet/ip/ip4.h
@@ -201,26 +201,6 @@ ip4_destination_matches_interface (ip4_main_t * im,
return ip4_destination_matches_route (im, key, a, ia->address_length);
}
-always_inline int
-ip4_src_address_for_packet (ip_lookup_main_t * lm,
- u32 sw_if_index, ip4_address_t * src)
-{
- u32 if_add_index = lm->if_address_pool_index_by_sw_if_index[sw_if_index];
- if (PREDICT_TRUE (if_add_index != ~0))
- {
- ip_interface_address_t *if_add =
- pool_elt_at_index (lm->if_address_pool, if_add_index);
- ip4_address_t *if_ip = ip_interface_address_get_address (lm, if_add);
- *src = *if_ip;
- return 0;
- }
- else
- {
- src->as_u32 = 0;
- }
- return (!0);
-}
-
/* Find interface address which matches destination. */
always_inline ip4_address_t *
ip4_interface_address_matching_destination (ip4_main_t * im,
diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c
index 919718035a1..5903ef892ca 100644
--- a/src/vnet/ip/ip4_forward.c
+++ b/src/vnet/ip/ip4_forward.c
@@ -380,28 +380,28 @@ ip4_add_interface_prefix_routes (ip4_main_t *im,
mhash_set (&lm->prefix_to_if_prefix_index, &key,
if_prefix - lm->if_prefix_pool, 0 /* old value */);
+ pfx_special.fp_len = a->address_length;
+ pfx_special.fp_addr.ip4.as_u32 = address->as_u32;
+
+ /* set the glean route for the prefix */
+ fib_table_entry_update_one_path (fib_index, &pfx_special,
+ FIB_SOURCE_INTERFACE,
+ (FIB_ENTRY_FLAG_CONNECTED |
+ FIB_ENTRY_FLAG_ATTACHED),
+ DPO_PROTO_IP4,
+ /* No next-hop address */
+ NULL,
+ sw_if_index,
+ /* invalid FIB index */
+ ~0,
+ 1,
+ /* no out-label stack */
+ NULL,
+ FIB_ROUTE_PATH_FLAG_NONE);
+
/* length <= 30 - add glean, drop first address, maybe drop bcast address */
if (a->address_length <= 30)
{
- pfx_special.fp_len = a->address_length;
- pfx_special.fp_addr.ip4.as_u32 = address->as_u32;
-
- /* set the glean route for the prefix */
- fib_table_entry_update_one_path (fib_index, &pfx_special,
- FIB_SOURCE_INTERFACE,
- (FIB_ENTRY_FLAG_CONNECTED |
- FIB_ENTRY_FLAG_ATTACHED),
- DPO_PROTO_IP4,
- /* No next-hop address */
- NULL,
- sw_if_index,
- /* invalid FIB index */
- ~0,
- 1,
- /* no out-label stack */
- NULL,
- FIB_ROUTE_PATH_FLAG_NONE);
-
/* set a drop route for the base address of the prefix */
pfx_special.fp_len = 32;
pfx_special.fp_addr.ip4.as_u32 =
@@ -528,90 +528,52 @@ ip4_del_interface_prefix_routes (ip4_main_t * im,
if_prefix->ref_count -= 1;
/*
- * Routes need to be adjusted if:
- * - deleting last intf addr in prefix
- * - deleting intf addr used as default source address in glean adjacency
+ * Routes need to be adjusted if deleting last intf addr in prefix
*
* We're done now otherwise
*/
- if ((if_prefix->ref_count > 0) &&
- !pool_is_free_index (lm->if_address_pool, if_prefix->src_ia_index))
+ if (if_prefix->ref_count > 0)
return;
/* length <= 30, delete glean route, first address, last address */
if (address_length <= 30)
{
+ /* Less work to do in FIB if we remove the covered /32s first */
- /* remove glean route for prefix */
- pfx_special.fp_addr.ip4 = *address;
- pfx_special.fp_len = address_length;
- fib_table_entry_delete (fib_index, &pfx_special, FIB_SOURCE_INTERFACE);
-
- /* if no more intf addresses in prefix, remove other special routes */
- if (!if_prefix->ref_count)
- {
- /* first address in prefix */
- pfx_special.fp_addr.ip4.as_u32 =
- address->as_u32 & im->fib_masks[address_length];
- pfx_special.fp_len = 32;
+ /* first address in prefix */
+ pfx_special.fp_addr.ip4.as_u32 =
+ address->as_u32 & im->fib_masks[address_length];
+ pfx_special.fp_len = 32;
- if (pfx_special.fp_addr.ip4.as_u32 != address->as_u32)
- fib_table_entry_special_remove (fib_index,
- &pfx_special,
- FIB_SOURCE_INTERFACE);
+ if (pfx_special.fp_addr.ip4.as_u32 != address->as_u32)
+ fib_table_entry_special_remove (fib_index,
+ &pfx_special,
+ FIB_SOURCE_INTERFACE);
- /* prefix broadcast address */
- pfx_special.fp_addr.ip4.as_u32 =
- address->as_u32 | ~im->fib_masks[address_length];
- pfx_special.fp_len = 32;
+ /* prefix broadcast address */
+ pfx_special.fp_addr.ip4.as_u32 =
+ address->as_u32 | ~im->fib_masks[address_length];
+ pfx_special.fp_len = 32;
- if (pfx_special.fp_addr.ip4.as_u32 != address->as_u32)
- fib_table_entry_special_remove (fib_index,
- &pfx_special,
- FIB_SOURCE_INTERFACE);
- }
- else
- /* default source addr just got deleted, find another */
- {
- ip_interface_address_t *new_src_ia = NULL;
- ip4_address_t *new_src_addr = NULL;
-
- new_src_addr =
- ip4_interface_address_matching_destination
- (im, address, sw_if_index, &new_src_ia);
-
- if_prefix->src_ia_index = new_src_ia - lm->if_address_pool;
-
- pfx_special.fp_len = address_length;
- pfx_special.fp_addr.ip4 = *new_src_addr;
-
- /* set new glean route for the prefix */
- fib_table_entry_update_one_path (fib_index, &pfx_special,
- FIB_SOURCE_INTERFACE,
- (FIB_ENTRY_FLAG_CONNECTED |
- FIB_ENTRY_FLAG_ATTACHED),
- DPO_PROTO_IP4,
- /* No next-hop address */
- NULL,
- sw_if_index,
- /* invalid FIB index */
- ~0,
- 1,
- /* no out-label stack */
- NULL,
- FIB_ROUTE_PATH_FLAG_NONE);
- return;
- }
+ if (pfx_special.fp_addr.ip4.as_u32 != address->as_u32)
+ fib_table_entry_special_remove (fib_index,
+ &pfx_special,
+ FIB_SOURCE_INTERFACE);
}
- /* length == 31, delete attached route for the other address */
else if (address_length == 31)
{
+ /* length == 31, delete attached route for the other address */
pfx_special.fp_addr.ip4.as_u32 =
address->as_u32 ^ clib_host_to_net_u32(1);
fib_table_entry_delete (fib_index, &pfx_special, FIB_SOURCE_INTERFACE);
}
+ /* remove glean route for prefix */
+ pfx_special.fp_addr.ip4 = *address;
+ pfx_special.fp_len = address_length;
+ fib_table_entry_delete (fib_index, &pfx_special, FIB_SOURCE_INTERFACE);
+
mhash_unset (&lm->prefix_to_if_prefix_index, &key, 0 /* old_value */);
pool_put (lm->if_prefix_pool, if_prefix);
}
@@ -623,16 +585,15 @@ ip4_del_interface_routes (u32 sw_if_index,
ip4_address_t * address, u32 address_length)
{
fib_prefix_t pfx = {
- .fp_len = address_length,
+ .fp_len = 32,
.fp_proto = FIB_PROTOCOL_IP4,
.fp_addr.ip4 = *address,
};
+ fib_table_entry_delete (fib_index, &pfx, FIB_SOURCE_INTERFACE);
+
ip4_del_interface_prefix_routes (im, sw_if_index, fib_index,
address, address_length);
-
- pfx.fp_len = 32;
- fib_table_entry_delete (fib_index, &pfx, FIB_SOURCE_INTERFACE);
}
#ifndef CLIB_MARCH_VARIANT
@@ -2540,9 +2501,8 @@ ip4_rewrite_inline_with_gso (vlib_main_t * vm,
thread_index, adj_index0, 1,
vlib_buffer_length_in_chain (vm, b[0]) + rw_len0);
- if (is_midchain && adj0->sub_type.midchain.fixup_func)
- adj0->sub_type.midchain.fixup_func
- (vm, adj0, b[0], adj0->sub_type.midchain.fixup_data);
+ if (is_midchain)
+ adj_midchain_fixup (vm, adj0, b[0]);
if (is_mcast)
/* copy bytes from the IP address into the MAC rewrite */
diff --git a/src/vnet/ip/ip6_link.c b/src/vnet/ip/ip6_link.c
index bd7ad73b695..082033a9de9 100644
--- a/src/vnet/ip/ip6_link.c
+++ b/src/vnet/ip/ip6_link.c
@@ -337,41 +337,6 @@ ip6_link_get_mcast_adj (u32 sw_if_index)
}
int
-ip6_src_address_for_packet (u32 sw_if_index,
- const ip6_address_t * dst, ip6_address_t * src)
-{
- ip_lookup_main_t *lm;
-
- lm = &ip6_main.lookup_main;
-
- if (ip6_address_is_link_local_unicast (dst))
- {
- ip6_address_copy (src, ip6_get_link_local_address (sw_if_index));
-
- return (!0);
- }
- else
- {
- u32 if_add_index =
- lm->if_address_pool_index_by_sw_if_index[sw_if_index];
- if (PREDICT_TRUE (if_add_index != ~0))
- {
- ip_interface_address_t *if_add =
- pool_elt_at_index (lm->if_address_pool, if_add_index);
- ip6_address_t *if_ip =
- ip_interface_address_get_address (lm, if_add);
- *src = *if_ip;
- return (!0);
- }
- }
-
- src->as_u64[0] = 0;
- src->as_u64[1] = 0;
-
- return (0);
-}
-
-int
ip6_link_set_local_address (u32 sw_if_index, const ip6_address_t * address)
{
ip6_link_delegate_t *ild;
diff --git a/src/vnet/ip/ip6_link.h b/src/vnet/ip/ip6_link.h
index a9dfa5edcb0..d9f611950ea 100644
--- a/src/vnet/ip/ip6_link.h
+++ b/src/vnet/ip/ip6_link.h
@@ -30,10 +30,6 @@ extern int ip6_link_set_local_address (u32 sw_if_index,
const ip6_address_t * address);
extern adj_index_t ip6_link_get_mcast_adj (u32 sw_if_index);
-extern int
-ip6_src_address_for_packet (u32 sw_if_index,
- const ip6_address_t * dst, ip6_address_t * src);
-
/**
* Delegates for the interfaces
*