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

Function unlink_nhop

freebsd/net/route/nhop.c:330–369  ·  view source on GitHub ↗

* Unlinks nexthop specified by @nh_priv data from the hash. * * Returns found nexthop or NULL. */

Source from the content-addressed store, hash-verified

328 * Returns found nexthop or NULL.
329 */
330struct nhop_priv *
331unlink_nhop(struct nh_control *ctl, struct nhop_priv *nh_priv_del)
332{
333 struct nhop_priv *priv_ret;
334 int idx;
335 uint32_t num_buckets_new, num_items_new;
336
337 idx = 0;
338
339 NHOPS_WLOCK(ctl);
340 CHT_SLIST_REMOVE_BYOBJ(&ctl->nh_head, nhops, nh_priv_del, priv_ret);
341
342 if (priv_ret != NULL) {
343 idx = priv_ret->nh_idx;
344 priv_ret->nh_idx = 0;
345
346 KASSERT((idx != 0), ("bogus nhop index 0"));
347 if ((bitmask_free_idx(&ctl->nh_idx_head, idx)) != 0) {
348 DPRINTF("Unable to remove index %d from fib %u af %d",
349 idx, ctl->ctl_rh->rib_fibnum,
350 ctl->ctl_rh->rib_family);
351 }
352 }
353
354 /* Check if hash or index needs to be resized */
355 num_buckets_new = CHT_SLIST_GET_RESIZE_BUCKETS(&ctl->nh_head);
356 num_items_new = bitmask_get_resize_items(&ctl->nh_idx_head);
357
358 NHOPS_WUNLOCK(ctl);
359
360 if (priv_ret == NULL)
361 DPRINTF("Unable to unlink nhop priv %p from hash, hash %u ctl %p",
362 nh_priv_del, hash_priv(nh_priv_del), ctl);
363 else
364 DPRINTF("Unlinked nhop %p priv idx %d", priv_ret, idx);
365
366 consider_resize(ctl, num_buckets_new, num_items_new);
367
368 return (priv_ret);
369}
370
371/*
372 * Searches for the nexthop by data specifcied in @nh_priv.

Callers 1

nhop_freeFunction · 0.85

Calls 4

bitmask_free_idxFunction · 0.85
bitmask_get_resize_itemsFunction · 0.85
hash_privFunction · 0.85
consider_resizeFunction · 0.70

Tested by

no test coverage detected