git: c1f711fd359f - stable/14 - siftr: remove the shutdown_pre_sync event handler on unload

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Fri, 02 Aug 2024 16:39:45 UTC
The branch stable/14 has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=c1f711fd359f41f9cdb18dd7a02d1fb0ce8866a2

commit c1f711fd359f41f9cdb18dd7a02d1fb0ce8866a2
Author:     Kristof Provost <kp@FreeBSD.org>
AuthorDate: 2024-07-19 06:08:14 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2024-08-02 07:30:38 +0000

    siftr: remove the shutdown_pre_sync event handler on unload
    
    PR:             280351
    MFC after:      2 weeks
    
    (cherry picked from commit fb05f761ac0b28b03eb057e36fe118f007d43d73)
---
 sys/netinet/siftr.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/netinet/siftr.c b/sys/netinet/siftr.c
index 52e2b8838b0f..255714cec0b1 100644
--- a/sys/netinet/siftr.c
+++ b/sys/netinet/siftr.c
@@ -273,6 +273,7 @@ static struct mtx siftr_pkt_queue_mtx;
 static struct mtx siftr_pkt_mgr_mtx;
 static struct thread *siftr_pkt_manager_thr = NULL;
 static char direction[2] = {'i','o'};
+static eventhandler_tag siftr_shutdown_tag;
 
 /* Required function prototypes. */
 static int siftr_sysctl_enabled_handler(SYSCTL_HANDLER_ARGS);
@@ -1281,6 +1282,7 @@ static int
 deinit_siftr(void)
 {
 	/* Cleanup. */
+	EVENTHANDLER_DEREGISTER(shutdown_pre_sync, siftr_shutdown_tag);
 	siftr_manage_ops(SIFTR_DISABLE);
 	hashdestroy(counter_hash, M_SIFTR, siftr_hashmask);
 	mtx_destroy(&siftr_pkt_queue_mtx);
@@ -1295,8 +1297,8 @@ deinit_siftr(void)
 static int
 init_siftr(void)
 {
-	EVENTHANDLER_REGISTER(shutdown_pre_sync, siftr_shutdown_handler, NULL,
-	    SHUTDOWN_PRI_FIRST);
+	siftr_shutdown_tag = EVENTHANDLER_REGISTER(shutdown_pre_sync,
+	    siftr_shutdown_handler, NULL, SHUTDOWN_PRI_FIRST);
 
 	/* Initialise our flow counter hash table. */
 	counter_hash = hashinit(SIFTR_EXPECTED_MAX_TCP_FLOWS, M_SIFTR,