public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.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: Sun, 14 Feb 2010 17:58:24 +0100	[thread overview]
Message-ID: <20100214165824.GC25585@pandem0nium> (raw)
In-Reply-To: <201002121906.46804.lindner_marek@yahoo.de>

[-- Attachment #1: Type: text/plain, Size: 1976 bytes --]

Works fine and really seems to make a difference when trying with the ssleep()
stuff from linus (which also crashes in my qemu testbed). After applying your
patch it works fine. I have committed it along with some other sanity checks 
in r1573.

On Fri, Feb 12, 2010 at 07:06:46PM +0800, Marek Lindner wrote:
> 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);
>  	}
>  


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

      reply	other threads:[~2010-02-14 16:58 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
2010-02-14 16:58       ` Simon Wunderlich [this message]

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=20100214165824.GC25585@pandem0nium \
    --to=simon.wunderlich@s2003.tu-chemnitz.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