Skip to content

Commit cb1c92e

Browse files
Simon Wunderlichordex
authored andcommitted
batman-adv: add debugfs support to view multiif tables
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>
1 parent 5bc7c1e commit cb1c92e

5 files changed

Lines changed: 73 additions & 7 deletions

File tree

‎net/batman-adv/bat_iv_ogm.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,9 +1777,11 @@ batadv_iv_ogm_orig_print_neigh(struct batadv_orig_node *orig_node,
17771777
* batadv_iv_ogm_orig_print - print the originator table
17781778
* @bat_priv: the bat priv with all the soft interface information
17791779
* @seq: debugfs table seq_file struct
1780+
* @if_outgoing: the outgoing interface for which this should be printed
17801781
*/
17811782
static void batadv_iv_ogm_orig_print(struct batadv_priv *bat_priv,
1782-
struct seq_file *seq)
1783+
struct seq_file *seq,
1784+
struct batadv_hard_iface *if_outgoing)
17831785
{
17841786
struct batadv_neigh_node *neigh_node;
17851787
struct batadv_hashtable *hash = bat_priv->orig_hash;
@@ -1801,12 +1803,12 @@ static void batadv_iv_ogm_orig_print(struct batadv_priv *bat_priv,
18011803
rcu_read_lock();
18021804
hlist_for_each_entry_rcu(orig_node, head, hash_entry) {
18031805
neigh_node = batadv_orig_router_get(orig_node,
1804-
BATADV_IF_DEFAULT);
1806+
if_outgoing);
18051807
if (!neigh_node)
18061808
continue;
18071809

18081810
n_ifinfo = batadv_neigh_ifinfo_get(neigh_node,
1809-
BATADV_IF_DEFAULT);
1811+
if_outgoing);
18101812
if (!n_ifinfo)
18111813
goto next;
18121814

@@ -1824,8 +1826,8 @@ static void batadv_iv_ogm_orig_print(struct batadv_priv *bat_priv,
18241826
neigh_node->addr,
18251827
neigh_node->if_incoming->net_dev->name);
18261828

1827-
batadv_iv_ogm_orig_print_neigh(orig_node,
1828-
BATADV_IF_DEFAULT, seq);
1829+
batadv_iv_ogm_orig_print_neigh(orig_node, if_outgoing,
1830+
seq);
18291831
seq_puts(seq, "\n");
18301832
batman_count++;
18311833

‎net/batman-adv/debugfs.c‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,19 @@ static int batadv_originators_open(struct inode *inode, struct file *file)
248248
return single_open(file, batadv_orig_seq_print_text, net_dev);
249249
}
250250

251+
/**
252+
* batadv_originators_hardif_open - handles debugfs output for the
253+
* originator table of an hard interface
254+
* @inode: inode pointer to debugfs file
255+
* @file: pointer to the seq_file
256+
*/
257+
static int batadv_originators_hardif_open(struct inode *inode,
258+
struct file *file)
259+
{
260+
struct net_device *net_dev = (struct net_device *)inode->i_private;
261+
return single_open(file, batadv_orig_hardif_seq_print_text, net_dev);
262+
}
263+
251264
static int batadv_gateways_open(struct inode *inode, struct file *file)
252265
{
253266
struct net_device *net_dev = (struct net_device *)inode->i_private;
@@ -383,8 +396,11 @@ struct batadv_debuginfo batadv_hardif_debuginfo_##_name = { \
383396
.release = single_release, \
384397
}, \
385398
};
399+
static BATADV_HARDIF_DEBUGINFO(originators, S_IRUGO,
400+
batadv_originators_hardif_open);
386401

387402
static struct batadv_debuginfo *batadv_hardif_debuginfos[] = {
403+
&batadv_hardif_debuginfo_originators,
388404
NULL,
389405
};
390406

‎net/batman-adv/originator.c‎

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,11 +940,57 @@ int batadv_orig_seq_print_text(struct seq_file *seq, void *offset)
940940
return 0;
941941
}
942942

943-
bat_priv->bat_algo_ops->bat_orig_print(bat_priv, seq);
943+
bat_priv->bat_algo_ops->bat_orig_print(bat_priv, seq,
944+
BATADV_IF_DEFAULT);
944945

945946
return 0;
946947
}
947948

949+
/**
950+
* batadv_orig_hardif_seq_print_text - writes originator infos for a specific
951+
* outgoing interface
952+
* @seq: debugfs table seq_file struct
953+
* @offset: not used
954+
*
955+
* Returns 0
956+
*/
957+
int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset)
958+
{
959+
struct net_device *net_dev = (struct net_device *)seq->private;
960+
struct batadv_hard_iface *hard_iface;
961+
struct batadv_priv *bat_priv;
962+
963+
hard_iface = batadv_hardif_get_by_netdev(net_dev);
964+
965+
if (!hard_iface || !hard_iface->soft_iface) {
966+
seq_puts(seq, "Interface not known to B.A.T.M.A.N.\n");
967+
goto out;
968+
}
969+
970+
bat_priv = netdev_priv(hard_iface->soft_iface);
971+
if (!bat_priv->bat_algo_ops->bat_orig_print) {
972+
seq_puts(seq,
973+
"No printing function for this routing protocol\n");
974+
goto out;
975+
}
976+
977+
if (hard_iface->if_status != BATADV_IF_ACTIVE) {
978+
seq_puts(seq, "Interface not active\n");
979+
goto out;
980+
}
981+
982+
seq_printf(seq, "[B.A.T.M.A.N. adv %s, IF/MAC: %s/%pM (%s %s)]\n",
983+
BATADV_SOURCE_VERSION, hard_iface->net_dev->name,
984+
hard_iface->net_dev->dev_addr,
985+
hard_iface->soft_iface->name, bat_priv->bat_algo_ops->name);
986+
987+
bat_priv->bat_algo_ops->bat_orig_print(bat_priv, seq, hard_iface);
988+
989+
out:
990+
batadv_hardif_free_ref(hard_iface);
991+
return 0;
992+
}
993+
948994
int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
949995
int max_if_num)
950996
{

‎net/batman-adv/originator.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ batadv_orig_ifinfo_new(struct batadv_orig_node *orig_node,
5353
void batadv_orig_ifinfo_free_ref(struct batadv_orig_ifinfo *orig_ifinfo);
5454

5555
int batadv_orig_seq_print_text(struct seq_file *seq, void *offset);
56+
int batadv_orig_hardif_seq_print_text(struct seq_file *seq, void *offset);
5657
int batadv_orig_hash_add_if(struct batadv_hard_iface *hard_iface,
5758
int max_if_num);
5859
int batadv_orig_hash_del_if(struct batadv_hard_iface *hard_iface,

‎net/batman-adv/types.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,8 @@ struct batadv_algo_ops {
10831083
struct batadv_neigh_node *neigh2,
10841084
struct batadv_hard_iface *if_outgoing2);
10851085
/* orig_node handling API */
1086-
void (*bat_orig_print)(struct batadv_priv *priv, struct seq_file *seq);
1086+
void (*bat_orig_print)(struct batadv_priv *priv, struct seq_file *seq,
1087+
struct batadv_hard_iface *hard_iface);
10871088
void (*bat_orig_free)(struct batadv_orig_node *orig_node);
10881089
int (*bat_orig_add_if)(struct batadv_orig_node *orig_node,
10891090
int max_if_num);

0 commit comments

Comments
 (0)