Skip to contentSkip to conversation

batman-adv: B.A.T.M.A.N. V - implement hard-iface init function

PATCH Superseded Antonio Quartulli 2 participants 3 messages May 12, 2016 – May 17, 2016 Batman advanced

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 batman-adv: B.A.T.M.A.N. V - implement hard-iface init function

Some fields in the hard-interface data structure are specific to the B.A.T.M.A.N. V protocol and have to be initialized only when such protocol is compiled in.
Instead of having a #ifdef block in the middle of the hard-interface.c code it is better to have an algorithm private function that hides the precompiler logic in its own header file (like other functions).

Fixes ffd2f27908e5 ("batman-adv: Only init ELP tweaking options when BATMAN_V is enabled")

---

Changes from v1:
- move bat_algo.h include line to the right location

 net/batman-adv/bat_algo.h       |  5 +++++
 net/batman-adv/bat_v.c          | 14 ++++++++++++++
 net/batman-adv/hard-interface.c | 10 ++--------
 3 files changed, 21 insertions(+), 8 deletions(-)
net/batman-adv/bat_algo.h +5 -0
index b727762..3654296 100644
@@ -25,6 +25,7 @@ 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;
net/batman-adv/bat_v.c +14 -0
index b9c2850..fb2d29d 100644
@@ -333,6 +333,20 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {
 };
 
 /**
+ * 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
  * @bat_priv: the object representing the mesh interface to initialise
net/batman-adv/hard-interface.c +2 -8
index a8cda76..3696929 100644
@@ -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,14 +684,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
 	if (batadv_is_wifi_netdev(net_dev))
 		hard_iface->num_bcasts = BATADV_NUM_BCASTS_WIRELESS;
 
-#ifdef CONFIG_BATMAN_ADV_BATMAN_V
-	/* 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);
-#endif
+	batadv_v_hardif_init(hard_iface);
 
 	/* extra reference for return */
 	kref_init(&hard_iface->refcount);
Signature · 1 line
2.8.2
#1 lore raw
Quoted 2 lines · On Friday, May 13, 2016 05:11:18 Antonio Quartulli wrote:

Changes from v1:
- move bat_algo.h include line to the right location

$ make CONFIG_BATMAN_ADV_BATMAN_V=y
/home/marek/batman-adv/gen-compat-autoconf.sh /home/marek/batman-adv/compat-autoconf.h
make -C /lib/modules/4.4.0-1-amd64/build M=/home/marek/batman-adv/net/batman-adv CONFIG_BATMAN_ADV=m CONFIG_BATMAN_ADV_DEBUG=n CONFIG_BATMAN_ADV_BLA=y CONFIG_BATMAN_ADV_DAT=y CONFIG_BATMAN_ADV_NC=n CONFIG_BATMAN_ADV_MCAST=y CONFIG_BATMAN_ADV_BATMAN_V=y INSTALL_MOD_DIR=updates/net/batman-adv/       modules
make[1]: Entering directory '/usr/src/linux-headers-4.4.0-1-amd64'
Makefile:10: *** mixed implicit and normal rules: deprecated syntax
  CC [M]  /home/marek/batman-adv/net/batman-adv/../../compat-sources/net/core/skbuff.o
  CC [M]  /home/marek/batman-adv/net/batman-adv/../../compat-sources/net/ipv4/igmp.o
  CC [M]  /home/marek/batman-adv/net/batman-adv/../../compat-sources/net/ipv6/mcast_snoop.o
  CC [M]  /home/marek/batman-adv/net/batman-adv/bat_iv_ogm.o
In file included from /home/marek/batman-adv/net/batman-adv/bat_iv_ogm.c:18:0:
/home/marek/batman-adv/net/batman-adv/bat_algo.h:28:34: warning: ‘struct batadv_hard_iface’ declared inside parameter list
 void batadv_v_hardif_init(struct batadv_hard_iface *hardif);
                                  ^
/home/marek/batman-adv/net/batman-adv/bat_algo.h:28:34: warning: its scope is only this definition or declaration, which is probably not what you want
  CC [M]  /home/marek/batman-adv/net/batman-adv/bat_v.o
In file included from /home/marek/batman-adv/net/batman-adv/bat_v.c:18:0:
/home/marek/batman-adv/net/batman-adv/bat_algo.h:28:34: warning: ‘struct batadv_hard_iface’ declared inside parameter list
 void batadv_v_hardif_init(struct batadv_hard_iface *hardif);
                                  ^
/home/marek/batman-adv/net/batman-adv/bat_algo.h:28:34: warning: its scope is only this definition or declaration, which is probably not what you want
/home/marek/batman-adv/net/batman-adv/bat_v.c:340:6: error: conflicting types for ‘batadv_v_hardif_init’
 void batadv_v_hardif_init(struct batadv_hard_iface *hard_iface)
      ^
In file included from /home/marek/batman-adv/net/batman-adv/bat_v.c:18:0:
/home/marek/batman-adv/net/batman-adv/bat_algo.h:28:6: note: previous declaration of ‘batadv_v_hardif_init’ was here
 void batadv_v_hardif_init(struct batadv_hard_iface *hardif);
      ^
/usr/src/linux-headers-4.4.0-1-common/scripts/Makefile.build:263: recipe for target '/home/marek/batman-adv/net/batman-adv/bat_v.o' failed
make[4]: *** [/home/marek/batman-adv/net/batman-adv/bat_v.o] Error 1
/usr/src/linux-headers-4.4.0-1-common/Makefile:1401: recipe for target '_module_/home/marek/batman-adv/net/batman-adv' failed
make[3]: *** [_module_/home/marek/batman-adv/net/batman-adv] Error 2
Makefile:146: recipe for target 'sub-make' failed
make[2]: *** [sub-make] Error 2
Makefile:8: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.4.0-1-amd64'
Makefile:72: recipe for target 'all' failed
make: *** [all] Error 2
#2 lore raw
Quoted 10 lines · Marek Lindner

make[4]: *** [/home/marek/batman-adv/net/batman-adv/bat_v.o] Error 1 /usr/src/linux-headers-4.4.0-1-common/Makefile:1401: recipe for target '_module_/home/marek/batman-adv/net/batman-adv' failed make[3]: *** [_module_/home/marek/batman-adv/net/batman-adv] Error 2
Makefile:146: recipe for target 'sub-make' failed
make[2]: *** [sub-make] Error 2
Makefile:8: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.4.0-1-amd64'
Makefile:72: recipe for target 'all' failed
make: *** [all] Error 2

Sorry, but I should have not separated this patch from the other (that was introducing the include line in bat_algo.h).

Now this patch depends on Sven's patchset.

I can rebase and resend it once Sven's patches have been merged.

Cheers,

Signature · 1 line
Antonio Quartulli