| 408 | } |
| 409 | |
| 410 | static int |
| 411 | vlan_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. |
no test coverage detected