aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander V. Chernikov <melifaro@FreeBSD.org>2022-08-12 13:36:53 +0000
committerAlexander V. Chernikov <melifaro@FreeBSD.org>2023-01-23 11:35:54 +0000
commit13a18f25560d98a48ab65f86b2b4653cb3c0a484 (patch)
tree45af438760648ad45597bb3d291612b692ae6cf0
parentfbdde1029e9202cf44ed3ce3e38a4d11e418eda5 (diff)
downloadsrc-13a18f25560d98a48ab65f86b2b4653cb3c0a484.tar.gz
src-13a18f25560d98a48ab65f86b2b4653cb3c0a484.zip
domains: allow pre-defined domains to be unloaded
Add domain_remove() SYSUNINT callback that removes the domain from the domain list. This change is required to support Netlink. This version is different from HEAD: it uses fixed family check, instead of the DOMF_UNLOADABLE flag. The dom_flag field appeared in HEAD and was not merged back, as there are no spare fields in 'struct domain'. Original commit message: Add domain_remove() SYSUNINT callback that removes the domain from the domain list if it has DOMF_UNLOADABLE flag set. This change is required to support netlink ( D36002 ). Reviewed by: glebius Differential Revision: https://reviews.freebsd.org/D36173 (cherry picked from commit 9b967bd65de6647aed68a141dc34f9b223a2593c)
-rw-r--r--sys/kern/uipc_domain.c23
-rw-r--r--sys/sys/domain.h3
2 files changed, 26 insertions, 0 deletions
diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c
index 08ad42224848..a0293b9a2745 100644
--- a/sys/kern/uipc_domain.c
+++ b/sys/kern/uipc_domain.c
@@ -268,6 +268,29 @@ domain_add(void *data)
mtx_unlock(&dom_mtx);
}
+void
+domain_remove(void *data)
+{
+ struct domain *dp = (struct domain *)data;
+
+ if (dp->dom_family != PF_NETLINK)
+ 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;
+ }
+ }
+ }
+ mtx_unlock(&dom_mtx);
+}
+
/* ARGSUSED*/
static void
domaininit(void *dummy)
diff --git a/sys/sys/domain.h b/sys/sys/domain.h
index 3d17879f1ccd..8e4ff20b3cf9 100644
--- a/sys/sys/domain.h
+++ b/sys/sys/domain.h
@@ -74,6 +74,7 @@ struct domain {
extern int domain_init_status;
extern struct domain *domains;
void domain_add(void *);
+void domain_remove(void *);
void domain_init(void *);
#ifdef VIMAGE
void vnet_domain_init(void *);
@@ -83,6 +84,8 @@ void vnet_domain_uninit(void *);
#define DOMAIN_SET(name) \
SYSINIT(domain_add_ ## name, SI_SUB_PROTO_DOMAIN, \
SI_ORDER_FIRST, domain_add, & name ## domain); \
+ SYSUNINIT(domain_remove_ ## name, SI_SUB_PROTO_DOMAIN, \
+ SI_ORDER_FIRST, domain_remove, & name ## domain); \
SYSINIT(domain_init_ ## name, SI_SUB_PROTO_DOMAIN, \
SI_ORDER_SECOND, domain_init, & name ## domain);
#ifdef VIMAGE