A question about "WARNING: attempt to domain_add(xyz) after domainfinalize()"

Svatopluk Kraus onwahe at gmail.com
Wed Jan 12 13:50:21 UTC 2011


Hi,

I'd like to add a new network domain into kernel (and never remove it)
from loadable module. In fact, I did it, but I got following warning
from domain_add(): "WARNING: attempt to domain_add(xyz) after
domainfinalize()". Now, I try to figure out what is behind the
warning, which seems to become KASSERT (now, in notyet section part of
code, which is 6 years old).

I found a few iteration on domains list and each domain protosw table,
which are not protected by any lock. OK, it is problem but when I only
add a domain (it's added at the head of domains list) and never remove
it then that could be safe. Moreover, it seems that without any
limits, it is possible to add a new protocol into domain on reserved
place labeled as PROTO_SPACER by pf_proto_register() function. Well,
it's not a list so it's a different case (but a copy into spacer isn't
atomic operation).

I found two global variables (max_hdr,max_datalen) which are evaluated
in each domain_init() from other variables (max_linkhdr,max_protohdr)
and a global variable (max_keylen) which is evaluated from all known
domains (dom_maxrtkey entry). The variables are used in other parts of
kernel. Futher, I know about 'dom_ifattach' and 'dom_ifdetach'
pointers to functions defined on each domain, which are responsible
for 'if_afdata' entry on ifnet structure.

Is there something more I didn't find in current kernel?
Will be there something more in future kernels, what legitimize
KASSERT in domain_add()?

My network domain doesn't influence any mentioned global variables,
doesn't define dom_ifattach() and dom_ifdetach() functions, and should
be only added from loadable module and never removed. So, I think it's
safe. But I'm a little bit nervous because of planned KASSERT in
domain_add().

Well, I can implement an empty domain with some spacers for protocols,
link it into kernel (thus shut down the warning), and make loadable
module in which I only register protocols I want on already added
domain, but why should I do it in that (for me good-for-nothing) way?

 Thanks for any response, Svata


More information about the freebsd-hackers mailing list