From patchwork Sat Jul 30 11:10:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 1219 Return-Path: Received: from nm2.bullet.mail.ukl.yahoo.com (nm2.bullet.mail.ukl.yahoo.com [217.146.183.219]) by open-mesh.org (Postfix) with SMTP id 9E8ED600724 for ; Sat, 30 Jul 2011 13:10:30 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.216] by nm2.bullet.mail.ukl.yahoo.com with NNFMP; 30 Jul 2011 11:10:30 -0000 Received: from [77.238.184.75] by tm9.bullet.mail.ukl.yahoo.com with NNFMP; 30 Jul 2011 11:10:29 -0000 Received: from [127.0.0.1] by smtp144.mail.ukl.yahoo.com with NNFMP; 30 Jul 2011 11:10:29 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1312024229; bh=c5Ci6y4VKZPGqjRzLOmAworcSEs9dGKEvgbrDGYWjsM=; 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; b=Gk2CPbRVPNxv9QUMMw6C6EQPIQ+dgfUDgBYl70wCOaMGB9TYq2pAdmdZSzIccHVUB3CyDLo5/74r4w6l8hivjUMsHOaW6475v/DpKOkPNTRJeCgnu0EFIGLjHeGCv/6OoF2AiQwr7N4iwUUSjSmMVzoccbYL6+c05Y6OAXwnxis= X-Yahoo-Newman-Id: 976631.58004.bm@smtp144.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: 6ehluiQVM1mFv32KSzO6MTE4alvLaO1CjrYWmBab3r85gkw PsbyUWQy8SCi48KNcR6INGv_NxDho1JlHVgsogdHBf_YKbg0NGpPbzTsLrCu EquqXkUW7OhK2FblEHyq5.ZvsoLbGalXOOogYz4zwj2oGDu9tSIBzPwVh4GE NoEs4criU1fX.cInQBZKFPVDUroZeWajzBsiRalwryUcc5ymIsDGp7dTIBb4 nRtNUHCJpVfHddvHe_65prBCb8PzmYFWvRFtzYdYp.rqAKVJPUY074UwNdxo wehPGhjN1CkK8YuH3al9vpkH.qjLl06ofAMRMpWVgrTm0I.JJ2JlTWw-- X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@202.130.127.139 with plain) by smtp144.mail.ukl.yahoo.com with SMTP; 30 Jul 2011 11:10:28 +0000 GMT From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Sat, 30 Jul 2011 13:10:18 +0200 Message-Id: <1312024218-8197-1-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.5.3 Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: merge update_transtable() into tt related code 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: Sat, 30 Jul 2011 11:10:30 -0000 Signed-off-by: Marek Lindner --- routing.c | 66 ++---------------------------------------------- translation-table.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++--- translation-table.h | 9 ++---- 3 files changed, 70 insertions(+), 74 deletions(-) diff --git a/routing.c b/routing.c index 91a7860..1949928 100644 --- a/routing.c +++ b/routing.c @@ -64,65 +64,6 @@ void slide_own_bcast_window(struct hard_iface *hard_iface) } } -static void update_transtable(struct bat_priv *bat_priv, - struct orig_node *orig_node, - const unsigned char *tt_buff, - uint8_t tt_num_changes, uint8_t ttvn, - uint16_t tt_crc) -{ - 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) { - /* 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 */ - if (!tt_num_changes) { - full_table = false; - goto request_table; - } - - tt_update_changes(bat_priv, orig_node, tt_num_changes, ttvn, - (struct tt_change *)tt_buff); - - /* Even if we received the precomputed crc with the OGM, we - * prefer to recompute it to spot any possible inconsistency - * in the global table */ - orig_node->tt_crc = tt_global_crc(bat_priv, orig_node); - - /* The ttvn alone is not enough to guarantee consistency - * because a single value could represent different states - * (due to the wrap around). Thus a node has to check whether - * the resulting table (after applying the changes) is still - * consistent or not. E.g. a node could disconnect while its - * ttvn is X and reconnect on ttvn = X + TTVN_MAX: in this case - * checking the CRC value is mandatory to detect the - * inconsistency */ - if (orig_node->tt_crc != tt_crc) - goto request_table; - - /* Roaming phase is over: tables are in sync again. I can - * unset the flag */ - orig_node->tt_poss_change = false; - } 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) { -request_table: - bat_dbg(DBG_TT, bat_priv, "TT inconsistency for %pM. " - "Need to retrieve the correct information " - "(ttvn: %u last_ttvn: %u crc: %u last_crc: " - "%u num_changes: %u)\n", orig_node->orig, ttvn, - orig_ttvn, tt_crc, orig_node->tt_crc, - tt_num_changes); - send_tt_request(bat_priv, orig_node, ttvn, tt_crc, - full_table); - return; - } - } -} - static void update_route(struct bat_priv *bat_priv, struct orig_node *orig_node, struct neigh_node *neigh_node) @@ -499,10 +440,9 @@ update_tt: if (((batman_packet->orig != ethhdr->h_source) && (batman_packet->ttl > 2)) || (batman_packet->flags & PRIMARIES_FIRST_HOP)) - update_transtable(bat_priv, orig_node, tt_buff, - batman_packet->tt_num_changes, - batman_packet->ttvn, - batman_packet->tt_crc); + tt_update_orig(bat_priv, orig_node, tt_buff, + batman_packet->tt_num_changes, + batman_packet->ttvn, batman_packet->tt_crc); if (orig_node->gw_flags != batman_packet->gw_flags) gw_node_update(bat_priv, orig_node, batman_packet->gw_flags); diff --git a/translation-table.c b/translation-table.c index e8f849f..cc53f78 100644 --- a/translation-table.c +++ b/translation-table.c @@ -1079,8 +1079,9 @@ out: return skb; } -int send_tt_request(struct bat_priv *bat_priv, struct orig_node *dst_orig_node, - uint8_t ttvn, uint16_t tt_crc, bool full_table) +static int send_tt_request(struct bat_priv *bat_priv, + struct orig_node *dst_orig_node, + uint8_t ttvn, uint16_t tt_crc, bool full_table) { struct sk_buff *skb = NULL; struct tt_query_packet *tt_request; @@ -1455,9 +1456,10 @@ out: orig_node_free_ref(orig_node); } -void tt_update_changes(struct bat_priv *bat_priv, struct orig_node *orig_node, - uint16_t tt_num_changes, uint8_t ttvn, - struct tt_change *tt_change) +static void tt_update_changes(struct bat_priv *bat_priv, + struct orig_node *orig_node, + uint16_t tt_num_changes, uint8_t ttvn, + struct tt_change *tt_change) { _tt_update_changes(bat_priv, orig_node, tt_change, tt_num_changes, ttvn); @@ -1802,3 +1804,60 @@ out: tt_local_entry_free_ref(tt_local_entry); return ret; } + +void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, + const unsigned char *tt_buff, uint8_t tt_num_changes, + uint8_t ttvn, uint16_t tt_crc) +{ + 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) { + /* 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 */ + if (!tt_num_changes) { + full_table = false; + goto request_table; + } + + tt_update_changes(bat_priv, orig_node, tt_num_changes, ttvn, + (struct tt_change *)tt_buff); + + /* Even if we received the precomputed crc with the OGM, we + * prefer to recompute it to spot any possible inconsistency + * in the global table */ + orig_node->tt_crc = tt_global_crc(bat_priv, orig_node); + + /* The ttvn alone is not enough to guarantee consistency + * because a single value could represent different states + * (due to the wrap around). Thus a node has to check whether + * the resulting table (after applying the changes) is still + * consistent or not. E.g. a node could disconnect while its + * ttvn is X and reconnect on ttvn = X + TTVN_MAX: in this case + * checking the CRC value is mandatory to detect the + * inconsistency */ + if (orig_node->tt_crc != tt_crc) + goto request_table; + + /* Roaming phase is over: tables are in sync again. I can + * unset the flag */ + orig_node->tt_poss_change = false; + } 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) { +request_table: + bat_dbg(DBG_TT, bat_priv, "TT inconsistency for %pM. " + "Need to retrieve the correct information " + "(ttvn: %u last_ttvn: %u crc: %u last_crc: " + "%u num_changes: %u)\n", orig_node->orig, ttvn, + orig_ttvn, tt_crc, orig_node->tt_crc, + tt_num_changes); + send_tt_request(bat_priv, orig_node, ttvn, tt_crc, + full_table); + return; + } + } +} diff --git a/translation-table.h b/translation-table.h index b47e876..30efd49 100644 --- a/translation-table.h +++ b/translation-table.h @@ -49,14 +49,8 @@ void tt_save_orig_buffer(struct bat_priv *bat_priv, struct orig_node *orig_node, uint16_t tt_local_crc(struct bat_priv *bat_priv); uint16_t tt_global_crc(struct bat_priv *bat_priv, struct orig_node *orig_node); void tt_free(struct bat_priv *bat_priv); -int send_tt_request(struct bat_priv *bat_priv, - struct orig_node *dst_orig_node, uint8_t ttvn, - uint16_t tt_crc, bool full_table); bool send_tt_response(struct bat_priv *bat_priv, struct tt_query_packet *tt_request); -void tt_update_changes(struct bat_priv *bat_priv, struct orig_node *orig_node, - uint16_t tt_num_changes, uint8_t ttvn, - struct tt_change *tt_change); bool is_my_client(struct bat_priv *bat_priv, const uint8_t *addr); void handle_tt_response(struct bat_priv *bat_priv, struct tt_query_packet *tt_response); @@ -64,5 +58,8 @@ void send_roam_adv(struct bat_priv *bat_priv, uint8_t *client, struct orig_node *orig_node); void tt_commit_changes(struct bat_priv *bat_priv); bool is_ap_isolated(struct bat_priv *bat_priv, uint8_t *src, uint8_t *dst); +void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, + const unsigned char *tt_buff, uint8_t tt_num_changes, + uint8_t ttvn, uint16_t tt_crc); #endif /* _NET_BATMAN_ADV_TRANSLATION_TABLE_H_ */