batman-adv: allowing changing the routing algorithm via module parameter
authorMarek Lindner <lindner_marek@yahoo.de>
Sat, 10 Dec 2011 11:45:53 +0000 (19:45 +0800)
committerMarek Lindner <lindner_marek@yahoo.de>
Thu, 16 Feb 2012 18:50:20 +0000 (02:50 +0800)
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
net/batman-adv/main.c

index bcc2bddd893af6e4e8e819db13906d7ae92da6a6..8ae497b26bd839180eecb38cb2e8741e16f193a0 100644 (file)
@@ -256,6 +256,30 @@ int bat_algo_seq_print_text(struct seq_file *seq, void *offset)
        return 0;
 }
 
+static int param_set_ra(const char *val, const struct kernel_param *kp)
+{
+       struct bat_algo_ops *bat_algo_ops;
+
+       bat_algo_ops = bat_algo_get((char *)val);
+       if (!bat_algo_ops) {
+               pr_err("Routing algorithm '%s' is not supported\n", val);
+               return -EINVAL;
+       }
+
+       return param_set_copystring(val, kp);
+}
+
+static const struct kernel_param_ops param_ops_ra = {
+       .set = param_set_ra,
+       .get = param_get_string,
+};
+
+static struct kparam_string __param_string_ra = {
+       .maxlen = sizeof(bat_routing_algo),
+       .string = bat_routing_algo,
+};
+
+module_param_cb(routing_algo, &param_ops_ra, &__param_string_ra, 0644);
 module_init(batman_init);
 module_exit(batman_exit);