batman-adv: init ELP tweaking options only once
authorMarek Lindner <mareklindner@neomailbox.ch>
Tue, 10 May 2016 14:31:59 +0000 (22:31 +0800)
committerSimon Wunderlich <sw@simonwunderlich.de>
Thu, 30 Jun 2016 08:29:43 +0000 (10:29 +0200)
The ELP interval and throughput override interface settings are initialized
with default settings on every time an interface is added to a mesh.
This patch prevents this behavior by moving the configuration init to the
interface detection routine which runs only once per interface.

Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
[a@unstable.cc: move initialization to batadv_v_hardif_init]
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
net/batman-adv/bat_algo.h
net/batman-adv/bat_v.c
net/batman-adv/bat_v_elp.c
net/batman-adv/hard-interface.c

index 03dafd33d23b086ce43892981dbeb8fd8036b1bb..36542962de7d738b2ca4cdbda2a25e002b29487f 100644 (file)
 #ifndef _NET_BATMAN_ADV_BAT_ALGO_H_
 #define _NET_BATMAN_ADV_BAT_ALGO_H_
 
-struct batadv_priv;
+#include "main.h"
 
 int batadv_iv_init(void);
 
 #ifdef CONFIG_BATMAN_ADV_BATMAN_V
 
 int batadv_v_init(void);
+void batadv_v_hardif_init(struct batadv_hard_iface *hardif);
 int batadv_v_mesh_init(struct batadv_priv *bat_priv);
 void batadv_v_mesh_free(struct batadv_priv *bat_priv);
 
@@ -35,6 +36,10 @@ static inline int batadv_v_init(void)
        return 0;
 }
 
+static inline void batadv_v_hardif_init(struct batadv_hard_iface *hardif)
+{
+}
+
 static inline int batadv_v_mesh_init(struct batadv_priv *bat_priv)
 {
        return 0;
index c16cd44a3b4ca0b14d1dce654099aa224c5540ad..c2fea812fb48227b7deb2ed079a23fbaab2088ab 100644 (file)
@@ -70,11 +70,6 @@ static int batadv_v_iface_enable(struct batadv_hard_iface *hard_iface)
        if (ret < 0)
                batadv_v_elp_iface_disable(hard_iface);
 
-       /* enable link throughput auto-detection by setting the throughput
-        * override to zero
-        */
-       atomic_set(&hard_iface->bat_v.throughput_override, 0);
-
        return ret;
 }
 
@@ -338,6 +333,20 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {
        .bat_neigh_print = batadv_v_neigh_print,
 };
 
+/**
+ * batadv_v_hardif_init - initialize the algorithm specific fields in the
+ *  hard-interface object
+ * @hard_iface: the hard-interface to initialize
+ */
+void batadv_v_hardif_init(struct batadv_hard_iface *hard_iface)
+{
+       /* enable link throughput auto-detection by setting the throughput
+        * override to zero
+        */
+       atomic_set(&hard_iface->bat_v.throughput_override, 0);
+       atomic_set(&hard_iface->bat_v.elp_interval, 500);
+}
+
 /**
  * batadv_v_mesh_init - initialize the B.A.T.M.A.N. V private resources for a
  *  mesh
index 8909d1eb962280180a30b5a7d4f6f04b225afeb2..cf0262becd083151c6888d81ade06721eba2fa89 100644 (file)
@@ -344,7 +344,6 @@ int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface)
        /* randomize initial seqno to avoid collision */
        get_random_bytes(&random_seqno, sizeof(random_seqno));
        atomic_set(&hard_iface->bat_v.elp_seqno, random_seqno);
-       atomic_set(&hard_iface->bat_v.elp_interval, 500);
 
        /* assume full-duplex by default */
        hard_iface->bat_v.flags |= BATADV_FULL_DUPLEX;
index db2009d84a2531f1cd67428d11801da9c4094670..3696929e5692a1e49b7541c3a8e376457754b9f2 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
 
+#include "bat_algo.h"
 #include "bridge_loop_avoidance.h"
 #include "debugfs.h"
 #include "distributed-arp-table.h"
@@ -683,6 +684,8 @@ batadv_hardif_add_interface(struct net_device *net_dev)
        if (batadv_is_wifi_netdev(net_dev))
                hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS;
 
+       batadv_v_hardif_init(hard_iface);
+
        /* extra reference for return */
        kref_init(&hard_iface->refcount);
        kref_get(&hard_iface->refcount);