Hi, I will do that. I just wanted to know if there is any other way. Thanx Regards bhaskar On Wed, 2004-06-16 at 18:00, Danilo Reinhardt wrote: > Hi, > > if you can't use devinet_ioctl() directly because of userspace copying, > just copy the code from devinet_ioctl() over or parts of them... > Not really a nice way, but a working one. > > Bye > > > Am Mi, den 16.06.2004 schrieb Bhaskar-ROCSYS um 13:24: > > Hi > > Thanks for the reply. I followed the same and found out that the > > function devinet_ioctl() function does the configuration changes. This > > function is defined in /usr/src/linux/net/ipv4/devinet.c > > > > But if you the code it copies the contents from user space memory to > > kernel space (copy_from_user). It would mean that I cannot call this > > function from kernel space, as the buffer I would be passing would > > definitely be in kernel space. > > > > I cannot even use get_fs() and set_fs() (using get_ds()) and continue > > calling the function because it is not always true that my module will > > always be initated in process context. > > > > Please comment if I am wrong. > > > > Regards > > bhaskar > > On Wed, 2004-06-16 at 16:12, Jan Hudec wrote: > > > On Wed, Jun 16, 2004 at 11:58:15 +0530, Bhaskar-ROCSYS wrote: > > > > Hi all, > > > > > > > > Is there any way to create a dynamic interface from kernel space. > > > > > > > > Is it possible to change the parameters of an interface from kernel > > > > space? > > > > > > > > All these can be done by using ifconfig. But I want to do it from > > > > kernel space. > > > > I want to change the IP address from kernel space and change the IP > > > > address. I have written a small code to do this but i am not able to > > > > see the effect. > > > > > > ifconfig obviously runs in userspace. So it can't touch the kernel > > > varaibles. So it has to communicate the data somehow. Look how it works > > > (strace will suffice -- you just need to know the syscalls it calls). > > > Then read the code of those syscalls until you get past the > > > copy_from_user stuff and basic sanity-checiking. Then call the function > > > that does the works. > > > > > > > The code I had written is: > > > > > > > [...] > > > > int init_module() > > > > { > > > > struct in_device *in_dev; > > > > struct in_ifaddr **ifap = NULL; > > > > struct in_ifaddr *ifa = NULL; > > > > struct net_device *dev; > > > > > > > > if((dev = __dev_get_by_name("eth0")) == NULL) > > > > { > > > > printk("<1>Cannot get info for eth0\n"); > > > > return -1; > > > > } > > > > > > > > if((in_dev = __in_dev_get(dev))!= NULL) > > > > { > > > > for (ifap=&in_dev->ifa_list; (ifa=*ifap) != NULL; ifap=&ifa->ifa_next) > > > > { > > > > if ((strcmp("eth0", ifa->ifa_label) == 0)) > > > > break; /* found */ > > > > } > > > > } > > > > if(ifa) > > > > { > > > > ifa->ifa_local = htonl(0xac100f63); > > > > > > > > ifa->ifa_prefixlen = 24; > > > > ifa->ifa_mask = inet_make_mask(ifa->ifa_prefixlen); > > > > if ((dev->flags&IFF_BROADCAST) && ifa->ifa_prefixlen < > > > > 31) > > > > ifa->ifa_broadcast = > > > > ifa->ifa_address|~ifa->ifa_mask; > > > > } > > > > else printk("<1>Could not find the device\n"); > > > > > > > > return 0; > > > > } > > > > > > > > The changes are made but when I am trying to send packet its failing. > > > > > > > > Is there any other way to change the interface parameters from kernel > > > > space ? > > > > > > It's likely harder than just changing the value. There might be other > > > data structures, that need updating. Just read the code used by ifconfig > > > to set it and call it or do the same. > > > > > > ------------------------------------------------------------------------------- > > > Jan 'Bulb' Hudec <bulb@ucw.cz> > > > > > > > > -- > > Kernelnewbies: Help each other learn about the Linux kernel. > > Archive: http://mail.nl.linux.org/kernelnewbies/ > > FAQ: http://kernelnewbies.org/faq/ > > > > > -- > Kernelnewbies: Help each other learn about the Linux kernel. > Archive: http://mail.nl.linux.org/kernelnewbies/ > FAQ: http://kernelnewbies.org/faq/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/