From nobody Tue Oct 8 04:01:56 2024 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XN2QX6d5wz5Yt4r; Tue, 08 Oct 2024 04:01:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XN2QX61Bbz4VnC; Tue, 8 Oct 2024 04:01:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728360116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5Fa+a6Jbg/ijHgWeWNKvPBAK5NNZO8HJjGbZmINWJIE=; b=AckwM/2st+nHf8/k+eXaRyMFTeFLa9GEBKD4xa/rorBoN7xv1T3r6oE9tHmV4g2dg4fW+Z z3BJQwU8W89D65jMzLviqm5j06doNaVXXsd/vhxviqf+rVauG9TTVZ/Yul7n35nbJGgbC+ VbxFo46fZZLM/bvQg+NMy2z6w4s1tySS/M0mlMGfil5Q3JuZ6DgjsOr1YksWNugzNISKeI GnMxKSgo+7jMEJEzJjO1b0eAEn6J1nAYTHYZ5OYzVLg8kEEi7BqNxkNq+st82lKUAS6V2G b6kM7Ee69kS37CrQ61elVwjYV9NRMpbvS0ejkmwOvSnfW8pV3ya5lJBT9iFwbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728360116; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5Fa+a6Jbg/ijHgWeWNKvPBAK5NNZO8HJjGbZmINWJIE=; b=g0aD1nRkY45u38Tbr/ilmvDWf1+O8lUjaIlL8QEPvzU3/2aYdByn3B0phWTw4b6oY5uSZJ QcMwaOfyMCTrar6s5xTHMOhkxlMMsjINGPhrdjSRGD7EJUHhOQKFUsuz8Kb6EtUlpyVDHP TyJBPzD8eJAfc6qapMUBGB60LxOc7S61J2dBfYW8AizxAeLVVAJn/DbK0m+W6GNl3+jW0S 1rMOsrsbUE/QlH5FvjxYUGjRgPgNhZQgFuSO/B/CW54p1JzwgaNIDh5fgDF0kkOBxUWTdK nSbfOwWwTM78iLdUS4Z3/XmNbqj7XQBxkrvkkSK8DihYK+jtVdOgZw7aJMKeyQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728360116; a=rsa-sha256; cv=none; b=minQ+bLrRlCxmED6A+ouBwyzGHAiL8z0zLKfkm+PM5aJXaKV/FYwwaKuHNg7yXVc31zq/C pFxGeHdQaUYDIxrvEItTvkmQoLNsxFw56Qj/odxYfaThQKnM5LbxH0864+MZfB9gz90s/p kcrxMewpHAf0/2YqwrX7rKe0lQj2q8HUhf3PlE9adm3P084gzom80+CbXs4AHegxrPL4RQ RgOfoomu5KzB6Olskv426xuXllzHcslP08ucdP7Bs8PB2idmZw+od+Tw9ruVH5+U79XfWY yJrEO5+0SYH+ECb95soT+neNv5Gyf7C4zRgT3AD54p4dlL8r4X7SwCvnW/JM1A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XN2QX5c3SzFNs; Tue, 8 Oct 2024 04:01:56 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49841ubb044557; Tue, 8 Oct 2024 04:01:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49841uXi044554; Tue, 8 Oct 2024 04:01:56 GMT (envelope-from git) Date: Tue, 8 Oct 2024 04:01:56 GMT Message-Id: <202410080401.49841uXi044554@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: 381601cfcb56 - stable/13 - ifnet: make if_alloc_domain() never fail List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zlei X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 381601cfcb56a98a14dcbfddb1b2be0ea7a5192c Auto-Submitted: auto-generated The branch stable/13 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=381601cfcb56a98a14dcbfddb1b2be0ea7a5192c commit 381601cfcb56a98a14dcbfddb1b2be0ea7a5192c Author: Gleb Smirnoff AuthorDate: 2021-11-23 03:49:57 +0000 Commit: Zhenlei Huang CommitDate: 2024-10-08 04:00:59 +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. MFC note: As for stable/13, there is one additional consumer sppp, which also never fails to allocate. This MFCing is mainly to keep behavioral compatibility of if_alloc_domain() and its wrappers if_alloc(), if_alloc_dev(), and if_gethandle() with stable/14 and onward branches. 3rd party drivers should be ready for this for years as this behavioral change was done in stable/14 at November 22 2021. As a good effect new drivers to be MFCed to stable/13 do not have to conditionally check failure from if_alloc() for stable/13. (cherry picked from commit 4787572d0580c6fdf818fd64efa3089de88720f0) --- 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 a7aed084143c..78da7cf02bfb 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -399,7 +399,7 @@ ifindex_alloc(void **old) } static void -ifindex_free_locked(u_short idx) +ifindex_free(u_short idx) { IFNET_WLOCK_ASSERT(); @@ -410,15 +410,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) { @@ -631,11 +622,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); @@ -730,7 +718,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)) @@ -1334,7 +1322,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(); /*