Problem in notifier chain for net device

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

 



static int edal_netdevice_event(struct notifier_block *this, unsigned long event, void *ptr)
{
 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
    //  struct net_device *dev = NULL;
     //   dev = ptr;
        switch (event)
        {
                case NETDEV_REGISTER:
                        printk(KERN_INFO"###### EDAL NET Interface is Up #######\n");
                        printk(KERN_INFO"EDAL MESSAGE: %s IS UP\n",dev->name);
                        break;
                case NETDEV_UNREGISTER:
                        printk(KERN_INFO"###### EDAL NET Interface is Down ######\n");
                        printk(KERN_INFO"EDAL MESSAGE: %s IS Down\n",dev->name);
                        break;
        }
        return 0;
}
 static struct notifier_block edal_netdevice_notifier=
{
.notifier_call = edal_netdevice_event,
.next = NULL,
.priority = 1,
};

        static struct notifier_block edal_netdevice_notifier;
static int __init initial(void)
{
        printk(KERN_INFO"This is initialisation function=%s\n",__func__);
        printk(KERN_INFO"hello kernel\n");
        register_netdevice_notifier(&edal_netdevice_notifier);
        return 0;
}
void __exit cleanup(void)
{
        printk(KERN_INFO"This is exit function=%s\n",__func__);
        printk(KERN_INFO"bye kernel\n");
        unregister_netdevice_notifier(&edal_netdevice_notifier);
}
module_init(initial);
module_exit(cleanup);

When I insmod the module it shows:
 ###### EDAL NET Interface is Up #######
[ 1315.348657] EDAL MESSAGE: lo IS UP
[ 1315.348659] ###### EDAL NET Interface is Up #######
[ 1315.348661] EDAL MESSAGE: eth0 IS UP
[ 1315.348663] ###### EDAL NET Interface is Up #######
[ 1315.348665] EDAL MESSAGE: wlan0 IS UP
 
but when I remove the Ethernet Interface It doesn't show anything but when I remove module then it shows:
[ 1171.403424] This is exit function=cleanup
[ 1171.403428] bye kernel
[ 1171.403431] ###### EDAL NET Interface is Down ######
[ 1171.403432] EDAL MESSAGE: lo IS Down
[ 1171.403434] ###### EDAL NET Interface is Down ######
[ 1171.403435] EDAL MESSAGE: eth0 IS Down
[ 1171.403437] ###### EDAL NET Interface is Down ######
[ 1171.403438] EDAL MESSAGE: wlan0 IS Down

Please help!
_______________________________________________
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