b.a.t.m.a.n.lists.open-mesh.org archive mirror
 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.net>
Subject: Re: [B.A.T.M.A.N.] [batman-adv] Start to send originator messages when interface gets active
Date: Thu, 22 Oct 2009 01:21:51 +0800	[thread overview]
Message-ID: <200910220121.51879.lindner_marek@yahoo.de> (raw)
In-Reply-To: <1256138761-12940-1-git-send-email-sven.eckelmann@gmx.de>


Please try this revised patch - it should avoid a race condition in which 
we may end up with 2 schedule_own_packet() running at the same time.

The module gets in a inactive state when all interfaces are down. This
stops the sending of new packets. When a interface gets activated again
it must reactivate the module and then start the sending of new
originator messages.

Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
---
diff --git a/batman-adv-kernelland/hard-interface.c b/batman-adv-kernelland/hard-interface.c
index f04d2db..960e86c 100644
--- a/batman-adv-kernelland/hard-interface.c
+++ b/batman-adv-kernelland/hard-interface.c
@@ -425,6 +425,10 @@ static int hard_if_event(struct notifier_block *this,
 		break;
 	case NETDEV_UP:
 		hardif_activate_interface(batman_if);
+		if ((atomic_read(&module_state) == MODULE_INACTIVE) &&
+		    (hardif_get_active_if_num() > 0)) {
+			activate_module();
+		}
 		break;
 	/* NETDEV_CHANGEADDR - mac address change - what are we doing here ? */
 	default:
diff --git a/batman-adv-kernelland/main.c b/batman-adv-kernelland/main.c
index 8fbefc2..4e70c95 100644
--- a/batman-adv-kernelland/main.c
+++ b/batman-adv-kernelland/main.c
@@ -173,7 +173,7 @@ end:
 /* shuts down the whole module.*/
 void shutdown_module(void)
 {
-	atomic_set(&module_state, MODULE_INACTIVE);
+	atomic_set(&module_state, MODULE_DEACTIVATING);
 
 	purge_outstanding_packets();
 	flush_workqueue(bat_event_workqueue);
@@ -199,6 +199,7 @@ void shutdown_module(void)
 
 	hardif_remove_interfaces();
 	synchronize_rcu();
+	atomic_set(&module_state, MODULE_INACTIVE);
 }
 
 void inc_module_count(void)
diff --git a/batman-adv-kernelland/main.h b/batman-adv-kernelland/main.h
index 21d3919..9493f96 100644
--- a/batman-adv-kernelland/main.h
+++ b/batman-adv-kernelland/main.h
@@ -63,7 +63,7 @@
 
 #define MODULE_INACTIVE 0
 #define MODULE_ACTIVE 1
-/* #define MODULE_WAITING 2 -- not needed anymore */
+#define MODULE_DEACTIVATING 2
 
 
 /*
diff --git a/batman-adv-kernelland/send.c b/batman-adv-kernelland/send.c
index 73fe371..01396b4 100644
--- a/batman-adv-kernelland/send.c
+++ b/batman-adv-kernelland/send.c
@@ -399,7 +399,7 @@ void send_outstanding_bcast_packet(struct work_struct *work)
 	/* if we still have some more bcasts to send and we are not shutting
 	 * down */
 	if ((forw_packet->num_packets < 3) &&
-	    (atomic_read(&module_state) != MODULE_INACTIVE))
+	    (atomic_read(&module_state) != MODULE_DEACTIVATING))
 		_add_bcast_packet_to_list(forw_packet, ((5 * HZ) / 1000));
 	else
 		forw_packet_free(forw_packet);
@@ -424,7 +424,7 @@ void send_outstanding_bat_packet(struct work_struct *work)
 	 * shutting down
 	 */
 	if ((forw_packet->own) &&
-	    (atomic_read(&module_state) != MODULE_INACTIVE))
+	    (atomic_read(&module_state) != MODULE_DEACTIVATING))
 		schedule_own_packet(forw_packet->if_incoming);
 
 	forw_packet_free(forw_packet);

  reply	other threads:[~2009-10-21 17:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-20 15:02 [B.A.T.M.A.N.] basic B.A.T.M.A.N-adv setup Francesco
2009-10-20 15:17 ` Sven Eckelmann
2009-10-20 15:23   ` Sven Eckelmann
2009-10-20 16:02   ` Francesco
2009-10-20 17:10     ` Sven Eckelmann
2009-10-20 17:17       ` Sven Eckelmann
2009-10-20 19:59         ` Francesco
2009-10-20 20:22           ` Sven Eckelmann
2009-10-21  6:54             ` Francesco
2009-10-21  7:05               ` Andrew Lunn
2009-10-21  7:35                 ` Francesco
2009-10-21 10:00                   ` Sven Eckelmann
2009-10-21 12:00                     ` Sven Eckelmann
2009-10-21 15:26                       ` [B.A.T.M.A.N.] [PATCH] Start to send originator messages when interface gets active Sven Eckelmann
2009-10-21 17:21                         ` Marek Lindner [this message]
2009-10-21 12:11                     ` [B.A.T.M.A.N.] basic B.A.T.M.A.N-adv setup Francesco
2009-10-20 15:33 ` Marek Lindner

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=200910220121.51879.lindner_marek@yahoo.de \
    --to=lindner_marek@yahoo.de \
    --cc=b.a.t.m.a.n@lists.open-mesh.net \
    /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;
as well as URLs for NNTP newsgroup(s).