drm/amd/powerplay: remove useless soft pptable in Asic related backend
[linux-2.6-microblaze.git] / net / batman-adv / bat_v.c
index 4026f19..0a12e5c 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/rculist.h>
 #include <linux/rcupdate.h>
 #include <linux/seq_file.h>
+#include <linux/stddef.h>
 #include <linux/types.h>
 #include <linux/workqueue.h>
 
 
 static void batadv_v_iface_activate(struct batadv_hard_iface *hard_iface)
 {
+       struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
+       struct batadv_hard_iface *primary_if;
+
+       primary_if = batadv_primary_if_get_selected(bat_priv);
+
+       if (primary_if) {
+               batadv_v_elp_iface_activate(primary_if, hard_iface);
+               batadv_hardif_put(primary_if);
+       }
+
        /* B.A.T.M.A.N. V does not use any queuing mechanism, therefore it can
         * set the interface as ACTIVE right away, without any risk of race
         * condition
@@ -72,16 +83,34 @@ static void batadv_v_iface_disable(struct batadv_hard_iface *hard_iface)
        batadv_v_elp_iface_disable(hard_iface);
 }
 
-static void batadv_v_iface_update_mac(struct batadv_hard_iface *hard_iface)
-{
-}
-
 static void batadv_v_primary_iface_set(struct batadv_hard_iface *hard_iface)
 {
        batadv_v_elp_primary_iface_set(hard_iface);
        batadv_v_ogm_primary_iface_set(hard_iface);
 }
 
+/**
+ * batadv_v_iface_update_mac - react to hard-interface MAC address change
+ * @hard_iface: the modified interface
+ *
+ * If the modified interface is the primary one, update the originator
+ * address in the ELP and OGM messages to reflect the new MAC address.
+ */
+static void batadv_v_iface_update_mac(struct batadv_hard_iface *hard_iface)
+{
+       struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
+       struct batadv_hard_iface *primary_if;
+
+       primary_if = batadv_primary_if_get_selected(bat_priv);
+       if (primary_if != hard_iface)
+               goto out;
+
+       batadv_v_primary_iface_set(hard_iface);
+out:
+       if (primary_if)
+               batadv_hardif_put(primary_if);
+}
+
 static void
 batadv_v_hardif_neigh_init(struct batadv_hardif_neigh_node *hardif_neigh)
 {
@@ -162,8 +191,8 @@ static void batadv_v_neigh_print(struct batadv_priv *bat_priv,
        struct batadv_hard_iface *hard_iface;
        int batman_count = 0;
 
-       seq_printf(seq, "  %-15s %s (%11s) [%10s]\n", "Neighbor",
-                  "last-seen", "throughput", "IF");
+       seq_puts(seq,
+                "  Neighbor        last-seen ( throughput) [        IF]\n");
 
        rcu_read_lock();
        list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
@@ -202,9 +231,8 @@ static void batadv_v_orig_print(struct batadv_priv *bat_priv,
        int batman_count = 0;
        u32 i;
 
-       seq_printf(seq, "  %-15s %s (%11s) %17s [%10s]: %20s ...\n",
-                  "Originator", "last-seen", "throughput", "Nexthop",
-                  "outgoingIF", "Potential nexthops");
+       seq_puts(seq,
+                "  Originator      last-seen ( throughput)           Nexthop [outgoingIF]:   Potential nexthops ...\n");
 
        for (i = 0; i < hash->size; i++) {
                head = &hash->table[i];
@@ -256,14 +284,23 @@ static int batadv_v_neigh_cmp(struct batadv_neigh_node *neigh1,
                              struct batadv_hard_iface *if_outgoing2)
 {
        struct batadv_neigh_ifinfo *ifinfo1, *ifinfo2;
+       int ret = 0;
 
        ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1);
+       if (WARN_ON(!ifinfo1))
+               goto err_ifinfo1;
+
        ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2);
+       if (WARN_ON(!ifinfo2))
+               goto err_ifinfo2;
 
-       if (WARN_ON(!ifinfo1 || !ifinfo2))
-               return 0;
+       ret = ifinfo1->bat_v.throughput - ifinfo2->bat_v.throughput;
 
-       return ifinfo1->bat_v.throughput - ifinfo2->bat_v.throughput;
+       batadv_neigh_ifinfo_put(ifinfo2);
+err_ifinfo2:
+       batadv_neigh_ifinfo_put(ifinfo1);
+err_ifinfo1:
+       return ret;
 }
 
 static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1,
@@ -273,14 +310,26 @@ static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1,
 {
        struct batadv_neigh_ifinfo *ifinfo1, *ifinfo2;
        u32 threshold;
+       bool ret = false;
 
        ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1);
+       if (WARN_ON(!ifinfo1))
+               goto err_ifinfo1;
+
        ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2);
+       if (WARN_ON(!ifinfo2))
+               goto err_ifinfo2;
 
        threshold = ifinfo1->bat_v.throughput / 4;
        threshold = ifinfo1->bat_v.throughput - threshold;
 
-       return ifinfo2->bat_v.throughput > threshold;
+       ret = ifinfo2->bat_v.throughput > threshold;
+
+       batadv_neigh_ifinfo_put(ifinfo2);
+err_ifinfo2:
+       batadv_neigh_ifinfo_put(ifinfo1);
+err_ifinfo1:
+       return ret;
 }
 
 static struct batadv_algo_ops batadv_batman_v __read_mostly = {