From patchwork Fri Feb 12 11:06:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 17 Return-Path: Received: from smtp125.mail.ukl.yahoo.com (smtp125.mail.ukl.yahoo.com [77.238.184.56]) by open-mesh.net (Postfix) with SMTP id B2D1115434F for ; Fri, 12 Feb 2010 12:31:55 +0100 (CET) Received: (qmail 70882 invoked from network); 12 Feb 2010 11:10:57 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.de; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Subject:Date:User-Agent:References:In-Reply-To:MIME-Version:Content-Type:Message-Id; b=0XNrAzcxmcfp9DD6ARjYjP+twWqfrNQ1ZZyCaj6etAcJ3gomvu06PZh11Y13Ml5hRab3jUsuzuxNUZLnwOJHfCel+ld7/9E3JKkfo9HqPj1WjlUBbkpjpDph6jvz3u3l3J5fU7qwf62hlEqwzdD7k2BVXMvlTmHqtc1xa73ZyO4= ; Received: from (lindner_marek@202.146.8.7 with plain) by smtp125.mail.ukl.yahoo.com with SMTP; 12 Feb 2010 11:10:57 +0000 GMT X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- X-YMail-OSG: xXREc2wVM1ljz.U1aMW4bfEWNv33n7qIkw7.j8A_vjAX6tYKMHmaWAzl5zaOYeSANfmfty0FXxZrYETybQ1Yq8MSctaqNXo7i9NVgrr5zChTvz7khsYlT2.7y7q2aUdgGoMt3lWOakKytPzcp9BA8_6_gyI7a0t.fxRntT5yB29iyroA_j2EgK8q2Zy_T3tml6GdVLNxqKzt_Bpet.Xi02oTtBIZ4aPTemdgSbwH1p4vvQ-- X-Yahoo-Newman-Property: ymail-3 From: Marek Lindner To: "The list for a Better Approach To Mobile Ad-hoc Networking" Date: Fri, 12 Feb 2010 19:06:46 +0800 User-Agent: KMail/1.12.4 (Linux/2.6.32-trunk-686; KDE/4.3.4; i686; ; ) References: <20100208193848.GA8545@Sellars> <20100211022543.GA6493@Linus-Debian> <201002111720.16266.lindner_marek@yahoo.de> In-Reply-To: <201002111720.16266.lindner_marek@yahoo.de> MIME-Version: 1.0 Message-Id: <201002121906.46804.lindner_marek@yahoo.de> Subject: Re: [B.A.T.M.A.N.] race condition with activate_module? X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Feb 2010 11:31:55 -0000 On Thursday 11 February 2010 17:20:16 Marek Lindner wrote: > Better than introducing some locking code which would need to halt the > whole module we should make sure that batman-adv does not process packets > before its initialization is complete. I made a proof-of-concept patch (no testing yet) but it should illustrate what I was talking about. Please try it. Cheers, Marek diff --git a/batman-adv-kernelland/proc.c b/batman-adv-kernelland/proc.c index 3f5744d..76dd4d2 100644 --- a/batman-adv-kernelland/proc.c +++ b/batman-adv-kernelland/proc.c @@ -115,10 +115,6 @@ static ssize_t proc_interfaces_write(struct file *instance, hardif_add_interface(if_string, if_num); - 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(); @@ -127,6 +123,11 @@ static ssize_t proc_interfaces_write(struct file *instance, rcu_read_unlock(); num_ifs = if_num + 1; + + if ((atomic_read(&module_state) == MODULE_INACTIVE) && + (hardif_get_active_if_num() > 0)) + activate_module(); + return count; end: @@ -453,7 +454,7 @@ static ssize_t proc_aggr_write(struct file *file, const char __user *buffer, atomic_read(&aggregation_enabled), (aggregation_enabled_tmp == 1 ? "enabled" : "disabled"), aggregation_enabled_tmp); - atomic_set(&aggregation_enabled, + atomic_set(&aggregation_enabled, (unsigned)aggregation_enabled_tmp); }