diff options
author | Ole Trøan <otroan@employees.org> | 2018-02-15 22:02:01 +0000 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2018-02-15 22:02:01 +0000 |
commit | 909c26bda66313b86168dda31003f76410c1d746 (patch) | |
tree | 116c02d48fe51239ffdbb719abbdf34d37928e73 /src/vnet/adj/adj_delegate.c | |
parent | a44b015aa012d3b07ed873925d47c6d5955b7dd2 (diff) |
Revert "Adj: VFTs for adjacency sub-blocks"
This reverts commit a44b015aa012d3b07ed873925d47c6d5955b7dd2.
Change-Id: I2d76bc0844f58e5ddf3f3a4326b86076f46e3751
Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/vnet/adj/adj_delegate.c')
-rw-r--r-- | src/vnet/adj/adj_delegate.c | 66 |
1 files changed, 27 insertions, 39 deletions
diff --git a/src/vnet/adj/adj_delegate.c b/src/vnet/adj/adj_delegate.c index c65cc8be64e..701b36e2fd9 100644 --- a/src/vnet/adj/adj_delegate.c +++ b/src/vnet/adj/adj_delegate.c @@ -17,11 +17,6 @@ #include <vnet/adj/adj.h> #include <vnet/adj/adj_internal.h> -/* - * The per-type vector of virtual function tables - */ -static adj_delegate_vft_t *ad_vfts; - static adj_delegate_t * adj_delegate_find_i (const ip_adjacency_t *adj, adj_delegate_type_t type, @@ -110,47 +105,40 @@ adj_delegate_find_or_add (ip_adjacency_t *adj, return (adj_delegate_get(adj, adt)); } -void adj_delegate_vft_lock_gone (ip_adjacency_t *adj) -{ - adj_delegate_t *delegate; - vec_foreach(delegate, adj->ia_delegates) { - if (ad_vfts[delegate->ad_type].adv_last_lock) - ad_vfts[delegate->ad_type].adv_last_lock(adj, delegate); - } -} +/** + * typedef for printing a delegate + */ +typedef u8 * (*adj_delegate_format_t)(const adj_delegate_t *aed, + u8 *s); -u8 * -format_adj_delegate (u8 * s, va_list * args) +/** + * Print a delegate that represents BFD tracking + */ +static u8 * +adj_delegate_fmt_bfd (const adj_delegate_t *aed, + u8 *s) { - adj_delegate_t *aed; + s = format(s, "BFD:[state:%d index:%d]", + aed->ad_bfd_state, + aed->ad_bfd_index); - aed = va_arg (*args, adj_delegate_t *); - if (ad_vfts[aed->ad_type].adv_format) - return ad_vfts[aed->ad_type].adv_format(aed, s); - return format(s, "unknown delegate"); + return (s); } /** - * adj_delegate_register_type - * - * Register the function table for a given type + * A delegate type to formatter map */ +static adj_delegate_format_t aed_formatters[] = +{ + [ADJ_DELEGATE_BFD] = adj_delegate_fmt_bfd, +}; -void -adj_delegate_register_type (adj_delegate_type_t type, - const adj_delegate_vft_t *vft) +u8 * +format_adj_deletegate (u8 * s, va_list * args) { - /* - * assert that one only registration is made per-node type - */ - if (vec_len(ad_vfts) > type) - ASSERT(NULL == ad_vfts[type].adv_last_lock); - - /* - * Assert that we are getting each of the required functions - */ - ASSERT(NULL != vft->adv_last_lock); - - vec_validate(ad_vfts, type); - ad_vfts[type] = *vft; + adj_delegate_t *aed; + + aed = va_arg (*args, adj_delegate_t *); + + return (aed_formatters[aed->ad_type](aed, s)); } |