From patchwork Mon Nov 7 15:36:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 1338 Return-Path: Received: from confino.investici.org (investici.nine.ch [217.150.252.179]) by open-mesh.org (Postfix) with ESMTPS id 4C5236007B2 for ; Mon, 7 Nov 2011 16:36:49 +0100 (CET) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@autistici.org; dkim-adsp=pass Received: from [217.150.252.179] (confino [217.150.252.179]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id 633FBC8672; Mon, 7 Nov 2011 15:36:48 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 confino.investici.org 633FBC8672 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1320680208; bh=9lOSX51+nkbPJdBTs9FscOSTPkZ+IhVkYj3lC9zIb8s=; h=From:To:Cc:Subject:Date:Message-Id; b=amsA8kgiJB4ApMo7ZgvAwkvaxQF1in5CmFFAU8D/lcmH5oP83n8q6X468vTdjuClb 95iOerMQw0vaGKe4DAcJVDNYs9U81u4A2k5VUUPv98GYGwV5f4Hucs8yPi0Emrq/QK 7el54IEjKEcSu82pybvbp003xQsheruYo1Xop44o= From: Antonio Quartulli To: b.a.t.m.a.n@lists.open-mesh.org Date: Mon, 7 Nov 2011 16:36:40 +0100 Message-Id: <1320680200-32024-1-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.3.4 Subject: [B.A.T.M.A.N.] [PATCH] 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: Mon, 07 Nov 2011 15:36:49 -0000 (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 Signed-off-by: Antonio Quartulli Reported-by: Alexey Fisher Tested-by: Alexey Fisher --- originator.c | 1 + translation-table.c | 11 ++++++++--- types.h | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/originator.c b/originator.c index 0bc2045..847ff7e 100644 --- a/originator.c +++ b/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/translation-table.c b/translation-table.c index 3726f33..e5f1c4e 100644 --- a/translation-table.c +++ b/translation-table.c @@ -704,6 +704,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) @@ -1463,6 +1464,7 @@ static void tt_update_changes(struct bat_priv *bat_priv, tt_save_orig_buffer(bat_priv, orig_node, (unsigned char *)tt_change, tt_num_changes); atomic_set(&orig_node->last_ttvn, ttvn); + orig_node->tt_initialised = true; } bool is_my_client(struct bat_priv *bat_priv, const uint8_t *addr) @@ -1823,8 +1825,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 */ @@ -1858,7 +1862,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/types.h b/types.h index e9eb043..35085f4 100644 --- a/types.h +++ b/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