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

Stefan Esser se at FreeBSD.org
Thu Jan 13 19:29:56 UTC 2011


Am 13.01.2011 06:42, schrieb Julian Elischer:
> 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 :-)

Well, yes, but there are actual problems in the current code and it
needs to be worked on. I checked the situation the last time the
question arose about half a year ago, and there are races and real
bugs (IIRC, you can only add one "domain" from a KLD, a second one
will not be initialized). My spare time was (and to date is) very
limited, but I still intend to prepare a fix (not sure whether the
races can be completely avoided, but they are extremely hard to
trigger since they only exist during module load).

> 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.

Not exactly true: In fact, domainfinalize performs some init work
for all domains and interfaces that have been compiled into the kernel.
After domainfinalize has been called, this domain initialization (the
initialization of pointers in the interface structure of all existing
network devices) has to be performed by a call to the same code that
domainfinalize calls in a loop for compiled in network interfaces.
But there are checks in that code, which need to be checked and fixed.
I had made annotations to the affected files, half a year ago, but do
not have access to my development system right now and thus I cannot
provide details, now.

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

The netgraph domain is probably the only one that is often loaded from
a KLD in generic systems. If another driver adds a domain and netgraph
is also required, then I'd strongly suggest to compile netgraph into
the kernel (and thus to have only one domain added from a KLD).

Best regards, STefan


More information about the freebsd-hackers mailing list