LISP: re-fetch mapping before it expires

Change-Id: I0581a1bddad55d8d573c546ec84b0b2760abab3d
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
This commit is contained in:
Filip Tehlar
2017-08-14 19:15:36 +02:00
parent dbfa574a1d
commit 809bc74b5b
10 changed files with 340 additions and 148 deletions

File diff suppressed because it is too large Load Diff

View File

@ -329,9 +329,11 @@ vnet_lisp_add_del_local_mapping (vnet_lisp_add_del_mapping_args_t * a,
u32 * map_index_result);
int
vnet_lisp_add_del_mapping (gid_address_t * deid, locator_t * dlocs, u8 action,
u8 authoritative, u32 ttl, u8 is_add, u8 is_static,
u32 * res_map_index);
vnet_lisp_add_mapping (vnet_lisp_add_del_mapping_args_t * a,
locator_t * rlocs, u32 * res_map_index,
u8 * is_changed);
int vnet_lisp_del_mapping (gid_address_t * eid, u32 * res_map_index);
typedef struct
{

View File

@ -521,8 +521,19 @@ static void
/* NOTE: for now this works as a static remote mapping, i.e.,
* not authoritative and ttl infinite. */
rv = vnet_lisp_add_del_mapping (eid, rlocs, mp->action, 0, ~0,
mp->is_add, 1 /* is_static */ , 0);
if (mp->is_add)
{
vnet_lisp_add_del_mapping_args_t _m_args, *m_args = &_m_args;
memset (m_args, 0, sizeof (m_args[0]));
gid_address_copy (&m_args->eid, eid);
m_args->action = mp->action;
m_args->is_static = 1;
m_args->ttl = ~0;
m_args->authoritative = 0;
rv = vnet_lisp_add_mapping (m_args, rlocs, NULL, NULL);
}
else
rv = vnet_lisp_del_mapping (eid, NULL);
if (mp->del_all)
vnet_lisp_clear_all_remote_adjacencies ();

View File

@ -394,8 +394,19 @@ lisp_add_del_remote_mapping_command_fn (vlib_main_t * vm,
/* add as static remote mapping, i.e., not authoritative and infinite
* ttl */
rv = vnet_lisp_add_del_mapping (&eid, rlocs, action, 0, ~0, is_add,
1 /* is_static */ , 0);
if (is_add)
{
vnet_lisp_add_del_mapping_args_t _map_args, *map_args = &_map_args;
memset (map_args, 0, sizeof (map_args[0]));
gid_address_copy (&map_args->eid, &eid);
map_args->action = action;
map_args->is_static = 1;
map_args->authoritative = 0;
map_args->ttl = ~0;
rv = vnet_lisp_add_mapping (map_args, rlocs, NULL, NULL);
}
else
rv = vnet_lisp_del_mapping (&eid, NULL);
if (rv)
clib_warning ("failed to %s remote mapping!", is_add ? "add" : "delete");

View File

@ -358,12 +358,14 @@ typedef struct
u8 is_static:1;
u8 pitr_set:1;
u8 nsh_set:1;
u8 rsvd:3;
u8 almost_expired:1;
u8 delete_after_expiration:1;
u8 rsvd:1;
u8 *key;
lisp_key_type_t key_id;
u8 timer_set;
counter_t packets;
} mapping_t;
uword

View File

@ -620,8 +620,19 @@ static void
/* NOTE: for now this works as a static remote mapping, i.e.,
* not authoritative and ttl infinite. */
rv = vnet_lisp_add_del_mapping (eid, rlocs, mp->action, 0, ~0,
mp->is_add, 1 /* is_static */ , 0);
if (mp->is_add)
{
vnet_lisp_add_del_mapping_args_t _m_args, *m_args = &_m_args;
memset (m_args, 0, sizeof (m_args[0]));
gid_address_copy (&m_args->eid, eid);
m_args->action = mp->action;
m_args->is_static = 1;
m_args->ttl = ~0;
m_args->authoritative = 0;
rv = vnet_lisp_add_mapping (m_args, rlocs, NULL, NULL);
}
else
rv = vnet_lisp_del_mapping (eid, NULL);
if (mp->del_all)
vnet_lisp_clear_all_remote_adjacencies ();

View File

@ -487,8 +487,19 @@ lisp_add_del_remote_mapping_command_fn (vlib_main_t * vm,
/* add as static remote mapping, i.e., not authoritative and infinite
* ttl */
rv = vnet_lisp_add_del_mapping (&eid, rlocs, action, 0, ~0, is_add,
1 /* is_static */ , 0);
if (is_add)
{
vnet_lisp_add_del_mapping_args_t _map_args, *map_args = &_map_args;
memset (map_args, 0, sizeof (map_args[0]));
gid_address_copy (&map_args->eid, &eid);
map_args->action = action;
map_args->is_static = 1;
map_args->authoritative = 0;
map_args->ttl = ~0;
rv = vnet_lisp_add_mapping (map_args, rlocs, NULL, NULL);
}
else
rv = vnet_lisp_del_mapping (&eid, NULL);
if (rv)
clib_warning ("failed to %s remote mapping!", is_add ? "add" : "delete");

View File

@ -193,12 +193,15 @@ ip_src_dst_fib_del_route (u32 src_fib_index,
* @param[in] src_fib_index The index/ID of the SRC FIB
* @param[in] src_prefix Source IP prefix.
* @param[in] src_dpo The DPO the route will link to.
*
* @return fib index of the inserted prefix
*/
static void
static fib_node_index_t
ip_src_fib_add_route_w_dpo (u32 src_fib_index,
const ip_prefix_t * src_prefix,
const dpo_id_t * src_dpo)
{
fib_node_index_t fei = ~0;
fib_prefix_t src_fib_prefix;
ip_prefix_to_fib_prefix (src_prefix, &src_fib_prefix);
@ -213,11 +216,13 @@ ip_src_fib_add_route_w_dpo (u32 src_fib_index,
if (FIB_NODE_INDEX_INVALID == src_fei ||
!fib_entry_is_sourced (src_fei, FIB_SOURCE_LISP))
{
fib_table_entry_special_dpo_add (src_fib_index,
&src_fib_prefix,
FIB_SOURCE_LISP,
FIB_ENTRY_FLAG_EXCLUSIVE, src_dpo);
fei = fib_table_entry_special_dpo_add (src_fib_index,
&src_fib_prefix,
FIB_SOURCE_LISP,
FIB_ENTRY_FLAG_EXCLUSIVE,
src_dpo);
}
return fei;
}
static fib_route_path_t *
@ -262,7 +267,7 @@ lisp_gpe_mk_fib_paths (const lisp_fwd_path_t * paths)
* @param[in] paths The paths from which to construct the
* load balance
*/
static void
static fib_node_index_t
ip_src_fib_add_route (u32 src_fib_index,
const ip_prefix_t * src_prefix,
const lisp_fwd_path_t * paths)
@ -274,10 +279,11 @@ ip_src_fib_add_route (u32 src_fib_index,
rpaths = lisp_gpe_mk_fib_paths (paths);
fib_table_entry_update (src_fib_index,
&src_fib_prefix,
FIB_SOURCE_LISP, FIB_ENTRY_FLAG_NONE, rpaths);
fib_node_index_t fib_entry_index =
fib_table_entry_update (src_fib_index, &src_fib_prefix, FIB_SOURCE_LISP,
FIB_ENTRY_FLAG_NONE, rpaths);
vec_free (rpaths);
return fib_entry_index;
}
static void
@ -311,9 +317,11 @@ gpe_native_fwd_add_del_lfe (lisp_gpe_fwd_entry_t * lfe, u8 is_add)
}
}
static void
static index_t
create_fib_entries (lisp_gpe_fwd_entry_t * lfe)
{
fib_node_index_t fi;
fib_entry_t *fe;
lisp_gpe_main_t *lgm = vnet_lisp_gpe_get_main ();
dpo_proto_t dproto;
ip_prefix_t ippref;
@ -361,13 +369,15 @@ create_fib_entries (lisp_gpe_fwd_entry_t * lfe)
dpo_copy (&dpo, drop_dpo_get (dproto));
break;
}
ip_src_fib_add_route_w_dpo (lfe->src_fib_index, &ippref, &dpo);
fi = ip_src_fib_add_route_w_dpo (lfe->src_fib_index, &ippref, &dpo);
dpo_reset (&dpo);
}
else
{
ip_src_fib_add_route (lfe->src_fib_index, &ippref, lfe->paths);
fi = ip_src_fib_add_route (lfe->src_fib_index, &ippref, lfe->paths);
}
fe = fib_entry_get (fi);
return fe->fe_lb.dpoi_index;
}
static void
@ -546,7 +556,7 @@ add_ip_fwd_entry (lisp_gpe_main_t * lgm,
lfe->action = a->action;
}
create_fib_entries (lfe);
lfe->dpoi_index = create_fib_entries (lfe);
return (0);
}
@ -793,6 +803,7 @@ lisp_gpe_l2_update_fwding (lisp_gpe_fwd_entry_t * lfe)
lisp_l2_fib_add_del_entry (lfe->l2.eid_bd_index,
fid_addr_mac (&lfe->key->lcl),
fid_addr_mac (&lfe->key->rmt), &dpo, 1);
lfe->dpoi_index = dpo.dpoi_index;
dpo_reset (&dpo);
}
@ -1538,6 +1549,29 @@ vnet_lisp_gpe_fwd_entries_get_by_vni (u32 vni)
return entries;
}
int
vnet_lisp_gpe_get_fwd_stats (vnet_lisp_gpe_add_del_fwd_entry_args_t * a,
vlib_counter_t * c)
{
lisp_gpe_main_t *lgm = vnet_lisp_gpe_get_main ();
lisp_gpe_fwd_entry_t *lfe;
lisp_gpe_fwd_entry_key_t unused;
lfe = find_fwd_entry (lgm, a, &unused);
if (NULL == lfe)
return -1;
if (LISP_GPE_FWD_ENTRY_TYPE_NEGATIVE == lfe->type)
return -1;
if (~0 == lfe->dpoi_index)
return -1;
vlib_get_combined_counter (&load_balance_main.lbm_to_counters,
lfe->dpoi_index, c);
return 0;
}
VLIB_INIT_FUNCTION (lisp_gpe_fwd_entry_init);
/*

View File

@ -198,6 +198,12 @@ typedef struct lisp_gpe_fwd_entry_t_
*/
negative_fwd_actions_e action;
};
/**
* used for getting load balance statistics
*/
index_t dpoi_index;
} lisp_gpe_fwd_entry_t;
extern int
@ -219,6 +225,10 @@ vnet_lisp_gpe_add_fwd_counters (vnet_lisp_gpe_add_del_fwd_entry_args_t * a,
u32 fwd_entry_index);
extern u32 *vnet_lisp_gpe_get_fwd_entry_vnis (void);
int
vnet_lisp_gpe_get_fwd_stats (vnet_lisp_gpe_add_del_fwd_entry_args_t * a,
vlib_counter_t * c);
#endif
/*

View File

@ -192,7 +192,7 @@ lisp_gpe_sub_interface_unlock (index_t l3si)
lisp_gpe_sub_interface_unset_table (l3s->sw_if_index,
l3s->eid_table_id);
lisp_gpe_tenant_l3_iface_unlock (clib_net_to_host_u32 (l3s->key->vni));
lisp_gpe_tenant_l3_iface_unlock (l3s->key->vni);
vnet_sw_interface_set_flags (vnet_get_main (), l3s->sw_if_index, 0);
vnet_delete_sub_interface (l3s->sw_if_index);