From owner-dev-commits-src-all@freebsd.org Sat Mar 20 09:59:46 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AFBD45796FA; Sat, 20 Mar 2021 09:59:46 +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 4F2bpT5TQRz3k1L; Sat, 20 Mar 2021 09: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 73F8725EA9; Sat, 20 Mar 2021 09: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 12K9xhEF064228; Sat, 20 Mar 2021 09: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 12K9xhNm064227; Sat, 20 Mar 2021 09:59:43 GMT (envelope-from git) Date: Sat, 20 Mar 2021 09:59:43 GMT Message-Id: <202103200959.12K9xhNm064227@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: f11b9574cd18 - stable/12 - pf: Fully remove interrupt events on vnet cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: f11b9574cd186762c4883e8819896c6475be3027 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Mar 2021 09:59:47 -0000 The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=f11b9574cd186762c4883e8819896c6475be3027 commit f11b9574cd186762c4883e8819896c6475be3027 Author: Kristof Provost AuthorDate: 2021-03-10 21:56:11 +0000 Commit: Kristof Provost CommitDate: 2021-03-19 22:42:27 +0000 pf: Fully remove interrupt events on vnet cleanup swi_remove() removes the software interrupt handler but does not remove the associated interrupt event. This is visible when creating and remove a vnet jail in `procstat -t 12`. We can remove it manually with intr_event_destroy(). PR: 254171 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D29211 (cherry picked from commit cecfaf9bede9665d6a10f1e575cd5d575450cff7) --- sys/net/pfvar.h | 2 ++ sys/netpfil/pf/if_pfsync.c | 10 ++++++++-- sys/netpfil/pf/pf.c | 1 + sys/netpfil/pf/pf_ioctl.c | 9 ++++++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index ef25bfc85605..a5ffba6c9d93 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1389,6 +1389,8 @@ VNET_DECLARE(struct pf_srchash *, pf_srchash); VNET_DECLARE(void *, pf_swi_cookie); #define V_pf_swi_cookie VNET(pf_swi_cookie) +VNET_DECLARE(struct intr_event *, pf_swi_ie); +#define V_pf_swi_ie VNET(pf_swi_ie) VNET_DECLARE(uint64_t, pf_stateid[MAXCPU]); #define V_pf_stateid VNET(pf_stateid) diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c index 0f55dacd18ad..dc149ff486d5 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -254,6 +254,8 @@ VNET_DEFINE_STATIC(struct pfsync_softc *, pfsyncif) = NULL; #define V_pfsyncif VNET(pfsyncif) VNET_DEFINE_STATIC(void *, pfsync_swi_cookie) = NULL; #define V_pfsync_swi_cookie VNET(pfsync_swi_cookie) +VNET_DEFINE_STATIC(struct intr_event *, pfsync_swi_ie); +#define V_pfsync_swi_ie VNET(pfsync_swi_ie) VNET_DEFINE_STATIC(struct pfsyncstats, pfsyncstats); #define V_pfsyncstats VNET(pfsyncstats) VNET_DEFINE_STATIC(int, pfsync_carp_adj) = CARP_MAXSKEW; @@ -2469,7 +2471,7 @@ vnet_pfsync_init(const void *unused __unused) V_pfsync_cloner = if_clone_simple(pfsyncname, pfsync_clone_create, pfsync_clone_destroy, 1); - error = swi_add(NULL, pfsyncname, pfsyncintr, V_pfsyncif, + error = swi_add(&V_pfsync_swi_ie, pfsyncname, pfsyncintr, V_pfsyncif, SWI_NET, INTR_MPSAFE, &V_pfsync_swi_cookie); if (error) { if_clone_detach(V_pfsync_cloner); @@ -2484,11 +2486,15 @@ VNET_SYSINIT(vnet_pfsync_init, SI_SUB_PROTO_FIREWALL, SI_ORDER_ANY, static void vnet_pfsync_uninit(const void *unused __unused) { + int ret; pfsync_pointers_uninit(); if_clone_detach(V_pfsync_cloner); - swi_remove(V_pfsync_swi_cookie); + ret = swi_remove(V_pfsync_swi_cookie); + MPASS(ret == 0); + ret = intr_event_destroy(V_pfsync_swi_ie); + MPASS(ret == 0); } VNET_SYSUNINIT(vnet_pfsync_uninit, SI_SUB_PROTO_FIREWALL, SI_ORDER_FOURTH, diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 3422cdea1e2e..9ad45ff9607e 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -388,6 +388,7 @@ SYSCTL_ULONG(_net_pf, OID_AUTO, request_maxcount, CTLFLAG_RWTUN, &pf_ioctl_maxcount, 0, "Maximum number of tables, addresses, ... in a single ioctl() call"); VNET_DEFINE(void *, pf_swi_cookie); +VNET_DEFINE(struct intr_event *, pf_swi_ie); VNET_DEFINE(uint32_t, pf_hashseed); #define V_pf_hashseed VNET(pf_hashseed) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index c50904e28dc6..d5e09ea1c443 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -331,7 +331,7 @@ pfattach_vnet(void) for (int i = 0; i < SCNT_MAX; i++) V_pf_status.scounters[i] = counter_u64_alloc(M_WAITOK); - if (swi_add(NULL, "pf send", pf_intr, curvnet, SWI_NET, + if (swi_add(&V_pf_swi_ie, "pf send", pf_intr, curvnet, SWI_NET, INTR_MPSAFE, &V_pf_swi_cookie) != 0) /* XXXGL: leaked all above. */ return; @@ -4669,7 +4669,7 @@ pf_load(void) static void pf_unload_vnet(void) { - int error; + int error, ret; V_pf_vnet_active = 0; V_pf_status.running = 0; @@ -4688,7 +4688,10 @@ pf_unload_vnet(void) shutdown_pf(); PF_RULES_WUNLOCK(); - swi_remove(V_pf_swi_cookie); + ret = swi_remove(V_pf_swi_cookie); + MPASS(ret == 0); + ret = intr_event_destroy(V_pf_swi_ie); + MPASS(ret == 0); pf_unload_vnet_purge();