Add nhop_ref_any() to unify referencing nhop or nexthop group.
It allows code within routing subsystem to transparently reference nexthops and nexthop groups, similar to nhop_free_any(), abstracting ROUTE_MPATH details. Differential Revision: https://reviews.freebsd.org/D27410
This commit is contained in:
parent
007f2a0dc9
commit
68ea980e22
@ -293,6 +293,17 @@ alloc_nhgrp(struct weightened_nhop *wn, int num_nhops)
|
||||
return (nhg_priv);
|
||||
}
|
||||
|
||||
void
|
||||
nhgrp_ref_object(struct nhgrp_object *nhg)
|
||||
{
|
||||
struct nhgrp_priv *nhg_priv;
|
||||
u_int old;
|
||||
|
||||
nhg_priv = NHGRP_PRIV(nhg);
|
||||
old = refcount_acquire(&nhg_priv->nhg_refcount);
|
||||
KASSERT(old > 0, ("%s: nhgrp object %p has 0 refs", __func__, nhg));
|
||||
}
|
||||
|
||||
void
|
||||
nhgrp_free(struct nhgrp_object *nhg)
|
||||
{
|
||||
|
@ -690,6 +690,19 @@ nhop_free(struct nhop_object *nh)
|
||||
&nh_priv->nh_epoch_ctx);
|
||||
}
|
||||
|
||||
void
|
||||
nhop_ref_any(struct nhop_object *nh)
|
||||
{
|
||||
#ifdef ROUTE_MPATH
|
||||
if (!NH_IS_NHGRP(nh))
|
||||
nhop_ref_object(nh);
|
||||
else
|
||||
nhgrp_ref_object((struct nhgrp_object *)nh);
|
||||
#else
|
||||
nhop_ref_object(nh);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
nhop_free_any(struct nhop_object *nh)
|
||||
{
|
||||
|
@ -242,6 +242,7 @@ int nhops_init_rib(struct rib_head *rh);
|
||||
void nhops_destroy_rib(struct rib_head *rh);
|
||||
void nhop_ref_object(struct nhop_object *nh);
|
||||
int nhop_try_ref_object(struct nhop_object *nh);
|
||||
void nhop_ref_any(struct nhop_object *nh);
|
||||
void nhop_free_any(struct nhop_object *nh);
|
||||
|
||||
void nhop_set_type(struct nhop_object *nh, enum nhop_type nh_type);
|
||||
@ -306,6 +307,7 @@ int nhgrp_get_addition_group(struct rib_head *rnh,
|
||||
struct route_nhop_data *rnd_orig, struct route_nhop_data *rnd_add,
|
||||
struct route_nhop_data *rnd_new);
|
||||
|
||||
void nhgrp_ref_object(struct nhgrp_object *nhg);
|
||||
uint32_t nhgrp_get_idx(const struct nhgrp_object *nhg);
|
||||
void nhgrp_free(struct nhgrp_object *nhg);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user