From patchwork Sun Dec 4 21:38:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 1434 Return-Path: Received: from confino.investici.org (investici.nine.ch [217.150.252.179]) by open-mesh.org (Postfix) with ESMTPS id C887060085E for ; Sun, 4 Dec 2011 22:39:47 +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 A42DFC864A; Sun, 4 Dec 2011 21:39:46 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 confino.investici.org A42DFC864A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1323034786; bh=d/pLa5WEW+ChrHWyY/XVnsLvWtZY95ly9+4VV/Hplzc=; h=From:To:Cc:Subject:Date:Message-Id; b=ojfl3fbPb2wVF8AIX3JZ5dIf121wWdo1Z2ZHVK/+o+G1ecYr4WUfRYYRQr9c/KN51 6pFE8kd9oas78KOhQcfQ0BEX+kiXhfBHVrV2fjafwAadJbjS/fQk7OyW/926lOVe6M Y2IlOf6vvRVL0czhHzNipZ2Rk5A2/VL7FAs79fWQ= From: Antonio Quartulli To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 4 Dec 2011 22:38:27 +0100 Message-Id: <1323034707-25325-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: delete global entry in case of roaming 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: Sun, 04 Dec 2011 21:39:48 -0000 When receiving a DEL change for a client due to a roaming event (change is marked with TT_CLIENT_ROAM), each node has to check if the client roamed to itself or somewhere else. In the latter case the global entry is kept to avoid having no route at all otherwise we can safely delete the global entry Signed-off-by: Antonio Quartulli --- translation-table.c | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/translation-table.c b/translation-table.c index cf3e2c2..6e01079 100644 --- a/translation-table.c +++ b/translation-table.c @@ -663,6 +663,7 @@ void tt_global_del(struct bat_priv *bat_priv, const char *message, bool roaming) { struct tt_global_entry *tt_global_entry = NULL; + struct tt_local_entry *tt_local_entry = NULL tt_global_entry = tt_global_hash_find(bat_priv, addr); if (!tt_global_entry) @@ -670,15 +671,29 @@ void tt_global_del(struct bat_priv *bat_priv, if (tt_global_entry->orig_node == orig_node) { if (roaming) { - tt_global_entry->common.flags |= TT_CLIENT_ROAM; - tt_global_entry->roam_at = jiffies; - goto out; + /* if we are deleting a global entry due to a roam + * event, there are two possibilities: + * 1) the client roamed from node A to node B => we mark + * it with TT_CLIENT_ROAM, we start a timer and we + * wait for node B to claim it. In case of timeout + * the entry is purged. + * 2) the client roamed to us => we can directly delete + * the global entry, since it is useless now. */ + tt_local_entry = tt_local_hash_find(bat_priv, + tt_global_entry->addr); + if (!tt_local_entry) { + tt_global_entry->common.flags |= TT_CLIENT_ROAM; + tt_global_entry->roam_at = jiffies; + goto out; + } } _tt_global_del(bat_priv, tt_global_entry, message); } out: if (tt_global_entry) tt_global_entry_free_ref(tt_global_entry); + if (tt_local_entry) + tt_local_entry_free_ref(tt_local_entry); } void tt_global_del_orig(struct bat_priv *bat_priv,