Back to home page

LXR

 
 

    


0001 /*
0002  * Kernel module for testing static keys.
0003  *
0004  * Copyright 2015 Akamai Technologies Inc. All Rights Reserved
0005  *
0006  * Authors:
0007  *      Jason Baron       <jbaron@akamai.com>
0008  *
0009  * This software is licensed under the terms of the GNU General Public
0010  * License version 2, as published by the Free Software Foundation, and
0011  * may be copied, distributed, and modified under those terms.
0012  *
0013  * This program is distributed in the hope that it will be useful,
0014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0016  * GNU General Public License for more details.
0017  */
0018 
0019 #include <linux/module.h>
0020 #include <linux/jump_label.h>
0021 
0022 /* old keys */
0023 struct static_key base_old_true_key = STATIC_KEY_INIT_TRUE;
0024 EXPORT_SYMBOL_GPL(base_old_true_key);
0025 struct static_key base_inv_old_true_key = STATIC_KEY_INIT_TRUE;
0026 EXPORT_SYMBOL_GPL(base_inv_old_true_key);
0027 struct static_key base_old_false_key = STATIC_KEY_INIT_FALSE;
0028 EXPORT_SYMBOL_GPL(base_old_false_key);
0029 struct static_key base_inv_old_false_key = STATIC_KEY_INIT_FALSE;
0030 EXPORT_SYMBOL_GPL(base_inv_old_false_key);
0031 
0032 /* new keys */
0033 DEFINE_STATIC_KEY_TRUE(base_true_key);
0034 EXPORT_SYMBOL_GPL(base_true_key);
0035 DEFINE_STATIC_KEY_TRUE(base_inv_true_key);
0036 EXPORT_SYMBOL_GPL(base_inv_true_key);
0037 DEFINE_STATIC_KEY_FALSE(base_false_key);
0038 EXPORT_SYMBOL_GPL(base_false_key);
0039 DEFINE_STATIC_KEY_FALSE(base_inv_false_key);
0040 EXPORT_SYMBOL_GPL(base_inv_false_key);
0041 
0042 static void invert_key(struct static_key *key)
0043 {
0044     if (static_key_enabled(key))
0045         static_key_disable(key);
0046     else
0047         static_key_enable(key);
0048 }
0049 
0050 static int __init test_static_key_base_init(void)
0051 {
0052     invert_key(&base_inv_old_true_key);
0053     invert_key(&base_inv_old_false_key);
0054     invert_key(&base_inv_true_key.key);
0055     invert_key(&base_inv_false_key.key);
0056 
0057     return 0;
0058 }
0059 
0060 static void __exit test_static_key_base_exit(void)
0061 {
0062 }
0063 
0064 module_init(test_static_key_base_init);
0065 module_exit(test_static_key_base_exit);
0066 
0067 MODULE_AUTHOR("Jason Baron <jbaron@akamai.com>");
0068 MODULE_LICENSE("GPL");