summaryrefslogtreecommitdiffstats
path: root/src/vnet/adj/adj_bfd.c
diff options
context:
space:
mode:
authorNeale Ranns <neale.ranns@cisco.com>2018-02-20 06:25:02 -0800
committerNeale Ranns <nranns@cisco.com>2018-02-21 08:34:12 +0000
commit76447a740a6989db08dcd0fcbd066b193a875177 (patch)
tree724e1b2fe1e35202c27a2cdd982bf578cd5c5138 /src/vnet/adj/adj_bfd.c
parent8a3e575dfca22500744df76c40de600d8aa61e12 (diff)
Adj Delegates; don't store raw pointers
... you'd think I'd have leanred by now... Change-Id: I65c54feb2ec016baa07ed96c81ab8f60277c3418 Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Diffstat (limited to 'src/vnet/adj/adj_bfd.c')
-rw-r--r--src/vnet/adj/adj_bfd.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/vnet/adj/adj_bfd.c b/src/vnet/adj/adj_bfd.c
index a4e7e277298..de7abfe4470 100644
--- a/src/vnet/adj/adj_bfd.c
+++ b/src/vnet/adj/adj_bfd.c
@@ -35,11 +35,6 @@ typedef enum adj_bfd_state_t_
typedef struct adj_bfd_delegate_t_
{
/**
- * Base class,linkage to the adjacency
- */
- adj_delegate_t abd_link;
-
- /**
* BFD session state
*/
adj_bfd_state_t abd_state;
@@ -58,25 +53,21 @@ static adj_bfd_delegate_t *abd_pool;
static inline adj_bfd_delegate_t*
adj_bfd_from_base (adj_delegate_t *ad)
{
- if (NULL == ad)
+ if (NULL != ad)
{
- return (NULL);
+ return (pool_elt_at_index(abd_pool, ad->ad_index));
}
- return ((adj_bfd_delegate_t*)((char*)ad -
- STRUCT_OFFSET_OF(adj_bfd_delegate_t,
- abd_link)));
+ return (NULL);
}
static inline const adj_bfd_delegate_t*
adj_bfd_from_const_base (const adj_delegate_t *ad)
{
- if (NULL == ad)
+ if (NULL != ad)
{
- return (NULL);
+ return (pool_elt_at_index(abd_pool, ad->ad_index));
}
- return ((adj_bfd_delegate_t*)((char*)ad -
- STRUCT_OFFSET_OF(adj_bfd_delegate_t,
- abd_link)));
+ return (NULL);
}
static adj_bfd_state_t
@@ -183,7 +174,7 @@ adj_bfd_notify (bfd_listen_event_e event,
abd->abd_state = ADJ_BFD_STATE_UP;
abd->abd_index = session->bs_idx;
- adj_delegate_add(adj_get(ai), ADJ_DELEGATE_BFD, &abd->abd_link);
+ adj_delegate_add(adj_get(ai), ADJ_DELEGATE_BFD, abd - abd_pool);
}
break;