Skip to content

Commit 536a23f

Browse files
Simon WunderlichAntonio Quartulli
authored andcommitted
batman-adv: Add the backbone gateway list to debugfs
This is especially useful if there are no claims yet, but we still want to know which gateways are using bridge loop avoidance in the network. Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
1 parent c704372 commit 536a23f

4 files changed

Lines changed: 89 additions & 3 deletions

File tree

‎Documentation/networking/batman-adv.txt‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ folder:
7575

7676
There is a special folder for debugging information:
7777

78-
# ls /sys/kernel/debug/batman_adv/bat0/
79-
# bla_claim_table log socket transtable_local
80-
# gateways originators transtable_global vis_data
78+
# ls /sys/kernel/debug/batman_adv/bat0/
79+
# bla_backbone_table log transtable_global
80+
# bla_claim_table originators transtable_local
81+
# gateways socket vis_data
8182

8283
Some of the files contain all sort of status information regard-
8384
ing the mesh network. For example, you can view the table of

‎net/batman-adv/bridge_loop_avoidance.c‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,3 +1616,68 @@ int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset)
16161616
batadv_hardif_free_ref(primary_if);
16171617
return ret;
16181618
}
1619+
1620+
int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq, void *offset)
1621+
{
1622+
struct net_device *net_dev = (struct net_device *)seq->private;
1623+
struct batadv_priv *bat_priv = netdev_priv(net_dev);
1624+
struct batadv_hashtable *hash = bat_priv->backbone_hash;
1625+
struct batadv_backbone_gw *backbone_gw;
1626+
struct batadv_hard_iface *primary_if;
1627+
struct hlist_node *node;
1628+
struct hlist_head *head;
1629+
int secs, msecs;
1630+
uint32_t i;
1631+
bool is_own;
1632+
int ret = 0;
1633+
uint8_t *primary_addr;
1634+
1635+
primary_if = batadv_primary_if_get_selected(bat_priv);
1636+
if (!primary_if) {
1637+
ret = seq_printf(seq,
1638+
"BATMAN mesh %s disabled - please specify interfaces to enable it\n",
1639+
net_dev->name);
1640+
goto out;
1641+
}
1642+
1643+
if (primary_if->if_status != BATADV_IF_ACTIVE) {
1644+
ret = seq_printf(seq,
1645+
"BATMAN mesh %s disabled - primary interface not active\n",
1646+
net_dev->name);
1647+
goto out;
1648+
}
1649+
1650+
primary_addr = primary_if->net_dev->dev_addr;
1651+
seq_printf(seq,
1652+
"Backbones announced for the mesh %s (orig %pM, group id %04x)\n",
1653+
net_dev->name, primary_addr,
1654+
ntohs(bat_priv->claim_dest.group));
1655+
seq_printf(seq, " %-17s %-5s %-9s (%-4s)\n",
1656+
"Originator", "VID", "last seen", "CRC");
1657+
for (i = 0; i < hash->size; i++) {
1658+
head = &hash->table[i];
1659+
1660+
rcu_read_lock();
1661+
hlist_for_each_entry_rcu(backbone_gw, node, head, hash_entry) {
1662+
msecs = jiffies_to_msecs(jiffies -
1663+
backbone_gw->lasttime);
1664+
secs = msecs / 1000;
1665+
msecs = msecs % 1000;
1666+
1667+
is_own = batadv_compare_eth(backbone_gw->orig,
1668+
primary_addr);
1669+
if (is_own)
1670+
continue;
1671+
1672+
seq_printf(seq,
1673+
" * %pM on % 5d % 4i.%03is (%04x)\n",
1674+
backbone_gw->orig, backbone_gw->vid,
1675+
secs, msecs, backbone_gw->crc);
1676+
}
1677+
rcu_read_unlock();
1678+
}
1679+
out:
1680+
if (primary_if)
1681+
batadv_hardif_free_ref(primary_if);
1682+
return ret;
1683+
}

‎net/batman-adv/bridge_loop_avoidance.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid);
2727
int batadv_bla_is_backbone_gw(struct sk_buff *skb,
2828
struct batadv_orig_node *orig_node, int hdr_size);
2929
int batadv_bla_claim_table_seq_print_text(struct seq_file *seq, void *offset);
30+
int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq,
31+
void *offset);
3032
int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, uint8_t *orig);
3133
int batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
3234
struct batadv_bcast_packet *bcast_packet,
@@ -65,6 +67,12 @@ static inline int batadv_bla_claim_table_seq_print_text(struct seq_file *seq,
6567
return 0;
6668
}
6769

70+
static inline int batadv_bla_backbone_table_seq_print_text(struct seq_file *seq,
71+
void *offset)
72+
{
73+
return 0;
74+
}
75+
6876
static inline int batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv,
6977
uint8_t *orig)
7078
{

‎net/batman-adv/debugfs.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,15 @@ static int batadv_bla_claim_table_open(struct inode *inode, struct file *file)
267267
return single_open(file, batadv_bla_claim_table_seq_print_text,
268268
net_dev);
269269
}
270+
271+
static int batadv_bla_backbone_table_open(struct inode *inode,
272+
struct file *file)
273+
{
274+
struct net_device *net_dev = (struct net_device *)inode->i_private;
275+
return single_open(file, batadv_bla_backbone_table_seq_print_text,
276+
net_dev);
277+
}
278+
270279
#endif
271280

272281
static int batadv_transtable_local_open(struct inode *inode, struct file *file)
@@ -305,6 +314,8 @@ static BATADV_DEBUGINFO(transtable_global, S_IRUGO,
305314
batadv_transtable_global_open);
306315
#ifdef CONFIG_BATMAN_ADV_BLA
307316
static BATADV_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open);
317+
static BATADV_DEBUGINFO(bla_backbone_table, S_IRUGO,
318+
batadv_bla_backbone_table_open);
308319
#endif
309320
static BATADV_DEBUGINFO(transtable_local, S_IRUGO,
310321
batadv_transtable_local_open);
@@ -316,6 +327,7 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = {
316327
&batadv_debuginfo_transtable_global,
317328
#ifdef CONFIG_BATMAN_ADV_BLA
318329
&batadv_debuginfo_bla_claim_table,
330+
&batadv_debuginfo_bla_backbone_table,
319331
#endif
320332
&batadv_debuginfo_transtable_local,
321333
&batadv_debuginfo_vis_data,

0 commit comments

Comments
 (0)