From nobody Tue Aug 30 02:24:54 2022 X-Original-To: dev-commits-src-main@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 4MGrjz0Y3fz4bHq2; Tue, 30 Aug 2022 02:24:55 +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 4MGrjy6j8qz42qX; Tue, 30 Aug 2022 02:24:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661826294; 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=xd4BEB9HcJbDCTk5wHhvIXRvMeopGJi9R11v7Q7t0cU=; b=ivq1DfTaeLqZfEkHSwUviasp8BVdjDoMdRAbX1hz5dlHaQAnh0X82JSD6NExKByoqEHMbG JtVfWNXSdK6GT/5yXVu60c/T7hxY8UtCWB56LvxcG9gn8ff9w3tsL58S4tGS6WVMec5vJ4 vnJS92Rugqf6/oxUw3ryG8RP58HiMXCIx5aC3awp1waNt1+ldKctjDSf8nd+rMm+MHvgZ1 iSWssWKBMmqrBIGypwlxHP9YLpjEUAx+0M/plkvlakl/J5DiNSTXNQ6GPXknyZip4l0OUI Z4/eaFg3qO5Aqu3qGsbLAF8alxdRv0oKOriJhCJAcf6JTL1zUjvNYAmXr8hCYA== 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 4MGrjy5q5szdQn; Tue, 30 Aug 2022 02:24:54 +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 27U2Os4D008101; Tue, 30 Aug 2022 02:24:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27U2OsCj008100; Tue, 30 Aug 2022 02:24:54 GMT (envelope-from git) Date: Tue, 30 Aug 2022 02:24:54 GMT Message-Id: <202208300224.27U2OsCj008100@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: e18c5816ea56 - main - domains: use queue(9) SLIST for linked list of domains List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: e18c5816ea56e64f3e792d0e02ef3c23f0f54047 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661826294; 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=xd4BEB9HcJbDCTk5wHhvIXRvMeopGJi9R11v7Q7t0cU=; b=lmgKK+aQW2hwfLEo6+0xxaxtE/ti69wGo1QcSYZOO5wopHu2RNeHzfRohLWY4g/dyuPkxE 7zDRdmKyGAQJVr6/AoO5dOhr5Dw03xzuZJnBpZagw82oSjLuFBo0rd5OIRjAxAHCd1TSAl fbReSYbMGksbPNGaahRcMCPfGq0Po/dbHKlq5PtTHd9nm/h5Kl5GdDNg0z1f3GhNjDVHHy YXj7NSncw9Fi7IzVcvpMOEBer9Y+HBEQTy7OwUTfxH73cgF27m1+yyzE6nd2jvtttPcURS qbxFNedwrSyp8frNlFlhMsKC63bUUmMBRlX+AF3v3kQ3Inoqzl/VGtfesNj3xQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1661826294; a=rsa-sha256; cv=none; b=oGHZYOnTdz/iGeZM+7stiEBhygjxcGUaz0iAceuFeqTmqIGD5Ag96bmwo8+Crhs0HY6X2a 3pdQggTsVfDFt8c67VfEOzPymMdjwjoiS/IzMPqPWUvAU2zFg9pAXbIlnO3lMhY+eqDEyH o1Pr5xNjYdNZBf8NKLsZWElyDQ3GEQXMB5/7bK6N0Kio8ecYy7Iq0ALZfeCi6+0Olf9jHM 1DEoWgHdpA/q0pB9VLHK2SyQKf08Em5K4SirYh6S5Lv5yv4kYxQGdYlKpGOToDaEFGX2Z3 xQPdz97eG/9yCh0tbhC/VNlSmfSo1H/RlnsEuUY25OA3JsW6iVs4N/hN/Kp95w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=e18c5816ea56e64f3e792d0e02ef3c23f0f54047 commit e18c5816ea56e64f3e792d0e02ef3c23f0f54047 Author: Gleb Smirnoff AuthorDate: 2022-08-30 02:15:01 +0000 Commit: Gleb Smirnoff CommitDate: 2022-08-30 02:15:01 +0000 domains: use queue(9) SLIST for linked list of domains --- sys/kern/uipc_debug.c | 2 +- sys/kern/uipc_domain.c | 19 ++++--------------- sys/net/if.c | 8 +++++--- sys/net/route/route_tables.c | 6 +++--- sys/sys/domain.h | 5 +++-- 5 files changed, 16 insertions(+), 24 deletions(-) diff --git a/sys/kern/uipc_debug.c b/sys/kern/uipc_debug.c index 3f54e3e46f26..62c8138c3bb3 100644 --- a/sys/kern/uipc_debug.c +++ b/sys/kern/uipc_debug.c @@ -248,7 +248,7 @@ db_print_domain(struct domain *d, const char *domain_name, int indent) db_print_indent(indent); db_printf("dom_protosw: %p ", d->dom_protosw); - db_printf("dom_next: %p\n", d->dom_next); + db_printf("dom_next: %p\n", d->dom_next.sle_next); db_print_indent(indent); db_printf("dom_rtattach: %p ", d->dom_rtattach); diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index 334a7a036daa..b12aefbd2a2d 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -71,7 +71,7 @@ static void domainfinalize(void *); SYSINIT(domainfin, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_FIRST, domainfinalize, NULL); -struct domain *domains; /* registered protocol domains */ +struct domainhead domains = SLIST_HEAD_INITIALIZER(&domains); int domain_init_status = 0; static struct mtx dom_mtx; /* domain list lock */ MTX_SYSINIT(domain, &dom_mtx, "domain list", MTX_DEF); @@ -282,8 +282,7 @@ domain_add(struct domain *dp) return; atomic_set_rel_int(&dp->dom_flags, DOMF_SUPPORTED); mtx_lock(&dom_mtx); - dp->dom_next = domains; - domains = dp; + SLIST_INSERT_HEAD(&domains, dp, dom_next); KASSERT(domain_init_status >= 1, ("attempt to domain_add(%s) before domaininit()", @@ -304,17 +303,7 @@ domain_remove(struct domain *dp) return; mtx_lock(&dom_mtx); - if (domains == dp) { - domains = dp->dom_next; - } else { - struct domain *curr; - for (curr = domains; curr != NULL; curr = curr->dom_next) { - if (curr->dom_next == dp) { - curr->dom_next = dp->dom_next; - break; - } - } - } + SLIST_REMOVE(&domains, dp, domain, dom_next); mtx_unlock(&dom_mtx); } @@ -345,7 +334,7 @@ pffinddomain(int family) { struct domain *dp; - for (dp = domains; dp != NULL; dp = dp->dom_next) + SLIST_FOREACH(dp, &domains, dom_next) if (dp->dom_family == family) return (dp); return (NULL); diff --git a/sys/net/if.c b/sys/net/if.c index 886d3f7833c0..ffaf7d004511 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -999,7 +999,7 @@ if_attachdomain1(struct ifnet *ifp) /* address family dependent data region */ bzero(ifp->if_afdata, sizeof(ifp->if_afdata)); - for (dp = domains; dp; dp = dp->dom_next) { + SLIST_FOREACH(dp, &domains, dom_next) { if (dp->dom_ifattach) ifp->if_afdata[dp->dom_family] = (*dp->dom_ifattach)(ifp); @@ -1244,7 +1244,9 @@ finish_vnet_shutdown: i = ifp->if_afdata_initialized; ifp->if_afdata_initialized = 0; IF_AFDATA_UNLOCK(ifp); - for (dp = domains; i > 0 && dp; dp = dp->dom_next) { + if (i == 0) + return (0); + SLIST_FOREACH(dp, &domains, dom_next) { if (dp->dom_ifdetach && ifp->if_afdata[dp->dom_family]) { (*dp->dom_ifdetach)(ifp, ifp->if_afdata[dp->dom_family]); @@ -4369,7 +4371,7 @@ if_getmtu_family(if_t ifp, int family) { struct domain *dp; - for (dp = domains; dp; dp = dp->dom_next) { + SLIST_FOREACH(dp, &domains, dom_next) { if (dp->dom_family == family && dp->dom_ifmtu != NULL) return (dp->dom_ifmtu((struct ifnet *)ifp)); } diff --git a/sys/net/route/route_tables.c b/sys/net/route/route_tables.c index f5fe4b5d2a81..614c28ded0cf 100644 --- a/sys/net/route/route_tables.c +++ b/sys/net/route/route_tables.c @@ -216,7 +216,7 @@ grow_rtables(uint32_t num_tables) V_rt_numfibs * (AF_MAX + 1) * sizeof(void *)); /* Populate the remainders */ - for (dom = domains; dom; dom = dom->dom_next) { + SLIST_FOREACH(dom, &domains, dom_next) { if (dom->dom_rtattach == NULL) continue; family = dom->dom_family; @@ -252,7 +252,7 @@ grow_rtables(uint32_t num_tables) #ifdef FIB_ALGO /* Attach fib algo to the new rtables */ - for (dom = domains; dom; dom = dom->dom_next) { + SLIST_FOREACH(dom, &domains, dom_next) { if (dom->dom_rtattach != NULL) fib_setup_family(dom->dom_family, num_tables); } @@ -296,7 +296,7 @@ rtables_destroy(const void *unused __unused) int family; RTABLES_LOCK(); - for (dom = domains; dom; dom = dom->dom_next) { + SLIST_FOREACH(dom, &domains, dom_next) { if (dom->dom_rtdetach == NULL) continue; family = dom->dom_family; diff --git a/sys/sys/domain.h b/sys/sys/domain.h index 2f3a698a369d..9b0e28137e18 100644 --- a/sys/sys/domain.h +++ b/sys/sys/domain.h @@ -34,6 +34,7 @@ #ifndef _SYS_DOMAIN_H_ #define _SYS_DOMAIN_H_ +#include /* * Structure per communications domain. @@ -48,6 +49,7 @@ struct socket; struct rib_head; struct domain { + SLIST_ENTRY(domain) dom_next; int dom_family; /* AF_xxx */ u_int dom_nprotosw; /* length of dom_protosw[] */ char *dom_name; @@ -57,7 +59,6 @@ struct domain { (struct mbuf *, struct mbuf **, int); void (*dom_dispose) /* dispose of internalized rights */ (struct socket *); - struct domain *dom_next; struct rib_head *(*dom_rtattach) /* initialize routing table */ (uint32_t); void (*dom_rtdetach) /* clean up routing table */ @@ -76,7 +77,7 @@ struct domain { #ifdef _KERNEL extern int domain_init_status; -extern struct domain *domains; +extern SLIST_HEAD(domainhead, domain) domains; void domain_add(struct domain *); void domain_remove(struct domain *); void domain_init(struct domain *);