Re: kernel panic
Re: kernel panic
- Subject: Re: kernel panic
- From: David A Rowland <email@hidden>
- Date: Fri, 2 Jun 2006 13:19:16 -0700
Title: Re: kernel panic
Are you unregistering the kernel control
socket? Is that returning an error. When you write a kext, you have to
be very careful about cleanup. Most of the APIs (socket filters,
interfaces filters, interfaces, etc) will give you a callback to let
you know when your kext is no longer in use. You need to make sure
that your unload function refuses to unload until you have been
notified that everything is no longer in use or a kernel panic will
ensue. The kernel control sockets are a little different. Kernel
control sockets simply refuse to let you unregister while they are
still in use. I believe you will get an EBUSY error.
It should be safe to call the kernel
control unregister function after your last control has been closed.
It is not necessary to do this though since you probably don't want
your kernel control unregistered until it is unloading. The
recommended approach is to try to unregister in your kext's unload
command. If the unregister fails, return KERN_FAILURE from your unload
function and your kext will not be unloaded.
If the unregister function isn't
returning an error and you're still seeing this behavior, please let
us know, that would be a bug.
The kernel extension identifies this routing to be executed on
startup:
kern_return_t
Mocana_start(kmod_info_t * ki,
void * d)
{
initAccumulator();
initIPfilter(&HKfilter);
if (ipf_addv4(&HKfilter,
&filterRef) ==
0)
{
if
(MOCANA_initMocana() ==
0)
{
if (IPSEC_init() == 0)
{
if
(initControl() ==
0) //calls ctl_register()
{
if
(kev_vendor_code_find(BUNDLENAME, &vendorCode) == 0)
{
return KERN_SUCCESS;
}
terminateControl();
//calls ctl_deregister
}
IPSEC_flush();
}
MOCANA_freeMocana();
}
ipf_remove(filterRef);
}
return KERN_FAILURE;
}
and this to be executed on shutdown
kern_return_t Mocana_stop
(kmod_info_t * ki,
void * d)
{
int err;
err = terminateControl();
printf("terminateControl err: %d\n", err);
err = IPSEC_flush();
printf("terminateControl err: %d\n", err);
err = IPSEC_flush();
printf("MOCANA_freeMocana err: %d\n", err);
err =
ipf_remove(filterRef);
printf("ipf_remove err: %d\n", err);
printf("Mocana stop\n");
return
KERN_SUCCESS;
}
All error returns are 0.
By "register" do you mean ipf_addv4() or ctl_register()? And the same question
for "unregister".
David
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden