Index: sys/net/route/nhgrp_ctl.c =================================================================== --- sys/net/route/nhgrp_ctl.c +++ sys/net/route/nhgrp_ctl.c @@ -294,6 +294,17 @@ } 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) { struct nhgrp_priv *nhg_priv; Index: sys/net/route/nhop_ctl.c =================================================================== --- sys/net/route/nhop_ctl.c +++ sys/net/route/nhop_ctl.c @@ -691,6 +691,19 @@ } 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) { Index: sys/net/route/route_ctl.h =================================================================== --- sys/net/route/route_ctl.h +++ sys/net/route/route_ctl.h @@ -87,6 +87,10 @@ const struct rtentry *rib_lookup_lpm(uint32_t fibnum, int family, const struct sockaddr *dst, struct route_nhop_data *rnd); +/* Nhops */ +void nhop_ref_any(struct nhop_object *nh); +void nhop_free_any(struct nhop_object *nh); + /* Multipath */ struct nhgrp_object; struct weightened_nhop; Index: sys/net/route/route_var.h =================================================================== --- sys/net/route/route_var.h +++ sys/net/route/route_var.h @@ -241,7 +241,6 @@ 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_free_any(struct nhop_object *nh); void nhop_set_type(struct nhop_object *nh, enum nhop_type nh_type); void nhop_set_rtflags(struct nhop_object *nh, int rt_flags); @@ -305,6 +304,7 @@ 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);