From patchwork Tue Feb 28 11:32:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 1560 Return-Path: Received: from nm22-vm1.bullet.mail.ukl.yahoo.com (nm22-vm1.bullet.mail.ukl.yahoo.com [217.12.10.75]) by open-mesh.org (Postfix) with SMTP id 12D636008E3 for ; Tue, 28 Feb 2012 12:35:41 +0100 (CET) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.182] by nm22.bullet.mail.ukl.yahoo.com with NNFMP; 28 Feb 2012 11:35:40 -0000 Received: from [77.238.184.63] by tm13.bullet.mail.ukl.yahoo.com with NNFMP; 28 Feb 2012 11:35:40 -0000 Received: from [127.0.0.1] by smtp132.mail.ukl.yahoo.com with NNFMP; 28 Feb 2012 11:35:40 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1330428940; bh=N0MZIhpMi+qM6ApGQaTvkajT84CAtXaWHNsRpwz97TA=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=J37EyvmPVDRpoA47HXBPasT+kVMctlEDKmdgKHi0lZrl0IzBP9eaAmX8dcmSM5r1gTiZ5bWNyIT0Dt72x2nXr1SJrCDGWpT9/hd7WhFKvec7QX+YKn2loIyxNCwvvu10wRstGdo50zXrcXEG09pzR/ZpOA4zkDeExRoSfSobFSE= X-Yahoo-Newman-Id: 898527.18931.bm@smtp132.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: Zc7XGy8VM1kHsivfPmsdga_47J5ZjKyxH3YNFcRRfLTRsZU J47PvoaO_Ox65oMUOlsilsZBUAQAnzJ0_TMjaOgFuzhiSUAuU2.FTEtlfQ1G mCCOYwhRisfALSmJJ99FSGIgtUC77ejzjIBIMFY9YzurKK7L1pQYaC4SCcv3 .w5xcBd2wCJpt0CzwnbDf57iWpnmOggAZlfP5l.mc5cKkWmzoo_aWhPJe7su I.nlEqOhh7cK5gPtdncuIaccPjsf8WA5CMpmk4bi1W6WG.qAwi7BeSbi51VH IwMrwS6IFd_1v9LKkxP9HRloZaw2B7SJTWW5Oitdsqz2zPnJI3XQhtdrz1S1 pHXMka5KA8pncw7QEuxeTls0mI5Q7kGZ2vUdlkjAuof4B8zfwhDxHcxQn22T ePl6GojpU4CA- X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@119.236.110.45 with plain) by smtp132.mail.ukl.yahoo.com with SMTP; 28 Feb 2012 11:35:37 +0000 GMT From: Marek Lindner To: davem@davemloft.net Date: Tue, 28 Feb 2012 19:32:24 +0800 Message-Id: <1330428748-23137-5-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.9 In-Reply-To: <1330428748-23137-1-git-send-email-lindner_marek@yahoo.de> References: <1330428748-23137-1-git-send-email-lindner_marek@yahoo.de> Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH 4/8] batman-adv: set TT_CLIENT_NEW flag before invoking hash_add() X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 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: Tue, 28 Feb 2012 11:35:41 -0000 From: Antonio Quartulli In case of a new tt_local_entry, the TT_CLIENT_NEW flag has to be set before adding such entry to the hash table. Otherwise, it opens a race condition in which the entry can be found but the flag has not been set. Signed-off-by: Antonio Quartulli Signed-off-by: Marek Lindner --- net/batman-adv/translation-table.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 4dc5af3..9be9c41 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -210,6 +210,11 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr, if (compare_eth(addr, soft_iface->dev_addr)) tt_local_entry->common.flags |= TT_CLIENT_NOPURGE; + /* The local entry has to be marked as NEW to avoid to send it in + * a full table response going out before the next ttvn increment + * (consistency check) */ + tt_local_entry->common.flags |= TT_CLIENT_NEW; + hash_added = hash_add(bat_priv->tt_local_hash, compare_tt, choose_orig, &tt_local_entry->common, &tt_local_entry->common.hash_entry); @@ -222,11 +227,6 @@ void tt_local_add(struct net_device *soft_iface, const uint8_t *addr, tt_local_event(bat_priv, addr, tt_local_entry->common.flags); - /* The local entry has to be marked as NEW to avoid to send it in - * a full table response going out before the next ttvn increment - * (consistency check) */ - tt_local_entry->common.flags |= TT_CLIENT_NEW; - /* remove address from global hash if present */ tt_global_entry = tt_global_hash_find(bat_priv, addr);