| 557 | #endif |
| 558 | |
| 559 | static void * |
| 560 | if_grow(void) |
| 561 | { |
| 562 | int oldlim; |
| 563 | u_int n; |
| 564 | struct ifnet **e; |
| 565 | void *old; |
| 566 | |
| 567 | old = NULL; |
| 568 | IFNET_WLOCK_ASSERT(); |
| 569 | oldlim = V_if_indexlim; |
| 570 | IFNET_WUNLOCK(); |
| 571 | n = (oldlim << 1) * sizeof(*e); |
| 572 | e = malloc(n, M_IFNET, M_WAITOK | M_ZERO); |
| 573 | IFNET_WLOCK(); |
| 574 | if (V_if_indexlim != oldlim) { |
| 575 | free(e, M_IFNET); |
| 576 | return (NULL); |
| 577 | } |
| 578 | if (V_ifindex_table != NULL) { |
| 579 | memcpy((caddr_t)e, (caddr_t)V_ifindex_table, n/2); |
| 580 | old = V_ifindex_table; |
| 581 | } |
| 582 | V_if_indexlim <<= 1; |
| 583 | V_ifindex_table = e; |
| 584 | return (old); |
| 585 | } |
| 586 | |
| 587 | /* |
| 588 | * Allocate a struct ifnet and an index for an interface. A layer 2 |
no test coverage detected