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

Function vlan_inithash

freebsd/net/if_vlan.c:342–362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340#define HASH(n, m) ((((n) >> 8) ^ ((n) >> 4) ^ (n)) & (m))
341
342static void
343vlan_inithash(struct ifvlantrunk *trunk)
344{
345 int i, n;
346
347 /*
348 * The trunk must not be locked here since we call malloc(M_WAITOK).
349 * It is OK in case this function is called before the trunk struct
350 * gets hooked up and becomes visible from other threads.
351 */
352
353 KASSERT(trunk->hwidth == 0 && trunk->hash == NULL,
354 ("%s: hash already initialized", __func__));
355
356 trunk->hwidth = VLAN_DEF_HWIDTH;
357 n = 1 << trunk->hwidth;
358 trunk->hmask = n - 1;
359 trunk->hash = malloc(sizeof(struct ifvlanhead) * n, M_VLAN, M_WAITOK);
360 for (i = 0; i < n; i++)
361 CK_SLIST_INIT(&trunk->hash[i]);
362}
363
364static void
365vlan_freehash(struct ifvlantrunk *trunk)

Callers 1

vlan_configFunction · 0.85

Calls 1

mallocFunction · 0.85

Tested by

no test coverage detected