1 #include <linux/kernel.h>
2 #include <linux/module.h>
3 #include <linux/netdevice.h>
5 #include "notifier-error-inject.h"
8 module_param(priority
, int, 0);
9 MODULE_PARM_DESC(priority
, "specify netdevice notifier priority");
11 static struct notifier_err_inject netdev_notifier_err_inject
= {
13 { NOTIFIER_ERR_INJECT_ACTION(NETDEV_REGISTER
) },
14 { NOTIFIER_ERR_INJECT_ACTION(NETDEV_CHANGEMTU
) },
15 { NOTIFIER_ERR_INJECT_ACTION(NETDEV_CHANGENAME
) },
16 { NOTIFIER_ERR_INJECT_ACTION(NETDEV_PRE_UP
) },
17 { NOTIFIER_ERR_INJECT_ACTION(NETDEV_PRE_TYPE_CHANGE
) },
18 { NOTIFIER_ERR_INJECT_ACTION(NETDEV_POST_INIT
) },
19 { NOTIFIER_ERR_INJECT_ACTION(NETDEV_PRECHANGEMTU
) },
20 { NOTIFIER_ERR_INJECT_ACTION(NETDEV_PRECHANGEUPPER
) },
21 { NOTIFIER_ERR_INJECT_ACTION(NETDEV_CHANGEUPPER
) },
26 static struct dentry
*dir
;
28 static int netdev_err_inject_init(void)
32 dir
= notifier_err_inject_init("netdev", notifier_err_inject_dir
,
33 &netdev_notifier_err_inject
, priority
);
37 err
= register_netdevice_notifier(&netdev_notifier_err_inject
.nb
);
39 debugfs_remove_recursive(dir
);
44 static void netdev_err_inject_exit(void)
46 unregister_netdevice_notifier(&netdev_notifier_err_inject
.nb
);
47 debugfs_remove_recursive(dir
);
50 module_init(netdev_err_inject_init
);
51 module_exit(netdev_err_inject_exit
);
53 MODULE_DESCRIPTION("Netdevice notifier error injection module");
54 MODULE_LICENSE("GPL");
55 MODULE_AUTHOR("Nikolay Aleksandrov <razor@blackwall.org>");