X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fvnet%2Fmfib%2Fmfib_entry.c;h=90b223e3c253f412387e1dc759227e79ef8389ab;hb=2af0e3a;hp=6c356c6b267f3a1865e4d85e595810a2ab21f0cb;hpb=630b9741659b9a4b68c64ebbeb675761c6f26842;p=vpp.git diff --git a/src/vnet/mfib/mfib_entry.c b/src/vnet/mfib/mfib_entry.c index 6c356c6b267..90b223e3c25 100644 --- a/src/vnet/mfib/mfib_entry.c +++ b/src/vnet/mfib/mfib_entry.c @@ -21,32 +21,23 @@ #include #include +/** + * the logger + */ +vlib_log_class_t mfib_entry_logger; + /** * Debug macro */ -#ifdef MFIB_DEBUG -#DEFIne MFIB_ENTRY_DBG(_e, _fmt, _args...) \ +#define MFIB_ENTRY_DBG(_e, _fmt, _args...) \ { \ - u8*__tmp = NULL; \ - __tmp = format(__tmp, "e:[%d:%U", \ + vlib_log_debug(mfib_entry_logger, \ + "e:[%d:%U]: " _fmt, \ mfib_entry_get_index(_e), \ - format_ip46_address, \ - &_e->mfe_prefix.fp_grp_addr, \ - IP46_TYPE_ANY); \ - __tmp = format(__tmp, "/%d,", \ - _e->mfe_prefix.fp_len); \ - __tmp = format(__tmp, "%U]", \ - mfib_entry_get_index(_e), \ - format_ip46_address, \ - &_e->mfe_prefix.fp_src_addr, \ - IP46_TYPE_ANY); \ - __tmp = format(__tmp, _fmt, ##_args); \ - clib_warning("%s", __tmp); \ - vec_free(__tmp); \ + format_mfib_prefix, \ + &_e->mfe_prefix, \ + ##_args); \ } -#else -#define MFIB_ENTRY_DBG(_e, _fmt, _args...) -#endif /** * MFIB extensions to each path @@ -217,7 +208,10 @@ format_mfib_entry (u8 * s, va_list * args) ({ s = format(s, "\n %U", format_mfib_itf, mfi); })); - s = format(s, "\n RPF-ID:%d", mfib_entry->mfe_rpf_id); + if (MFIB_RPF_ID_NONE != mfib_entry->mfe_rpf_id) + { + s = format(s, "\n RPF-ID:%d", mfib_entry->mfe_rpf_id); + } s = format(s, "\n %U-chain\n %U", format_fib_forw_chain_type, mfib_entry_get_default_chain_type(mfib_entry), @@ -409,7 +403,7 @@ mfib_entry_alloc (u32 fib_index, /* * Some of the members require non-default initialisation - * so we also init those that don't and thus save on the call to memset. + * so we also init those that don't and thus save on the call to clib_memset. */ mfib_entry->mfe_flags = 0; mfib_entry->mfe_fib_index = fib_index; @@ -835,9 +829,9 @@ mfib_entry_path_update (fib_node_index_t mfib_entry_index, { fib_node_index_t path_index; mfib_path_ext_t *path_ext; - mfib_itf_flags_t old, new; mfib_entry_t *mfib_entry; mfib_entry_src_t *msrc; + mfib_itf_flags_t old; mfib_entry = mfib_entry_get(mfib_entry_index); ASSERT(NULL != mfib_entry); @@ -873,37 +867,32 @@ mfib_entry_path_update (fib_node_index_t mfib_entry_index, { mfib_itf_t *mfib_itf; - new = itf_flags; - - if (old != new) + if (old != itf_flags) { - if (MFIB_ITF_FLAG_NONE == new) - { - /* - * no more interface flags on this path, remove - * from the data-plane set - */ - mfib_entry_itf_remove(msrc, rpath[0].frp_sw_if_index); - } - else if (MFIB_ITF_FLAG_NONE == old) + /* + * change of flag contributions + */ + mfib_itf = mfib_entry_itf_find(msrc->mfes_itfs, + rpath[0].frp_sw_if_index); + + if (NULL == mfib_itf) { - /* - * This interface is now contributing - */ mfib_entry_itf_add(msrc, rpath[0].frp_sw_if_index, - mfib_itf_create(rpath[0].frp_sw_if_index, - itf_flags)); + mfib_itf_create(path_index, itf_flags)); } else { - /* - * change of flag contributions - */ - mfib_itf = mfib_entry_itf_find(msrc->mfes_itfs, - rpath[0].frp_sw_if_index); - /* Seen by packets inflight */ - mfib_itf->mfi_flags = new; + if (mfib_itf_update(mfib_itf, + path_index, + itf_flags)) + { + /* + * no more interface flags on this path, remove + * from the data-plane set + */ + mfib_entry_itf_remove(msrc, rpath[0].frp_sw_if_index); + } } } } @@ -952,7 +941,21 @@ mfib_entry_path_remove (fib_node_index_t mfib_entry_index, mfib_path_ext_remove(msrc, path_index); if (~0 != rpath[0].frp_sw_if_index) { - mfib_entry_itf_remove(msrc, rpath[0].frp_sw_if_index); + mfib_itf_t *mfib_itf; + + mfib_itf = mfib_entry_itf_find(msrc->mfes_itfs, + rpath[0].frp_sw_if_index); + + if (mfib_itf_update(mfib_itf, + path_index, + MFIB_ITF_FLAG_NONE)) + { + /* + * no more interface flags on this path, remove + * from the data-plane set + */ + mfib_entry_itf_remove(msrc, rpath[0].frp_sw_if_index); + } } } @@ -1094,6 +1097,16 @@ mfib_entry_last_lock_gone (fib_node_t *node) pool_put(mfib_entry_pool, mfib_entry); } +u32 +mfib_entry_get_stats_index (fib_node_index_t fib_entry_index) +{ + mfib_entry_t *mfib_entry; + + mfib_entry = mfib_entry_get(fib_entry_index); + + return (mfib_entry->mfe_rep.dpoi_index); +} + /* * mfib_entry_back_walk_notify * @@ -1185,6 +1198,7 @@ mfib_entry_module_init (void) { fib_node_register_type (FIB_NODE_TYPE_MFIB_ENTRY, &mfib_entry_vft); dpo_register(DPO_MFIB_ENTRY, &mfib_entry_dpo_vft, mfib_entry_nodes); + mfib_entry_logger = vlib_log_register_class("mfib", "entry"); } void @@ -1226,6 +1240,16 @@ mfib_entry_get_fib_index (fib_node_index_t mfib_entry_index) return (mfib_entry->mfe_fib_index); } +const dpo_id_t* +mfib_entry_contribute_ip_forwarding (fib_node_index_t mfib_entry_index) +{ + mfib_entry_t *mfib_entry; + + mfib_entry = mfib_entry_get(mfib_entry_index); + + return (&mfib_entry->mfe_rep); +} + void mfib_entry_contribute_forwarding (fib_node_index_t mfib_entry_index, fib_forward_chain_type_t type,