]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
batman-adv: add debugfs support to view multiif tables
authorSimon Wunderlich <simon@open-mesh.com>
Thu, 21 Nov 2013 10:52:16 +0000 (11:52 +0100)
committerAntonio Quartulli <antonio@meshcoding.com>
Sun, 12 Jan 2014 13:41:16 +0000 (14:41 +0100)
Show tables for the multi interface operation. Originator tables
are added per hard interface.

This patch also changes the API by adding the interface to the
bat_orig_print() parameters.

Signed-off-by: Simon Wunderlich <simon@open-mesh.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
net/batman-adv/bat_iv_ogm.c
net/batman-adv/debugfs.c
net/batman-adv/originator.c
net/batman-adv/originator.h
net/batman-adv/types.h

index a9b7e82feb31195460c714a0b5ca7f6d132291bb..fb196a07812c287c69a2f5eb453a1fe9da4a54f8 100644 (file)
@@ -1777,9 +1777,11 @@ batadv_iv_ogm_orig_print_neigh(struct batadv_orig_node *orig_node,
  * batadv_iv_ogm_orig_print - print the originator table
  * @bat_priv: the bat priv with all the soft interface information
  * @seq: debugfs table seq_file struct
+ * @if_outgoing: the outgoing interface for which this should be printed
  */
 static void batadv_iv_ogm_orig_print(struct batadv_priv *bat_priv,
-                                    struct seq_file *seq)
+                                    struct seq_file *seq,
+                                    struct batadv_hard_iface *if_outgoing)
 {
        struct batadv_neigh_node *neigh_node;
        struct batadv_hashtable *hash = bat_priv->orig_hash;
@@ -1801,12 +1803,12 @@ static void batadv_iv_ogm_orig_print(struct batadv_priv *bat_priv,
                rcu_read_lock();
                hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
                        neigh_node = batadv_orig_router_get(orig_node,
-                                                           BATADV_IF_DEFAULT);
+                                                           if_outgoing);
                        if (!neigh_node)
                                continue;
 
                        n_ifinfo = batadv_neigh_ifinfo_get(neigh_node,
-                                                          BATADV_IF_DEFAULT);
+                                                          if_outgoing);
                        if (!n_ifinfo)
                                goto next;
 
@@ -1824,8 +1826,8 @@ static void batadv_iv_ogm_orig_print(struct batadv_priv *bat_priv,
                                   neigh_node->addr,
                                   neigh_node->if_incoming->net_dev->name);
 
-                       batadv_iv_ogm_orig_print_neigh(orig_node,
-                                                      BATADV_IF_DEFAULT, seq);
+                       batadv_iv_ogm_orig_print_neigh(orig_node, if_outgoing,
+                                                      seq);
                        seq_puts(seq, "\n");
                        batman_count++;
 
index 2ea36952139aefbb92e8f03afcbd9ee890452b4b..26cbf34fca03d3baa583913467623b6270ab6379 100644 (file)
@@ -248,6 +248,19 @@ static int batadv_originators_open(struct inode *inode, struct file *file)
        return single_open(file, batadv_orig_seq_print_text, net_dev);
 }
 
+/**
+ * batadv_originators_hardif_open - handles debugfs output for the
+ *  originator table of an hard interface
+ * @inode: inode pointer to debugfs file
+ * @file: pointer to the seq_file
+ */
+static int batadv_originators_hardif_open(struct inode *inode,
+                                         struct file *file)
+{
+       struct net_device *net_dev = (struct net_device *)inode->i_private;
+       return single_open(file, batadv_orig_hardif_seq_print_text, net_dev);
+}
+
 static int batadv_gateways_open(struct inode *inode, struct file *file)
 {
        struct net_device *net_dev = (struct net_device *)inode->i_private;
@@ -383,8 +396,11 @@ struct batadv_debuginfo batadv_hardif_debuginfo_##_name = {        \
                .release = single_release,                      \
        },                                                      \
 };
+static BATADV_HARDIF_DEBUGINFO(originators, S_IRUGO,
+                              batadv_originators_hardif_open);
 
 static struct batadv_debuginfo *batadv_hardif_debuginfos[] = {
+       &batadv_hardif_debuginfo_originators,
        NULL,
 };
 
index bd887809f08e07afac085440a0fe7d0bfecb35f2..5ed037fab1843cad6df553710636418bbe862580 100644 (file)
@@ -940,11 +940,57 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
                return 0;
        }
 
-       bat_priv->bat_algo_ops->bat_orig_print(bat_priv, seq);
+       bat_priv->bat_algo_ops->bat_orig_print(bat_priv, seq,
+                                              BATADV_IF_DEFAULT);
 
        return 0;
 }
 
+/**
+ * batadv_orig_hardif_seq_print_text - writes originator infos for a specific
+ *  outgoing interface
+ * @seq: debugfs table seq_file struct
+ * @offset: not used
+ *
+ * Returns 0
+ */
+int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset)
+{
+       struct net_device *net_dev = (struct net_device *)seq->private;
+       struct batadv_hard_iface *hard_iface;
+       struct batadv_priv *bat_priv;
+
+       hard_iface = batadv_hardif_get_by_netdev(net_dev);
+
+       if (!hard_iface || !hard_iface->soft_iface) {
+               seq_puts(seq, "Interface not known to B.A.T.M.A.N.\n");
+               goto out;
+       }
+
+       bat_priv = netdev_priv(hard_iface->soft_iface);
+       if (!bat_priv->bat_algo_ops->bat_orig_print) {
+               seq_puts(seq,
+                        "No printing function for this routing protocol\n");
+               goto out;
+       }
+
+       if (hard_iface->if_status != BATADV_IF_ACTIVE) {
+               seq_puts(seq, "Interface not active\n");
+               goto out;
+       }
+
+       seq_printf(seq, "[B.A.T.M.A.N. adv %s, IF/MAC: %s/%pM (%s %s)]\n",
+                  BATADV_SOURCE_VERSION, hard_iface->net_dev->name,
+                  hard_iface->net_dev->dev_addr,
+                  hard_iface->soft_iface->name, bat_priv->bat_algo_ops->name);
+
+       bat_priv->bat_algo_ops->bat_orig_print(bat_priv, seq, hard_iface);
+
+out:
+       batadv_hardif_free_ref(hard_iface);
+       return 0;
+}
+
 int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
                            int max_if_num)
 {
index 75a4d7bad620ecadeb9688f780182ab9d0dbed5c..ad17c3cb032d0947f1767824b233dc534bfc07a4 100644 (file)
@@ -53,6 +53,7 @@ batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node,
 void batadv_orig_ifinfo_free_ref(struct batadv_orig_ifinfo *orig_ifinfo);
 
 int batadv_orig_seq_print_text(struct seq_file *seq, void *offset);
+int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset);
 int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
                            int max_if_num);
 int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface,
index 529b3747a08555580bf887bd7915b8542b4445b0..8a1fa167e126fd8cc443c782da8275cdb94b27ba 100644 (file)
@@ -1083,7 +1083,8 @@ struct batadv_algo_ops {
                 struct batadv_neigh_node *neigh2,
                 struct batadv_hard_iface *if_outgoing2);
        /* orig_node handling API */
-       void (*bat_orig_print)(struct batadv_priv *priv, struct seq_file *seq);
+       void (*bat_orig_print)(struct batadv_priv *priv, struct seq_file *seq,
+                              struct batadv_hard_iface *hard_iface);
        void (*bat_orig_free)(struct batadv_orig_node *orig_node);
        int (*bat_orig_add_if)(struct batadv_orig_node *orig_node,
                               int max_if_num);