public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Marek Lindner <lindner_marek@yahoo.de>
To: The list for a Better Approach To Mobile Ad-hoc Networking
	<b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] race condition with activate_module?
Date: Fri, 12 Feb 2010 19:06:46 +0800	[thread overview]
Message-ID: <201002121906.46804.lindner_marek@yahoo.de> (raw)
In-Reply-To: <201002111720.16266.lindner_marek@yahoo.de>

[-- Attachment #1: Type: Text/Plain, Size: 384 bytes --]

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

[-- Attachment #2: if_num_crash.patch --]
[-- Type: text/x-patch, Size: 1135 bytes --]

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);
 	}
 

  reply	other threads:[~2010-02-12 11:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-08 19:38 [B.A.T.M.A.N.] race condition with activate_module? Linus Lüssing
2010-02-11  2:25 ` Linus Lüssing
2010-02-11  9:20   ` Marek Lindner
2010-02-12 11:06     ` Marek Lindner [this message]
2010-02-14 16:58       ` Simon Wunderlich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201002121906.46804.lindner_marek@yahoo.de \
    --to=lindner_marek@yahoo.de \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox