From patchwork Sun Nov 10 04:58:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Linus_L=C3=BCssing?= X-Patchwork-Id: 3621 Return-Path: Received: from mout.web.de (mout.web.de [212.227.17.11]) by open-mesh.org (Postfix) with ESMTPS id 68B936021A1 for ; Sun, 10 Nov 2013 06:02:55 +0100 (CET) Received: from localhost ([46.165.228.119]) by smtp.web.de (mrweb004) with ESMTPSA (Nemesis) id 0MQt6E-1VBEli2y6Q-00UHqM for ; Sun, 10 Nov 2013 05:57:54 +0100 From: =?UTF-8?q?Linus=20L=C3=BCssing?= To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 10 Nov 2013 05:58:03 +0100 Message-Id: <1384059483-17815-1-git-send-email-linus.luessing@web.de> X-Mailer: git-send-email 1.8.4.2 MIME-Version: 1.0 X-Provags-ID: V03:K0:E5vlFDYk77ajqtpP1j9/30Cvs1w6BLvgsAd9Zw2UIhlH+Ocrky+ TvRis8Qyx219VcjzhxmIssuvp2bpxTx+tESn+MFLIFh2gktj1WFM+Y6EPf1mm5b4Pl/fC7A apX9YYqQg/YLXMpPuETUxkT3fVHUIMrEClvoUBI0kFWOpyz3q97JaerbrN6j+t1LfhjCWPk 62G7hn+nfAEvTugnY5bUA== Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: introduce capability initialization bitfield X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 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: Sun, 10 Nov 2013 05:02:55 -0000 The new bitfield allows us to keep track whether capability subsets of an originator have gone through their initialization phase yet. The translation table is the only user right now, but a new one will be added soon. Signed-off-by: Linus Lüssing --- originator.c | 1 - translation-table.c | 11 ++++++----- types.h | 6 ++++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/originator.c b/originator.c index edfb921..24e0681 100644 --- a/originator.c +++ b/originator.c @@ -335,7 +335,6 @@ struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv, /* extra reference for return */ atomic_set(&orig_node->refcount, 2); - orig_node->tt_initialised = false; orig_node->bat_priv = bat_priv; memcpy(orig_node->orig, addr, ETH_ALEN); batadv_dat_init_orig_node_addr(orig_node); diff --git a/translation-table.c b/translation-table.c index 1f482a4..128d20c 100644 --- a/translation-table.c +++ b/translation-table.c @@ -1748,7 +1748,7 @@ void batadv_tt_global_del_orig(struct batadv_priv *bat_priv, } spin_unlock_bh(list_lock); } - orig_node->tt_initialised = false; + orig_node->capa_initialized &= ~BATADV_ORIG_CAPA_HAS_TVLV; } static bool batadv_tt_global_to_purge(struct batadv_tt_global_entry *tt_global, @@ -2702,7 +2702,7 @@ static void _batadv_tt_update_changes(struct batadv_priv *bat_priv, return; } } - orig_node->tt_initialised = true; + orig_node->capa_initialized |= BATADV_ORIG_CAPA_HAS_TVLV; } static void batadv_tt_fill_gtable(struct batadv_priv *bat_priv, @@ -3197,8 +3197,8 @@ static void batadv_tt_update_orig(struct batadv_priv *bat_priv, /* 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) { + if ((!(orig_node->capa_initialized & BATADV_ORIG_CAPA_HAS_TVLV) && + ttvn == 1) || ttvn - orig_ttvn == 1) { /* the OGM could not contain the changes due to their size or * because they have already been sent BATADV_TT_OGM_APPEND_MAX * times. @@ -3239,7 +3239,8 @@ static void batadv_tt_update_orig(struct batadv_priv *bat_priv, /* if we missed more than one change or our tables are not * in sync anymore -> request fresh tt data */ - if (!orig_node->tt_initialised || ttvn != orig_ttvn || + if (!(orig_node->capa_initialized + & BATADV_ORIG_CAPA_HAS_TVLV) || ttvn != orig_ttvn || !batadv_tt_global_check_crc(orig_node, tt_vlan, tt_num_vlan)) { request_table: diff --git a/types.h b/types.h index 8966508..54ea34a 100644 --- a/types.h +++ b/types.h @@ -166,13 +166,12 @@ struct batadv_orig_bat_iv { * @bcast_seqno_reset: time when the broadcast seqno window was reset * @batman_seqno_reset: time when the batman seqno window was reset * @capabilities: announced capabilities of this originator + * @capa_initialized: bitfield to remember whether a capability was initialized * @last_ttvn: last seen translation table version number * @tt_buff: last tt changeset this node received from the orig node * @tt_buff_len: length of the last tt changeset this node received from the * orig node * @tt_buff_lock: lock that protects tt_buff and tt_buff_len - * @tt_initialised: bool keeping track of whether or not this node have received - * any translation table information from the orig node yet * @tt_lock: prevents from updating the table while reading it. Table update is * made up by two operations (data structure update and metdata -CRC/TTVN- * recalculation) and they have to be executed atomically in order to avoid @@ -213,6 +212,7 @@ struct batadv_orig_node { unsigned long bcast_seqno_reset; unsigned long batman_seqno_reset; uint8_t capabilities; + uint8_t capa_initialized; atomic_t last_ttvn; unsigned char *tt_buff; int16_t tt_buff_len; @@ -251,10 +251,12 @@ struct batadv_orig_node { * enum batadv_orig_capabilities - orig node capabilities * @BATADV_ORIG_CAPA_HAS_DAT: orig node has distributed arp table enabled * @BATADV_ORIG_CAPA_HAS_NC: orig node has network coding enabled + * @BATADV_ORIG_CAPA_HAS_TVLV: orig node has tvlv capability */ enum batadv_orig_capabilities { BATADV_ORIG_CAPA_HAS_DAT = BIT(0), BATADV_ORIG_CAPA_HAS_NC = BIT(1), + BATADV_ORIG_CAPA_HAS_TVLV = BIT(2), }; /**