From patchwork Fri Feb 17 07:18:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 1522 Return-Path: Received: from nm17.bullet.mail.ukl.yahoo.com (nm17.bullet.mail.ukl.yahoo.com [217.146.183.191]) by open-mesh.org (Postfix) with SMTP id 7DD4A60079D for ; Fri, 17 Feb 2012 08:18:49 +0100 (CET) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.216] by nm17.bullet.mail.ukl.yahoo.com with NNFMP; 17 Feb 2012 07:18:48 -0000 Received: from [217.146.182.253] by tm9.bullet.mail.ukl.yahoo.com with NNFMP; 17 Feb 2012 07:18:48 -0000 Received: from [127.0.0.1] by smtp155.mail.ukl.yahoo.com with NNFMP; 17 Feb 2012 07:18:48 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1329463128; bh=pscO01+Ue4YtaWTX+KDjqqJMEqwsA1sMerzp4cH111k=; 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=IlMlA6P/XShkMCyai1sfFhBtuQmTjR/soq8sByqEu0KXJ+Kpp5NCD/KA7y2yx/jOrUmJJvhXao1HXGVKKCHJxBBjbxQxJHI0Cccu/910IucBWgfJxxq4WE3+0MDrVnwTRD7VttHAcDJQwgLwBG9IdG/mibWUa8ogpcFVs5w1g2Y= X-Yahoo-Newman-Id: 312276.18250.bm@smtp155.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: qptfTJ4VM1kNrXAi_k9WIRwZ9Z4XKvrXOFtwCNfe2K4xSvL sLzkLQbxSaCBGLokPYvKyeG2LdR2NAWdhG6wgrm5yYyci7yWBsMAtxzyZfkh y0l3ipP0d6YMmbA3HSgiGU5xVTtc4tx66Lam9LS_brXxoN_Lr8.JlBJvn9m8 lLD0iOze6RWFQsywmMekvREenXhvSBdL1oYp__.e1rFl0C03_38bArxW0vMx MzixqM6Lu5ek853Ixf62JhAZc19TeOMZfb86HatTDR6SiGka9168ryjxV5Pw Tm9SmoeVasBtQIam3_w6wRXrwIB3rt4djEo09OrFi9ZeC9iKG7DRwm8Oy5y2 dgn.1DMqX8_vo0eYO5QLY8audl7WJgt5MRJN5.tfb.JyRKcIONR1C_qCtaLL 9ey7gJply X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@210.177.7.38 with plain) by smtp155.mail.ukl.yahoo.com with SMTP; 16 Feb 2012 23:18:46 -0800 PST From: Marek Lindner To: davem@davemloft.net Date: Fri, 17 Feb 2012 15:18:21 +0800 Message-Id: <1329463110-856-2-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.9 In-Reply-To: <1329463110-856-1-git-send-email-lindner_marek@yahoo.de> References: <1329463110-856-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 , Simon Wunderlich Subject: [B.A.T.M.A.N.] [PATCH 01/10] batman-adv: add tt_initialised flag to the orig_node struct 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: Fri, 17 Feb 2012 07:18:49 -0000 From: Antonio Quartulli (ttvn == 0) is currently used as initial condition. However this is not a good idea because ttvn gets the vale zero each time after reaching the maximum value (wrap around). For this reason a new flag is added in order to define whether a node has an initialised table or not. Moreover, after invoking tt_global_del_orig(), tt_initialised has to be set to false Reported-by: Alexey Fisher Signed-off-by: Antonio Quartulli Signed-off-by: Simon Wunderlich Tested-by: Alexey Fisher Signed-off-by: Marek Lindner --- net/batman-adv/originator.c | 1 + net/batman-adv/translation-table.c | 11 ++++++++--- net/batman-adv/types.h | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 0bc2045..847ff7e 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -219,6 +219,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr) /* extra reference for return */ atomic_set(&orig_node->refcount, 2); + orig_node->tt_initialised = false; orig_node->tt_poss_change = false; orig_node->bat_priv = bat_priv; memcpy(orig_node->orig, addr, ETH_ALEN); diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index ab8dea8..c632475 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -733,6 +733,7 @@ void tt_global_del_orig(struct bat_priv *bat_priv, spin_unlock_bh(list_lock); } atomic_set(&orig_node->tt_size, 0); + orig_node->tt_initialised = false; } static void tt_global_roam_purge(struct bat_priv *bat_priv) @@ -1450,6 +1451,7 @@ static void _tt_update_changes(struct bat_priv *bat_priv, */ return; } + orig_node->tt_initialised = true; } static void tt_fill_gtable(struct bat_priv *bat_priv, @@ -1854,8 +1856,10 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn); bool full_table = true; - /* the ttvn increased by one -> we can apply the attached changes */ - if (ttvn - orig_ttvn == 1) { + /* orig table not initialised AND first diff is in the OGM OR the ttvn + * increased by one -> we can apply the attached changes */ + if ((!orig_node->tt_initialised && ttvn == 1) || + ttvn - orig_ttvn == 1) { /* the OGM could not contain the changes due to their size or * because they have already been sent TT_OGM_APPEND_MAX times. * In this case send a tt request */ @@ -1889,7 +1893,8 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, } else { /* if we missed more than one change or our tables are not * in sync anymore -> request fresh tt data */ - if (ttvn != orig_ttvn || orig_node->tt_crc != tt_crc) { + if (!orig_node->tt_initialised || ttvn != orig_ttvn || + orig_node->tt_crc != tt_crc) { request_table: bat_dbg(DBG_TT, bat_priv, "TT inconsistency for %pM. " "Need to retrieve the correct information " diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index e9eb043..35085f41 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -81,6 +81,7 @@ struct orig_node { int16_t tt_buff_len; spinlock_t tt_buff_lock; /* protects tt_buff */ atomic_t tt_size; + bool tt_initialised; /* The tt_poss_change flag is used to detect an ongoing roaming phase. * If true, then I sent a Roaming_adv to this orig_node and I have to * inspect every packet directed to it to check whether it is still