Different versions of the batman-adv module may use the same compatibility version, but this is not understandable at runtime (the only way is to parse the kernel log and fetch the batman-adv advertisement message on loading). The user may want to know whether two nodes using different versions can communicate or not. For this purpose the module has to export this value through debugfs.
Reported-by: Moritz Warning moritzwarning@web.de Signed-off-by: Antonio Quartulli ordex@autistici.org --- debugfs.c | 18 ++++++++++++++++++ main.c | 12 ++++++++++++ main.h | 1 + 3 files changed, 31 insertions(+)
diff --git a/debugfs.c b/debugfs.c index bd032bc..26349e5 100644 --- a/debugfs.c +++ b/debugfs.c @@ -244,6 +244,16 @@ static int batadv_algorithms_open(struct inode *inode, struct file *file) return single_open(file, batadv_algo_seq_print_text, NULL); }
+/** + * batadv_compat_open - Prepare file handler for printing of the compat version + * @inode: inode which was opened + * @file: file handle to be initialized + */ +static int batadv_compat_open(struct inode *inode, struct file *file) +{ + return single_open(file, batadv_compat_seq_print_text, NULL); +} + static int batadv_originators_open(struct inode *inode, struct file *file) { struct net_device *net_dev = (struct net_device *)inode->i_private; @@ -310,6 +320,7 @@ struct batadv_debuginfo batadv_debuginfo_##_name = { \ };
static BATADV_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open); +static BATADV_DEBUGINFO(compat_version, S_IRUGO, batadv_compat_open); static BATADV_DEBUGINFO(originators, S_IRUGO, batadv_originators_open); static BATADV_DEBUGINFO(gateways, S_IRUGO, batadv_gateways_open); static BATADV_DEBUGINFO(transtable_global, S_IRUGO, @@ -355,6 +366,13 @@ void batadv_debugfs_init(void) if (!file) pr_err("Can't add debugfs file: %s\n", bat_debug->attr.name);
+ bat_debug = &batadv_debuginfo_compat_version; + file = debugfs_create_file(bat_debug->attr.name, + S_IFREG | bat_debug->attr.mode, + batadv_debugfs, NULL, &bat_debug->fops); + if (!file) + pr_err("Can't add debugfs file: %s\n", bat_debug->attr.name); + out: return; } diff --git a/main.c b/main.c index f9bcfa1..b37e08f 100644 --- a/main.c +++ b/main.c @@ -411,6 +411,18 @@ int batadv_algo_seq_print_text(struct seq_file *seq, void *offset) return 0; }
+/** + * batadv_compat_seq_print_text - print the compatibility version + * @seq: not used + * @offset: not used + */ +int batadv_compat_seq_print_text(struct seq_file *seq, void *offset) +{ + seq_printf(seq, "%d\n", BATADV_COMPAT_VERSION); + + return 0; +} + static int batadv_param_set_ra(const char *val, const struct kernel_param *kp) { struct batadv_algo_ops *bat_algo_ops; diff --git a/main.h b/main.h index b45d5ad..2c5412d 100644 --- a/main.h +++ b/main.h @@ -167,6 +167,7 @@ void batadv_recv_handler_unregister(uint8_t packet_type); int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops); int batadv_algo_select(struct batadv_priv *bat_priv, char *name); int batadv_algo_seq_print_text(struct seq_file *seq, void *offset); +int batadv_compat_seq_print_text(struct seq_file *seq, void *offset);
/** * enum batadv_dbg_level - available log levels