Move ng_socket and ng_btsocket initialization to SI_SUB_PROTO_DOMAIN as they

call net_add_domain(). Calling this function too early (or late) breaks
assertations about the global domains list.
Actually it should be forbidden to call net_add_domain() outside of
SI_SUB_PROTO_DOMAIN completely as there are many places where we traverse
the domains list unprotected, but for now we allow late calls (mostly to
support netgraph). In order to really fix this we have to lock the domains
list in all places or find another way to ensure that we can safely walk the
list while another thread might be adding a new domain.

Spotted by:	se
Reviewed by:	julian, glebius
PR:		kern/73321	(partly)
This commit is contained in:
Max Laier 2004-11-30 22:28:50 +00:00
parent 6210b1477c
commit 4f240aff01
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=138238
2 changed files with 3 additions and 2 deletions

View File

@ -234,7 +234,8 @@ static moduledata_t ng_btsocket_mod = {
NULL
};
DECLARE_MODULE(ng_btsocket, ng_btsocket_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
DECLARE_MODULE(ng_btsocket, ng_btsocket_mod, SI_SUB_PROTO_DOMAIN,
SI_ORDER_ANY);
MODULE_VERSION(ng_btsocket, NG_BLUETOOTH_VERSION);
MODULE_DEPEND(ng_btsocket, ng_bluetooth, NG_BLUETOOTH_VERSION,
NG_BLUETOOTH_VERSION, NG_BLUETOOTH_VERSION);

View File

@ -143,7 +143,7 @@ static struct ng_type typestruct = {
.rcvdata = ngs_rcvdata,
.disconnect = ngs_disconnect,
};
NETGRAPH_INIT(socket, &typestruct);
NETGRAPH_INIT_ORDERED(socket, &typestruct, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY);
/* Buffer space */
static u_long ngpdg_sendspace = 20 * 1024; /* really max datagram size */