From patchwork Sat Jan 22 22:03:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 708 Return-Path: Received: from nm15.bullet.mail.ukl.yahoo.com (nm15.bullet.mail.ukl.yahoo.com [217.146.183.189]) by open-mesh.org (Postfix) with SMTP id 0E700154652 for ; Sat, 22 Jan 2011 23:06:53 +0100 (CET) Received: from [217.146.183.211] by nm15.bullet.mail.ukl.yahoo.com with NNFMP; 22 Jan 2011 22:06:47 -0000 Received: from [77.238.184.64] by tm4.bullet.mail.ukl.yahoo.com with NNFMP; 22 Jan 2011 22:06:47 -0000 Received: from [127.0.0.1] by smtp133.mail.ukl.yahoo.com with NNFMP; 22 Jan 2011 22:06:47 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1295734007; bh=B0A2FI5FJZQ2x8q9t0y6fQ3dOYamJ9v2NrQTleYS72s=; h=X-Yahoo-Newman-Id:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version:Content-Type:Content-Transfer-Encoding; b=AjxxXYKUCVWWxWPaIwX3WRmp8x45PEaGG5rJLGzjTUJYSRY6jjyI1xz89C+UykDO6SVUXRFTLigFZjJLGGz56gecC8u675CVqwrTTtYSV4GTQJrI+Yuf1GXDLd8PTewmbah1FmA/FUP0fL3B2q0n9R82u4UCqKGnTIcCrkEPcV0= X-Yahoo-Newman-Id: 377072.60268.bm@smtp133.mail.ukl.yahoo.com Received: from localhost (lindner_marek@81.57.254.118 with plain) by smtp133.mail.ukl.yahoo.com with SMTP; 22 Jan 2011 22:06:44 +0000 GMT X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- X-YMail-OSG: Ew6rSOYVM1ncWl_imiZU2YJGUlpzgQH0VebGR47Nbt.mZoU 2lzsja8ieFBhmQMOFKupvAHHuibpPKQOJeJw.6jISdNPpv4o62wXAu8tJTQX NrFaD4LSBcRYwMHk9HWGYoI2FcW2omsakSJpwg4kmXhnio5d6dwG3jwXvkCA DMhWT51i66mBK5nkvKc9HREnTUJL1ea39joz8dP3A_8TpgRm_PFTO7VMzPBd otwQzepkAopkG2viFbwUjrmQpnJuSbBhY1X5a1UlOWIuU6tRFc0ZbvW_Ij1Y xViv0UyU- X-Yahoo-Newman-Property: ymail-3 From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Sat, 22 Jan 2011 23:03:17 +0100 Message-Id: <1295733797-1552-1-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.2.3 MIME-Version: 1.0 Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: protect bit operations to count OGMs with spinlock 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: Sat, 22 Jan 2011 22:06:53 -0000 Reported-by: Linus Lüssing Signed-off-by: Marek Lindner --- batman-adv/routing.c | 13 +++++++------ 1 files changed, 7 insertions(+), 6 deletions(-) diff --git a/batman-adv/routing.c b/batman-adv/routing.c index a90d105..fe3471a 100644 --- a/batman-adv/routing.c +++ b/batman-adv/routing.c @@ -539,18 +539,19 @@ static char count_real_packets(struct ethhdr *ethhdr, char is_duplicate = 0; int32_t seq_diff; int need_update = 0; - int set_mark; + int set_mark, ret = -1; orig_node = get_orig_node(bat_priv, batman_packet->orig); if (!orig_node) return 0; + spin_lock_bh(&orig_node->ogm_cnt_lock); seq_diff = batman_packet->seqno - orig_node->last_real_seqno; /* signalize caller that the packet is to be dropped. */ if (window_protected(bat_priv, seq_diff, &orig_node->batman_seqno_reset)) - goto err; + goto out; rcu_read_lock(); hlist_for_each_entry_rcu(tmp_neigh_node, node, @@ -583,12 +584,12 @@ static char count_real_packets(struct ethhdr *ethhdr, orig_node->last_real_seqno = batman_packet->seqno; } - kref_put(&orig_node->refcount, orig_node_free_ref); - return is_duplicate; + ret = is_duplicate; -err: +out: + spin_unlock_bh(&orig_node->ogm_cnt_lock); kref_put(&orig_node->refcount, orig_node_free_ref); - return -1; + return ret; } void receive_bat_packet(struct ethhdr *ethhdr,