b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: "Linus Lüssing" <linus.luessing@web.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCH 5/5] batman-adv: Protect global TQ window with a spinlock
Date: Sun, 13 Mar 2011 20:52:25 +0100	[thread overview]
Message-ID: <1300045945-28734-6-git-send-email-linus.luessing@web.de> (raw)
In-Reply-To: <1300045945-28734-1-git-send-email-linus.luessing@web.de>

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
---
 originator.c |    1 +
 routing.c    |    4 ++++
 types.h      |    1 +
 3 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/batman-adv/originator.c b/batman-adv/originator.c
index 4989bbb..4905619 100644
--- a/batman-adv/originator.c
+++ b/batman-adv/originator.c
@@ -102,6 +102,7 @@ struct neigh_node *create_neighbor(struct orig_node *orig_node,
 
 	INIT_HLIST_NODE(&neigh_node->list);
 	INIT_LIST_HEAD(&neigh_node->bonding_list);
+	spin_lock_init(&neigh_node->tq_lock);
 
 	memcpy(neigh_node->addr, neigh, ETH_ALEN);
 	neigh_node->orig_node = orig_neigh_node;
diff --git a/batman-adv/routing.c b/batman-adv/routing.c
index 9780a62..cd578d4 100644
--- a/batman-adv/routing.c
+++ b/batman-adv/routing.c
@@ -408,10 +408,12 @@ static void update_orig(struct bat_priv *bat_priv,
 		if (is_duplicate)
 			continue;
 
+		spin_lock_bh(&tmp_neigh_node->tq_lock);
 		ring_buffer_set(tmp_neigh_node->tq_recv,
 				&tmp_neigh_node->tq_index, 0);
 		tmp_neigh_node->tq_avg =
 			ring_buffer_avg(tmp_neigh_node->tq_recv);
+		spin_unlock_bh(&tmp_neigh_node->tq_lock);
 	}
 
 	if (!neigh_node) {
@@ -436,10 +438,12 @@ static void update_orig(struct bat_priv *bat_priv,
 	orig_node->flags = batman_packet->flags;
 	neigh_node->last_valid = jiffies;
 
+	spin_lock_bh(&neigh_node->tq_lock);
 	ring_buffer_set(neigh_node->tq_recv,
 			&neigh_node->tq_index,
 			batman_packet->tq);
 	neigh_node->tq_avg = ring_buffer_avg(neigh_node->tq_recv);
+	spin_unlock_bh(&neigh_node->tq_lock);
 
 	if (!is_duplicate) {
 		orig_node->last_ttl = batman_packet->ttl;
diff --git a/batman-adv/types.h b/batman-adv/types.h
index 1854cbb..091476d 100644
--- a/batman-adv/types.h
+++ b/batman-adv/types.h
@@ -125,6 +125,7 @@ struct neigh_node {
 	struct rcu_head rcu;
 	struct orig_node *orig_node;
 	struct hard_iface *if_incoming;
+	spinlock_t tq_lock;	/* protects: tq_recv, tq_index */
 };
 
 
-- 
1.7.4.1


  parent reply	other threads:[~2011-03-13 19:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-13 19:52 [B.A.T.M.A.N.] Various fixes and clean-ups Linus Lüssing
2011-03-13 19:52 ` [B.A.T.M.A.N.] [PATCH 1/5] batman-adv: Move bonding / iface alternating router search to own functions Linus Lüssing
2011-03-13 19:52 ` [B.A.T.M.A.N.] [PATCH 2/5] batman-adv: Make gateway_get_selected type safe Linus Lüssing
2011-03-13 19:52 ` [B.A.T.M.A.N.] [PATCH 3/5] batman-adv: Simplify gw_check_election(), use gw_get_selected() Linus Lüssing
2011-03-13 19:52 ` [B.A.T.M.A.N.] [PATCH 4/5] batman-adv: Make orig_node->router an rcu protected pointer Linus Lüssing
2011-03-13 19:52 ` Linus Lüssing [this message]
2011-03-14 22:48 ` [B.A.T.M.A.N.] Various fixes and clean-ups 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=1300045945-28734-6-git-send-email-linus.luessing@web.de \
    --to=linus.luessing@web.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;
as well as URLs for NNTP newsgroup(s).