From nobody Mon Jan 03 18:22:55 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 4F35B191D3C4; Mon, 3 Jan 2022 18:22:57 +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 4JSPHh1sZXz3F2C; Mon, 3 Jan 2022 18:22:56 +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 C8F5B221C; Mon, 3 Jan 2022 18:22:55 +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 203IMtC9026271; Mon, 3 Jan 2022 18:22:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 203IMtFB026270; Mon, 3 Jan 2022 18:22:55 GMT (envelope-from git) Date: Mon, 3 Jan 2022 18:22:55 GMT Message-Id: <202201031822.203IMtFB026270@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: 9880323a99de - main - netipsec: use SYSINIT(9) instead of dom_init/dom_destroy 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: 9880323a99de1e39a82b75cd91d64f35d36c8559 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641234176; 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=eZKN7Ewx4ABC5EWmAzeAnbqaiPc2LUzp0RePjRJ14I8=; b=UOW8M4dOgfXGBntg9zg1PhFel3PZKWIlRgvq7JH6Tmgq6E5wZBHBgaArXZITh+r4fAjg9Y ry8VwFpo2tX5FAHVoGg1CGpw/JEGaelcdEj98gADvYO/nGnZLCPPB8Vcj8cL+miP676Ltm Dw3XEdqt21Wtagmjhp8hScUlWpYXFSb0JS+HEJhgbdiEXhjqvJ8wDPn8c3pTPXamUDyswZ SSTWSmQN5iyyVXOD1C4+f2si7y9KarYegeZdd9QwD0DtkiirdsoRvavnXgsy4NjXmDZWK5 2dJ9eYvOCuOelG2SUn+IFaLZQkeApgiRzHJZ5eXZxAtVYa7KictUnfzd0KcuxQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641234176; a=rsa-sha256; cv=none; b=EVWpxgRcds7vGpAIG2YUKHkz7XUcabFlB4bp33/rEaUDIPIzBfsjWWke0ekvOkZ9m2vGPF dXEPt1Gx8TCZQXLqxf9GMeTzAA1apOjbtUKUUv7FeSpcdb98bztDmDRS5zPd+xKcdrAMmU CVGwUyABSwhyNm0XY85K0MraTtW/9auPCENj/cMkv21cbHSuMQQnWHAtrTKQKpqayYIBEq +pekmp0qTRdP+3MmyJ4fVvdT8MAwIHOj4A+D3vQkpKBhT1yesrzsUgn0xvudiDTTE4FGML djhc/0yU/AF1KrMK0XeJk1399hEuZkg69H/3QoU64YJOhQ807Oo2W43C6HYdDA== 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=9880323a99de1e39a82b75cd91d64f35d36c8559 commit 9880323a99de1e39a82b75cd91d64f35d36c8559 Author: Gleb Smirnoff AuthorDate: 2022-01-03 18:15:21 +0000 Commit: Gleb Smirnoff CommitDate: 2022-01-03 18:15:21 +0000 netipsec: use SYSINIT(9) instead of dom_init/dom_destroy While here, use just static initializer for key_cb. Differential revision: https://reviews.freebsd.org/D33539 --- sys/netipsec/key.c | 34 ++++++++++++++++++++++++---------- sys/netipsec/key.h | 4 ---- sys/netipsec/keysock.c | 17 ++--------------- 3 files changed, 26 insertions(+), 29 deletions(-) diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c index 168ec3441faf..480879a58aa4 100644 --- a/sys/netipsec/key.c +++ b/sys/netipsec/key.c @@ -8300,8 +8300,9 @@ spdcache_destroy(void) } } #endif -void -key_init(void) + +static void +key_vnet_init(void *arg __unused) { int i; @@ -8327,9 +8328,13 @@ key_init(void) LIST_INIT(&V_acqtree); LIST_INIT(&V_spacqtree); +} +VNET_SYSINIT(key_vnet_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_SECOND, + key_vnet_init, NULL); - if (!IS_DEFAULT_VNET(curvnet)) - return; +static void +key_init(void *arg __unused) +{ ipsec_key_lft_zone = uma_zcreate("IPsec SA lft_c", sizeof(uint64_t) * 2, NULL, NULL, NULL, NULL, @@ -8353,10 +8358,11 @@ key_init(void) if (bootverbose) printf("IPsec: Initialized Security Association Processing.\n"); } +SYSINIT(key_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_FIRST, key_init, NULL); #ifdef VIMAGE -void -key_destroy(void) +static void +key_vnet_destroy(void *arg __unused) { struct secashead_queue sahdrainq; struct secpolicy_queue drainq; @@ -8451,10 +8457,18 @@ key_destroy(void) SPACQ_UNLOCK(); hashdestroy(V_acqaddrhashtbl, M_IPSEC_SAQ, V_acqaddrhash_mask); hashdestroy(V_acqseqhashtbl, M_IPSEC_SAQ, V_acqseqhash_mask); +} +VNET_SYSUNINIT(key_vnet_destroy, SI_SUB_PROTO_DOMAIN, SI_ORDER_SECOND, + key_vnet_destroy, NULL); +#endif - if (!IS_DEFAULT_VNET(curvnet)) - return; - +/* + * XXX: as long as domains are not unloadable, this function is never called, + * provided for consistensy and future unload support. + */ +static void +key_destroy(void *arg __unused) +{ uma_zdestroy(ipsec_key_lft_zone); #ifndef IPSEC_DEBUG2 @@ -8467,7 +8481,7 @@ key_destroy(void) SPACQ_LOCK_DESTROY(); SPI_ALLOC_LOCK_DESTROY(); } -#endif +SYSUNINIT(key_destroy, SI_SUB_PROTO_DOMAIN, SI_ORDER_FIRST, key_destroy, NULL); /* record data transfer on SA, and update timestamps */ void diff --git a/sys/netipsec/key.h b/sys/netipsec/key.h index 2ee7c208f195..4d0f4b1ea512 100644 --- a/sys/netipsec/key.h +++ b/sys/netipsec/key.h @@ -80,10 +80,6 @@ void key_delete_xform(const struct xformsw *); extern u_long key_random(void); extern void key_freereg(struct socket *); extern int key_parse(struct mbuf *, struct socket *); -extern void key_init(void); -#ifdef VIMAGE -extern void key_destroy(void); -#endif extern void key_sa_recordxfer(struct secasvar *, struct mbuf *); uint16_t key_portfromsaddr(struct sockaddr *); void key_porttosaddr(struct sockaddr *, uint16_t port); diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c index 83ed2bca2f47..1ee1f619b860 100644 --- a/sys/netipsec/keysock.c +++ b/sys/netipsec/keysock.c @@ -71,7 +71,7 @@ struct key_cb { int key_count; int any_count; }; -VNET_DEFINE_STATIC(struct key_cb, key_cb); +VNET_DEFINE_STATIC(struct key_cb, key_cb) = {}; #define V_key_cb VNET(key_cb) static struct sockaddr key_src = { 2, PF_KEY, }; @@ -452,23 +452,10 @@ struct protosw keysw[] = { } }; -static void -key_init0(void) -{ - - bzero((caddr_t)&V_key_cb, sizeof(V_key_cb)); - key_init(); -} - struct domain keydomain = { .dom_family = PF_KEY, .dom_name = "key", - .dom_init = key_init0, -#ifdef VIMAGE - .dom_destroy = key_destroy, -#endif .dom_protosw = keysw, .dom_protoswNPROTOSW = &keysw[nitems(keysw)] }; - -VNET_DOMAIN_SET(key); +DOMAIN_SET(key);