diff options
Diffstat (limited to 'net/batman-adv/bat_v.c')
-rw-r--r-- | net/batman-adv/bat_v.c | 247 |
1 files changed, 1 insertions, 246 deletions
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c index 0ecaf1bb0068..e4455babe4c2 100644 --- a/net/batman-adv/bat_v.c +++ b/net/batman-adv/bat_v.c @@ -13,14 +13,13 @@ #include <linux/if_ether.h> #include <linux/init.h> #include <linux/jiffies.h> -#include <linux/kernel.h> #include <linux/kref.h> #include <linux/list.h> +#include <linux/minmax.h> #include <linux/netdevice.h> #include <linux/netlink.h> #include <linux/rculist.h> #include <linux/rcupdate.h> -#include <linux/seq_file.h> #include <linux/skbuff.h> #include <linux/spinlock.h> #include <linux/stddef.h> @@ -119,92 +118,6 @@ batadv_v_hardif_neigh_init(struct batadv_hardif_neigh_node *hardif_neigh) batadv_v_elp_throughput_metric_update); } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/** - * batadv_v_orig_print_neigh() - print neighbors for the originator table - * @orig_node: the orig_node for which the neighbors are printed - * @if_outgoing: outgoing interface for these entries - * @seq: debugfs table seq_file struct - * - * Must be called while holding an rcu lock. - */ -static void -batadv_v_orig_print_neigh(struct batadv_orig_node *orig_node, - struct batadv_hard_iface *if_outgoing, - struct seq_file *seq) -{ - struct batadv_neigh_node *neigh_node; - struct batadv_neigh_ifinfo *n_ifinfo; - - hlist_for_each_entry_rcu(neigh_node, &orig_node->neigh_list, list) { - n_ifinfo = batadv_neigh_ifinfo_get(neigh_node, if_outgoing); - if (!n_ifinfo) - continue; - - seq_printf(seq, " %pM (%9u.%1u)", - neigh_node->addr, - n_ifinfo->bat_v.throughput / 10, - n_ifinfo->bat_v.throughput % 10); - - batadv_neigh_ifinfo_put(n_ifinfo); - } -} - -/** - * batadv_v_hardif_neigh_print() - print a single ELP neighbour node - * @seq: neighbour table seq_file struct - * @hardif_neigh: hardif neighbour information - */ -static void -batadv_v_hardif_neigh_print(struct seq_file *seq, - struct batadv_hardif_neigh_node *hardif_neigh) -{ - int last_secs, last_msecs; - u32 throughput; - - last_secs = jiffies_to_msecs(jiffies - hardif_neigh->last_seen) / 1000; - last_msecs = jiffies_to_msecs(jiffies - hardif_neigh->last_seen) % 1000; - throughput = ewma_throughput_read(&hardif_neigh->bat_v.throughput); - - seq_printf(seq, "%pM %4i.%03is (%9u.%1u) [%10s]\n", - hardif_neigh->addr, last_secs, last_msecs, throughput / 10, - throughput % 10, hardif_neigh->if_incoming->net_dev->name); -} - -/** - * batadv_v_neigh_print() - print the single hop neighbour list - * @bat_priv: the bat priv with all the soft interface information - * @seq: neighbour table seq_file struct - */ -static void batadv_v_neigh_print(struct batadv_priv *bat_priv, - struct seq_file *seq) -{ - struct net_device *net_dev = (struct net_device *)seq->private; - struct batadv_hardif_neigh_node *hardif_neigh; - struct batadv_hard_iface *hard_iface; - int batman_count = 0; - - seq_puts(seq, - " Neighbor last-seen ( throughput) [ IF]\n"); - - rcu_read_lock(); - list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) { - if (hard_iface->soft_iface != net_dev) - continue; - - hlist_for_each_entry_rcu(hardif_neigh, - &hard_iface->neigh_list, list) { - batadv_v_hardif_neigh_print(seq, hardif_neigh); - batman_count++; - } - } - rcu_read_unlock(); - - if (batman_count == 0) - seq_puts(seq, "No batman nodes in range ...\n"); -} -#endif - /** * batadv_v_neigh_dump_neigh() - Dump a neighbour into a message * @msg: Netlink message to dump into @@ -337,75 +250,6 @@ batadv_v_neigh_dump(struct sk_buff *msg, struct netlink_callback *cb, cb->args[1] = idx; } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/** - * batadv_v_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_v_orig_print(struct batadv_priv *bat_priv, - struct seq_file *seq, - struct batadv_hard_iface *if_outgoing) -{ - struct batadv_neigh_node *neigh_node; - struct batadv_hashtable *hash = bat_priv->orig_hash; - int last_seen_msecs, last_seen_secs; - struct batadv_orig_node *orig_node; - struct batadv_neigh_ifinfo *n_ifinfo; - unsigned long last_seen_jiffies; - struct hlist_head *head; - int batman_count = 0; - u32 i; - - seq_puts(seq, - " Originator last-seen ( throughput) Nexthop [outgoingIF]: Potential nexthops ...\n"); - - for (i = 0; i < hash->size; i++) { - head = &hash->table[i]; - - rcu_read_lock(); - hlist_for_each_entry_rcu(orig_node, head, hash_entry) { - neigh_node = batadv_orig_router_get(orig_node, - if_outgoing); - if (!neigh_node) - continue; - - n_ifinfo = batadv_neigh_ifinfo_get(neigh_node, - if_outgoing); - if (!n_ifinfo) - goto next; - - last_seen_jiffies = jiffies - orig_node->last_seen; - last_seen_msecs = jiffies_to_msecs(last_seen_jiffies); - last_seen_secs = last_seen_msecs / 1000; - last_seen_msecs = last_seen_msecs % 1000; - - seq_printf(seq, "%pM %4i.%03is (%9u.%1u) %pM [%10s]:", - orig_node->orig, last_seen_secs, - last_seen_msecs, - n_ifinfo->bat_v.throughput / 10, - n_ifinfo->bat_v.throughput % 10, - neigh_node->addr, - neigh_node->if_incoming->net_dev->name); - - batadv_v_orig_print_neigh(orig_node, if_outgoing, seq); - seq_putc(seq, '\n'); - batman_count++; - -next: - batadv_neigh_node_put(neigh_node); - if (n_ifinfo) - batadv_neigh_ifinfo_put(n_ifinfo); - } - rcu_read_unlock(); - } - - if (batman_count == 0) - seq_puts(seq, "No batman nodes in range ...\n"); -} -#endif - /** * batadv_v_orig_dump_subentry() - Dump an originator subentry into a message * @msg: Netlink message to dump into @@ -685,13 +529,6 @@ static ssize_t batadv_v_store_sel_class(struct batadv_priv *bat_priv, return count; } -static ssize_t batadv_v_show_sel_class(struct batadv_priv *bat_priv, char *buff) -{ - u32 class = atomic_read(&bat_priv->gw.sel_class); - - return sprintf(buff, "%u.%u MBit\n", class / 10, class % 10); -} - /** * batadv_v_gw_throughput_get() - retrieve the GW-bandwidth for a given GW * @gw_node: the GW to retrieve the metric for @@ -829,78 +666,6 @@ out: return ret; } -#ifdef CONFIG_BATMAN_ADV_DEBUGFS -/* fails if orig_node has no router */ -static int batadv_v_gw_write_buffer_text(struct batadv_priv *bat_priv, - struct seq_file *seq, - const struct batadv_gw_node *gw_node) -{ - struct batadv_gw_node *curr_gw; - struct batadv_neigh_node *router; - struct batadv_neigh_ifinfo *router_ifinfo = NULL; - int ret = -1; - - router = batadv_orig_router_get(gw_node->orig_node, BATADV_IF_DEFAULT); - if (!router) - goto out; - - router_ifinfo = batadv_neigh_ifinfo_get(router, BATADV_IF_DEFAULT); - if (!router_ifinfo) - goto out; - - curr_gw = batadv_gw_get_selected_gw_node(bat_priv); - - seq_printf(seq, "%s %pM (%9u.%1u) %pM [%10s]: %u.%u/%u.%u MBit\n", - (curr_gw == gw_node ? "=>" : " "), - gw_node->orig_node->orig, - router_ifinfo->bat_v.throughput / 10, - router_ifinfo->bat_v.throughput % 10, router->addr, - router->if_incoming->net_dev->name, - gw_node->bandwidth_down / 10, - gw_node->bandwidth_down % 10, - gw_node->bandwidth_up / 10, - gw_node->bandwidth_up % 10); - ret = seq_has_overflowed(seq) ? -1 : 0; - - if (curr_gw) - batadv_gw_node_put(curr_gw); -out: - if (router_ifinfo) - batadv_neigh_ifinfo_put(router_ifinfo); - if (router) - batadv_neigh_node_put(router); - return ret; -} - -/** - * batadv_v_gw_print() - print the gateway list - * @bat_priv: the bat priv with all the soft interface information - * @seq: gateway table seq_file struct - */ -static void batadv_v_gw_print(struct batadv_priv *bat_priv, - struct seq_file *seq) -{ - struct batadv_gw_node *gw_node; - int gw_count = 0; - - seq_puts(seq, - " Gateway ( throughput) Nexthop [outgoingIF]: advertised uplink bandwidth\n"); - - rcu_read_lock(); - hlist_for_each_entry_rcu(gw_node, &bat_priv->gw.gateway_list, list) { - /* fails if orig_node has no router */ - if (batadv_v_gw_write_buffer_text(bat_priv, seq, gw_node) < 0) - continue; - - gw_count++; - } - rcu_read_unlock(); - - if (gw_count == 0) - seq_puts(seq, "No gateways in range ...\n"); -} -#endif - /** * batadv_v_gw_dump_entry() - Dump a gateway into a message * @msg: Netlink message to dump into @@ -1046,26 +811,16 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = { .hardif_init = batadv_v_hardif_neigh_init, .cmp = batadv_v_neigh_cmp, .is_similar_or_better = batadv_v_neigh_is_sob, -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - .print = batadv_v_neigh_print, -#endif .dump = batadv_v_neigh_dump, }, .orig = { -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - .print = batadv_v_orig_print, -#endif .dump = batadv_v_orig_dump, }, .gw = { .init_sel_class = batadv_v_init_sel_class, .store_sel_class = batadv_v_store_sel_class, - .show_sel_class = batadv_v_show_sel_class, .get_best_gw_node = batadv_v_gw_get_best_gw_node, .is_eligible = batadv_v_gw_is_eligible, -#ifdef CONFIG_BATMAN_ADV_DEBUGFS - .print = batadv_v_gw_print, -#endif .dump = batadv_v_gw_dump, }, }; |