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

Function ifindex_alloc

freebsd/net/if.c:370–393  ·  view source on GitHub ↗

* Allocate an ifindex array entry; return 0 on success or an error on * failure. */

Source from the content-addressed store, hash-verified

368 * failure.
369 */
370static u_short
371ifindex_alloc(void **old)
372{
373 u_short idx;
374
375 IFNET_WLOCK_ASSERT();
376 /*
377 * Try to find an empty slot below V_if_index. If we fail, take the
378 * next slot.
379 */
380 for (idx = 1; idx <= V_if_index; idx++) {
381 if (V_ifindex_table[idx] == NULL)
382 break;
383 }
384
385 /* Catch if_index overflow. */
386 if (idx >= V_if_indexlim) {
387 *old = if_grow();
388 return (USHRT_MAX);
389 }
390 if (idx > V_if_index)
391 V_if_index = idx;
392 return (idx);
393}
394
395static void
396ifindex_free_locked(u_short idx)

Callers 2

if_alloc_domainFunction · 0.85
if_vmoveFunction · 0.85

Calls 1

if_growFunction · 0.85

Tested by

no test coverage detected