On 1/12/11 5:26 AM, Svatopluk Kraus wrote:
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).


just ignore that message, everyone else does :-)

teh problem is that the idea of domainfinalize() is incompatible with having the ability
to add domains from modules.
Luckily domain finalize doesn't actually do anything that stops your new domain
from working so it doesn't matter.

you'll get the same message if you add netgraph.ko as an object.


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
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[email protected]"


_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[email protected]"

Reply via email to