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

Function nhops_init_rib

freebsd/net/route/nhop.c:71–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69/* Hash management functions */
70
71int
72nhops_init_rib(struct rib_head *rh)
73{
74 struct nh_control *ctl;
75 size_t alloc_size;
76 uint32_t num_buckets, num_items;
77 void *ptr;
78
79 ctl = malloc(sizeof(struct nh_control), M_NHOP, M_WAITOK | M_ZERO);
80
81 /*
82 * Allocate nexthop hash. Start with 16 items by default (128 bytes).
83 * This will be enough for most of the cases.
84 */
85 num_buckets = 16;
86 alloc_size = CHT_SLIST_GET_RESIZE_SIZE(num_buckets);
87 ptr = malloc(alloc_size, M_NHOP, M_WAITOK | M_ZERO);
88 CHT_SLIST_INIT(&ctl->nh_head, ptr, num_buckets);
89
90 /*
91 * Allocate nexthop index bitmask.
92 */
93 num_items = 128 * 8; /* 128 bytes */
94 ptr = malloc(bitmask_get_size(num_items), M_NHOP, M_WAITOK | M_ZERO);
95 bitmask_init(&ctl->nh_idx_head, ptr, num_items);
96
97 NHOPS_LOCK_INIT(ctl);
98
99 rh->nh_control = ctl;
100 ctl->ctl_rh = rh;
101
102 DPRINTF("NHOPS init for fib %u af %u: ctl %p rh %p", rh->rib_fibnum,
103 rh->rib_family, ctl, rh);
104
105 return (0);
106}
107
108static void
109destroy_ctl(struct nh_control *ctl)

Callers 1

rt_table_initFunction · 0.85

Calls 3

mallocFunction · 0.85
bitmask_get_sizeFunction · 0.85
bitmask_initFunction · 0.85

Tested by

no test coverage detected