MCPcopy Create free account
hub / github.com/F-Stack/f-stack / nhop_free

Function nhop_free

freebsd/net/route/nhop_ctl.c:648–691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

646}
647
648void
649nhop_free(struct nhop_object *nh)
650{
651 struct nh_control *ctl;
652 struct nhop_priv *nh_priv = nh->nh_priv;
653 struct epoch_tracker et;
654
655 if (!refcount_release(&nh_priv->nh_refcnt))
656 return;
657
658 /*
659 * There are only 2 places, where nh_linked can be decreased:
660 * rib destroy (nhops_destroy_rib) and this function.
661 * nh_link can never be increased.
662 *
663 * Hence, use initial value of 2 to make use of
664 * refcount_release_if_not_last().
665 *
666 * There can be two scenarious when calling this function:
667 *
668 * 1) nh_linked value is 2. This means that either
669 * nhops_destroy_rib() has not been called OR it is running,
670 * but we are guaranteed that nh_control won't be freed in
671 * this epoch. Hence, nexthop can be safely unlinked.
672 *
673 * 2) nh_linked value is 1. In that case, nhops_destroy_rib()
674 * has been called and nhop unlink can be skipped.
675 */
676
677 NET_EPOCH_ENTER(et);
678 if (refcount_release_if_not_last(&nh_priv->nh_linked)) {
679 ctl = nh_priv->nh_control;
680 if (unlink_nhop(ctl, nh_priv) == NULL) {
681 /* Do not try to reclaim */
682 DPRINTF("Failed to unlink nexhop %p", nh_priv);
683 NET_EPOCH_EXIT(et);
684 return;
685 }
686 }
687 NET_EPOCH_EXIT(et);
688
689 epoch_call(net_epoch_preempt, destroy_nhop_epoch,
690 &nh_priv->nh_epoch_ctx);
691}
692
693void
694nhop_ref_any(struct nhop_object *nh)

Callers 6

create_rtentryFunction · 0.85
add_routeFunction · 0.85
change_mpath_routeFunction · 0.85
ref_nhgrp_nhopsFunction · 0.85
free_nhgrp_nhopsFunction · 0.85
nhop_free_anyFunction · 0.85

Calls 4

refcount_releaseFunction · 0.85
unlink_nhopFunction · 0.85
epoch_callFunction · 0.50

Tested by

no test coverage detected