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

Function pop_stack_entry

freebsd/netinet/in_fib_algo.c:276–308  ·  view source on GitHub ↗

* * Example: * stack: 10.0.1.0/24,nh=3 array: 10.0.1.0/25,nh=4 -> ++10.0.1.128/24,nh=3 * * */

Source from the content-addressed store, hash-verified

274 *
275 */
276static bool
277pop_stack_entry(struct bsearch4_array *dst_array, struct bsearch4_array *stack)
278{
279 uint32_t last_stack_addr, last_array_addr;
280
281 struct bsearch4_record *br_prev = get_last_entry(dst_array);
282 struct bsearch4_record *pstack = get_last_entry(stack);
283
284 /* Regardless of the result, pop stack entry */
285 stack->num_items--;
286
287 /* Prefix last address for the last entry in lookup array */
288 last_array_addr = (br_prev->addr4 | ~br_prev->mask4);
289 /* Prefix last address for the stack record entry */
290 last_stack_addr = (pstack->addr4 | ~pstack->mask4);
291
292 if (last_stack_addr > last_array_addr) {
293 /*
294 * Stack record covers > address space than
295 * the last entry in the lookup array.
296 * Add the remaining parts of a stack record to
297 * the lookup array.
298 */
299 struct bsearch4_record br_new = {
300 .addr4 = last_array_addr + 1,
301 .mask4 = pstack->mask4,
302 .nh = pstack->nh,
303 };
304 return (add_array_entry(dst_array, &br_new));
305 }
306
307 return (true);
308}
309
310/*
311 * Updates resulting array @dst_array with a rib entry @rib_entry.

Callers 2

bsearch4_process_recordFunction · 0.85
bsearch4_build_arrayFunction · 0.85

Calls 2

get_last_entryFunction · 0.85
add_array_entryFunction · 0.85

Tested by

no test coverage detected