From nobody Tue Aug 20 12:43:47 2024 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 4Wp8KJ5p3xz5T4Gq; Tue, 20 Aug 2024 12:43:48 +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 4Wp8KJ0n2Sz4TWt; Tue, 20 Aug 2024 12:43:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724157828; 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=7mEGomBJMuVcgqEumIB0Uh01nyPhnCUgvtvOrJ/xhro=; b=rEVUt21m0T7bQPY5nMiWrRRFznLwcldwda9nQT7yOHo5LOxUAZV0fNVqv5cCexM0Tr4fqf KMlKLAciKz6YWfxQnSQwDxA2na/B8E7jvWPJoQcYKrw2CrE8XBDMaWl2Da03PxSxUjRbkZ m9NKiOu9M2cylPzm372CfJ6vC2I/i9Cc0U66jKXREvijrDIv9p4zcEYN74fIRMaMiiCNYv 9+LeH6/O2jzEJBVV/Yxz7YJ7lOECn+s1xa9MD6106gJQUAipLKVI1MM1QN/J3kVg1DG65w aOw61qiAuSB6VikgvUKche9dSYsyIcBvVlgYuXH7rDWucDeQ7GVIX24pdLPWEQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724157828; a=rsa-sha256; cv=none; b=tmvICPLKYpwYZ2gOcmOPqHoYBimFjat2UwrXopC1zv5KPNB7PbooNvx3Ml2SzMJvH1wuG/ 6clrP0OflhL8P9Gfor/moHMYLCPuAUtZQ57olLSyYE2l1gAo9w+RHI2lLvI0FLVQpvF8mS dou+F3nypUe4EKnnDz7NW5j33EeK4SwwLmPQEOlhF2PwQd5mWrJoW5HB0JngWddFU1AKfw qO0BDHOJ6yBowmi60+LymAlfOPlb++RmeOfYP/TvUrIBX4HZhGnYNJlh/L3J4XA/uJ5L2J VRrv/WItziBwQlylwBq1yjEZBc6H3YYpF9isObhtBujLEOogdM+ATpG0Ny8bbw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724157828; 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=7mEGomBJMuVcgqEumIB0Uh01nyPhnCUgvtvOrJ/xhro=; b=VzZvCxTJTIi9sogtDujjUvTN7C6mIWJrGVMlzN7LvRHFXLHDEA+prbe6mZNEyzEFCqkFfZ A7ipV5/svFORImW1inGz6NE3l4iIB8UfsPYCDX41sqkjtaWyr7LFJxCEZqQ5GG3EfznY7y RgtWBrFFBFK4x2YcePMC5t10hkvDCLXyK/tETeXs3vdYCpxJVySXKE1ujCgwa+ZuyM62/W irMONRxTf1ibqTai3sCx1YTPlRWsKlFwDQ0g1HuZE3dZU7z+s54/nhp6FloyzrGUeX1vNI 8xKAjh+ojKb0AfND3wxkMI0adrqfKB913jraAA7tVzrciPrADoDldne3pC20Pw== 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 4Wp8KJ0Nhfz11XD; Tue, 20 Aug 2024 12:43:48 +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 47KChloR054371; Tue, 20 Aug 2024 12:43:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47KChlUD054368; Tue, 20 Aug 2024 12:43:47 GMT (envelope-from git) Date: Tue, 20 Aug 2024 12:43:47 GMT Message-Id: <202408201243.47KChlUD054368@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: c4a0ee9b97bf - main - ipsec_offload: add handler for interface down events 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c4a0ee9b97bfc7407366567aaa2c09313b3e6bd2 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c4a0ee9b97bfc7407366567aaa2c09313b3e6bd2 commit c4a0ee9b97bfc7407366567aaa2c09313b3e6bd2 Author: Konstantin Belousov AuthorDate: 2024-08-08 11:43:28 +0000 Commit: Konstantin Belousov CommitDate: 2024-08-20 12:42:12 +0000 ipsec_offload: add handler for interface down events Remove all offloaded SAs and SPs on ifdown. Sponsored by: NVIDIA networking --- sys/netipsec/ipsec_offload.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sys/netipsec/ipsec_offload.c b/sys/netipsec/ipsec_offload.c index 984134539d8b..4d81803f4be7 100644 --- a/sys/netipsec/ipsec_offload.c +++ b/sys/netipsec/ipsec_offload.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -138,6 +139,8 @@ PCTRIE_DEFINE(DRVSPI_SA, ifp_handle_sav, drv_spi, drvspi_sa_trie_alloc, drvspi_sa_trie_free); static struct pctrie drv_spi_pctrie; +static eventhandler_tag ipsec_accel_ifdetach_event_tag; + static void ipsec_accel_sa_newkey_impl(struct secasvar *sav); static int ipsec_accel_handle_sav(struct secasvar *sav, struct ifnet *ifp, u_int drv_spi, void *priv, uint32_t flags, struct ifp_handle_sav **ires); @@ -154,6 +157,7 @@ static struct mbuf *ipsec_accel_key_setaccelif_impl(struct secasvar *sav); static void ipsec_accel_on_ifdown_impl(struct ifnet *ifp); static void ipsec_accel_drv_sa_lifetime_update_impl(struct secasvar *sav, if_t ifp, u_int drv_spi, uint64_t octets, uint64_t allocs); +static void ipsec_accel_ifdetach_event(void *arg, struct ifnet *ifp); static void ipsec_accel_init(void *arg) @@ -174,6 +178,9 @@ ipsec_accel_init(void *arg) ipsec_accel_drv_sa_lifetime_update_p = ipsec_accel_drv_sa_lifetime_update_impl; pctrie_init(&drv_spi_pctrie); + ipsec_accel_ifdetach_event_tag = EVENTHANDLER_REGISTER( + ifnet_departure_event, ipsec_accel_ifdetach_event, NULL, + EVENTHANDLER_PRI_ANY); } SYSINIT(ipsec_accel_init, SI_SUB_VNET_DONE, SI_ORDER_ANY, ipsec_accel_init, NULL); @@ -181,6 +188,8 @@ SYSINIT(ipsec_accel_init, SI_SUB_VNET_DONE, SI_ORDER_ANY, static void ipsec_accel_fini(void *arg) { + EVENTHANDLER_DEREGISTER(ifnet_departure_event, + ipsec_accel_ifdetach_event_tag); ipsec_accel_sa_newkey_p = NULL; ipsec_accel_forget_sav_p = NULL; ipsec_accel_spdadd_p = NULL; @@ -799,6 +808,14 @@ ipsec_accel_on_ifdown_impl(struct ifnet *ifp) ipsec_accel_on_ifdown_sav(ifp); } +static void +ipsec_accel_ifdetach_event(void *arg __unused, struct ifnet *ifp) +{ + if ((ifp->if_flags & IFF_RENAMING) != 0) + return; + ipsec_accel_on_ifdown_impl(ifp); +} + static bool ipsec_accel_output_pad(struct mbuf *m, struct secasvar *sav, int skip, int mtu) {