git: 13a18f25560d - stable/13 - domains: allow pre-defined domains to be unloaded
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 23 Jan 2023 11:36:45 UTC
The branch stable/13 has been updated by melifaro:
URL: https://cgit.FreeBSD.org/src/commit/?id=13a18f25560d98a48ab65f86b2b4653cb3c0a484
commit 13a18f25560d98a48ab65f86b2b4653cb3c0a484
Author: Alexander V. Chernikov <melifaro@FreeBSD.org>
AuthorDate: 2022-08-12 13:36:53 +0000
Commit: Alexander V. Chernikov <melifaro@FreeBSD.org>
CommitDate: 2023-01-23 11:35:54 +0000
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)
---
sys/kern/uipc_domain.c | 23 +++++++++++++++++++++++
sys/sys/domain.h | 3 +++
2 files changed, 26 insertions(+)
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