Hello everyone! I'm writing a network kernel extension right now and I have to configure it through a user space program. I'm trying to use the PF_NKE Domain (SYSPROTO_CONTROL protocol) for that, but calling ctl_deregister causes very strange effects. I have attached some sample code further below. I can register using ctl_register, but whenever I unregister using ctl_deregister, a message box pop ups on my desk saying: Server Connection Time Out Attempting to connect to the file Server "" And it will stay there forever, unless I click Disconnect twice and then I get an new message box Server Disconnect In Progress Please wait as this ... And this one really stays infinite. This behavior is 100% reproducible and caused by the code below and I have no idea why. Only loggin out and loggin in again fixes the problem. I tried two different machines, both with the latest Panther version installed, it's the same. The box just doesn't appear if you enable root account and log in as root. Have ever heard about it? Do you thing it is a bug? Is there anything wrong with my short piece of code? Can you maybe help me to somehow get around this problem? Thank you in advance. Here's code from the file dummy_kernelext.c: #include <sys/param.h> #include <sys/kernel.h> #include <sys/malloc.h> #include <sys/mbuf.h> #include <sys/queue.h> #include <sys/socket.h> #include <sys/sockio.h> #include <sys/sysctl.h> #include <sys/systm.h> #include <sys/kern_event.h> #include <net/bpf.h> #include <net/ethernet.h> #include <net/if.h> #include <net/if_arp.h> #include <net/if_dl.h> #include <net/if_types.h> #include <net/dlil.h> #include <net/if_var.h> #include <mach/mach_types.h> #include <sys/types.h> #include <sys/malloc.h> #include <sys/kern_control.h> #define OUR_ID 0x56706E54 /* Four byte ID */ /* I know that it is no valid ID and yes, I did try different ones */ static kern_ctl_ref ctlRef; int dummy_kernelext_ctlSet( kern_ctl_ref ctlref, void *userdata, int opt, void *data, size_t len); int dummy_kernelext_ctlGet( kern_ctl_ref ctlref, void *userdata, int opt, void *data, size_t *len); int dummy_kernelext_ctlConnect( kern_ctl_ref ctlref, void *userdata); void dummy_kernelext_ctlDisconnect( kern_ctl_ref ctlref, void *userdata); int dummy_kernelext_ctlWrite(kern_ctl_ref ctlref, void *userdata, struct mbuf *m); kern_return_t dummy_kernelext_start(kmod_info_t * ki, void * d) { struct kern_ctl_reg myCTL; /* Create my CTL structure */ ctlRef = NULL; bzero(&myCTL, sizeof(myCTL)); myCTL.ctl_id = OUR_ID; myCTL.ctl_unit = 0; myCTL.ctl_flags = CTL_FLAG_PRIVILEGED; myCTL.ctl_write = &dummy_kernelext_ctlWrite; myCTL.ctl_get = &dummy_kernelext_ctlGet; myCTL.ctl_set = &dummy_kernelext_ctlSet; myCTL.ctl_connect = &dummy_kernelext_ctlConnect; myCTL.ctl_disconnect = &dummy_kernelext_ctlDisconnect; /* Register kernel extension to retrieve user space config data */ if (ctl_register(&myCTL, NULL, &ctlRef)) { printf("Could not register CTL!\n"); goto error; } printf("Succesfully registered CTL\n"); /* Return success */ return KERN_SUCCESS; error: printf("We ran into an error ...\n"); /* Return error */ return KERN_FAILURE; } kern_return_t dummy_kernelext_stop(kmod_info_t * ki, void * d) { if (ctlRef) { /* Remove CTL connection */ if (ctl_deregister(ctlRef)) { printf("Could not deregister CTL!\n"); } else { printf("CTL succesfully deregistered\n"); } } return KERN_SUCCESS; } int dummy_kernelext_ctlSet( kern_ctl_ref ctlref, void *userdata, int opt, void *data, size_t len) { printf("CTL SET\n"); return ctl_enqueuedata(ctlref, data, len, 0); // return KERN_SUCCESS; } int dummy_kernelext_ctlGet( kern_ctl_ref ctlref, void *userdata, int opt, void *data, size_t *len) { printf("CTL GET\n"); return KERN_SUCCESS; } int dummy_kernelext_ctlConnect( kern_ctl_ref ctlref, void *userdata) { printf("CTL CONNECT\n"); return KERN_SUCCESS; } void dummy_kernelext_ctlDisconnect( kern_ctl_ref ctlref, void *userdata) { printf("CTL DISCONNECT\n"); } int dummy_kernelext_ctlWrite(kern_ctl_ref ctlref, void *userdata, struct mbuf *m) { printf("CTL WRITE\n"); return KERN_SUCCESS; } #undef OUR_ID -- Best Regards, Markus Hanauska _______________________________________________ darwin-kernel mailing list | darwin-kernel@lists.apple.com Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-kernel Do not post admin requests to the list. They will be ignored.
participants (1)
-
Markus Hanauska