All of lore.kernel.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH] batman-adv: export compatibility version via debugfs
@ 2012-10-03 16:35 Antonio Quartulli
  2012-10-03 17:06 ` Marek Lindner
  0 siblings, 1 reply; 4+ messages in thread
From: Antonio Quartulli @ 2012-10-03 16:35 UTC (permalink / raw)
  To: b.a.t.m.a.n

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
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: export compatibility version via debugfs
  2012-10-03 16:35 [B.A.T.M.A.N.] [PATCH] batman-adv: export compatibility version via debugfs Antonio Quartulli
@ 2012-10-03 17:06 ` Marek Lindner
  2012-10-03 21:18   ` Antonio Quartulli
  0 siblings, 1 reply; 4+ messages in thread
From: Marek Lindner @ 2012-10-03 17:06 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Thursday, October 04, 2012 00:35:36 Antonio Quartulli wrote:
> @@ -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;
>  }

If we start to create more files here you should add a a loop like in 
batadv_debugfs_add_meshif() to avoid duplicate code.

Cheers,
Marek

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: export compatibility version via debugfs
  2012-10-03 17:06 ` Marek Lindner
@ 2012-10-03 21:18   ` Antonio Quartulli
  2012-10-06 16:43     ` Marek Lindner
  0 siblings, 1 reply; 4+ messages in thread
From: Antonio Quartulli @ 2012-10-03 21:18 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

[-- Attachment #1: Type: text/plain, Size: 1233 bytes --]

On Thu, Oct 04, 2012 at 01:06:55AM +0800, Marek Lindner wrote:
> On Thursday, October 04, 2012 00:35:36 Antonio Quartulli wrote:
> > @@ -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;
> >  }
> 
> If we start to create more files here you should add a a loop like in 
> batadv_debugfs_add_meshif() to avoid duplicate code.

do you think we should do that for two files already?
I do not think there will be so much to add in this debugfs folder. Maybe
we can add a loop as soon as add the next one, but for two I think we can still
leave with this implementation.

Don't you think so?

Cheers,

-- 
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: export compatibility version via debugfs
  2012-10-03 21:18   ` Antonio Quartulli
@ 2012-10-06 16:43     ` Marek Lindner
  0 siblings, 0 replies; 4+ messages in thread
From: Marek Lindner @ 2012-10-06 16:43 UTC (permalink / raw)
  To: The list for a Better Approach To Mobile Ad-hoc Networking

On Thursday, October 04, 2012 05:18:00 Antonio Quartulli wrote:
> On Thu, Oct 04, 2012 at 01:06:55AM +0800, Marek Lindner wrote:
> > On Thursday, October 04, 2012 00:35:36 Antonio Quartulli wrote:
> > > @@ -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;
> > >  
> > >  }
> > 
> > If we start to create more files here you should add a a loop like in
> > batadv_debugfs_add_meshif() to avoid duplicate code.
> 
> do you think we should do that for two files already?
> I do not think there will be so much to add in this debugfs folder. Maybe
> we can add a loop as soon as add the next one, but for two I think we can
> still leave with this implementation.

Well, when I added the 'routing_algos' file I also thought nobody else would 
want to add something there ... 

Cheers,
Marek


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-10-06 16:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-03 16:35 [B.A.T.M.A.N.] [PATCH] batman-adv: export compatibility version via debugfs Antonio Quartulli
2012-10-03 17:06 ` Marek Lindner
2012-10-03 21:18   ` Antonio Quartulli
2012-10-06 16:43     ` Marek Lindner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.