Re: Kernelnewbies Digest, Vol 79, Issue 18

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 21, 2017 at 12:35:54PM +0200, wiktoria.lewicka wrote:
> Thank you all, I make some changes in my code, but its still not work. When my module is loading and loading I have a problems with connection with Internet- is it a matter of configuration?
> My changes:
>
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/init.h>
> #include <linux/netdevice.h>
> #include <linux/string.h>
> #define DEV_NAME "my_dev\n"
>
> struct net_device my_netdev;
>
> int init_mdev(struct net_device *dev);
>
> struct net_device_ops nops = {
>   .ndo_init = init_mdev,
>   /*.ndo_uninit = unin_mdev,*/
> };
>
> static int __init init_dev(void)
> {
>   /*my_netdev.netdev_ops = &nops;*/
>   int result;
>   if(!(netdev_boot_setup_check(&my_netdev))){
>     printk(KERN_ERR "NETDEV: setup error");
>     return 0;
You might want to return a -1 here. Are you sure netdev_boot_setup_check()
returns 0 on *un*successful return? That's what the ! seems to suggest.
>   }
>   strcpy(my_netdev.name, DEV_NAME);
>   if((result = register_netdev(&my_netdev)))
>     printk(KERN_ERR "NETDEV: Error registering device");
>   printk("NETDEV: Device registered successfully");
Both of the printk()'s above will execute on error. How about adding braces and
returning result on error?
>   return 0;
> }
>
> static void __exit remove_dev(void)
> {
>   unregister_netdev(&my_netdev);
> }
> int init_mdev(struct net_device *dev)
> {
>   printk("INIT");
>   return 0;
> }
> module_init(init_dev);
> module_exit(remove_dev);
>

It seems that your e-mail client (the Onet WebUI) keeps malforming your
indentation. This link might come in handy:
https://www.kernel.org/doc/html/v4.10/process/email-clients.html?highlight=email,
I'm sure more people will join the discussion once your style looks more
approachable.

I'm not much into network devices myself, but could you maybe try and find which
call hangs your init function e.g. with printk()'s before each call? I believe
your net_device structure might be incomplete. Once you find the problematic
call, a cross-reference source code search engine like lxr.free-electrons.com/
could help you understand which struct net_device members might need your
attention.

Stan

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux