public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: support array of debugfs general attributes
@ 2012-10-14 20:03 Antonio Quartulli
  2012-10-14 20:03 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: export compatibility version via debugfs Antonio Quartulli
  2012-10-16  0:08 ` [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: support array of debugfs general attributes Sven Eckelmann
  0 siblings, 2 replies; 6+ messages in thread
From: Antonio Quartulli @ 2012-10-14 20:03 UTC (permalink / raw)
  To: b.a.t.m.a.n

This patch adds support for an array of debugfs general (not soft_iface
specific) attributes. With this change it will be possible to add more general
attributes by simply appending them to the array without touching the rest of
the code.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 debugfs.c | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/debugfs.c b/debugfs.c
index 61c7d4d..43e0fde 100644
--- a/debugfs.c
+++ b/debugfs.c
@@ -328,7 +328,17 @@ struct batadv_debuginfo batadv_debuginfo_##_name = {	\
 		}					\
 };
 
+/* the following attributes are general and therefore they will be directly
+ * placed in the BATADV_DEBUGFS_SUBDIR subdirectory of debugfs
+ */
 static BATADV_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open);
+
+static struct batadv_debuginfo *batadv_general_debuginfos[] = {
+	&batadv_debuginfo_routing_algos,
+	NULL,
+};
+
+/* The following attributes are per soft interface */
 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,
@@ -363,7 +373,7 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = {
 
 void batadv_debugfs_init(void)
 {
-	struct batadv_debuginfo *bat_debug;
+	struct batadv_debuginfo **bat_debug;
 	struct dentry *file;
 
 	batadv_debugfs = debugfs_create_dir(BATADV_DEBUGFS_SUBDIR, NULL);
@@ -371,17 +381,23 @@ void batadv_debugfs_init(void)
 		batadv_debugfs = NULL;
 
 	if (!batadv_debugfs)
-		goto out;
+		goto err;
 
-	bat_debug = &batadv_debuginfo_routing_algos;
-	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);
+	for (bat_debug = batadv_general_debuginfos; *bat_debug; ++bat_debug) {
+		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 general debugfs file: %s\n",
+			       ((*bat_debug)->attr).name);
+			goto err;
+		}
+	}
 
-out:
 	return;
+err:
+	debugfs_remove_recursive(batadv_debugfs);
 }
 
 void batadv_debugfs_destroy(void)
-- 
1.7.12.3


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

* [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: export compatibility version via debugfs
  2012-10-14 20:03 [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: support array of debugfs general attributes Antonio Quartulli
@ 2012-10-14 20:03 ` Antonio Quartulli
  2012-10-14 20:05   ` Antonio Quartulli
  2012-10-16  0:09   ` Sven Eckelmann
  2012-10-16  0:08 ` [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: support array of debugfs general attributes Sven Eckelmann
  1 sibling, 2 replies; 6+ messages in thread
From: Antonio Quartulli @ 2012-10-14 20:03 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 | 12 ++++++++++++
 main.c    | 12 ++++++++++++
 main.h    |  1 +
 3 files changed, 25 insertions(+)

diff --git a/debugfs.c b/debugfs.c
index 43e0fde..57eddc6 100644
--- a/debugfs.c
+++ b/debugfs.c
@@ -245,6 +245,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;
@@ -332,9 +342,11 @@ struct batadv_debuginfo batadv_debuginfo_##_name = {	\
  * placed in the BATADV_DEBUGFS_SUBDIR subdirectory of debugfs
  */
 static BATADV_DEBUGINFO(routing_algos, S_IRUGO, batadv_algorithms_open);
+static BATADV_DEBUGINFO(compat_version, S_IRUGO, batadv_compat_open);
 
 static struct batadv_debuginfo *batadv_general_debuginfos[] = {
 	&batadv_debuginfo_routing_algos,
+	&batadv_debuginfo_compat_version,
 	NULL,
 };
 
diff --git a/main.c b/main.c
index dc33a0c..53dedbf 100644
--- a/main.c
+++ b/main.c
@@ -420,6 +420,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 4d92ce6..2dfcf8c 100644
--- a/main.h
+++ b/main.h
@@ -176,6 +176,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.3


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

* Re: [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: export compatibility version via debugfs
  2012-10-14 20:03 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: export compatibility version via debugfs Antonio Quartulli
@ 2012-10-14 20:05   ` Antonio Quartulli
  2012-10-16  0:09   ` Sven Eckelmann
  1 sibling, 0 replies; 6+ messages in thread
From: Antonio Quartulli @ 2012-10-14 20:05 UTC (permalink / raw)
  To: b.a.t.m.a.n

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

On Sun, Oct 14, 2012 at 10:03:01PM +0200, Antonio Quartulli wrote:
> 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>

2/2 intended to be v2 of a patch with the same name sent some days
ago over the ml. This PATCHv2 is based on the array of general attributes
introduced with 1/2.

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] 6+ messages in thread

* Re: [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: support array of debugfs general attributes
  2012-10-14 20:03 [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: support array of debugfs general attributes Antonio Quartulli
  2012-10-14 20:03 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: export compatibility version via debugfs Antonio Quartulli
@ 2012-10-16  0:08 ` Sven Eckelmann
  1 sibling, 0 replies; 6+ messages in thread
From: Sven Eckelmann @ 2012-10-16  0:08 UTC (permalink / raw)
  To: b.a.t.m.a.n

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

On Sunday 14 October 2012 22:03:00 Antonio Quartulli wrote:
> This patch adds support for an array of debugfs general (not soft_iface
> specific) attributes. With this change it will be possible to add more
> general attributes by simply appending them to the array without touching
> the rest of the code.
> 
> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
> ---

Acked-by: Sven Eckelmann <sven@narfation.org>

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: export compatibility version via debugfs
  2012-10-14 20:03 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: export compatibility version via debugfs Antonio Quartulli
  2012-10-14 20:05   ` Antonio Quartulli
@ 2012-10-16  0:09   ` Sven Eckelmann
  2012-10-16  6:07     ` Antonio Quartulli
  1 sibling, 1 reply; 6+ messages in thread
From: Sven Eckelmann @ 2012-10-16  0:09 UTC (permalink / raw)
  To: b.a.t.m.a.n

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

On Sunday 14 October 2012 22:03:01 Antonio Quartulli wrote:
> 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>
> ---
[...]
> +/**
> + * 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;
> +}
> +

seq is not used? Marek also segfaulted after reading this.

Kind regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: export compatibility version via debugfs
  2012-10-16  0:09   ` Sven Eckelmann
@ 2012-10-16  6:07     ` Antonio Quartulli
  0 siblings, 0 replies; 6+ messages in thread
From: Antonio Quartulli @ 2012-10-16  6:07 UTC (permalink / raw)
  To: Sven Eckelmann; +Cc: b.a.t.m.a.n

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

On Tue, Oct 16, 2012 at 02:09:23AM +0200, Sven Eckelmann wrote:
> On Sunday 14 October 2012 22:03:01 Antonio Quartulli wrote:
> > 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>
> > ---
> [...]
> > +/**
> > + * 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;
> > +}
> > +
> 
> seq is not used? Marek also segfaulted after reading this.

You, know..when you really don't know what to write in the kernel doc...!!
I'm going to change it :-)

Thanks Sven,

p.s. please reboot Marek

-- 
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] 6+ messages in thread

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

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-14 20:03 [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: support array of debugfs general attributes Antonio Quartulli
2012-10-14 20:03 ` [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: export compatibility version via debugfs Antonio Quartulli
2012-10-14 20:05   ` Antonio Quartulli
2012-10-16  0:09   ` Sven Eckelmann
2012-10-16  6:07     ` Antonio Quartulli
2012-10-16  0:08 ` [B.A.T.M.A.N.] [PATCH 1/2] batman-adv: support array of debugfs general attributes Sven Eckelmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox