From nobody Tue Nov 23 03:59:43 2021 X-Original-To: dev-commits-src-all@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 EE3971889088; Tue, 23 Nov 2021 03:59:43 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hyr4b6JNMz3mx6; Tue, 23 Nov 2021 03:59:43 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 B8384716E; Tue, 23 Nov 2021 03:59:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1AN3xh1H073317; Tue, 23 Nov 2021 03:59:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AN3xhhw073316; Tue, 23 Nov 2021 03:59:43 GMT (envelope-from git) Date: Tue, 23 Nov 2021 03:59:43 GMT Message-Id: <202111230359.1AN3xhhw073316@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: fe499a8452cd - main - ifnet: merge if_destroy() and if_free_internal() into one List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: fe499a8452cd9c25a4949c33f4396966872ae589 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=fe499a8452cd9c25a4949c33f4396966872ae589 commit fe499a8452cd9c25a4949c33f4396966872ae589 Author: Gleb Smirnoff AuthorDate: 2021-11-23 03:53:12 +0000 Commit: Gleb Smirnoff CommitDate: 2021-11-23 03:53:12 +0000 ifnet: merge if_destroy() and if_free_internal() into one New function has more meaningful name if_free_deferred() and has its header comment fixed to reflect reality. NFC --- sys/net/if.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 9f971d958030..3e640ebfa679 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -671,15 +671,16 @@ if_alloc(u_char type) } /* * Do the actual work of freeing a struct ifnet, and layer 2 common - * structure. This call is made when the last reference to an - * interface is released. + * structure. This call is made when the network epoch guarantees + * us that nobody holds a pointer to the interface. */ static void -if_free_internal(struct ifnet *ifp) +if_free_deferred(epoch_context_t ctx) { + struct ifnet *ifp = __containerof(ctx, struct ifnet, if_epoch_ctx); KASSERT((ifp->if_flags & IFF_DYING), - ("if_free_internal: interface not dying")); + ("%s: interface not dying", __func__)); if (if_com_free[ifp->if_alloctype] != NULL) if_com_free[ifp->if_alloctype](ifp->if_l2com, @@ -700,15 +701,6 @@ if_free_internal(struct ifnet *ifp) free(ifp, M_IFNET); } -static void -if_destroy(epoch_context_t ctx) -{ - struct ifnet *ifp; - - ifp = __containerof(ctx, struct ifnet, if_epoch_ctx); - if_free_internal(ifp); -} - /* * Deregister an interface and free the associated storage. */ @@ -727,7 +719,7 @@ if_free(struct ifnet *ifp) IFNET_WUNLOCK(); if (refcount_release(&ifp->if_refcount)) - NET_EPOCH_CALL(if_destroy, &ifp->if_epoch_ctx); + NET_EPOCH_CALL(if_free_deferred, &ifp->if_epoch_ctx); CURVNET_RESTORE(); } @@ -759,7 +751,7 @@ if_rele(struct ifnet *ifp) if (!refcount_release(&ifp->if_refcount)) return; - NET_EPOCH_CALL(if_destroy, &ifp->if_epoch_ctx); + NET_EPOCH_CALL(if_free_deferred, &ifp->if_epoch_ctx); } void