cgroup: implement cgroup v2 thread support
[linux/fpc-iii.git] / lib / netdev-notifier-error-inject.c
blob13e9c62e216ff010bcace555da96daabb708fe67
1 #include <linux/kernel.h>
2 #include <linux/module.h>
3 #include <linux/netdevice.h>
5 #include "notifier-error-inject.h"
7 static int priority;
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 = {
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 { NOTIFIER_ERR_INJECT_ACTION(NETDEV_CHANGEUPPER) },
26 static struct dentry *dir;
28 static int netdev_err_inject_init(void)
30 int err;
32 dir = notifier_err_inject_init("netdev", notifier_err_inject_dir,
33 &netdev_notifier_err_inject, priority);
34 if (IS_ERR(dir))
35 return PTR_ERR(dir);
37 err = register_netdevice_notifier(&netdev_notifier_err_inject.nb);
38 if (err)
39 debugfs_remove_recursive(dir);
41 return err;
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>");