Changeset View
Changeset View
Standalone View
Standalone View
head/sys/net/route/nhop.c
Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
* NHF_DEFAULT | * NHF_DEFAULT | ||||
* | * | ||||
* All nexthops are stored in the resizable hash table. | * All nexthops are stored in the resizable hash table. | ||||
* Additionally, each nexthop gets assigned its unique index (nexthop index) | * Additionally, each nexthop gets assigned its unique index (nexthop index) | ||||
* so userland programs can interact with the nexthops easier. Index allocation | * so userland programs can interact with the nexthops easier. Index allocation | ||||
* is backed by the bitmask array. | * is backed by the bitmask array. | ||||
*/ | */ | ||||
static MALLOC_DEFINE(M_NHOP, "nhops", "nexthops data"); | MALLOC_DEFINE(M_NHOP, "nhops", "nexthops data"); | ||||
/* Hash management functions */ | /* Hash management functions */ | ||||
int | int | ||||
nhops_init_rib(struct rib_head *rh) | nhops_init_rib(struct rib_head *rh) | ||||
{ | { | ||||
struct nh_control *ctl; | struct nh_control *ctl; | ||||
size_t alloc_size; | size_t alloc_size; | ||||
Show All 31 Lines | |||||
static void | static void | ||||
destroy_ctl(struct nh_control *ctl) | destroy_ctl(struct nh_control *ctl) | ||||
{ | { | ||||
NHOPS_LOCK_DESTROY(ctl); | NHOPS_LOCK_DESTROY(ctl); | ||||
free(ctl->nh_head.ptr, M_NHOP); | free(ctl->nh_head.ptr, M_NHOP); | ||||
free(ctl->nh_idx_head.idx, M_NHOP); | free(ctl->nh_idx_head.idx, M_NHOP); | ||||
#ifdef ROUTE_MPATH | |||||
nhgrp_ctl_free(ctl); | |||||
#endif | |||||
free(ctl, M_NHOP); | free(ctl, M_NHOP); | ||||
} | } | ||||
/* | /* | ||||
* Epoch callback indicating ctl is safe to destroy | * Epoch callback indicating ctl is safe to destroy | ||||
*/ | */ | ||||
static void | static void | ||||
destroy_ctl_epoch(epoch_context_t ctx) | destroy_ctl_epoch(epoch_context_t ctx) | ||||
Show All 26 Lines | nhops_destroy_rib(struct rib_head *rh) | ||||
* details. | * details. | ||||
*/ | */ | ||||
NHOPS_WLOCK(ctl); | NHOPS_WLOCK(ctl); | ||||
CHT_SLIST_FOREACH(&ctl->nh_head, nhops, nh_priv) { | CHT_SLIST_FOREACH(&ctl->nh_head, nhops, nh_priv) { | ||||
DPRINTF("Marking nhop %u unlinked", nh_priv->nh_idx); | DPRINTF("Marking nhop %u unlinked", nh_priv->nh_idx); | ||||
refcount_release(&nh_priv->nh_linked); | refcount_release(&nh_priv->nh_linked); | ||||
} CHT_SLIST_FOREACH_END; | } CHT_SLIST_FOREACH_END; | ||||
#ifdef ROUTE_MPATH | |||||
nhgrp_ctl_unlink_all(ctl); | |||||
#endif | |||||
NHOPS_WUNLOCK(ctl); | NHOPS_WUNLOCK(ctl); | ||||
/* | /* | ||||
* Postpone destruction till the end of current epoch | * Postpone destruction till the end of current epoch | ||||
* so nhop_free() can safely use nh_control pointer. | * so nhop_free() can safely use nh_control pointer. | ||||
*/ | */ | ||||
epoch_call(net_epoch_preempt, destroy_ctl_epoch, | epoch_call(net_epoch_preempt, destroy_ctl_epoch, | ||||
&ctl->ctl_epoch_ctx); | &ctl->ctl_epoch_ctx); | ||||
▲ Show 20 Lines • Show All 221 Lines • Show Last 20 Lines |