git: 6ff4cac2ee9e - main - ifnet: initial if_grow() shall always succeed

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Mon, 06 Dec 2021 17:32:47 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=6ff4cac2ee9ee74911b538a67337bf510c4cffe4

commit 6ff4cac2ee9ee74911b538a67337bf510c4cffe4
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2021-12-04 17:49:35 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2021-12-06 17:32:31 +0000

    ifnet: initial if_grow() shall always succeed
    
    So let's just call malloc() directly.  This also avoids hidden
    doubling of default V_if_indexlim.
    
    Reviewed by:            melifaro, bz, kp
    Differential revision:  https://reviews.freebsd.org/D33261
---
 sys/net/if.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/sys/net/if.c b/sys/net/if.c
index 8b820eb562ed..079ad734812b 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -441,15 +441,11 @@ ifaddr_byindex(u_short idx)
 static void
 vnet_if_init(const void *unused __unused)
 {
-	void *old;
 
 	CK_STAILQ_INIT(&V_ifnet);
 	CK_STAILQ_INIT(&V_ifg_head);
-	IFNET_WLOCK();
-	old = if_grow();				/* create initial table */
-	IFNET_WUNLOCK();
-	epoch_wait_preempt(net_epoch_preempt);
-	free(old, M_IFNET);
+	V_ifindex_table = malloc(V_if_indexlim * sizeof(*V_ifindex_table),
+	    M_IFNET, M_WAITOK | M_ZERO);
 	vnet_if_clone_init();
 }
 VNET_SYSINIT(vnet_if_init, SI_SUB_INIT_IF, SI_ORDER_SECOND, vnet_if_init,