domains: use queue(9) SLIST for linked list of domains
This commit is contained in:
parent
d7574c7432
commit
e18c5816ea
@ -248,7 +248,7 @@ db_print_domain(struct domain *d, const char *domain_name, int indent)
|
||||
|
||||
db_print_indent(indent);
|
||||
db_printf("dom_protosw: %p ", d->dom_protosw);
|
||||
db_printf("dom_next: %p\n", d->dom_next);
|
||||
db_printf("dom_next: %p\n", d->dom_next.sle_next);
|
||||
|
||||
db_print_indent(indent);
|
||||
db_printf("dom_rtattach: %p ", d->dom_rtattach);
|
||||
|
@ -71,7 +71,7 @@ static void domainfinalize(void *);
|
||||
SYSINIT(domainfin, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_FIRST, domainfinalize,
|
||||
NULL);
|
||||
|
||||
struct domain *domains; /* registered protocol domains */
|
||||
struct domainhead domains = SLIST_HEAD_INITIALIZER(&domains);
|
||||
int domain_init_status = 0;
|
||||
static struct mtx dom_mtx; /* domain list lock */
|
||||
MTX_SYSINIT(domain, &dom_mtx, "domain list", MTX_DEF);
|
||||
@ -282,8 +282,7 @@ domain_add(struct domain *dp)
|
||||
return;
|
||||
atomic_set_rel_int(&dp->dom_flags, DOMF_SUPPORTED);
|
||||
mtx_lock(&dom_mtx);
|
||||
dp->dom_next = domains;
|
||||
domains = dp;
|
||||
SLIST_INSERT_HEAD(&domains, dp, dom_next);
|
||||
|
||||
KASSERT(domain_init_status >= 1,
|
||||
("attempt to domain_add(%s) before domaininit()",
|
||||
@ -304,17 +303,7 @@ domain_remove(struct domain *dp)
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
SLIST_REMOVE(&domains, dp, domain, dom_next);
|
||||
mtx_unlock(&dom_mtx);
|
||||
}
|
||||
|
||||
@ -345,7 +334,7 @@ pffinddomain(int family)
|
||||
{
|
||||
struct domain *dp;
|
||||
|
||||
for (dp = domains; dp != NULL; dp = dp->dom_next)
|
||||
SLIST_FOREACH(dp, &domains, dom_next)
|
||||
if (dp->dom_family == family)
|
||||
return (dp);
|
||||
return (NULL);
|
||||
|
@ -999,7 +999,7 @@ if_attachdomain1(struct ifnet *ifp)
|
||||
|
||||
/* address family dependent data region */
|
||||
bzero(ifp->if_afdata, sizeof(ifp->if_afdata));
|
||||
for (dp = domains; dp; dp = dp->dom_next) {
|
||||
SLIST_FOREACH(dp, &domains, dom_next) {
|
||||
if (dp->dom_ifattach)
|
||||
ifp->if_afdata[dp->dom_family] =
|
||||
(*dp->dom_ifattach)(ifp);
|
||||
@ -1244,7 +1244,9 @@ if_detach_internal(struct ifnet *ifp, bool vmove)
|
||||
i = ifp->if_afdata_initialized;
|
||||
ifp->if_afdata_initialized = 0;
|
||||
IF_AFDATA_UNLOCK(ifp);
|
||||
for (dp = domains; i > 0 && dp; dp = dp->dom_next) {
|
||||
if (i == 0)
|
||||
return (0);
|
||||
SLIST_FOREACH(dp, &domains, dom_next) {
|
||||
if (dp->dom_ifdetach && ifp->if_afdata[dp->dom_family]) {
|
||||
(*dp->dom_ifdetach)(ifp,
|
||||
ifp->if_afdata[dp->dom_family]);
|
||||
@ -4369,7 +4371,7 @@ if_getmtu_family(if_t ifp, int family)
|
||||
{
|
||||
struct domain *dp;
|
||||
|
||||
for (dp = domains; dp; dp = dp->dom_next) {
|
||||
SLIST_FOREACH(dp, &domains, dom_next) {
|
||||
if (dp->dom_family == family && dp->dom_ifmtu != NULL)
|
||||
return (dp->dom_ifmtu((struct ifnet *)ifp));
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ grow_rtables(uint32_t num_tables)
|
||||
V_rt_numfibs * (AF_MAX + 1) * sizeof(void *));
|
||||
|
||||
/* Populate the remainders */
|
||||
for (dom = domains; dom; dom = dom->dom_next) {
|
||||
SLIST_FOREACH(dom, &domains, dom_next) {
|
||||
if (dom->dom_rtattach == NULL)
|
||||
continue;
|
||||
family = dom->dom_family;
|
||||
@ -252,7 +252,7 @@ grow_rtables(uint32_t num_tables)
|
||||
|
||||
#ifdef FIB_ALGO
|
||||
/* Attach fib algo to the new rtables */
|
||||
for (dom = domains; dom; dom = dom->dom_next) {
|
||||
SLIST_FOREACH(dom, &domains, dom_next) {
|
||||
if (dom->dom_rtattach != NULL)
|
||||
fib_setup_family(dom->dom_family, num_tables);
|
||||
}
|
||||
@ -296,7 +296,7 @@ rtables_destroy(const void *unused __unused)
|
||||
int family;
|
||||
|
||||
RTABLES_LOCK();
|
||||
for (dom = domains; dom; dom = dom->dom_next) {
|
||||
SLIST_FOREACH(dom, &domains, dom_next) {
|
||||
if (dom->dom_rtdetach == NULL)
|
||||
continue;
|
||||
family = dom->dom_family;
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#ifndef _SYS_DOMAIN_H_
|
||||
#define _SYS_DOMAIN_H_
|
||||
#include <sys/queue.h>
|
||||
|
||||
/*
|
||||
* Structure per communications domain.
|
||||
@ -48,6 +49,7 @@ struct socket;
|
||||
struct rib_head;
|
||||
|
||||
struct domain {
|
||||
SLIST_ENTRY(domain) dom_next;
|
||||
int dom_family; /* AF_xxx */
|
||||
u_int dom_nprotosw; /* length of dom_protosw[] */
|
||||
char *dom_name;
|
||||
@ -57,7 +59,6 @@ struct domain {
|
||||
(struct mbuf *, struct mbuf **, int);
|
||||
void (*dom_dispose) /* dispose of internalized rights */
|
||||
(struct socket *);
|
||||
struct domain *dom_next;
|
||||
struct rib_head *(*dom_rtattach) /* initialize routing table */
|
||||
(uint32_t);
|
||||
void (*dom_rtdetach) /* clean up routing table */
|
||||
@ -76,7 +77,7 @@ struct domain {
|
||||
|
||||
#ifdef _KERNEL
|
||||
extern int domain_init_status;
|
||||
extern struct domain *domains;
|
||||
extern SLIST_HEAD(domainhead, domain) domains;
|
||||
void domain_add(struct domain *);
|
||||
void domain_remove(struct domain *);
|
||||
void domain_init(struct domain *);
|
||||
|
Loading…
Reference in New Issue
Block a user