]>
Commit | Line | Data |
---|---|---|
02fff96a NA |
1 | #include <linux/kernel.h> |
2 | #include <linux/module.h> | |
3 | #include <linux/netdevice.h> | |
4 | ||
5 | #include "notifier-error-inject.h" | |
6 | ||
7 | static int priority; | |
8 | module_param(priority, int, 0); | |
9 | MODULE_PARM_DESC(priority, "specify netdevice notifier priority"); | |
10 | ||
11 | static struct notifier_err_inject netdev_notifier_err_inject = { | |
12 | .actions = { | |
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 | {} | |
22 | } | |
23 | }; | |
24 | ||
25 | static struct dentry *dir; | |
26 | ||
27 | static int netdev_err_inject_init(void) | |
28 | { | |
29 | int err; | |
30 | ||
31 | dir = notifier_err_inject_init("netdev", notifier_err_inject_dir, | |
32 | &netdev_notifier_err_inject, priority); | |
33 | if (IS_ERR(dir)) | |
34 | return PTR_ERR(dir); | |
35 | ||
36 | err = register_netdevice_notifier(&netdev_notifier_err_inject.nb); | |
37 | if (err) | |
38 | debugfs_remove_recursive(dir); | |
39 | ||
40 | return err; | |
41 | } | |
42 | ||
43 | static void netdev_err_inject_exit(void) | |
44 | { | |
45 | unregister_netdevice_notifier(&netdev_notifier_err_inject.nb); | |
46 | debugfs_remove_recursive(dir); | |
47 | } | |
48 | ||
49 | module_init(netdev_err_inject_init); | |
50 | module_exit(netdev_err_inject_exit); | |
51 | ||
52 | MODULE_DESCRIPTION("Netdevice notifier error injection module"); | |
53 | MODULE_LICENSE("GPL"); | |
54 | MODULE_AUTHOR("Nikolay Aleksandrov <razor@blackwall.org>"); |