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

Function vlan_remhash

freebsd/net/if_vlan.c:410–432  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

408}
409
410static int
411vlan_remhash(struct ifvlantrunk *trunk, struct ifvlan *ifv)
412{
413 int i, b;
414 struct ifvlan *ifv2;
415
416 VLAN_XLOCK_ASSERT();
417 KASSERT(trunk->hwidth > 0, ("%s: hwidth not positive", __func__));
418
419 b = 1 << trunk->hwidth;
420 i = HASH(ifv->ifv_vid, trunk->hmask);
421 CK_SLIST_FOREACH(ifv2, &trunk->hash[i], ifv_list)
422 if (ifv2 == ifv) {
423 trunk->refcnt--;
424 CK_SLIST_REMOVE(&trunk->hash[i], ifv2, ifvlan, ifv_list);
425 if (trunk->refcnt < (b * b) / 2)
426 vlan_growhash(trunk, -1);
427 return (0);
428 }
429
430 panic("%s: vlan not found\n", __func__);
431 return (ENOENT); /*NOTREACHED*/
432}
433
434/*
435 * Grow the hash larger or smaller if memory permits.

Callers 1

vlan_unconfig_lockedFunction · 0.85

Calls 2

vlan_growhashFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected