X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Ffib%2Ffib_entry.c;h=6ff692dea98df93bbb191a6225b3e3a50b53fd6f;hb=097fa66b986f06281f603767d321ab13ab6c88c3;hp=cd1300dee39b94689035e217b612fe819c2b9d31;hpb=abcf3ea674aea6a87da9675935b663aa95819e0e;p=vpp.git diff --git a/src/vnet/fib/fib_entry.c b/src/vnet/fib/fib_entry.c index cd1300dee39..6ff692dea98 100644 --- a/src/vnet/fib/fib_entry.c +++ b/src/vnet/fib/fib_entry.c @@ -41,6 +41,11 @@ static const char *fib_src_attribute_names[] = FIB_ENTRY_SRC_ATTRIBUTES; */ static fib_entry_t *fib_entry_pool; +/** + * the logger + */ +vlib_log_class_t fib_entry_logger; + fib_entry_t * fib_entry_get (fib_node_index_t index) { @@ -101,11 +106,39 @@ format_fib_source (u8 * s, va_list * args) } u8 * -format_fib_entry (u8 * s, va_list * args) +format_fib_entry_flags (u8 *s, va_list *args) +{ + fib_entry_attribute_t attr; + fib_entry_flag_t flag = va_arg(*args, int); + + FOR_EACH_FIB_ATTRIBUTE(attr) { + if ((1<fes_ref_count); if (FIB_ENTRY_FLAG_NONE != src->fes_entry_flags) { - s = format(s, " entry-flags:"); - FOR_EACH_FIB_ATTRIBUTE(attr) { - if ((1<fes_entry_flags) { - s = format (s, "%s,", fib_attribute_names[attr]); - } - } + s = format(s, " entry-flags:%U", + format_fib_entry_flags, src->fes_entry_flags); } if (FIB_ENTRY_SRC_FLAG_NONE != src->fes_flags) { - s = format(s, " src-flags:"); - FOR_EACH_FIB_SRC_ATTRIBUTE(sattr) { - if ((1<fes_flags) { - s = format (s, "%s,", fib_src_attribute_names[sattr]); - } - } + s = format(s, " src-flags:%U", + format_fib_entry_src_flags, src->fes_flags); } s = fib_entry_src_format(fib_entry, source, s); s = format (s, "\n"); @@ -316,6 +341,9 @@ fib_entry_back_walk_notify (fib_node_t *node, */ ctx->fnbw_flags &= ~FIB_NODE_BW_FLAG_FORCE_SYNC; + FIB_ENTRY_DBG(fib_entry, "bw:%U", + format_fib_node_bw_reason, ctx->fnbw_reason); + /* * propagate the backwalk further if we haven't already reached the * maximum depth. @@ -573,7 +601,7 @@ fib_entry_alloc (u32 fib_index, fib_prefix_t *fep; pool_get(fib_entry_pool, fib_entry); - memset(fib_entry, 0, sizeof(*fib_entry)); + clib_memset(fib_entry, 0, sizeof(*fib_entry)); fib_node_init(&fib_entry->fe_node, FIB_NODE_TYPE_ENTRY); @@ -601,8 +629,6 @@ fib_entry_alloc (u32 fib_index, *fib_entry_index = fib_entry_get_index(fib_entry); - FIB_ENTRY_DBG(fib_entry, "alloc"); - return (fib_entry); } @@ -719,6 +745,8 @@ fib_entry_create (u32 fib_index, fib_entry_post_install_actions(fib_entry, source, FIB_ENTRY_FLAG_NONE); + FIB_ENTRY_DBG(fib_entry, "create"); + return (fib_entry_index); } @@ -733,7 +761,7 @@ fib_entry_create_special (u32 fib_index, fib_entry_t *fib_entry; /* - * create and initiliase the new enty + * create and initialize the new enty */ fib_entry = fib_entry_alloc(fib_index, prefix, &fib_entry_index); @@ -745,6 +773,8 @@ fib_entry_create_special (u32 fib_index, fib_entry_post_install_actions(fib_entry, source, FIB_ENTRY_FLAG_NONE); + FIB_ENTRY_DBG(fib_entry, "create-special"); + return (fib_entry_index); } @@ -850,6 +880,7 @@ fib_entry_special_add (fib_node_index_t fib_entry_index, fib_entry = fib_entry_src_action_add(fib_entry, source, flags, dpo); fib_entry_source_change(fib_entry, best_source, source); + FIB_ENTRY_DBG(fib_entry, "special-add:%U", format_fib_source, source); } void @@ -866,6 +897,8 @@ fib_entry_special_update (fib_node_index_t fib_entry_index, fib_entry = fib_entry_src_action_update(fib_entry, source, flags, dpo); fib_entry_source_change(fib_entry, best_source, source); + + FIB_ENTRY_DBG(fib_entry, "special-updated:%U", format_fib_source, source); } @@ -873,23 +906,23 @@ void fib_entry_path_add (fib_node_index_t fib_entry_index, fib_source_t source, fib_entry_flag_t flags, - const fib_route_path_t *rpath) + const fib_route_path_t *rpaths) { fib_source_t best_source; fib_entry_t *fib_entry; fib_entry_src_t *bsrc; - ASSERT(1 == vec_len(rpath)); - fib_entry = fib_entry_get(fib_entry_index); ASSERT(NULL != fib_entry); bsrc = fib_entry_get_best_src_i(fib_entry); best_source = fib_entry_src_get_source(bsrc); - fib_entry = fib_entry_src_action_path_add(fib_entry, source, flags, rpath); + fib_entry = fib_entry_src_action_path_add(fib_entry, source, flags, rpaths); fib_entry_source_change(fib_entry, best_source, source); + + FIB_ENTRY_DBG(fib_entry, "path add:%U", format_fib_source, source); } static fib_entry_src_flag_t @@ -968,7 +1001,7 @@ fib_entry_source_removed (fib_entry_t *fib_entry, fib_entry_src_flag_t fib_entry_path_remove (fib_node_index_t fib_entry_index, fib_source_t source, - const fib_route_path_t *rpath) + const fib_route_path_t *rpaths) { fib_entry_src_flag_t sflag; fib_source_t best_source; @@ -976,8 +1009,6 @@ fib_entry_path_remove (fib_node_index_t fib_entry_index, fib_entry_t *fib_entry; fib_entry_src_t *bsrc; - ASSERT(1 == vec_len(rpath)); - fib_entry = fib_entry_get(fib_entry_index); ASSERT(NULL != fib_entry); @@ -985,7 +1016,9 @@ fib_entry_path_remove (fib_node_index_t fib_entry_index, best_source = fib_entry_src_get_source(bsrc); bflags = fib_entry_src_get_flags(bsrc); - sflag = fib_entry_src_action_path_remove(fib_entry, source, rpath); + sflag = fib_entry_src_action_path_remove(fib_entry, source, rpaths); + + FIB_ENTRY_DBG(fib_entry, "path remove:%U", format_fib_source, source); /* * if the path list for the source passed is invalid, @@ -1074,6 +1107,8 @@ fib_entry_special_remove (fib_node_index_t fib_entry_index, best_source = fib_entry_src_get_source(bsrc); bflags = fib_entry_src_get_flags(bsrc); + FIB_ENTRY_DBG(fib_entry, "special remove:%U", format_fib_source, source); + sflag = fib_entry_src_action_remove_or_update_inherit(fib_entry, source); /* @@ -1154,7 +1189,7 @@ fib_entry_special_remove (fib_node_index_t fib_entry_index, /** * fib_entry_inherit * - * If the source on the cover is inherting then push this source + * If the source on the cover is inheriting then push this source * down to the covered. */ void @@ -1206,6 +1241,7 @@ fib_entry_update (fib_node_index_t fib_entry_index, paths); fib_entry_source_change_w_flags(fib_entry, best_source, bflags, source); + FIB_ENTRY_DBG(fib_entry, "update"); } @@ -1235,7 +1271,7 @@ fib_entry_cover_changed (fib_node_index_t fib_entry_index) fib_attached_export_cover_change(fib_entry); /* - * propagate the notificuation to each of the added sources + * propagate the notification to each of the added sources */ index = 0; FOR_EACH_SRC_ADDED(fib_entry, esrc, source, @@ -1279,6 +1315,7 @@ fib_entry_cover_changed (fib_node_index_t fib_entry_index) fib_walk_sync(FIB_NODE_TYPE_ENTRY, fib_entry_index, &bw_ctx); } + FIB_ENTRY_DBG(fib_entry, "cover-changed"); } /* @@ -1308,7 +1345,7 @@ fib_entry_cover_updated (fib_node_index_t fib_entry_index) fib_attached_export_cover_update(fib_entry); /* - * propagate the notificuation to each of the added sources + * propagate the notification to each of the added sources */ index = 0; FOR_EACH_SRC_ADDED(fib_entry, esrc, source, @@ -1352,6 +1389,7 @@ fib_entry_cover_updated (fib_node_index_t fib_entry_index) fib_walk_sync(FIB_NODE_TYPE_ENTRY, fib_entry_index, &bw_ctx); } + FIB_ENTRY_DBG(fib_entry, "cover-updated"); } int @@ -1428,7 +1466,16 @@ fib_entry_get_best_source (fib_node_index_t entry_index) } /** - * Return !0 is the entry is reoslved, i.e. will return a valid forwarding + * Return !0 is the entry represents a host prefix + */ +int +fib_entry_is_host (fib_node_index_t fib_entry_index) +{ + return (fib_prefix_is_host(fib_entry_get_prefix(fib_entry_index))); +} + +/** + * Return !0 is the entry is resolved, i.e. will return a valid forwarding * chain */ int @@ -1486,14 +1533,24 @@ fib_entry_set_flow_hash_config (fib_node_index_t fib_entry_index, } } +u32 +fib_entry_get_stats_index (fib_node_index_t fib_entry_index) +{ + fib_entry_t *fib_entry; + + fib_entry = fib_entry_get(fib_entry_index); + + return (fib_entry->fe_lb.dpoi_index); +} + static int fib_ip4_address_compare (const ip4_address_t * a1, const ip4_address_t * a2) { /* - * IP addresses are unsiged ints. the return value here needs to be signed + * IP addresses are unsigned ints. the return value here needs to be signed * a simple subtraction won't cut it. - * If the addresses are the same, the sort order is undefiend, so phoey. + * If the addresses are the same, the sort order is undefined, so phoey. */ return ((clib_net_to_host_u32(a1->data_u32) > clib_net_to_host_u32(a2->data_u32) ) ? @@ -1583,30 +1640,48 @@ fib_entry_unlock (fib_node_index_t fib_entry_index) void fib_entry_module_init (void) { - fib_node_register_type (FIB_NODE_TYPE_ENTRY, &fib_entry_vft); + fib_node_register_type(FIB_NODE_TYPE_ENTRY, &fib_entry_vft); + fib_entry_logger = vlib_log_register_class("fib", "entry"); } -void -fib_entry_encode (fib_node_index_t fib_entry_index, - fib_route_path_encode_t **api_rpaths) +fib_route_path_t * +fib_entry_encode (fib_node_index_t fib_entry_index) { + fib_path_ext_list_t *ext_list; + fib_path_encode_ctx_t ctx = { + .rpaths = NULL, + }; fib_entry_t *fib_entry; + fib_entry_src_t *bsrc; + ext_list = NULL; fib_entry = fib_entry_get(fib_entry_index); + bsrc = fib_entry_get_best_src_i(fib_entry); + + if (bsrc) + { + ext_list = &bsrc->fes_path_exts; + } + if (FIB_NODE_INDEX_INVALID != fib_entry->fe_parent) { - fib_path_list_walk(fib_entry->fe_parent, fib_path_encode, api_rpaths); + fib_path_list_walk_w_ext(fib_entry->fe_parent, + ext_list, + fib_path_encode, + &ctx); } + + return (ctx.rpaths); } -void -fib_entry_get_prefix (fib_node_index_t fib_entry_index, - fib_prefix_t *pfx) +const fib_prefix_t * +fib_entry_get_prefix (fib_node_index_t fib_entry_index) { fib_entry_t *fib_entry; fib_entry = fib_entry_get(fib_entry_index); - *pfx = fib_entry->fe_prefix; + + return (&fib_entry->fe_prefix); } u32