git: 4787572d0580 - main - ifnet: make if_alloc_domain() never fail
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 23 Nov 2021 03:52:15 UTC
The branch main has been updated by glebius:
URL: https://cgit.FreeBSD.org/src/commit/?id=4787572d0580c6fdf818fd64efa3089de88720f0
commit 4787572d0580c6fdf818fd64efa3089de88720f0
Author: Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2021-11-23 03:49:57 +0000
Commit: Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2021-11-23 03:49:57 +0000
ifnet: make if_alloc_domain() never fail
The last consumer of if_com_alloc() is firewire. It never fails
to allocate. Most likely the if_com_alloc() KPI will go away
together with if_fwip(), less likely new consumers of if_com_alloc()
will be added, but they would need to follow the no fail KPI.
---
sys/net/if.c | 22 +++++-----------------
1 file changed, 5 insertions(+), 17 deletions(-)
diff --git a/sys/net/if.c b/sys/net/if.c
index f840fa369474..9f971d958030 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -406,7 +406,7 @@ ifindex_alloc(void **old)
}
static void
-ifindex_free_locked(u_short idx)
+ifindex_free(u_short idx)
{
IFNET_WLOCK_ASSERT();
@@ -417,15 +417,6 @@ ifindex_free_locked(u_short idx)
V_if_index--;
}
-static void
-ifindex_free(u_short idx)
-{
-
- IFNET_WLOCK();
- ifindex_free_locked(idx);
- IFNET_WUNLOCK();
-}
-
static void
ifnet_setbyindex(u_short idx, struct ifnet *ifp)
{
@@ -636,11 +627,8 @@ if_alloc_domain(u_char type, int numa_domain)
#endif
if (if_com_alloc[type] != NULL) {
ifp->if_l2com = if_com_alloc[type](type, ifp);
- if (ifp->if_l2com == NULL) {
- free(ifp, M_IFNET);
- ifindex_free(idx);
- return (NULL);
- }
+ KASSERT(ifp->if_l2com, ("%s: if_com_alloc[%u] failed", __func__,
+ type));
}
IF_ADDR_LOCK_INIT(ifp);
@@ -735,7 +723,7 @@ if_free(struct ifnet *ifp)
KASSERT(ifp == ifnet_byindex(ifp->if_index),
("%s: freeing unallocated ifnet", ifp->if_xname));
- ifindex_free_locked(ifp->if_index);
+ ifindex_free(ifp->if_index);
IFNET_WUNLOCK();
if (refcount_release(&ifp->if_refcount))
@@ -1356,7 +1344,7 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet)
* or we'd lock on one vnet and unlock on another.
*/
IFNET_WLOCK();
- ifindex_free_locked(ifp->if_index);
+ ifindex_free(ifp->if_index);
IFNET_WUNLOCK();
/*