[commits] r1573 - trunk/batman-adv-kernelland

postmaster at open-mesh.net postmaster at open-mesh.net
Sun Feb 14 18:18:56 CET 2010


Author: simon
Date: 2010-02-14 18:18:29 +0100 (Sun, 14 Feb 2010)
New Revision: 1573

Modified:
   trunk/batman-adv-kernelland/hard-interface.c
   trunk/batman-adv-kernelland/proc.c
Log:
batman-adv: fix module initialization

Mareks patch to make sure that batman-adv does not process packets before its
initialization is complete. Some sanity checks added to the receiver function.

Signed-off-by: Marek Lindner <lindner_marek at yahoo.de>
Signed-off-by: Simon Wunderlich <siwu at hrz.tu-chemnitz.de>


Modified: trunk/batman-adv-kernelland/hard-interface.c
===================================================================
--- trunk/batman-adv-kernelland/hard-interface.c	2010-02-14 16:30:15 UTC (rev 1572)
+++ trunk/batman-adv-kernelland/hard-interface.c	2010-02-14 17:18:29 UTC (rev 1573)
@@ -433,6 +433,9 @@
 	if (!skb)
 		goto err_out;
 
+	if (atomic_read(&module_state) != MODULE_ACTIVE)
+		goto err_free;
+
 	/* packet should hold at least type and version */
 	if (unlikely(skb_headlen(skb) < 2))
 		goto err_free;
@@ -446,6 +449,10 @@
 	if (!batman_if)
 		goto err_free;
 
+	/* discard frames on not active interfaces */
+	if (batman_if->if_active != IF_ACTIVE)
+		goto err_free;
+
 	stats = (struct net_device_stats *)dev_get_stats(skb->dev);
 	if (stats) {
 		stats->rx_packets++;

Modified: trunk/batman-adv-kernelland/proc.c
===================================================================
--- trunk/batman-adv-kernelland/proc.c	2010-02-14 16:30:15 UTC (rev 1572)
+++ trunk/batman-adv-kernelland/proc.c	2010-02-14 17:18:29 UTC (rev 1573)
@@ -67,7 +67,7 @@
 				     size_t count, loff_t *data)
 {
 	char *if_string, *colon_ptr = NULL, *cr_ptr = NULL;
-	int not_copied = 0, if_num = 0;
+	int not_copied = 0, if_num = 0, add_success;
 	struct batman_if *batman_if = NULL;
 
 	if_string = kmalloc(count, GFP_KERNEL);
@@ -113,22 +113,17 @@
 	}
 	rcu_read_unlock();
 
-	hardif_add_interface(if_string, if_num);
+	add_success = hardif_add_interface(if_string, if_num);
+	if (add_success < 0)
+		goto end;
 
+	num_ifs = if_num + 1;
+
 	if ((atomic_read(&module_state) == MODULE_INACTIVE) &&
 	    (hardif_get_active_if_num() > 0))
 		activate_module();
 
-	rcu_read_lock();
-	if (list_empty(&if_list)) {
-		rcu_read_unlock();
-		goto end;
-	}
-	rcu_read_unlock();
-
-	num_ifs = if_num + 1;
 	return count;
-
 end:
 	kfree(if_string);
 	return count;



More information about the commits mailing list