Ravi, I dont know about the divert code, but it seems that ethernet device identification is done on the first 3 letters of the device name, i.e. your device must be named "eth"xxx. Check alloc_divert_blk in dv.c HTH 19/04/2004 1:18 PM To: Suvidh Mathur <Suvidh.Mathur@lntinfotech.com> cc: kernelnewbies@nl.linux.org From: Ravi Kumar <ravivsn@rocsys.com> Subject: Re: problem in initilisation Suvid, Thanks for the information. Now, I allocated memory and the problem seems to be with identification as ethernet device. dmesg shows the below info divert: not allocating divert_blk for non-ethernet device testdev0 Unable to handle kernel paging request at virtual address 0180040e printing eip: c01f64a4 *pde = 00000000 Oops: 0000 testdriver i810_audio ac97_codec soundcore mousedev input i810 agpgart autofs CPU: 0 EIP: 0010:[<c01f64a4>] Tainted: PF EFLAGS: 00210296 EIP is at __rta_fill [kernel] 0x64 (2.4.18-14) eax: 0000000a ebx: 00000004 ecx: 00000001 edx: c7e21c60 esi: 0180040e edi: c187b060 ebp: 00000008 esp: c676fe1c ds: 0018 es: 0018 ss: 0018 Process insmod (pid: 1056, stackpage=c676f000) Stack: 00000000 c0154a30 00000001 0000000a 00000000 c7ba4a00 c034192d c7e21c60 c01f6a6f c7e21c60 0000000a 00000004 0180040e c0341928 00000f10 c0341960 00000010 c187b000 000005dc c7e21c60 c7ba4a00 00000010 ffffffff c01f6ced Call Trace: [<c0154a30>] alloc_inode [kernel] 0xa0 (0xc676fe20)) [<c01f6a6f>] rtnetlink_fill_ifinfo [kernel] 0x37f (0xc676fe3c)) [<c01f6ced>] rtmsg_ifinfo [kernel] 0x5d (0xc676fe78)) [<c01f6f7f>] rtnetlink_event [kernel] 0x2f (0xc676fea4)) [<c012613d>] notifier_call_chain [kernel] 0x2d (0xc676feb4)) [<c01f2585>] register_netdevice [kernel] 0x115 (0xc676fed0)) [<c8e5d2f4>] init_module [testdriver] 0x130 (0xc676feec)) [<c8e5d526>] .rodata [testdriver] 0x86 (0xc676fef4)) [<c011bf79>] sys_init_module [kernel] 0x4d9 (0xc676ff1c)) [<c8e5d060>] test_open [testdriver] 0x0 (0xc676ff20)) [<c8e5d060>] test_open [testdriver] 0x0 (0xc676ff58)) [<c010910f>] system_call [kernel] 0x33 (0xc676ffc0)) Code: f3 a5 f6 c3 02 74 02 66 a5 f6 c3 01 74 01 a4 8b 5c 24 10 8b Thanks in advance, -Ravi Suvidh Mathur wrote: >Hi, >At first glance, I could not find where you have allocated your netdevice >structure. The struct test_struct contains a pointer to net_device, but >where are you allocating it? > >Regards, > > > >19/04/2004 10:53 AM >To: kernelnewbies@nl.linux.org >cc: >From: Ravi Kumar <ravivsn@rocsys.com> >Subject: problem in initilisation > > > >HI, >I wrote one character device which should create network device. When I >do insmod it gave a segmentation fault and lsmod shows initializing. > >A dmesg shows: > >EIP is at init_module [testdriver] 0xa6 (2.4.18-14) >eax: 00000000 ebx: ffffffea ecx: c05b6000 edx: c8e7f4d3 >esi: 00000000 edi: 00000000 ebp: c672df18 esp: c672df00 >ds: 0018 es: 0018 ss: 0018 >Process insmod (pid: 9922, stackpage=c672d000) >Stack: 00200206 ffffffff 00002f3f c05b6940 00000000 00000000 c8e7f000 >c011bf79 > c8e7f060 08075228 00000908 00000000 080756f4 0000052c 00000060 > 00000060 > 0000000a c05b6c40 c6231000 c6e7e000 00000060 c8def000 c8e7f060 > 00000968 > Call Trace: [<c011bf79>] sys_init_module [kernel] 0x4d9 >(0xc672df1c)) > [<c8e7f060>] test_open [testdriver] 0x0 (0xc672df20)) > [<c8e7f060>] test_open [testdriver] 0x0 (0xc672df58)) > [<c010910f>] system_call [kernel] 0x33 (0xc672dfc0)) > > >Code: c7 40 34 fe f0 e7 c8 83 ec 08 68 d4 f4 e7 c8 8b 45 f4 ff 30 > > >I am attaching the code, pls help me to solve this problem. >Thanks a lot, >-Ravi > >#ifndef __KERNEL__ ># define __KERNEL__ >#endif > >#ifndef MODULE ># define MODULE >#endif > >#define DEVNAME "testdev" > >#include <linux/module.h> >#include <linux/kernel.h> >#include <linux/fs.h> >#include <linux/slab.h> > >#include <linux/netdevice.h> >#include <linux/if_ether.h> > > > >int test_open(struct inode *,struct file *); >int test_release(struct inode *,struct file*); > > >struct test_struct{ >struct net_device *dev; >char name[IFNAMSIZ]; >}; > > > >struct file_operations test_fop={ >llseek: NULL, >read: NULL, >write: NULL, >ioctl: NULL, >open: test_open, >release: test_release, >}; > > > >int test_open(struct inode *inode, struct file *filep) >{ > MOD_INC_USE_COUNT; > return 0; >} > >int test_release(struct inode *inode, struct file *filep) >{ > MOD_DEC_USE_COUNT; > return 0; >} > >int testdev_open(struct net_device *dev) >{ > MOD_INC_USE_COUNT; > return 0; >} > >int testdev_close(struct net_device *dev) >{ > unregister_netdev(dev); > MOD_DEC_USE_COUNT; > return 0; >} > >static int test_init_dev(struct net_device *dev) >{ > struct test_struct *c; > > dev->priv = kmalloc(sizeof(struct net_device),GFP_KERNEL); > if(!dev->priv) > { > printk(KERN_ERR "out of memory while allocating to dev->priv\n"); > return -ENOMEM; > } > c = (struct test_struct *)dev->priv; > if(!c) > return -ENODEV; > > memset(c,0,sizeof(struct test_struct)); > c->dev = dev; > ether_setup(dev); > > dev->open = testdev_open; > dev->stop = testdev_close; > dev->mtu = ETH_DATA_LEN; > dev_init_buffers(dev); > return 0; >} > > >int init_module(void) >{ > int result,i; > > struct test_struct *pTestStruct; > result = register_chrdev(16,"test",&test_fop); > if( result < 0 ){ > printk(KERN_WARNING "test: cant get major\n"); > return result; > } > pTestStruct = (struct test_struct *)kmalloc(sizeof( struct > test_struct),GFP_KERNEL); > if(!pTestStruct) > { > printk(KERN_ERR "failed to allocate memory\n"); > return -ENOMEM; > } > > memset((void *)pTestStruct,0,sizeof(pTestStruct)); > sprintf(pTestStruct->name, DEVNAME); > //pTestStruct->dev->priv = pTestStruct; > pTestStruct->dev->init = test_init_dev; > > i = dev_alloc_name(pTestStruct->dev,"testdev%d"); > if(i < 0 ) > { > printk(KERN_ERR "cant allocate device\n"); > return -ENODEV; > } > i = register_netdevice((pTestStruct->dev)); > if( i < 0 ) > printk(KERN_ERR "register netdevice failed\n"); > > return 0; > } > >void cleanup_module(void) >{ > > unregister_chrdev(16,"test"); > } > > > > > > > >(Attachments removed) > > > > > > > > > > > > > > > > > > > > > > > > > > > > >This email may contain confidential or privileged information for the >intended recipient(s). If you are not the intended recipient, please do not >use or disseminate the information, notify the sender and delete it from >your system. Thanks > > > This email may contain confidential or privileged information for the intended recipient(s). If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system. Thanks -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/