X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Ffib%2Ffib_path.c;h=baf8275d1816fe42c0ca70a324b9b1e3688441ef;hb=609e1210c6339376dd6cdd0f79195b436d5614d2;hp=687e716731219ceb6f52959f39d558f2edf7aff0;hpb=4a6d02337b9058182172f19df894ad2e18e6ac68;p=vpp.git diff --git a/src/vnet/fib/fib_path.c b/src/vnet/fib/fib_path.c index 687e7167312..baf8275d181 100644 --- a/src/vnet/fib/fib_path.c +++ b/src/vnet/fib/fib_path.c @@ -409,22 +409,22 @@ static const char *fib_path_cfg_attribute_names[] = FIB_PATH_CFG_ATTRIBUTES; */ static fib_path_t *fib_path_pool; +/** + * the logger + */ +vlib_log_class_t fib_path_logger; + /* * Debug macro */ -#ifdef FIB_DEBUG -#define FIB_PATH_DBG(_p, _fmt, _args...) \ -{ \ - u8 *_tmp = NULL; \ - _tmp = fib_path_format(fib_path_get_index(_p), _tmp); \ - clib_warning("path:[%d:%U]:" _fmt, \ - fib_path_get_index(_p), format_fib_path, _p, 0,\ - ##_args); \ - vec_free(_tmp); \ +#define FIB_PATH_DBG(_p, _fmt, _args...) \ +{ \ + vlib_log_debug (fib_path_logger, \ + "[%U]: " _fmt, \ + format_fib_path, fib_path_get_index(_p), 0, \ + FIB_PATH_FORMAT_FLAGS_ONE_LINE, \ + ##_args); \ } -#else -#define FIB_PATH_DBG(_p, _fmt, _args...) -#endif static fib_path_t * fib_path_get (fib_node_index_t index) @@ -456,10 +456,21 @@ format_fib_path (u8 * s, va_list * args) { fib_node_index_t path_index = va_arg (*args, fib_node_index_t); u32 indent = va_arg (*args, u32); + fib_format_path_flags_t flags = va_arg (*args, fib_format_path_flags_t); vnet_main_t * vnm = vnet_get_main(); fib_path_oper_attribute_t oattr; fib_path_cfg_attribute_t cattr; fib_path_t *path; + const char *eol; + + if (flags & FIB_PATH_FORMAT_FLAGS_ONE_LINE) + { + eol = ""; + } + else + { + eol = "\n"; + } path = fib_path_get(path_index); @@ -486,7 +497,8 @@ format_fib_path (u8 * s, va_list * args) } } } - s = format(s, "\n%U", format_white_space, indent+2); + if (!(flags & FIB_PATH_FORMAT_FLAGS_ONE_LINE)) + s = format(s, "\n%U", format_white_space, indent+2); switch (path->fp_type) { @@ -514,11 +526,11 @@ format_fib_path (u8 * s, va_list * args) } if (!dpo_id_is_valid(&path->fp_dpo)) { - s = format(s, "\n%Uunresolved", format_white_space, indent+2); + s = format(s, "%s%Uunresolved", eol, format_white_space, indent+2); } else { - s = format(s, "\n%U%U", + s = format(s, "%s%U%U", eol, format_white_space, indent, format_dpo_id, &path->fp_dpo, 13); @@ -608,17 +620,6 @@ format_fib_path (u8 * s, va_list * args) return (s); } -u8 * -fib_path_format (fib_node_index_t pi, u8 *s) -{ - fib_path_t *path; - - path = fib_path_get(pi); - ASSERT(NULL != path); - - return (format (s, "%U", format_fib_path, path)); -} - /* * fib_path_last_lock_gone * @@ -874,14 +875,14 @@ fib_path_unresolve (fib_path_t *path) case FIB_PATH_TYPE_RECURSIVE: if (FIB_NODE_INDEX_INVALID != path->fp_via_fib) { - fib_prefix_t pfx; - - fib_entry_get_prefix(path->fp_via_fib, &pfx); fib_entry_child_remove(path->fp_via_fib, path->fp_sibling); fib_table_entry_special_remove(path->recursive.fp_tbl_id, - &pfx, + fib_entry_get_prefix(path->fp_via_fib), FIB_SOURCE_RR); + fib_table_unlock(path->recursive.fp_tbl_id, + dpo_proto_to_fib(path->fp_nh_proto), + FIB_SOURCE_RR); path->fp_via_fib = FIB_NODE_INDEX_INVALID; } break; @@ -906,7 +907,7 @@ fib_path_unresolve (fib_path_t *path) adj_unlock(path->fp_dpo.dpoi_index); break; case FIB_PATH_TYPE_UDP_ENCAP: - udp_encap_unlock_w_index(path->fp_dpo.dpoi_index); + udp_encap_unlock(path->fp_dpo.dpoi_index); break; case FIB_PATH_TYPE_EXCLUSIVE: dpo_reset(&path->exclusive.fp_ex_dpo); @@ -966,6 +967,9 @@ fib_path_back_walk_notify (fib_node_t *node, path = fib_path_from_fib_node(node); + FIB_PATH_DBG(path, "bw:%U", + format_fib_node_bw_reason, ctx->fnbw_reason); + switch (path->fp_type) { case FIB_PATH_TYPE_RECURSIVE: @@ -1252,7 +1256,7 @@ fib_path_create (fib_node_index_t pl_index, fib_path_t *path; pool_get(fib_path_pool, path); - memset(path, 0, sizeof(*path)); + clib_memset(path, 0, sizeof(*path)); fib_node_init(&path->fp_node, FIB_NODE_TYPE_PATH); @@ -1323,6 +1327,11 @@ fib_path_create (fib_node_index_t pl_index, path->fp_type = FIB_PATH_TYPE_DVR; path->dvr.fp_interface = rpath->frp_sw_if_index; } + else if (rpath->frp_flags & FIB_ROUTE_PATH_EXCLUSIVE) + { + path->fp_type = FIB_PATH_TYPE_EXCLUSIVE; + dpo_copy(&path->exclusive.fp_ex_dpo, &rpath->dpo); + } else if (~0 != rpath->frp_sw_if_index) { if (ip46_address_is_zero(&rpath->frp_addr)) @@ -1388,7 +1397,7 @@ fib_path_create_special (fib_node_index_t pl_index, fib_path_t *path; pool_get(fib_path_pool, path); - memset(path, 0, sizeof(*path)); + clib_memset(path, 0, sizeof(*path)); fib_node_init(&path->fp_node, FIB_NODE_TYPE_PATH); @@ -1447,7 +1456,7 @@ fib_path_copy (fib_node_index_t path_index, path->fp_oper_flags = FIB_PATH_OPER_FLAG_NONE; path->fp_pl_index = path_list_index; path->fp_via_fib = FIB_NODE_INDEX_INVALID; - memset(&path->fp_dpo, 0, sizeof(path->fp_dpo)); + clib_memset(&path->fp_dpo, 0, sizeof(path->fp_dpo)); dpo_reset(&path->fp_dpo); return (fib_path_get_index(path)); @@ -1574,9 +1583,11 @@ fib_path_cmp_i (const fib_path_t *path1, case FIB_PATH_TYPE_DVR: res = (path1->dvr.fp_interface - path2->dvr.fp_interface); break; + case FIB_PATH_TYPE_EXCLUSIVE: + res = dpo_cmp(&path1->exclusive.fp_ex_dpo, &path2->exclusive.fp_ex_dpo); + break; case FIB_PATH_TYPE_SPECIAL: case FIB_PATH_TYPE_RECEIVE: - case FIB_PATH_TYPE_EXCLUSIVE: res = 0; break; } @@ -1711,9 +1722,11 @@ fib_path_cmp_w_route_path (fib_node_index_t path_index, case FIB_PATH_TYPE_DVR: res = (path->dvr.fp_interface - rpath->frp_sw_if_index); break; + case FIB_PATH_TYPE_EXCLUSIVE: + res = dpo_cmp(&path->exclusive.fp_ex_dpo, &rpath->dpo); + break; case FIB_PATH_TYPE_SPECIAL: case FIB_PATH_TYPE_RECEIVE: - case FIB_PATH_TYPE_EXCLUSIVE: res = 0; break; } @@ -1900,6 +1913,9 @@ fib_path_resolve (fib_node_index_t path_index) fib_prefix_from_ip46_addr(&path->recursive.fp_nh.fp_ip, &pfx); } + fib_table_lock(path->recursive.fp_tbl_id, + dpo_proto_to_fib(path->fp_nh_proto), + FIB_SOURCE_RR); fei = fib_table_entry_special_add(path->recursive.fp_tbl_id, &pfx, FIB_SOURCE_RR, @@ -2299,8 +2315,6 @@ fib_path_contribute_forwarding (fib_node_index_t path_index, ASSERT(path); ASSERT(FIB_FORW_CHAIN_TYPE_MPLS_EOS != fct); - FIB_PATH_DBG(path, "contribute"); - /* * The DPO stored in the path was created when the path was resolved. * This then represents the path's 'native' protocol; IP. @@ -2509,15 +2523,20 @@ fib_path_append_nh_for_multipath_hash (fib_node_index_t path_index, ASSERT(path); + vec_add2(hash_key, mnh, 1); + + mnh->path_weight = path->fp_weight; + mnh->path_index = path_index; + if (fib_path_is_resolved(path_index)) { - vec_add2(hash_key, mnh, 1); - - mnh->path_weight = path->fp_weight; - mnh->path_index = path_index; - fib_path_contribute_forwarding(path_index, fct, &mnh->path_dpo); + fib_path_contribute_forwarding(path_index, fct, &mnh->path_dpo); + } + else + { + dpo_copy(&mnh->path_dpo, + drop_dpo_get(fib_forw_chain_type_to_dpo_proto(fct))); } - return (hash_key); } @@ -2593,6 +2612,7 @@ fib_path_encode (fib_node_index_t path_list_index, api_rpath->rpath.frp_preference = path->fp_preference; api_rpath->rpath.frp_proto = path->fp_nh_proto; api_rpath->rpath.frp_sw_if_index = ~0; + api_rpath->rpath.frp_fib_index = 0; api_rpath->dpo = path->fp_dpo; switch (path->fp_type) @@ -2618,6 +2638,7 @@ fib_path_encode (fib_node_index_t path_list_index, break; case FIB_PATH_TYPE_RECURSIVE: api_rpath->rpath.frp_addr = path->recursive.fp_nh.fp_ip; + api_rpath->rpath.frp_fib_index = path->recursive.fp_tbl_id; break; case FIB_PATH_TYPE_DVR: api_rpath->rpath.frp_sw_if_index = path->dvr.fp_interface; @@ -2648,6 +2669,7 @@ void fib_path_module_init (void) { fib_node_register_type (FIB_NODE_TYPE_PATH, &fib_path_vft); + fib_path_logger = vlib_log_register_class ("fib", "path"); } static clib_error_t * @@ -2666,7 +2688,8 @@ show_fib_path_command (vlib_main_t * vm, if (!pool_is_free_index(fib_path_pool, pi)) { path = fib_path_get(pi); - u8 *s = format(NULL, "%U", format_fib_path, pi, 1); + u8 *s = format(NULL, "%U", format_fib_path, pi, 1, + FIB_PATH_FORMAT_FLAGS_NONE); s = format(s, "children:"); s = fib_node_children_format(path->fp_node.fn_children, s); vlib_cli_output (vm, "%s", s); @@ -2682,7 +2705,8 @@ show_fib_path_command (vlib_main_t * vm, vlib_cli_output (vm, "FIB Paths"); pool_foreach_index (pi, fib_path_pool, ({ - vlib_cli_output (vm, "%U", format_fib_path, pi, 0); + vlib_cli_output (vm, "%U", format_fib_path, pi, 0, + FIB_PATH_FORMAT_FLAGS_NONE); })); }