Re: git: 9b967bd65de6 - main - domains: allow domains to be unloaded
Date: Sun, 14 Aug 2022 14:51:54 UTC
On Sun, Aug 14, 2022 at 2:22 AM Alexander V. Chernikov <melifaro@freebsd.org> wrote: > > The branch main has been updated by melifaro: > > URL: https://cgit.FreeBSD.org/src/commit/?id=9b967bd65de6647aed68a141dc34f9b223a2593c > > commit 9b967bd65de6647aed68a141dc34f9b223a2593c > Author: Alexander V. Chernikov <melifaro@FreeBSD.org> > AuthorDate: 2022-08-12 13:36:53 +0000 > Commit: Alexander V. Chernikov <melifaro@FreeBSD.org> > CommitDate: 2022-08-14 09:22:33 +0000 > > domains: allow domains to be unloaded > > 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 > --- > sys/kern/uipc_domain.c | 23 +++++++++++++++++++++++ > sys/sys/domain.h | 4 ++++ > 2 files changed, 27 insertions(+) > > diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c > index c70b3150cbf0..2cae08be089a 100644 > --- a/sys/kern/uipc_domain.c > +++ b/sys/kern/uipc_domain.c > @@ -239,6 +239,29 @@ domain_add(void *data) > mtx_unlock(&dom_mtx); > } > > +void > +domain_remove(void *data) > +{ > + struct domain *dp = (struct domain *)data; > + > + if ((dp->dom_flags & DOMF_UNLOADABLE) == 0) > + 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) While it's not important for the one domain you care about, this should likely also check if any contained protocols have pr_fasttimo/pr_slowtimo and purge them from the appropriate list, just to be technically correct. (Or at least assert under INVARIANTS that they do not)